STM32_EVAL_SDIO_SD_Private_Functions
[STM32_EVAL_SDIO_SD]

Functions

static SD_Error CmdError (void)
 Checks for error conditions for CMD0.
static SD_Error CmdResp1Error (uint8_t cmd)
 Checks for error conditions for R1 response.
static SD_Error CmdResp2Error (void)
 Checks for error conditions for R2 (CID or CSD) response.
static SD_Error CmdResp3Error (void)
 Checks for error conditions for R3 (OCR) response.
static SD_Error CmdResp6Error (uint8_t cmd, uint16_t *prca)
 Checks for error conditions for R6 (RCA) response.
static SD_Error CmdResp7Error (void)
 Checks for error conditions for R7 response.
static uint8_t convert_from_bytes_to_power_of_two (uint16_t NumberOfBytes)
 Converts the number of bytes in power of two and returns the power.
static SD_Error FindSCR (uint16_t rca, uint32_t *pscr)
 Find the SD card SCR register value.
static SD_Error IsCardProgramming (uint8_t *pstatus)
 Checks if the SD card is in programming state.
void SD_DeInit (void)
 DeInitializes the SDIO interface.
uint8_t SD_Detect (void)
 Detect if SD card is correctly plugged in the memory slot.
SD_Error SD_EnableWideBusOperation (uint32_t WideMode)
 Enables wide bus opeartion for the requeseted card if supported by card.
SD_Error SD_Erase (uint32_t startaddr, uint32_t endaddr)
 Allows to erase memory area specified for the given card.
SD_Error SD_GetCardInfo (SD_CardInfo *cardinfo)
 Returns information about specific card.
SDCardState SD_GetState (void)
 Returns the current card's state.
SDTransferState SD_GetStatus (void)
 Gets the cuurent sd card data transfer status.
SDTransferState SD_GetTransferState (void)
 Gets the cuurent data transfer state.
SD_Error SD_Init (void)
 Initializes the SD Card and put it into StandBy State (Ready for data transfer).
SD_Error SD_InitializeCards (void)
 Intialises all cards or single card as the case may be Card(s) come into standby state.
SD_Error SD_PowerOFF (void)
 Turns the SDIO output signals off.
SD_Error SD_PowerON (void)
 Enquires cards about their operating voltage and configures clock controls.
SD_Error SD_ProcessIRQSrc (void)
 Allows to process all the interrupts that are high.
