/* Gets the SD card data response and check the busy flag.  */
uint8_t SD_GetDataResponse(void)
/* Gets the SD card data response and check the busy flag.  */
uint8_t SD_GetDataResponse(void)
{
  uint8_t dataresponse;
  uint8_t rvalue = SD_DATA_OTHER_ERROR;
  dataresponse = SD_IO_WriteByte(SD_DUMMY_BYTE);
  SD_IO_WriteByte(SD_DUMMY_BYTE);
  switch (dataresponse & 0x1F)
  {
  case SD_DATA_OK:
    rvalue = SD_DATA_OK;
    SD_IO_CSState(1);
    SD_IO_CSState(0);
    while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF);
    break;
  case SD_DATA_CRC_ERROR:
    rvalue =  SD_DATA_CRC_ERROR;
    break;
  case SD_DATA_WRITE_ERROR:
    rvalue = SD_DATA_WRITE_ERROR;
    break;
  default:
    break;
  }
  return rvalue;
}