Atmel UC3A0512 FAT API 定义 FREERTOS_USED 符号后出现问题
Atmel UC3A0512 FAT API problems after defining FREERTOS_USED symbol
我正在使用ASF提供的FAT API从闪存中读取数据,
FAT API 使用全局变量 fs_g_status
来帮助调试问题,但 fs_g_status
似乎需要
无意义的值:
fs_g_status 的可能值:
#define FS_ERR_HW (FAIL+0) //!< Hardware driver error
#define FS_ERR_NO_FORMAT (FAIL+1) //!< The selected drive isn't formated
#define FS_ERR_NO_PART (FAIL+2) //!< The selected partition doesn't existed
#define FS_ERR_NO_SUPPORT_PART (FAIL+3) //!< The selected partition isn't supported
#define FS_ERR_TOO_FILE_OPEN (FAIL+4) //!< The navigation have already opened a file
#define FS_ERR_END_OF_DRIVE (FAIL+5) //!< There are not other driver
#define FS_ERR_BAD_POS (FAIL+6) //!< The position is over the file
#define FS_ERR_FS (FAIL+7) //!< File system error
#define FS_ERR_NO_FIND (FAIL+8) //!< File no found
#define FS_ERR_ENTRY_EMPTY (FAIL+9) //!< File entry empty
#define FS_ERR_ENTRY_BAD (FAIL+10) //!< File entry bad
#define FS_ERR_ENTRY_BADTYPE (FAIL+11) //!< File entry type don't corresponding
#define FS_ERR_NO_DIR (FAIL+12) //!< The selected file isn't a directory
#define FS_ERR_NO_MOUNT (FAIL+13) //!< The partition isn't mounted
#define FS_ERR_NO_FILE_SEL (FAIL+14) //!< There are no selected file
#define FS_NO_LAST_LFN_ENTRY (FAIL+15) //!< The file entry isn't the last long file entry
#define FS_ERR_ID_FILE (FAIL+17) //!< The file identifier is bad
#define FS_ERR_NO_FILE (FAIL+18) //!< The selected file entry isn't a file
#define FS_LUN_WP (FAIL+19) //!< Drive is in read only mode
#define FS_ERR_READ_ONLY (FAIL+20) //!< File is on read access only
#define FS_ERR_NAME_INCORRECT (FAIL+21) //!< The name don't corresponding at the filter name
//...
和
#define FAIL 1
这是我用来从闪存读取数据的函数
int read_Flash_Data()
{
/* initialize FSACCESS mutex and navigators */
if (b_fsaccess_init())
{
usart_write_line((&AVR32_USART0), " b_fsaccess_init return true \r\n");
}
//fs_g_status = 0x00 OK
/* Try to init data flash */
if (at45dbx_mem_check())
{
/* display message */
usart_write_line((&AVR32_USART0), " at45dbx_mem_check return true \r\n");
}
else
{
/* display error message */
usart_write_line((&AVR32_USART0)," at45dbx_mem_check return false\r\n");
return (-1);
}
//fs_g_status = 0x00 OK
if (nav_drive_set(LUN_ID_1) == false)
{
usart_write_line((&AVR32_USART0)," nav_drive_set return false \r\n");
return (-1);
}
//fs_g_status = 0x01 ==> Hardware driver error NOK , but the nav_drive_set(LUN_ID_1) return true !!!!
if( !nav_partition_mount() )
{
usart_write_line((&AVR32_USART0),"nav_partition_mount return false \r\n");
return (-1);
}
//fs_g_status = 0x04 ==> The navigation have already opened a file, but the nav_partition_mount() return true !!!!
if ((ret = open(ACTUAL_CONFIG_FILE_PATH, O_RDONLY)) < 0)
{
usart_write_line((&AVR32_USART0),"Opening file failed \r\n");
return (-1);
}
//fs_g_status = 0x10 ==16(decimal) open return true !!!!
//...
}
我认为这不符合逻辑,只有当函数 return 为 false 时才应设置 fs_g_status
。
好吧,说说有小问题和大问题导致功能失效,评论不够好。
现在这个函数在freeRTOS任务中使用,我必须在编译中定义符号FREERTOS_USED以在并发访问中保护闪存,在上面的描述中没有定义符号。
现在 nav_partition_mount()
return false 和 fs_g_status = 0x01
.
有没有人遇到这个问题我似乎找不到调试问题的方法,欢迎任何建议。
您忘记初始化 ctrl_access_semphr
,
您必须使用 ctrl_access.c
中定义的函数 ctrl_access_init
。
#ifdef FREERTOS_USED
bool ctrl_access_init(void)
{
// If the handle to the protecting semaphore is not valid,
if (!ctrl_access_semphr)
{
// try to create the semaphore.
vSemaphoreCreateBinary(ctrl_access_semphr);
// If the semaphore could not be created, there is no backup solution.
if (!ctrl_access_semphr) return false;
}
return true;
}
#endif
您的函数应如下所示:
int read_Flash_Data()
{
/* initialize FSACCESS mutex and navigators */
if (b_fsaccess_init())
{
usart_write_line((&AVR32_USART0), " b_fsaccess_init return true \r\n");
}
/* initialize ctrl_access semaphore */
if (ctrl_access_init())
{
usart_write_line((&AVR32_USART0), " ctrl_access_init return true \r\n");
}
//......
我正在使用ASF提供的FAT API从闪存中读取数据,
FAT API 使用全局变量 fs_g_status
来帮助调试问题,但 fs_g_status
似乎需要
无意义的值:
fs_g_status 的可能值:
#define FS_ERR_HW (FAIL+0) //!< Hardware driver error
#define FS_ERR_NO_FORMAT (FAIL+1) //!< The selected drive isn't formated
#define FS_ERR_NO_PART (FAIL+2) //!< The selected partition doesn't existed
#define FS_ERR_NO_SUPPORT_PART (FAIL+3) //!< The selected partition isn't supported
#define FS_ERR_TOO_FILE_OPEN (FAIL+4) //!< The navigation have already opened a file
#define FS_ERR_END_OF_DRIVE (FAIL+5) //!< There are not other driver
#define FS_ERR_BAD_POS (FAIL+6) //!< The position is over the file
#define FS_ERR_FS (FAIL+7) //!< File system error
#define FS_ERR_NO_FIND (FAIL+8) //!< File no found
#define FS_ERR_ENTRY_EMPTY (FAIL+9) //!< File entry empty
#define FS_ERR_ENTRY_BAD (FAIL+10) //!< File entry bad
#define FS_ERR_ENTRY_BADTYPE (FAIL+11) //!< File entry type don't corresponding
#define FS_ERR_NO_DIR (FAIL+12) //!< The selected file isn't a directory
#define FS_ERR_NO_MOUNT (FAIL+13) //!< The partition isn't mounted
#define FS_ERR_NO_FILE_SEL (FAIL+14) //!< There are no selected file
#define FS_NO_LAST_LFN_ENTRY (FAIL+15) //!< The file entry isn't the last long file entry
#define FS_ERR_ID_FILE (FAIL+17) //!< The file identifier is bad
#define FS_ERR_NO_FILE (FAIL+18) //!< The selected file entry isn't a file
#define FS_LUN_WP (FAIL+19) //!< Drive is in read only mode
#define FS_ERR_READ_ONLY (FAIL+20) //!< File is on read access only
#define FS_ERR_NAME_INCORRECT (FAIL+21) //!< The name don't corresponding at the filter name
//...
和
#define FAIL 1
这是我用来从闪存读取数据的函数
int read_Flash_Data()
{
/* initialize FSACCESS mutex and navigators */
if (b_fsaccess_init())
{
usart_write_line((&AVR32_USART0), " b_fsaccess_init return true \r\n");
}
//fs_g_status = 0x00 OK
/* Try to init data flash */
if (at45dbx_mem_check())
{
/* display message */
usart_write_line((&AVR32_USART0), " at45dbx_mem_check return true \r\n");
}
else
{
/* display error message */
usart_write_line((&AVR32_USART0)," at45dbx_mem_check return false\r\n");
return (-1);
}
//fs_g_status = 0x00 OK
if (nav_drive_set(LUN_ID_1) == false)
{
usart_write_line((&AVR32_USART0)," nav_drive_set return false \r\n");
return (-1);
}
//fs_g_status = 0x01 ==> Hardware driver error NOK , but the nav_drive_set(LUN_ID_1) return true !!!!
if( !nav_partition_mount() )
{
usart_write_line((&AVR32_USART0),"nav_partition_mount return false \r\n");
return (-1);
}
//fs_g_status = 0x04 ==> The navigation have already opened a file, but the nav_partition_mount() return true !!!!
if ((ret = open(ACTUAL_CONFIG_FILE_PATH, O_RDONLY)) < 0)
{
usart_write_line((&AVR32_USART0),"Opening file failed \r\n");
return (-1);
}
//fs_g_status = 0x10 ==16(decimal) open return true !!!!
//...
}
我认为这不符合逻辑,只有当函数 return 为 false 时才应设置 fs_g_status
。
好吧,说说有小问题和大问题导致功能失效,评论不够好。
现在这个函数在freeRTOS任务中使用,我必须在编译中定义符号FREERTOS_USED以在并发访问中保护闪存,在上面的描述中没有定义符号。
现在 nav_partition_mount()
return false 和 fs_g_status = 0x01
.
有没有人遇到这个问题我似乎找不到调试问题的方法,欢迎任何建议。
您忘记初始化 ctrl_access_semphr
,
您必须使用 ctrl_access.c
中定义的函数 ctrl_access_init
。
#ifdef FREERTOS_USED
bool ctrl_access_init(void)
{
// If the handle to the protecting semaphore is not valid,
if (!ctrl_access_semphr)
{
// try to create the semaphore.
vSemaphoreCreateBinary(ctrl_access_semphr);
// If the semaphore could not be created, there is no backup solution.
if (!ctrl_access_semphr) return false;
}
return true;
}
#endif
您的函数应如下所示:
int read_Flash_Data()
{
/* initialize FSACCESS mutex and navigators */
if (b_fsaccess_init())
{
usart_write_line((&AVR32_USART0), " b_fsaccess_init return true \r\n");
}
/* initialize ctrl_access semaphore */
if (ctrl_access_init())
{
usart_write_line((&AVR32_USART0), " ctrl_access_init return true \r\n");
}
//......