- if( State == 0)
- {
- HAL_UART_Transmit(&huart1, (uint8_t *)"SD Card OK\n", 11, 500);
- if(HAL_SD_ReadBlocks(&hsd, pReadBuffer, 0x00000000, 512, 1) == 0)
- HAL_UART_Transmit(&huart1, (uint8_t *)"Sector read is OK\n", 18, 500);
- else
- {
- HAL_UART_Transmit(&huart1, (uint8_t *)"ERROR\n", 6, 500);
- break;
- }
-
- for(int i = 0;i < 128;i++)
- {
- for(int j = 0;j < 4;j++)
- {
- SendBuffer = pReadBuffer[i];
- pReadBuffer[i] >>= 8;
- sprintf((char*)&Char, "%X", SendBuffer);
- HAL_UART_Transmit(&huart1, &Char, 1, 500);
- }
-
- }
- while(1);
- }
2、SD卡处于繁忙的状态
这个时候我们就发送一个Busy的消息就可以了,等待1S钟进行下一次SD卡状态的读取。- else if(State == 1)
- {
- HAL_UART_Transmit(&huart1, (uint8_t *)"Busy\n", 5, 500);
- }
|