|
楼主 |
发表于 2020-7-6 11:38:11
|
显示全部楼层
感谢你的支持。
不知道为何,我贴的图不见显示。以下是SD卡初始化代码,是cubemx生成的。
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()) 此处,只有当OS运行状态,才会执行。否则返回 STA_NOINIT
#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;
}
|
|