我是一名初学者,使用的是CC1310 LaunchPad开发板。在测试spiffsexternal例程时候,想把Flash的读取操作转为一个任务,主体代码如下:
主程序:
int main(void)
{
Board_initGeneral();
FlashTask_Init();
BIOS_start();
return (0);
}
FlashTask_Init程序:
#define MESSAGE_LENGTH (22)
#define SPIFFS_LOGICAL_BLOCK_SIZE (4096)
#define SPIFFS_LOGICAL_PAGE_SIZE (256)
#define SPIFFS_FILE_DESCRIPTOR_SIZE (44)
#define Flash_TASK_STACK_SIZE 1536
#define Flash_TASK_PRIORITY 3
static uint8_t spiffsWorkBuffer[SPIFFS_LOGICAL_PAGE_SIZE * 2];
/* The array below will be used by SPIFFS as a file descriptor cache. */
static uint8_t spiffsFileDescriptorCache[SPIFFS_FILE_DESCRIPTOR_SIZE * 4];
/* The array below will be used by SPIFFS as a read/write cache. */
static uint8_t spiffsReadWriteCache[SPIFFS_LOGICAL_PAGE_SIZE * 2];
spiffs fs;
SPIFFSNVS_Data spiffsnvsData;
spiffs_config fsConfig;
spiffs_file fd;
int32_t status;
//事件参数
Event_Struct FlashEvent;
Event_Handle FlashEventHandle;
//任务参数
static Task_Params FlashTaskParams;
Task_Struct FlashTask;static uint8_t FlashTaskStack[Flash_TASK_STACK_SIZE];
void FlashTask_Init(void)
{
Event_Params FlasheventParam;
Event_Params_init(&FlasheventParam);
Event_construct(&FlashEvent, &FlasheventParam);
FlashEventHandle = Event_handle(&FlashEvent);
Task_Params_init(&FlashTaskParams);
FlashTaskParams.stackSize = Flash_TASK_STACK_SIZE;
FlashTaskParams.priority = Flash_TASK_PRIORITY;
FlashTaskParams.stack = &FlashTaskStack;
Task_construct(&FlashTask, FlashTaskFunction, &FlashTaskParams, NULL);
#ifdef Board_wakeUpExtFlash
Board_wakeUpExtFlash();
#endif
GPIO_init();
status = SPIFFSNVS_config(&spiffsnvsData, Board_NVSEXTERNAL, &fs, &fsConfig,
SPIFFS_LOGICAL_BLOCK_SIZE, SPIFFS_LOGICAL_PAGE_SIZE);
if (status != SPIFFSNVS_STATUS_SUCCESS) {
while (1);
}
status = SPIFFS_mount(&fs, &fsConfig, spiffsWorkBuffer,
spiffsFileDescriptorCache, sizeof(spiffsFileDescriptorCache),
spiffsReadWriteCache, sizeof(spiffsReadWriteCache), NULL);
if (status != SPIFFS_OK) {
if (status == SPIFFS_ERR_NOT_A_FS) {
SPIFFS_unmount(&fs);
status = SPIFFS_format(&fs);
if (status != SPIFFS_OK) {
while (1);
}
status = SPIFFS_mount(&fs, &fsConfig, spiffsWorkBuffer,
spiffsFileDescriptorCache, sizeof(spiffsFileDescriptorCache),
spiffsReadWriteCache, sizeof(spiffsReadWriteCache), NULL);
if (status != SPIFFS_OK) {
while (1);
}
}
else {
/* Received an unexpected error when mounting file system */
while (1);
}
}
}
在Debug模式测试后,发现程序总是在status = SPIFFS_mount(&fs, &fsConfig, spiffsWorkBuffer,spiffsFileDescriptorCache, sizeof(spiffsFileDescriptorCache),
spiffsReadWriteCache, sizeof(spiffsReadWriteCache), NULL);处卡死,很久都没有找到原因,请问有什么解决方法吗?
Viki Shi:
SPIFFS的使用建议参考以下链接:
dev.ti.com/…/_s_p_i_f_f_s_n_v_s_8h.html
dev.ti.com/…/Users_Guide.html