SD_Error SD_ReadBlock (uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
 Allows to read one block from a specified address in a card.
SD_Error SD_ReadMultiBlocks (uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Allows to read blocks from a specified address in a card.
SD_Error SD_SelectDeselect (uint32_t addr)
 Selects od Deselects the corresponding card.
SD_Error SD_SendSDStatus (uint32_t *psdstatus)
 Returns the current SD card's status.
SD_Error SD_SendStatus (uint32_t *pcardstatus)
 Returns the current card's status.
SD_Error SD_SetDeviceMode (uint32_t Mode)
 Sets device mode whether to operate in Polling, Interrupt or DMA mode.
SD_Error SD_StopTransfer (void)
 Aborts an ongoing data transfer.
SD_Error SD_WriteBlock (uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize)
 Allows to write one block starting from a specified address in a card.
SD_Error SD_WriteMultiBlocks (uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
 Allows to write blocks starting from a specified address in a card.
static SD_Error SDEnWideBus (FunctionalState NewState)
 Enables or disables the SDIO wide bus mode.

Function Documentation

static SD_Error CmdError ( void   )  [static]

Checks for error conditions for CMD0.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< 10000

Definition at line 2228 of file stm32_eval_sdio_sd.c.

References RESET, SD_CMD_RSP_TIMEOUT, SD_OK, SDIO_ClearFlag(), SDIO_CMD0TIMEOUT, SDIO_FLAG_CMDSENT, SDIO_GetFlagStatus(), and SDIO_STATIC_FLAGS.

Referenced by SD_PowerON().

static SD_Error CmdResp1Error ( uint8_t  cmd  )  [static]

Checks for error conditions for R1 response.

Parameters:
cmd,: The sent command index.
Return values:
SD_Error,: SD Card Error code.

< We have received response, retrieve it for analysis

Definition at line 2294 of file stm32_eval_sdio_sd.c.

References SD_ADDR_MISALIGNED, SD_ADDR_OUT_OF_RANGE, SD_AKE_SEQ_ERROR, SD_ALLZERO, SD_BAD_ERASE_PARAM, SD_BLOCK_LEN_ERR, SD_CARD_ECC_DISABLED, SD_CARD_ECC_FAILED, SD_CC_ERROR, SD_CID_CSD_OVERWRITE, SD_CMD_CRC_FAIL, SD_CMD_RSP_TIMEOUT, SD_COM_CRC_FAILED, SD_ERASE_RESET, SD_ERASE_SEQ_ERR, SD_GENERAL_UNKNOWN_ERROR, SD_ILLEGAL_CMD, SD_LOCK_UNLOCK_FAILED, SD_OCR_ADDR_MISALIGNED, SD_OCR_ADDR_OUT_OF_RANGE, SD_OCR_AKE_SEQ_ERROR, SD_OCR_BAD_ERASE_PARAM, SD_OCR_BLOCK_LEN_ERR, SD_OCR_CARD_ECC_DISABLED, SD_OCR_CARD_ECC_FAILED, SD_OCR_CC_ERROR, SD_OCR_CID_CSD_OVERWRIETE, SD_OCR_COM_CRC_FAILED, SD_OCR_ERASE_RESET, SD_OCR_ERASE_SEQ_ERR, SD_OCR_ERRORBITS, SD_OCR_GENERAL_UNKNOWN_ERROR, SD_OCR_ILLEGAL_CMD, SD_OCR_LOCK_UNLOCK_FAILED, SD_OCR_STREAM_READ_UNDERRUN, SD_OCR_STREAM_WRITE_OVERRUN, SD_OCR_WP_ERASE_SKIP, SD_OCR_WRITE_PROT_VIOLATION, SD_OK, SD_STREAM_READ_UNDERRUN, SD_STREAM_WRITE_OVERRUN, SD_WP_ERASE_SKIP, SD_WRITE_PROT_VIOLATION, SDIO, SDIO_ClearFlag(), SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, SDIO_GetCommandResponse(), SDIO_GetResponse(), SDIO_RESP1, SDIO_STATIC_FLAGS, and status.

Referenced by FindSCR(), SD_Erase(), SD_PowerON(), SD_ReadBlock(), SD_ReadMultiBlocks(), SD_SelectDeselect(), SD_SendSDStatus(), SD_SendStatus(), SD_StopTransfer(), SD_WriteBlock(), SD_WriteMultiBlocks(), and SDEnWideBus().

static SD_Error CmdResp2Error ( void   )  [static]

Checks for error conditions for R2 (CID or CSD) response.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

Definition at line 2468 of file stm32_eval_sdio_sd.c.

References SD_CMD_CRC_FAIL, SD_CMD_RSP_TIMEOUT, SD_OK, SDIO, SDIO_ClearFlag(), SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, SDIO_STATIC_FLAGS, and status.

Referenced by SD_InitializeCards().

static SD_Error CmdResp3Error ( void   )  [static]

Checks for error conditions for R3 (OCR) response.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

Definition at line 2440 of file stm32_eval_sdio_sd.c.

References SD_CMD_RSP_TIMEOUT, SD_OK, SDIO, SDIO_ClearFlag(), SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, SDIO_STATIC_FLAGS, and status.

Referenced by SD_PowerON().

static SD_Error CmdResp6Error ( uint8_t  cmd,
uint16_t *  prca 
) [static]

Checks for error conditions for R6 (RCA) response.

Parameters:
cmd,: The sent command index.
prca,: pointer to the variable that will contain the SD card relative address RCA.
Return values:
SD_Error,: SD Card Error code.

< We have received response, retrieve it.

Definition at line 2506 of file stm32_eval_sdio_sd.c.

References SD_ALLZERO, SD_CMD_CRC_FAIL, SD_CMD_RSP_TIMEOUT, SD_COM_CRC_FAILED, SD_GENERAL_UNKNOWN_ERROR, SD_ILLEGAL_CMD, SD_OK, SD_R6_COM_CRC_FAILED, SD_R6_GENERAL_UNKNOWN_ERROR, SD_R6_ILLEGAL_CMD, SDIO, SDIO_ClearFlag(), SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, SDIO_GetCommandResponse(), SDIO_GetResponse(), SDIO_RESP1, SDIO_STATIC_FLAGS, and status.

Referenced by SD_InitializeCards().

static SD_Error CmdResp7Error ( void   )  [static]

Checks for error conditions for R7 response.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< Card is not V2.0 complient or card does not support the set voltage range

< Card is SD V2.0 compliant

Definition at line 2257 of file stm32_eval_sdio_sd.c.

References SD_CMD_RSP_TIMEOUT, SD_OK, SDIO, SDIO_ClearFlag(), SDIO_CMD0TIMEOUT, SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, and status.

Referenced by SD_PowerON().

static uint8_t convert_from_bytes_to_power_of_two ( uint16_t  NumberOfBytes  )  [static]

Converts the number of bytes in power of two and returns the power.

Parameters:
NumberOfBytes,: number of bytes.
Return values:
None 

Definition at line 2957 of file stm32_eval_sdio_sd.c.

Referenced by SD_ReadBlock(), SD_ReadMultiBlocks(), SD_WriteBlock(), and SD_WriteMultiBlocks().

static SD_Error FindSCR ( uint16_t  rca,
uint32_t *  pscr 
) [static]
static SD_Error IsCardProgramming ( uint8_t *  pstatus  )  [static]

Checks if the SD card is in programming state.

Parameters:
pstatus,: pointer to the variable that will contain the SD card state.
Return values:
SD_Error,: SD Card Error code.

< Check response received is of desired command

< We have received response, retrieve it for analysis

< Find out card status

Definition at line 2689 of file stm32_eval_sdio_sd.c.

References RCA, SD_ADDR_MISALIGNED, SD_ADDR_OUT_OF_RANGE, SD_AKE_SEQ_ERROR, SD_ALLZERO, SD_BAD_ERASE_PARAM, SD_BLOCK_LEN_ERR, SD_CARD_ECC_DISABLED, SD_CARD_ECC_FAILED, SD_CC_ERROR, SD_CID_CSD_OVERWRITE, SD_CMD_CRC_FAIL, SD_CMD_RSP_TIMEOUT, SD_CMD_SEND_STATUS, SD_COM_CRC_FAILED, SD_ERASE_RESET, SD_ERASE_SEQ_ERR, SD_GENERAL_UNKNOWN_ERROR, SD_ILLEGAL_CMD, SD_LOCK_UNLOCK_FAILED, SD_OCR_ADDR_MISALIGNED, SD_OCR_ADDR_OUT_OF_RANGE, SD_OCR_AKE_SEQ_ERROR, SD_OCR_BAD_ERASE_PARAM, SD_OCR_BLOCK_LEN_ERR, SD_OCR_CARD_ECC_DISABLED, SD_OCR_CARD_ECC_FAILED, SD_OCR_CC_ERROR, SD_OCR_CID_CSD_OVERWRIETE, SD_OCR_COM_CRC_FAILED, SD_OCR_ERASE_RESET, SD_OCR_ERASE_SEQ_ERR, SD_OCR_ERRORBITS, SD_OCR_GENERAL_UNKNOWN_ERROR, SD_OCR_ILLEGAL_CMD, SD_OCR_LOCK_UNLOCK_FAILED, SD_OCR_STREAM_READ_UNDERRUN, SD_OCR_STREAM_WRITE_OVERRUN, SD_OCR_WP_ERASE_SKIP, SD_OCR_WRITE_PROT_VIOLATION, SD_OK, SD_STREAM_READ_UNDERRUN, SD_STREAM_WRITE_OVERRUN, SD_WP_ERASE_SKIP, SD_WRITE_PROT_VIOLATION, SDIO, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_ClearFlag(), SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_FLAG_CCRCFAIL, SDIO_FLAG_CMDREND, SDIO_FLAG_CTIMEOUT, SDIO_GetCommandResponse(), SDIO_GetResponse(), SDIO_RESP1, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_STATIC_FLAGS, SDIO_CmdInitTypeDef::SDIO_Wait, SDIO_Wait_No, and status.

Referenced by SD_Erase(), SD_WriteBlock(), and SD_WriteMultiBlocks().

void SD_DeInit ( void   ) 

DeInitializes the SDIO interface.

Parameters:
None 
Return values:
None 

Definition at line 211 of file stm32_eval_sdio_sd.c.

uint8_t SD_Detect ( void   ) 

Detect if SD card is correctly plugged in the memory slot.

Parameters:
None 
Return values:
Return if SD is detected or not

< Check GPIO to detect SD

Definition at line 342 of file stm32_eval_sdio_sd.c.

Referenced by SD_GetState().

SD_Error SD_EnableWideBusOperation ( uint32_t  WideMode  ) 

Enables wide bus opeartion for the requeseted card if supported by card.

Parameters:
WideMode,: Specifies the SD card wide bus mode. This parameter can be one of the following values:

  • SDIO_BusWide_8b: 8-bit data transfer (Only for MMC)
  • SDIO_BusWide_4b: 4-bit data transfer
  • SDIO_BusWide_1b: 1-bit data transfer
Return values:
SD_Error,: SD Card Error code.

< MMC Card doesn't support this feature

< Configure the SDIO peripheral

< Configure the SDIO peripheral

Definition at line 820 of file stm32_eval_sdio_sd.c.

References CardType, DISABLE, ENABLE, SD_OK, SD_UNSUPPORTED_FEATURE, SDEnWideBus(), SDIO_InitTypeDef::SDIO_BusWide, SDIO_BusWide_1b, SDIO_BusWide_4b, SDIO_BusWide_8b, SDIO_InitTypeDef::SDIO_ClockBypass, SDIO_ClockBypass_Disable, SDIO_InitTypeDef::SDIO_ClockDiv, SDIO_InitTypeDef::SDIO_ClockEdge, SDIO_ClockEdge_Rising, SDIO_InitTypeDef::SDIO_ClockPowerSave, SDIO_ClockPowerSave_Disable, SDIO_InitTypeDef::SDIO_HardwareFlowControl, SDIO_HardwareFlowControl_Disable, SDIO_HIGH_CAPACITY_SD_CARD, SDIO_Init(), SDIO_MULTIMEDIA_CARD, SDIO_STD_CAPACITY_SD_CARD_V1_1, SDIO_STD_CAPACITY_SD_CARD_V2_0, and SDIO_TRANSFER_CLK_DIV.

Referenced by SD_Init().

SD_Error SD_Erase ( uint32_t  startaddr,
uint32_t  endaddr 
)

Allows to erase memory area specified for the given card.

Parameters:
startaddr,: the start address.
endaddr,: the end address.
Return values:
SD_Error,: SD Card Error code.

< Check if the card coomnd class supports erase command

< Send CMD32 SD_ERASE_GRP_START with argument as addr

Definition at line 1843 of file stm32_eval_sdio_sd.c.

References CardType, CmdResp1Error(), CSD_Tab, delay(), IsCardProgramming(), SD_CARD_LOCKED, SD_CARD_PROGRAMMING, SD_CARD_RECEIVING, SD_CCCC_ERASE, SD_CMD_ERASE, SD_CMD_SD_ERASE_GRP_END, SD_CMD_SD_ERASE_GRP_START, SD_LOCK_UNLOCK_FAILED, SD_OK, SD_REQUEST_NOT_APPLICABLE, SDIO, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_GetResponse(), SDIO_HIGH_CAPACITY_SD_CARD, SDIO_RESP1, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_STD_CAPACITY_SD_CARD_V1_1, SDIO_STD_CAPACITY_SD_CARD_V2_0, SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by main().

SD_Error SD_GetCardInfo ( SD_CardInfo cardinfo  ) 

Returns information about specific card.

Parameters:
cardinfo,: pointer to a SD_CardInfo structure that contains all SD card information.
Return values:
SD_Error,: SD Card Error code.

< Byte 0

< Byte 1

< Byte 2

< Byte 3

< Byte 4

< Byte 5

< Byte 6

< Reserved

< Byte 7

< Byte 8

< Byte 9

< Byte 10

< Byte 7

< Byte 8

< Byte 9

< Byte 10

< Byte 11

< Byte 12

< Byte 13

< Byte 14

< Byte 15

< Byte 0

< Byte 1

< Byte 2

< Byte 3

< Byte 4

< Byte 5

< Byte 6

< Byte 7

< Byte 8

< Byte 9

< Byte 10

< Byte 11

< Byte 12

< Byte 13

< Byte 14

< Byte 15

Definition at line 608 of file stm32_eval_sdio_sd.c.

Referenced by SD_Init().

SDCardState SD_GetState ( void   ) 

Returns the current card's state.

Parameters:
None 
Return values:
SDCardState,: SD Card Error or SD Card Current State.

Definition at line 316 of file stm32_eval_sdio_sd.c.

References SD_CARD_ERROR, SD_Detect(), SD_OK, SD_PRESENT, and SD_SendStatus().

Referenced by SD_GetStatus().

SDTransferState SD_GetStatus ( void   ) 

Gets the cuurent sd card data transfer status.

Parameters:
None 
Return values:
SDTransferState,: Data Transfer state. This value can be:

  • SD_TRANSFER_OK: No data transfer is acting
  • SD_TRANSFER_BUSY: Data transfer is acting

Definition at line 291 of file stm32_eval_sdio_sd.c.

SDTransferState SD_GetTransferState ( void   ) 

Gets the cuurent data transfer state.

Parameters:
None 
Return values:
SDTransferState,: Data Transfer state. This value can be:

  • SD_TRANSFER_OK: No data transfer is acting
  • SD_TRANSFER_BUSY: Data transfer is acting

Definition at line 1803 of file stm32_eval_sdio_sd.c.

References SD_TRANSFER_BUSY, SD_TRANSFER_OK, SDIO, SDIO_FLAG_RXACT, and SDIO_FLAG_TXACT.

SD_Error SD_Init ( void   ) 

Initializes the SD Card and put it into StandBy State (Ready for data transfer).

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< CMD Response TimeOut (wait for CMDSENT flag)

< CMD Response TimeOut (wait for CMDSENT flag)

< SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_TRANSFER_CLK_DIV)

Definition at line 222 of file stm32_eval_sdio_sd.c.

Referenced by main().

SD_Error SD_InitializeCards ( void   ) 

Intialises all cards or single card as the case may be Card(s) come into standby state.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< Send CMD2 ALL_SEND_CID

< Send CMD3 SET_REL_ADDR with argument 0

< SD Card publishes its RCA.

< Send CMD9 SEND_CSD with argument as card's RCA

< All cards get intialized

Definition at line 519 of file stm32_eval_sdio_sd.c.

References CardType, CID_Tab, CmdResp2Error(), CmdResp6Error(), CSD_Tab, RCA, SD_CMD_ALL_SEND_CID, SD_CMD_SEND_CSD, SD_CMD_SET_REL_ADDR, SD_OK, SD_REQUEST_NOT_APPLICABLE, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_GetPowerState(), SDIO_GetResponse(), SDIO_HIGH_CAPACITY_SD_CARD, SDIO_PowerState_OFF, SDIO_RESP1, SDIO_RESP2, SDIO_RESP3, SDIO_RESP4, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Long, SDIO_Response_Short, SDIO_SECURE_DIGITAL_IO_CARD, SDIO_SECURE_DIGITAL_IO_COMBO_CARD, SDIO_SendCommand(), SDIO_STD_CAPACITY_SD_CARD_V1_1, SDIO_STD_CAPACITY_SD_CARD_V2_0, SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_Init().

SD_Error SD_PowerOFF ( void   ) 

Turns the SDIO output signals off.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< Set Power State to OFF

Definition at line 503 of file stm32_eval_sdio_sd.c.

References SD_OK, SDIO_PowerState_OFF, and SDIO_SetPowerState().

SD_Error SD_PowerON ( void   ) 

Enquires cards about their operating voltage and configures clock controls.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< Power ON Sequence -----------------------------------------------------

< Configure the SDIO peripheral

< SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_INIT_CLK_DIV)

< SDIO_CK for initialization should not exceed 400 KHz

< Set Power State to ON

< Enable SDIO Clock

< CMD0: GO_IDLE_STATE ---------------------------------------------------

< No CMD response required

< CMD Response TimeOut (wait for CMDSENT flag)

< Send CMD8 to verify SD card interface operating condition

< Argument: - [31:12]: Reserved (shall be set to '0')

  • [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
  • [7:0]: Check Pattern (recommended 0xAA)

< CMD Response: R7

< SD Card 2.0

< CMD55

< If errorstatus is Command TimeOut, it is a MMC card

< If errorstatus is SD_OK it is a SD card: SD card 2.0 (voltage range mismatch) or SD card 1.x

< SD CARD

< Send ACMD41 SD_APP_OP_COND with Argument 0x80100000

< SEND CMD55 APP_CMD with RCA as 0

Definition at line 360 of file stm32_eval_sdio_sd.c.

References CardType, CmdError(), CmdResp1Error(), CmdResp3Error(), CmdResp7Error(), ENABLE, SD_CHECK_PATTERN, SD_CMD_APP_CMD, SD_CMD_GO_IDLE_STATE, SD_CMD_SD_APP_OP_COND, SD_HIGH_CAPACITY, SD_INVALID_VOLTRANGE, SD_MAX_VOLT_TRIAL, SD_OK, SD_STD_CAPACITY, SD_VOLTAGE_WINDOW_SD, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_InitTypeDef::SDIO_BusWide, SDIO_BusWide_1b, SDIO_InitTypeDef::SDIO_ClockBypass, SDIO_ClockBypass_Disable, SDIO_ClockCmd(), SDIO_InitTypeDef::SDIO_ClockDiv, SDIO_InitTypeDef::SDIO_ClockEdge, SDIO_ClockEdge_Rising, SDIO_InitTypeDef::SDIO_ClockPowerSave, SDIO_ClockPowerSave_Disable, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_GetResponse(), SDIO_InitTypeDef::SDIO_HardwareFlowControl, SDIO_HardwareFlowControl_Disable, SDIO_HIGH_CAPACITY_SD_CARD, SDIO_Init(), SDIO_INIT_CLK_DIV, SDIO_PowerState_ON, SDIO_RESP1, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_No, SDIO_Response_Short, SDIO_SEND_IF_COND, SDIO_SendCommand(), SDIO_SetPowerState(), SDIO_STD_CAPACITY_SD_CARD_V2_0, SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_Init().

SD_Error SD_ProcessIRQSrc ( void   ) 
SD_Error SD_ReadBlock ( uint8_t *  readbuff,
uint32_t  ReadAddr,
uint16_t  BlockSize 
)

Allows to read one block from a specified address in a card.

Parameters:
readbuff,: pointer to the buffer that will contain the received data
ReadAddr,: Address from where data are to be read.
BlockSize,: the SD card Data block size.
Return values:
SD_Error,: SD Card Error code.

< Clear all DPSM configuration

< Set Block Size for Card

< Send CMD17 READ_SINGLE_BLOCK

< Polling mode

Definition at line 928 of file stm32_eval_sdio_sd.c.

Referenced by main().

SD_Error SD_ReadMultiBlocks ( uint8_t *  readbuff,
uint32_t  ReadAddr,
uint16_t  BlockSize,
uint32_t  NumberOfBlocks 
)

Allows to read blocks from a specified address in a card.

Parameters:
readbuff,: pointer to the buffer that will contain the received data.
ReadAddr,: Address from where data are to be read.
BlockSize,: the SD card Data block size.
NumberOfBlocks,: number of blocks to be read.
Return values:
SD_Error,: SD Card Error code.

< Clear all DPSM configuration

< Set Block Size for Card

< Common to all modes

< Send CMD18 READ_MULT_BLOCK with argument data address

< Polling mode

< In Case Of SD-CARD Send Command STOP_TRANSMISSION

< Send CMD12 STOP_TRANSMISSION

Definition at line 1098 of file stm32_eval_sdio_sd.c.

Referenced by main().

SD_Error SD_SelectDeselect ( uint32_t  addr  ) 

Selects od Deselects the corresponding card.

Parameters:
addr,: Address of the Card to be selected.
Return values:
SD_Error,: SD Card Error code.

< Send CMD7 SDIO_SEL_DESEL_CARD

Definition at line 904 of file stm32_eval_sdio_sd.c.

References CmdResp1Error(), SD_CMD_SEL_DESEL_CARD, SD_OK, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_Init().

SD_Error SD_SendSDStatus ( uint32_t *  psdstatus  ) 
SD_Error SD_SendStatus ( uint32_t *  pcardstatus  ) 

Returns the current card's status.

Parameters:
pcardstatus,: pointer to the buffer that will contain the SD card status (Card Status register).
Return values:
SD_Error,: SD Card Error code.

Definition at line 1938 of file stm32_eval_sdio_sd.c.

References CmdResp1Error(), NULL, RCA, SD_CMD_SEND_STATUS, SD_INVALID_PARAMETER, SD_OK, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_GetResponse(), SDIO_RESP1, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_GetState().

SD_Error SD_SetDeviceMode ( uint32_t  Mode  ) 

Sets device mode whether to operate in Polling, Interrupt or DMA mode.

Parameters:
Mode,: Specifies the Data Transfer mode. This parameter can be one of the following values:

  • SD_DMA_MODE: Data transfer using DMA.
  • SD_INTERRUPT_MODE: Data transfer using interrupts.
  • SD_POLLING_MODE: Data transfer using flags.
Return values:
SD_Error,: SD Card Error code.

Definition at line 883 of file stm32_eval_sdio_sd.c.

References DeviceMode, SD_DMA_MODE, SD_INTERRUPT_MODE, SD_INVALID_PARAMETER, SD_OK, and SD_POLLING_MODE.

Referenced by SD_Init().

SD_Error SD_StopTransfer ( void   ) 

Aborts an ongoing data transfer.

Parameters:
None 
Return values:
SD_Error,: SD Card Error code.

< Send CMD12 STOP_TRANSMISSION

Definition at line 1820 of file stm32_eval_sdio_sd.c.

References CmdResp1Error(), SD_CMD_STOP_TRANSMISSION, SD_OK, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_ProcessIRQSrc().

SD_Error SD_WriteBlock ( uint8_t *  writebuff,
uint32_t  WriteAddr,
uint16_t  BlockSize 
)

Allows to write one block starting from a specified address in a card.

Parameters:
writebuff,: pointer to the buffer that contain the data to be transferred.
WriteAddr,: Address from where data are to be read.
BlockSize,: the SD card Data block size.
Return values:
SD_Error,: SD Card Error code.

< In case of single data block transfer no need of stop command at all

< Wait till the card is in programming state

Definition at line 1299 of file stm32_eval_sdio_sd.c.

Referenced by main().

SD_Error SD_WriteMultiBlocks ( uint8_t *  writebuff,
uint32_t  WriteAddr,
uint16_t  BlockSize,
uint32_t  NumberOfBlocks 
)

Allows to write blocks starting from a specified address in a card.

Parameters:
WriteAddr,: Address from where data are to be read.
writebuff,: pointer to the buffer that contain the data to be transferred.
BlockSize,: the SD card Data block size.
NumberOfBlocks,: number of blocks to be written.
Return values:
SD_Error,: SD Card Error code.

< Common to all modes

< To improve performance

< Send CMD12 STOP_TRANSMISSION

< Add some delay before checking the Card Status

Definition at line 1530 of file stm32_eval_sdio_sd.c.

Referenced by main().

static SD_Error SDEnWideBus ( FunctionalState  NewState  )  [static]

Enables or disables the SDIO wide bus mode.

Parameters:
NewState,: new state of the SDIO wide bus mode. This parameter can be: ENABLE or DISABLE.
Return values:
SD_Error,: SD Card Error code.

< If requested card supports wide bus operation

< Send CMD55 APP_CMD with argument as card's RCA.

< If requested card supports 1 bit mode operation

< Send CMD55 APP_CMD with argument as card's RCA.

Definition at line 2575 of file stm32_eval_sdio_sd.c.

References CmdResp1Error(), ENABLE, FindSCR(), RCA, SD_ALLZERO, SD_CARD_LOCKED, SD_CMD_APP_CMD, SD_CMD_APP_SD_SET_BUSWIDTH, SD_LOCK_UNLOCK_FAILED, SD_OK, SD_REQUEST_NOT_APPLICABLE, SD_SINGLE_BUS_SUPPORT, SD_WIDE_BUS_SUPPORT, SDIO_CmdInitTypeDef::SDIO_Argument, SDIO_CmdInitTypeDef::SDIO_CmdIndex, SDIO_CmdInitTypeDef::SDIO_CPSM, SDIO_CPSM_Enable, SDIO_GetResponse(), SDIO_RESP1, SDIO_CmdInitTypeDef::SDIO_Response, SDIO_Response_Short, SDIO_SendCommand(), SDIO_CmdInitTypeDef::SDIO_Wait, and SDIO_Wait_No.

Referenced by SD_EnableWideBusOperation().

STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32