TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1310的使用NVS提示出错等问题?

程序源码:

{
NVS_Handle rHandle;
NVS_Attrs regionAttrs;
NVS_Params nvsParams;
uint_fast16_t status;
char buf[32];
NVS_Params_init();
// Initialize the NVS driver
NVS_init();
//
// Open the NVS region specified by the 0th element in the NVS_config[] array
// in Board.c
//
rHandle = NVS_open(0, NULL); // use default NVS_Params to open this flash region
// confirm that the NVS region opened properly
if (rHandle == NULL) {
}
// fetch the generic NVS region attributes
NVS_getAttrs(rHandle, &regionAttrs);
// erase the first sector of the NVS region
// status = NVS_erase(rHandle, 0, regionAttrs.sectorSize);
// if (status != NVS_STATUS_SUCCESS) {
//// }}

编译后出现了下面的错误提示,这个问题是哪里出错了,

Error[Li005]: no definition for "NVS_config" [referenced from NVS.orm3(drivers_cc13xxware.arm3)]

还有有没有相关的NVS初始化操作的历程参考,谢谢。

Felix ZF:

SDK中有NVS的例程,可以直接使用。

C:\TI\simplelink_cc13x0_sdk_1_60_00_21\examples\rtos\CC1310_LAUNCHXL\drivers\nvs

Alvin Chen:

/** Copyright (c) 2017, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
/**======== nvsspi.c ========*/#include <string.h>
#include <stdlib.h>
#include <stdint.h>/* Driver Header files */
#include <ti/display/Display.h>
#include <ti/drivers/NVS.h>/* Example/Board Header files */
#include "Board.h"#define HEADER "=================================================="static char buf[64];/** Some devices have a minimum FLASH write size of 4-bytes (1 word).Trying* to write a non-multiple of 4 amount of data will fail.This array is* rounded up (to next multiple of 4) to meet this requirement. Refer to NVS* driver documentation for more details.*/
static const char signature[52] ={"SimpleLink SDK Non-Volatile Storage (NVS) Example."};/**======== mainThread ========*/
void *mainThread(void *arg0)
{NVS_Handle nvsHandle;NVS_Attrs regionAttrs;NVS_Params nvsParams;Display_Handle displayHandle;Display_init();NVS_init();displayHandle = Display_open(Display_Type_UART, NULL);if (displayHandle == NULL) {/* Display_open() failed */while (1);}Display_printf(displayHandle, 0, 0, "\n");NVS_Params_init(&nvsParams);nvsHandle = NVS_open(Board_NVS0, &nvsParams);if (nvsHandle == NULL) {Display_printf(displayHandle, 0, 0, "NVS_open() failed.");return (NULL);}NVS_getAttrs(nvsHandle, &regionAttrs);/* Print NVS region details */Display_printf(displayHandle, 0, 0, "Region Base Address: 0x%x",regionAttrs.regionBase);Display_printf(displayHandle, 0, 0, "Sector Size: 0x%x",regionAttrs.sectorSize);Display_printf(displayHandle, 0, 0, "Region Size: 0x%x\n",regionAttrs.regionSize);NVS_read(nvsHandle, 0, (void *) buf, sizeof(signature));/* Determine if flash contains signature string */if (strcmp((char *) buf, (char *) signature) == 0) {/* Write signature directly from flash to the console */Display_printf(displayHandle, 0, 0, "%s", regionAttrs.regionBase);Display_printf(displayHandle, 0, 0, "Erasing flash...");/* Erase the entire flash region */NVS_erase(nvsHandle, 0, regionAttrs.regionSize);}else {Display_printf(displayHandle, 0, 0, "Writing signature to flash...");/* Write signature to memory */NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);}Display_printf(displayHandle, 0, 0, "Reset the device.");Display_printf(displayHandle, 0, 0, HEADER);return (NULL);
}

da qin zheng sheng:

可以参考这个帖子
e2echina.ti.com/…/131169

Viki Shi:

无定义的报错大概率是因为头文件没包含, 可以直接参考TI例程

FreePom:

回复 Viki Shi:

如果是在C:\ti\tirtos_cc13xx_cc26xx_2_21_00_06\examples\IAR\CC1310DK_7XD里的历程里添加NVS的应用要怎么弄,

FreePom:

回复 Felix ZF:

这个历程初始化过不了怎么办?

Felix ZF:

回复 FreePom:

你使用的哪个SDK?
你对例程做过修改吗?

FreePom:

回复 Felix ZF:

tirtos_cc13xx_cc26xx_2_21_00_06这个SDK,没修改过底层,只是在上面增加了些应用,是在CC1350上面开发,现在要做一个掉电保存的功能,如果有其他好的方案推荐也可以

FreePom:

回复 Felix ZF:

tirtos_cc13xx_cc26xx_2_21_00_06的SDK除了用NVS操作flash还有其他的方法吗

赞(0)
未经允许不得转载:TI中文支持网 » CC1310的使用NVS提示出错等问题?
分享到: 更多 (0)