|
PER Firmware
|
Secure Digital Input Output Interface driver for STM32F4. More...
#include "sdio.h"#include "main.h"#include "string.h"Macros | |
| #define | SD_LOG(...) |
| #define | SDIO_TXDMA_CONFIG(tx_addr_, priority_) |
| #define | SDIO_RXDMA_CONFIG(rx_addr_, priority_) |
Functions | |
| bool | PHAL_SDIO_init (void) |
| Configures the SDIO peripheral. | |
| SD_Error | SD_Init (void) |
| Initializes the SD Card and put it into StandBy State (Ready for data transfer). | |
| SDTransferState | SD_GetStatus (void) |
| Gets the cuurent sd card data transfer status. | |
| SDCardState | SD_GetState (void) |
| Returns the current card's state. | |
| uint8_t | SD_Detect (void) |
| Detect if SD card is correctly plugged in the memory slot. | |
| SD_Error | SD_PowerON (void) |
| Enquires cards about their operating voltage and configures clock controls. | |
| 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_GetCardInfo (SD_CardInfo *cardinfo) |
| Returns information about specific card. | |
| SD_Error | SD_EnableWideBusOperation (uint32_t WideMode) |
| Enables wide bus opeartion for the requeseted card if supported by card. | |
| SD_Error | SD_SelectDeselect (uint64_t addr) |
| Selects od Deselects the corresponding card. | |
| void | PHAL_SDIO_SendCommand (PHAL_SD_Cmd_t *cmd) |
| Send a command. | |
| SD_Error | SD_ReadMultiBlocks (uint8_t *readbuff, uint64_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) |
| Allows to read blocks from a specified address in a card. The Data transfer can be managed by DMA mode or Polling mode. | |
| SD_Error | SD_WaitReadOperation (void) |
| This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_ReadMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller. | |
| SD_Error | SD_WriteMultiBlocks (uint8_t *writebuff, uint64_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) |
| Allows to write blocks starting from a specified address in a card. The Data transfer can be managed by DMA mode only. | |
| SD_Error | SD_WaitWriteOperation (void) |
| This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_WriteBlock() and SDIO_WriteMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller. | |
| SD_Error | SD_StopTransfer (void) |
| Aborts an ongoing data transfer. | |
| SD_Error | SD_SendStatus (uint32_t *pcardstatus) |
| Returns the current card's status. | |
| void | SDIO_IRQHandler (void) |
| Allows to process all the interrupts that are high. | |
| void | DMA2_Stream6_IRQHandler (void) |
| void | SD_LowLevel_DMA_TxConfig (uint32_t *BufferSRC, uint32_t BufferSize) |
| Configures the DMA 2 Channel 6 for SDIO Tx request. | |
| void | SD_LowLevel_DMA_RxConfig (uint32_t *BufferDST, uint32_t BufferSize) |
| Configures the DMA2 Channel4 for SDIO Rx request. | |
| void | SD_DeInit (void) |
Variables | |
| __IO SD_Error | TransferError = SD_OK |
| __IO uint32_t | TransferEnd = 0 |
| __IO uint32_t | DMAEndOfTransfer = 0 |
| SD_CardInfo | SDCardInfo |
Secure Digital Input Output Interface driver for STM32F4.
| #define SDIO_RXDMA_CONFIG | ( | rx_addr_, | |
| priority_ ) |
| #define SDIO_TXDMA_CONFIG | ( | tx_addr_, | |
| priority_ ) |
| bool PHAL_SDIO_init | ( | void | ) |
Configures the SDIO peripheral.
Initialize SDIO peripheral with the configuired structure.
| cfg |
| void PHAL_SDIO_SendCommand | ( | PHAL_SD_Cmd_t * | cmd | ) |
Send a command.
| cmd |
| void SD_DeInit | ( | void | ) |
< Disable SDIO Clock
< Set Power State to OFF
< DeInitializes the SDIO peripheral
| uint8_t SD_Detect | ( | void | ) |
Detect if SD card is correctly plugged in the memory slot.
| None |
| Return | if SD is detected or not |
| SD_Error SD_EnableWideBusOperation | ( | uint32_t | WideMode | ) |
Enables wide bus opeartion for the requeseted card if supported by card.
| WideMode | Specifies the SD card wide bus mode. This parameter can be one of the following values:
|
| SD_Error | SD Card Error code. |
< MMC Card doesn't support this feature
< Configure the SDIO peripheral
< Configure the SDIO peripheral
| SD_Error SD_GetCardInfo | ( | SD_CardInfo * | cardinfo | ) |
Returns information about specific card.
| cardinfo | pointer to a SD_CardInfo structure that contains all SD card information. |
| 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
| SDCardState SD_GetState | ( | void | ) |
Returns the current card's state.
| None |
| SDCardState | SD Card Error or SD Card Current State. |
| SDTransferState SD_GetStatus | ( | void | ) |
Gets the cuurent sd card data transfer status.
| None |
| SDTransferState | Data Transfer state. This value can be:
|
| SD_Error SD_Init | ( | void | ) |
Initializes the SD Card and put it into StandBy State (Ready for data transfer).
| None |
| SD_Error | SD Card Error code. |
< CMD Response TimeOut (wait for CMDSENT flag)
| SD_Error SD_InitializeCards | ( | void | ) |
Intialises all cards or single card as the case may be Card(s) come into standby state.
| None |
| 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
| void SD_LowLevel_DMA_RxConfig | ( | uint32_t * | BufferDST, |
| uint32_t | BufferSize ) |
Configures the DMA2 Channel4 for SDIO Rx request.
| BufferDST | pointer to the destination buffer |
| BufferSize | buffer size |
| None |
| void SD_LowLevel_DMA_TxConfig | ( | uint32_t * | BufferSRC, |
| uint32_t | BufferSize ) |
Configures the DMA 2 Channel 6 for SDIO Tx request.
| BufferSRC | pointer to the source buffer |
| BufferSize | buffer size |
| None |
| SD_Error SD_PowerON | ( | void | ) |
Enquires cards about their operating voltage and configures clock controls.
| None |
| SD_Error | SD Card Error code. |
< CMD0: GO_IDLE_STATE ------------------------------------------------—
< No CMD response required
< CMD Response TimeOut (wait for CMDSENT flag)
< CMD8: SEND_IF_COND -------------------------------------------------—
< Send CMD8 to verify SD card interface operating condition
< Argument: - [31:12]: Reserved (shall be set to '0')
< 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
| SD_Error SD_ReadMultiBlocks | ( | uint8_t * | readbuff, |
| uint64_t | ReadAddr, | ||
| uint16_t | BlockSize, | ||
| uint32_t | NumberOfBlocks ) |
Allows to read blocks from a specified address in a card. The Data transfer can be managed by DMA mode or Polling mode.
| 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. The Block size should be 512. |
| NumberOfBlocks | number of blocks to be read. |
| SD_Error | SD Card Error code. |
< Send CMD18 READ_MULT_BLOCK with argument data address
< Send CMD17 READ_SINGLE_BLOCK with argument data address
| SD_Error SD_SelectDeselect | ( | uint64_t | addr | ) |
Selects od Deselects the corresponding card.
| addr | Address of the Card to be selected. |
| SD_Error | SD Card Error code. |
< Send CMD7 SDIO_SEL_DESEL_CARD
| SD_Error SD_SendStatus | ( | uint32_t * | pcardstatus | ) |
Returns the current card's status.
| pcardstatus | pointer to the buffer that will contain the SD card status (Card Status register). |
| SD_Error | SD Card Error code. |
| SD_Error SD_StopTransfer | ( | void | ) |
Aborts an ongoing data transfer.
| None |
| SD_Error | SD Card Error code. |
< Send CMD12 STOP_TRANSMISSION
| SD_Error SD_WaitReadOperation | ( | void | ) |
This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_ReadMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller.
| None. |
| SD_Error | SD Card Error code. |
| SD_Error SD_WaitWriteOperation | ( | void | ) |
This function waits until the SDIO DMA data transfer is finished. This function should be called after SDIO_WriteBlock() and SDIO_WriteMultiBlocks() function to insure that all data sent by the card are already transferred by the DMA controller.
| None. |
| SD_Error | SD Card Error code. |
| SD_Error SD_WriteMultiBlocks | ( | uint8_t * | writebuff, |
| uint64_t | WriteAddr, | ||
| uint16_t | BlockSize, | ||
| uint32_t | NumberOfBlocks ) |
Allows to write blocks starting from a specified address in a card. The Data transfer can be managed by DMA mode only.
| 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. The Block size should be 512. |
| NumberOfBlocks | number of blocks to be written. |
| SD_Error | SD Card Error code. |