当我在stm32f407配置好后,我想在OsKernel
开启前在SD卡读写一段文字,确始终永远无法成功,最终debug发现程序跳过了这条代码
DSTATUS SD_initialize(BYTE lun)
{
Stat = STA_NOINIT;
/*
* check that the kernel has been started before continuing
* as the osMessage API will fail otherwise
*/
#if (osCMSIS <= 0x20000U)
if(osKernelRunning())
#else
if(osKernelGetState() == osKernelRunning)
#endif
{
#if !defined(DISABLE_SD_INIT)
if(BSP_SD_Init() == MSD_OK)
{
Stat = SD_CheckStatus(lun);
}
#else
Stat = SD_CheckStatus(lun);
#endif
/*
* if the SD is correctly initialized, create the operation queue
* if not already created
*/
if (Stat != STA_NOINIT)
{
if (SDQueueID == NULL)
{
#if (osCMSIS <= 0x20000U)
osMessageQDef(SD_Queue, QUEUE_SIZE, uint16_t);
SDQueueID = osMessageCreate (osMessageQ(SD_Queue), NULL);
#else
SDQueueID = osMessageQueueNew(QUEUE_SIZE, 2, NULL);
#endif
}
if (SDQueueID == NULL)
{
Stat |= STA_NOINIT;
}
}
}
return Stat;
}
所以,我们把SD卡读写任务放在vTask
里面就能正常读写了