【iCore4 雙核心板_ARM】例程十三:SDIO實驗——讀取SD卡資訊

XiaomaGee發表於2017-08-25

實驗現象:

核心程式碼:

int main(void)
{    
    system_clock.initialize();                                                                                       
    led.initialize();                                                                                         
    usart6.initialize(115200);                                                                                    
    usart6.printf("\x0c");                                                             
    usart6.printf("\033[1;32;40m");                                                 
    usart6.printf("Hello, I am iCore4!\r\n\r\n\r\n");                                     

    if(BSP_SD_Init() != 0){
        usart6.printf("SD ERROR!\r\n");
        while(1){
            LED_RED_ON;
            HAL_Delay(500);
            LED_RED_OFF;
            HAL_Delay(500);
        }
    }
  
    BSP_SD_GetCardInfo(&SDCardInfo);
  
    switch(SDCardInfo.CardType){
        case CARD_SDSC:usart6.printf("SD CardType\t\t: CARD_SDSC\r\n");break;
        case CARD_SDHC_SDXC:usart6.printf("SD CardType\t\t: CARD_SDHC_SDXC\r\n");break;
        case CARD_SECURED:usart6.printf("SD CardType\t\t: CARD_SECURED\r\n");break;
    }
    switch(SDCardInfo.CardVersion){
        case CARD_V1_X:usart6.printf("SD CardVersion\t: CARD_V1_X\r\n");break;
        case CARD_V2_X:usart6.printf("SD SD CardVersion\t: CARD_V2_X\r\n");break;        
    }
    usart6.printf("SD CardCapacity\t\t: %dMB\r\n",(unsigned int)(SDCardInfo.BlockNbr * SDCardInfo.BlockSize) >> 20);
    usart6.printf("SD BlockSize\t\t: %dByte\r\n",SDCardInfo.BlockSize);
    usart6.printf("SD RelCardAdd\t\t: %d\r\n",SDCardInfo.RelCardAdd);
    
    while(1){
        LED_GREEN_ON;
        HAL_Delay(500);
        LED_GREEN_OFF;
        HAL_Delay(500);
    }
}

原始碼下載連結:

連結:https://pan.baidu.com/s/1nwsI8HF 密碼:0imt

iCore4連結:

相關文章