主题中讨论的其他器件:SysConfig
尊敬的 TI 成员:
最近、我在驱动程序示例之后编写了一个 nvsinternal 测试代码。 下面是代码片段:
int Peripheral_NVS_init (void) { struct nvs_bt_rf_last_state bt_last_st = { .nvsHandle = NULL, \ .nvsParams = {NULL}, \ .regionAttrs = {NULL, 0, 0}, \ .first_boot = "first boot" \ }; int bt_state = -1; char buffer[12]; NVS_init(); NVS_Params_init(&bt_last_st.nvsParams); if ((bt_last_st.nvsHandle = NVS_open(CONFIG_NVSINTERNAL, &bt_last_st.nvsParams)) == NULL) { Log_printf(LogModule_App1, Log_DEBUG, "NVS_open() failed."); return bt_state; } NVS_read(bt_last_st.nvsHandle, 0, (void*)&bt_state, sizeof(bt_state)); NVS_read(bt_last_st.nvsHandle, 1, (void*)buffer, sizeof(bt_last_st.first_boot)); /* device boot for the first time */ if (strncmp(bt_last_st.first_boot, buffer, sizeof(bt_last_st.first_boot))) { NVS_write(bt_last_st.nvsHandle, 1, (void*)bt_last_st.first_boot, sizeof(bt_last_st.first_boot), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY); return 1; } if (bt_state != 1 || bt_state != 0) { return -1; } return bt_state; }
但是,NVS_OPEN()返回导致失败的 NULL 指针。
我在初始化期间是否错过了某些内容?
下表是我当前的建筑环境:
Code Composer Studio |
12.4.0.202306011800 |
SimpleLink SDK |
7.20.1.10 |
XDCtools |
3.62.1.16_CORE |
谢谢。
扎赫