|
Hardware Abstraction Layer for FreeRTOS
|

Data Structures | |
| struct | sd_generic |
| struct | sd_response |
| struct | sd_setting |
Macros | |
| #define | SD_ERROR_AKE_SEQ_ERROR -2 |
| #define | SD_ERROR_ERROR -3 |
| #define | SD_ERROR_CC_ERROR -4 |
| #define | SD_ERROR_CARD_ECC_FAIELD -5 |
| #define | SD_ERROR_ILLEGAL_COMMAND -6 |
| #define | SD_ERROR_COM_CRC_ERROR -7 |
| #define | SD_ERROR_LOCK_UNLOCK_FAILED -8 |
| #define | SD_ERROR_CARD_IS_LOCKED -9 |
| #define | SD_ERROR_WP_VIOLATION -10 |
| #define | SD_ERROR_ERASE_PARAM -11 |
| #define | SD_ERROR_ERASE_SEQ_ERROR -12 |
| #define | SD_ERROR_ERASE_LEN_ERROR -13 |
| #define | SD_ERROR_ADDRESS_ERROR -14 |
| #define | SD_ERROR_OUT_OF_RANGE -15 |
| #define | SD_ERROR_FUNCTION_NUMBER -16 |
| #define | CMD(x) (x) |
| #define | ACMD(x) (x) |
Enumerations | |
| enum | sd_mode { SD_SPI, SD_SD, SD_SDIO } |
| enum | sd_block_size { SD_BLOCK_SIZE_1B, SD_BLOCK_SIZE_2B, SD_BLOCK_SIZE_4B, SD_BLOCK_SIZE_8B, SD_BLOCK_SIZE_16B, SD_BLOCK_SIZE_32B, SD_BLOCK_SIZE_64B, SD_BLOCK_SIZE_128B, SD_BLOCK_SIZE_256B, SD_BLOCK_SIZE_512B, SD_BLOCK_SIZE_1024B, SD_BLOCK_SIZE_2048B } |
| enum | sd_bus_wide { SD_BusWide_1b, SD_BusWide_4b, SD_BusWide_8b } |
Functions | |
| struct sd * | sd_init (uint32_t index, struct sd_setting *settings) |
| int32_t | sd_deinit (struct sd *sd) |
| int32_t | sd_setBlockSize (struct sd *sd, enum sd_block_size blockSize) |
| int32_t | sd_setBusWide (struct sd *sd, enum sd_bus_wide busWide) |
| int32_t | sd_setClock (struct sd *sd, uint64_t clock) |
| int32_t | sd_sendCommand (struct sd *sd, uint32_t command, uint32_t argument, struct sd_response *response, TickType_t waittime) |
| int32_t | sd_write (struct sd *sd, uint32_t command, uint32_t argument, size_t size, uint32_t *data, TickType_t waittime) |
| int32_t | sd_read (struct sd *sd, uint32_t command, uint32_t argument, size_t size, uint32_t *data, TickType_t waittime) |
| int32_t | sd_sendCommandISR (struct sd *sd, uint32_t command, uint32_t argument, struct sd_response *response) |
| int32_t | sd_writeISR (struct sd *sd, uint32_t command, uint32_t argument, size_t size, uint32_t *data) |
| int32_t | sd_readISR (struct sd *sd, uint32_t command, uint32_t argument, size_t size, uint32_t *data) |
| #define ACMD | ( | x | ) | (x) |
| #define CMD | ( | x | ) | (x) |
Define a CMD
| x | CMD ID |
| #define SD_ERROR_ADDRESS_ERROR -14 |
A misaligned address which did not match the block length was used in the command.
| #define SD_ERROR_AKE_SEQ_ERROR -2 |
Error in the sequence of the authentication process
| #define SD_ERROR_CARD_ECC_FAIELD -5 |
Card internal ECC was applied but failed to correct the data.
| #define SD_ERROR_CARD_IS_LOCKED -9 |
When set, signals that the card is locked by the host
| #define SD_ERROR_CC_ERROR -4 |
Internal card controller error
| #define SD_ERROR_COM_CRC_ERROR -7 |
The CRC check of the previous command failed.
| #define SD_ERROR_ERASE_LEN_ERROR -13 |
The transferred block length is not allowed for this card, or the number of transferred bytes does not match the block length.
| #define SD_ERROR_ERASE_PARAM -11 |
An invalid selection of write-blocks for erase occurred.
| #define SD_ERROR_ERASE_SEQ_ERROR -12 |
An error in the sequence of erase commands occurred.
| #define SD_ERROR_ERROR -3 |
A general or an unknown error occurred during the operation.
| #define SD_ERROR_FUNCTION_NUMBER -16 |
An invalid function number was requested
| #define SD_ERROR_ILLEGAL_COMMAND -6 |
Command not legal for the card state
| #define SD_ERROR_LOCK_UNLOCK_FAILED -8 |
Set when a sequence or password error has been detected in lock/unlock card command.
| #define SD_ERROR_OUT_OF_RANGE -15 |
The command's argument was out of the allowed range for this card.
| #define SD_ERROR_WP_VIOLATION -10 |
Set when the host attempts to write to a protected block or to the temporary or permanent writeprotected card.
| enum sd_block_size |
| enum sd_bus_wide |
| enum sd_mode |
| int32_t sd_deinit | ( | struct sd * | sd | ) |
Deinit Driver Instants
| sd | Instant |
| struct sd* sd_init | ( | uint32_t | index, |
| struct sd_setting * | settings | ||
| ) |
Init Function
| index | in sds Array |
| settings | Settings |
| int32_t sd_read | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| size_t | size, | ||
| uint32_t * | data, | ||
| TickType_t | waittime | ||
| ) |
Read Data to SD
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| size | Buffer Size |
| data | Buffer Pointer |
| waittime | Waittime |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)
| int32_t sd_readISR | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| size_t | size, | ||
| uint32_t * | data | ||
| ) |
Read Data to SD
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| size | Buffer Size |
| data | Buffer Pointer |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)
| int32_t sd_sendCommand | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| struct sd_response * | response, | ||
| TickType_t | waittime | ||
| ) |
Send Command
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| response | Card Response NULL on not needed |
| waittime | Waittime |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)
| int32_t sd_sendCommandISR | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| struct sd_response * | response | ||
| ) |
Send Command
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| response | Card Response |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)
| int32_t sd_setBlockSize | ( | struct sd * | sd, |
| enum sd_block_size | blockSize | ||
| ) |
Set Block Size
| sd | Instants |
| blockSize | Block Size |
| int32_t sd_setBusWide | ( | struct sd * | sd, |
| enum sd_bus_wide | busWide | ||
| ) |
Set Bus Wide
| sd | Instants |
| busWide | Bus Wide |
| int32_t sd_setClock | ( | struct sd * | sd, |
| uint64_t | clock | ||
| ) |
Set Clock
| sd | Instants |
| clock | Clock Speed in Hz |
| int32_t sd_write | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| size_t | size, | ||
| uint32_t * | data, | ||
| TickType_t | waittime | ||
| ) |
Wirte Data to SD
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| size | Buffer Size |
| data | Buffer Pointer |
| waittime | Waittime |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)
| int32_t sd_writeISR | ( | struct sd * | sd, |
| uint32_t | command, | ||
| uint32_t | argument, | ||
| size_t | size, | ||
| uint32_t * | data | ||
| ) |
Wirte Data to SD
| sd | Instants |
| command | Command |
| argument | Command Argument without CMD ID and CRC. CRC is Calculated by Driver or Hardware |
| size | Buffer Size |
| data | Buffer Pointer |
Is Response == R2, R3, R4 and R7 return is always 0
Is Response == R1 following error can occur (Desciption in Standart s. Card Status)
Is Response == R5 following error can occur (Desciption in Standart s. SDIO R5)
Is Response == R6 following error can occur (Desciption in Standart Response R6)