lib/stm32/BSP/STM32F4xx-Nucleo/stm32f4xx_nucleo.c
HAL_StatusTypeDef SD_IO_WriteCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
{
  uint32_t counter = 0x00;
  uint8_t frame[6];

  /* Prepare Frame to send */
  frame[0] = (Cmd | 0x40);         /* Construct byte 1 */
  frame[1] = (uint8_t)(Arg >> 24); /* Construct byte 2 */
  frame[2] = (uint8_t)(Arg >> 16); /* Construct byte 3 */
  frame[3] = (uint8_t)(Arg >> 8);  /* Construct byte 4 */
  frame[4] = (uint8_t)(Arg);       /* Construct byte 5 */
  frame[5] = (Crc);                /* Construct byte 6 */
  
  /* SD chip select low */
  SD_CS_LOW();
    
  /* Send Frame */
  for (counter = 0; counter < 6; counter++)
  {
    SD_IO_WriteByte(frame[counter]); /* Send the Cmd bytes */
  }

  if(Response != SD_NO_RESPONSE_EXPECTED)
  {
    return SD_IO_WaitResponse(Response);
  }
  
  return HAL_OK;
}
/**
  * @brief  Sends 5 bytes command to the SD card and get response.
  * @param  Cmd: The user expected command to send to SD card.
  * @param  Arg: The command argument
  * @param  Crc: The CRC
  * @param  Response: Expected response from the SD card
  * @retval HAL_StatusTypeDef HAL Status
  */
@brief  Sends 5 bytes command to the SD card and get response.
@param  Cmd: The user expected command to send to SD card.
@param  Arg: The command argument
@param  Crc: The CRC
@param  Response: Expected response from the SD card
@retval HAL_StatusTypeDef HAL Status
@brief Sends 5 bytes command to the SD card and get response . @param Cmd : The user expected command to send to SD card . @param Arg : The command argument @param Crc : The CRC @param Response : Expected response from the SD card @retval HAL_StatusTypeDef HAL Status
HAL_StatusTypeDef SD_IO_WriteCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
{
  uint32_t counter = 0x00;
  uint8_t frame[6];
  frame[0] = (Cmd | 0x40);         
  frame[1] = (uint8_t)(Arg >> 24); 
  frame[2] = (uint8_t)(Arg >> 16); 
  frame[3] = (uint8_t)(Arg >> 8);  
  frame[4] = (uint8_t)(Arg);       
  frame[5] = (Crc);                
  SD_CS_LOW();
  for (counter = 0; counter < 6; counter++)
  {
    SD_IO_WriteByte(frame[counter]); 
  }
  if(Response != SD_NO_RESPONSE_EXPECTED)
  {
    return SD_IO_WaitResponse(Response);
  }
  return HAL_OK;
}
HAL_StatusTypeDef SD_IO_WriteCmd ( uint8_t Cmd , uint32_t Arg , uint8_t Crc , uint8_t Response ) { uint32_t counter = 0x00 ; uint8_t frame [ 6 ] ; frame [ 0 ] = ( Cmd | 0x40 ) ; frame [ 1 ] = ( uint8_t ) ( Arg >> 24 ) ; frame [ 2 ] = ( uint8_t ) ( Arg >> 16 ) ; frame [ 3 ] = ( uint8_t ) ( Arg >> 8 ) ; frame [ 4 ] = ( uint8_t ) ( Arg ) ; frame [ 5 ] = ( Crc ) ; SD_CS_LOW ( ) ; for ( counter = 0 ; counter < 6 ; counter ++ ) { SD_IO_WriteByte ( frame [ counter ] ) ; } if ( Response != SD_NO_RESPONSE_EXPECTED ) { return SD_IO_WaitResponse ( Response ) ; } return HAL_OK ; }
@brief  Sends 5 bytes command to the SD card and get response.
@brief Sends 5 bytes command to the SD card and get response .
/* Prepare Frame to send */ /* Construct byte 1 */ /* Construct byte 2 */ /* Construct byte 3 */ /* Construct byte 4 */ /* Construct byte 5 */ /* Construct byte 6 */ /* SD chip select low */ /* Send Frame */ /* Send the Cmd bytes */