然后在while(1)之前编写如下读取信息代码:
/* USER CODE BEGIN 2 */
printf("Micro SD Card Test...\r\n");
/* 检测SD卡是否正常(处于数据传输模式的传输状态) */
sdcard_status = HAL_SD_GetCardState(&hsd1);
if(sdcard_status == HAL_SD_CARD_TRANSFER)
{
printf("SD card init ok!\r\n\r\n");
//打印SD卡基本信息
printf("SD card information!\r\n");
printf("CardCapacity: %llu\r\n",((unsigned long long)hsd1.SdCard.BlockSize*hsd1.SdCard.BlockNbr));
printf("CardBlockSize: %d \r\n",hsd1.SdCard.BlockSize);
printf("RCA: %d \r\n",hsd1.SdCard.RelCardAdd);
printf("CardType: %d \r\n",hsd1.SdCard.CardType);
//读取并打印SD卡的CID信息
HAL_SD_GetCardCID(&hsd1,&sdcard_cid);
printf("ManufacturerID: %d \r\n",sdcard_cid.ManufacturerID);
}
else
{
printf("SD card init fail!\r\n" );
return 0;
}
/* USER CODE END 2 */
|