SAM4S-EK_FreeRTOS+FAT-SL
1.0
An example project to test the functionality of FreeRTOS+FAT-SL using SD card as data storage medium
|
Macros | |
#define | SDMMC_CLOCK_INIT 400000 |
Macros for command definition | |
Specific MMC norms: CMD1, CMD2 & CMD3 are processed in the open-drain mode. The CMD line is driven with push-pull drivers. Specific SD norms: There is no open drain mode in SD memory card. Responses types: R1, R3, R4 & R5 use a 48 bits response protected by a 7bit CRC checksum
R1b assert the BUSY signal and respond with R1. If the busy signal is asserted, it is done two clock cycles (Nsr time) after the end bit of the command. The DAT0 line is driven low. DAT1-DAT7 lines are driven by the card though their values are not relevant. R2 use a 136 bits response protected by a 7bit CRC checksum The content is CID or CSD Specific MMC norms:
Specific SD norms:
| |
typedef uint32_t | sdmmc_cmd_def_t |
Value to define a SD/MMC/SDIO command. More... | |
Flags used to define a SD/MMC/SDIO command | |
#define | SDMMC_CMD_GET_INDEX(cmd) (cmd & 0x3F) |
#define | SDMMC_RESP_PRESENT (1lu << 8) |
Have response (MCI only) More... | |
#define | SDMMC_RESP_8 (1lu << 9) |
8 bit response (SPI only) More... | |
#define | SDMMC_RESP_32 (1lu << 10) |
32 bit response (SPI only) More... | |
#define | SDMMC_RESP_136 (1lu << 11) |
136 bit response (MCI only) More... | |
#define | SDMMC_RESP_CRC (1lu << 12) |
Expect valid crc (MCI only) More... | |
#define | SDMMC_RESP_BUSY (1lu << 13) |
Card may send busy. More... | |
#define | SDMMC_CMD_OPENDRAIN (1lu << 14) |
#define | SDMMC_CMD_WRITE (1lu << 15) |
To signal a data write operation. More... | |
#define | SDMMC_CMD_SDIO_BYTE (1lu << 16) |
To signal a SDIO tranfer in multi byte mode. More... | |
#define | SDMMC_CMD_SDIO_BLOCK (1lu << 17) |
To signal a SDIO tranfer in block mode. More... | |
#define | SDMMC_CMD_STREAM (1lu << 18) |
To signal a data transfer in stream mode. More... | |
#define | SDMMC_CMD_SINGLE_BLOCK (1lu << 19) |
To signal a data transfer in single block mode. More... | |
#define | SDMMC_CMD_MULTI_BLOCK (1lu << 20) |
To signal a data transfer in multi block mode. More... | |
Set of flags to define a reponse type | |
#define | SDMMC_CMD_NO_RESP (0) |
#define | SDMMC_CMD_R1 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC) |
#define | SDMMC_CMD_R1B (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC | SDMMC_RESP_BUSY) |
#define | SDMMC_CMD_R2 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_136 | SDMMC_RESP_CRC) |
#define | SDMMC_CMD_R3 (SDMMC_RESP_PRESENT | SDMMC_RESP_32) |
#define | SDMMC_CMD_R4 (SDMMC_RESP_PRESENT | SDMMC_RESP_32) |
#define | SDMMC_CMD_R5 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_CRC) |
#define | SDMMC_CMD_R6 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC) |
#define | SDMMC_CMD_R7 (SDMMC_RESP_PRESENT | SDMMC_RESP_32 | SDMMC_RESP_CRC) |
#define MMC_CMD11_READ_DAT_UNTIL_STOP (11 | SDMMC_CMD_R1) |
MMC Cmd11(adtc, R1): Read data stream from the card, starting at the given address, until a STOP_TRANSMISSION follows.
Definition at line 204 of file sd_mmc_protocol.h.
#define MMC_CMD14_BUSTEST_R (14 | SDMMC_CMD_R1) |
MMC Cmd14(adtc, R1): Read the reversed bus testing data pattern from a card.
Definition at line 214 of file sd_mmc_protocol.h.
#define MMC_CMD19_BUSTEST_W (19 | SDMMC_CMD_R1) |
MMC Cmd19(adtc, R1): Send the bus test data pattern
Definition at line 219 of file sd_mmc_protocol.h.
#define MMC_CMD20_WRITE_DAT_UNTIL_STOP (20 | SDMMC_CMD_R1) |
MMC Cmd20(adtc, R1): Write a data stream from the host, starting at the given address, until a STOP_TRANSMISSION follows.
Definition at line 243 of file sd_mmc_protocol.h.
#define MMC_CMD23_SET_BLOCK_COUNT (23 | SDMMC_CMD_R1) |
MMC Cmd23(ac, R1): Set block count
Definition at line 249 of file sd_mmc_protocol.h.
#define MMC_CMD26_PROGRAM_CID (26 | SDMMC_CMD_R1) |
MMC Cmd26(adtc, R1): Programming of the card identification register.
Definition at line 255 of file sd_mmc_protocol.h.
#define MMC_CMD35_ERASE_GROUP_START (35 | SDMMC_CMD_R1) |
MMC Cmd35(ac, R1):
Definition at line 267 of file sd_mmc_protocol.h.
#define MMC_CMD36_ERASE_GROUP_END (36 | SDMMC_CMD_R1) |
MMC Cmd36(ac, R1):
Definition at line 269 of file sd_mmc_protocol.h.
#define MMC_CMD39_FAST_IO (39 | SDMMC_CMD_R4) |
MMC Cmd39(ac, R4): Used to write and read 8 bit (register) data fields.
Definition at line 350 of file sd_mmc_protocol.h.
#define MMC_CMD3_SET_RELATIVE_ADDR (3 | SDMMC_CMD_R1) |
MMC Cmd3(ac, R1): Assigns relative address to the card
Definition at line 178 of file sd_mmc_protocol.h.
#define MMC_CMD40_GO_IRQ_STATE (40 | SDMMC_CMD_R5 | SDMMC_CMD_OPENDRAIN) |
MMC Cmd40(bcr, R5): Set the system into interrupt mode
Definition at line 352 of file sd_mmc_protocol.h.
#define MMC_CMD5_SLEEP_AWAKE (5 | SDMMC_CMD_R1B) |
MMC Cmd5(ac, R1b): Toggle the card between Sleep state and Standby state.
Definition at line 182 of file sd_mmc_protocol.h.
#define MMC_CMD6_SWITCH (6 | SDMMC_CMD_R1B) |
MMC Cmd6(ac, R1b) : Switche the mode of operation of the selected card or modifies the EXT_CSD registers.
Definition at line 307 of file sd_mmc_protocol.h.
#define MMC_CMD8_SEND_EXT_CSD (8 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK) |
MMC Cmd8(adtc, R1): Send EXT_CSD register as a block of data
Definition at line 191 of file sd_mmc_protocol.h.
#define MMC_MCI_CMD1_SEND_OP_COND (1 | SDMMC_CMD_R3 | SDMMC_CMD_OPENDRAIN) |
Definition at line 172 of file sd_mmc_protocol.h.
#define MMC_SPI_CMD1_SEND_OP_COND (1 | SDMMC_CMD_R1) |
MMC Cmd1(bcr, R3): Ask the card to send its Operating Conditions
Definition at line 171 of file sd_mmc_protocol.h.
#define SD_ACMD13_SD_STATUS (13 | SDMMC_CMD_R1) |
ACMD13(adtc, R1): Send the SD Status.
Definition at line 316 of file sd_mmc_protocol.h.
#define SD_ACMD22_SEND_NUM_WR_BLOCKS (22 | SDMMC_CMD_R1) |
ACMD22(adtc, R1): Send the number of the written (with-out errors) write blocks.
Definition at line 321 of file sd_mmc_protocol.h.
#define SD_ACMD23_SET_WR_BLK_ERASE_COUNT (23 | SDMMC_CMD_R1) |
ACMD23(ac, R1): Set the number of write blocks to be pre-erased before writing
Definition at line 326 of file sd_mmc_protocol.h.
#define SD_ACMD42_SET_CLR_CARD_DETECT (42 | SDMMC_CMD_R1) |
ACMD42(ac, R1): Connect[1]/Disconnect[0] the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card.
Definition at line 342 of file sd_mmc_protocol.h.
#define SD_ACMD51_SEND_SCR (51 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK) |
ACMD51(adtc, R1): Read the SD Configuration Register (SCR).
Definition at line 344 of file sd_mmc_protocol.h.
#define SD_ACMD6_SET_BUS_WIDTH (6 | SDMMC_CMD_R1) |
ACMD6(ac, R1): Define the data bus width
Definition at line 314 of file sd_mmc_protocol.h.
#define SD_CMD11_READ_DAT_UNTIL_STOP (11 | SDMMC_CMD_R1) |
Definition at line 206 of file sd_mmc_protocol.h.
#define SD_CMD32_ERASE_WR_BLK_START (32 | SDMMC_CMD_R1) |
SD Cmd32(ac, R1):
Definition at line 263 of file sd_mmc_protocol.h.
#define SD_CMD33_ERASE_WR_BLK_END (33 | SDMMC_CMD_R1) |
SD Cmd33(ac, R1):
Definition at line 265 of file sd_mmc_protocol.h.
#define SD_CMD3_SEND_RELATIVE_ADDR (3 | SDMMC_CMD_R6 | SDMMC_CMD_OPENDRAIN) |
SD Cmd3(bcr, R6): Ask the card to publish a new relative address (RCA)
Definition at line 176 of file sd_mmc_protocol.h.
#define SD_CMD6_SWITCH_FUNC (6 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK) |
SD Cmd6(adtc, R1) : Check switchable function (mode 0) and switch card function (mode 1).
Definition at line 312 of file sd_mmc_protocol.h.
#define SD_CMD8_SEND_IF_COND (8 | SDMMC_CMD_R7 | SDMMC_CMD_OPENDRAIN) |
SD Cmd8(bcr, R7) : Send SD Memory Card interface condition
Definition at line 193 of file sd_mmc_protocol.h.
#define SD_MCI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R3 | SDMMC_CMD_OPENDRAIN) |
ACMD41(bcr, R3): Send host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response
Definition at line 332 of file sd_mmc_protocol.h.
#define SD_SPI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R1) |
ACMD41(R1): Send host capacity support information (HCS) and activates the card's initilization process
Definition at line 337 of file sd_mmc_protocol.h.
#define SDIO_CMD52_IO_RW_DIRECT (52 | SDMMC_CMD_R5) |
SDIO CMD52(R5): Direct IO read/write
Definition at line 356 of file sd_mmc_protocol.h.
#define SDIO_CMD53_IO_R_BLOCK_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BLOCK) |
Definition at line 360 of file sd_mmc_protocol.h.
#define SDIO_CMD53_IO_R_BYTE_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BYTE) |
SDIO CMD53(R5): Extended IO read/write
Definition at line 358 of file sd_mmc_protocol.h.
#define SDIO_CMD53_IO_W_BLOCK_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BLOCK | SDMMC_CMD_WRITE) |
Definition at line 361 of file sd_mmc_protocol.h.
#define SDIO_CMD53_IO_W_BYTE_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BYTE | SDMMC_CMD_WRITE) |
Definition at line 359 of file sd_mmc_protocol.h.
#define SDIO_CMD5_SEND_OP_COND (5 | SDMMC_CMD_R4 | SDMMC_CMD_OPENDRAIN) |
SDIO Cmd5(R4): Send operation condition
Definition at line 354 of file sd_mmc_protocol.h.
#define SDMMC_CLOCK_INIT 400000 |
Definition at line 60 of file sd_mmc_protocol.h.
#define SDMMC_CMD10_SEND_CID (10 | SDMMC_CMD_R2) |
Cmd10(ac, R2): Addressed card sends its card identification (CID)
Definition at line 199 of file sd_mmc_protocol.h.
#define SDMMC_CMD12_STOP_TRANSMISSION (12 | SDMMC_CMD_R1B) |
Cmd12(ac, R1b): Force the card to stop transmission
Definition at line 208 of file sd_mmc_protocol.h.
#define SDMMC_CMD15_GO_INACTIVE_STATE (15 | SDMMC_CMD_NO_RESP | SDMMC_CMD_OPENDRAIN) |
Cmd15(ac): Send an addressed card into the Inactive State.
Definition at line 217 of file sd_mmc_protocol.h.
#define SDMMC_CMD16_SET_BLOCKLEN (16 | SDMMC_CMD_R1) |
Cmd16(ac, R1): Set the block length (in bytes)
Definition at line 229 of file sd_mmc_protocol.h.
#define SDMMC_CMD17_READ_SINGLE_BLOCK (17 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK) |
Cmd17(adtc, R1): Read single block
Definition at line 231 of file sd_mmc_protocol.h.
#define SDMMC_CMD18_READ_MULTIPLE_BLOCK (18 | SDMMC_CMD_R1 | SDMMC_CMD_MULTI_BLOCK) |
Cmd18(adtc, R1): Read multiple block
Definition at line 233 of file sd_mmc_protocol.h.
#define SDMMC_CMD24_WRITE_BLOCK (24 | SDMMC_CMD_R1 | SDMMC_CMD_WRITE | SDMMC_CMD_SINGLE_BLOCK) |
Cmd24(adtc, R1): Write block
Definition at line 251 of file sd_mmc_protocol.h.
#define SDMMC_CMD25_WRITE_MULTIPLE_BLOCK (25 | SDMMC_CMD_R1 | SDMMC_CMD_WRITE | SDMMC_CMD_MULTI_BLOCK) |
Cmd25(adtc, R1): Write multiple block
Definition at line 253 of file sd_mmc_protocol.h.
#define SDMMC_CMD27_PROGRAM_CSD (27 | SDMMC_CMD_R1) |
Cmd27(adtc, R1): Programming of the programmable bits of the CSD.
Definition at line 257 of file sd_mmc_protocol.h.
#define SDMMC_CMD28_SET_WRITE_PROT (28 | SDMMC_CMD_R1B) |
Cmd28(ac, R1b): Set write protection
Definition at line 277 of file sd_mmc_protocol.h.
#define SDMMC_CMD29_CLR_WRITE_PROT (29 | SDMMC_CMD_R1B) |
Cmd29(ac, R1b): Clr write protection
Definition at line 279 of file sd_mmc_protocol.h.
#define SDMMC_CMD2_ALL_SEND_CID (2 | SDMMC_CMD_R2 | SDMMC_CMD_OPENDRAIN) |
Cmd2(bcr, R2): Ask the card to send its CID number (stuff but arg 0 used)
Definition at line 174 of file sd_mmc_protocol.h.
#define SDMMC_CMD30_SEND_WRITE_PROT (30 | SDMMC_CMD_R1) |
Cmd30(adtc, R1b): Send write protection
Definition at line 281 of file sd_mmc_protocol.h.
#define SDMMC_CMD38_ERASE (38 | SDMMC_CMD_R1B) |
Cmd38(ac, R1B):
Definition at line 271 of file sd_mmc_protocol.h.
#define SDMMC_CMD42_LOCK_UNLOCK (42 | SDMMC_CMD_R1) |
Cmd42(adtc, R1): Used to set/reset the password or lock/unlock the card.
Definition at line 287 of file sd_mmc_protocol.h.
#define SDMMC_CMD4_SET_DSR (4 | SDMMC_CMD_NO_RESP) |
Cmd4(bc): Program the DSR of all cards (MCI only)
Definition at line 180 of file sd_mmc_protocol.h.
#define SDMMC_CMD55_APP_CMD (55 | SDMMC_CMD_R1) |
Cmd55(ac, R1): Indicate to the card that the next command is an application specific command rather than a standard command.
Definition at line 296 of file sd_mmc_protocol.h.
#define SDMMC_CMD56_GEN_CMD (56 | SDMMC_CMD_R1) |
Cmd 56(adtc, R1): Used either to transfer a data block to the card or to get a data block from the card for general purpose/application specific commands.
Definition at line 301 of file sd_mmc_protocol.h.
#define SDMMC_CMD7_DESELECT_CARD_CMD (7 | SDMMC_CMD_R1) |
Definition at line 189 of file sd_mmc_protocol.h.
#define SDMMC_CMD7_SELECT_CARD_CMD (7 | SDMMC_CMD_R1B) |
Cmd7(ac, R1/R1b): Select/Deselect card For SD: R1b only from the selected card. For MMC: R1 while selecting from Stand-By State to Transfer State; R1b while selecting from Disconnected State to Programming State.
Definition at line 188 of file sd_mmc_protocol.h.
#define SDMMC_CMD_GET_INDEX | ( | cmd | ) | (cmd & 0x3F) |
Definition at line 113 of file sd_mmc_protocol.h.
#define SDMMC_CMD_MULTI_BLOCK (1lu << 20) |
To signal a data transfer in multi block mode.
Definition at line 140 of file sd_mmc_protocol.h.
#define SDMMC_CMD_NO_RESP (0) |
Definition at line 145 of file sd_mmc_protocol.h.
#define SDMMC_CMD_OPENDRAIN (1lu << 14) |
Definition at line 128 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R1 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC) |
Definition at line 146 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R1B (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC | SDMMC_RESP_BUSY) |
Definition at line 147 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R2 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_136 | SDMMC_RESP_CRC) |
Definition at line 148 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R3 (SDMMC_RESP_PRESENT | SDMMC_RESP_32) |
Definition at line 149 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R4 (SDMMC_RESP_PRESENT | SDMMC_RESP_32) |
Definition at line 150 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R5 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_CRC) |
Definition at line 151 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R6 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC) |
Definition at line 152 of file sd_mmc_protocol.h.
#define SDMMC_CMD_R7 (SDMMC_RESP_PRESENT | SDMMC_RESP_32 | SDMMC_RESP_CRC) |
Definition at line 153 of file sd_mmc_protocol.h.
#define SDMMC_CMD_SDIO_BLOCK (1lu << 17) |
To signal a SDIO tranfer in block mode.
Definition at line 134 of file sd_mmc_protocol.h.
#define SDMMC_CMD_SDIO_BYTE (1lu << 16) |
To signal a SDIO tranfer in multi byte mode.
Definition at line 132 of file sd_mmc_protocol.h.
#define SDMMC_CMD_SINGLE_BLOCK (1lu << 19) |
To signal a data transfer in single block mode.
Definition at line 138 of file sd_mmc_protocol.h.
#define SDMMC_CMD_STREAM (1lu << 18) |
To signal a data transfer in stream mode.
Definition at line 136 of file sd_mmc_protocol.h.
#define SDMMC_CMD_WRITE (1lu << 15) |
To signal a data write operation.
Definition at line 130 of file sd_mmc_protocol.h.
#define SDMMC_MCI_CMD0_GO_IDLE_STATE (0 | SDMMC_CMD_NO_RESP | SDMMC_CMD_OPENDRAIN) |
Definition at line 169 of file sd_mmc_protocol.h.
#define SDMMC_MCI_CMD13_SEND_STATUS (13 | SDMMC_CMD_R1) |
Cmd13(ac, R1): Addressed card sends its status register.
Definition at line 212 of file sd_mmc_protocol.h.
#define SDMMC_MCI_CMD9_SEND_CSD (9 | SDMMC_CMD_R2) |
Cmd9 MCI (ac, R2): Addressed card sends its card-specific data (CSD)
Definition at line 197 of file sd_mmc_protocol.h.
#define SDMMC_RESP_136 (1lu << 11) |
136 bit response (MCI only)
Definition at line 121 of file sd_mmc_protocol.h.
#define SDMMC_RESP_32 (1lu << 10) |
32 bit response (SPI only)
Definition at line 119 of file sd_mmc_protocol.h.
#define SDMMC_RESP_8 (1lu << 9) |
8 bit response (SPI only)
Definition at line 117 of file sd_mmc_protocol.h.
#define SDMMC_RESP_BUSY (1lu << 13) |
Card may send busy.
Definition at line 125 of file sd_mmc_protocol.h.
#define SDMMC_RESP_CRC (1lu << 12) |
Expect valid crc (MCI only)
Definition at line 123 of file sd_mmc_protocol.h.
#define SDMMC_RESP_PRESENT (1lu << 8) |
Have response (MCI only)
Definition at line 115 of file sd_mmc_protocol.h.
#define SDMMC_SPI_CMD0_GO_IDLE_STATE (0 | SDMMC_CMD_R1) |
Cmd0(bc): Reset all cards to idle state
Definition at line 168 of file sd_mmc_protocol.h.
#define SDMMC_SPI_CMD13_SEND_STATUS (13 | SDMMC_CMD_R2) |
Cmd13(R2): Addressed card sends its status register.
Definition at line 210 of file sd_mmc_protocol.h.
#define SDMMC_SPI_CMD58_READ_OCR (58 | SDMMC_CMD_R3) |
Cmd58(R3): Reads the OCR register of a card
Definition at line 221 of file sd_mmc_protocol.h.
#define SDMMC_SPI_CMD59_CRC_ON_OFF (59 | SDMMC_CMD_R1) |
Cmd59(R1): Turns the CRC option on or off
Definition at line 223 of file sd_mmc_protocol.h.
#define SDMMC_SPI_CMD9_SEND_CSD (9 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK) |
Cmd9 SPI (R1): Addressed card sends its card-specific data (CSD)
Definition at line 195 of file sd_mmc_protocol.h.
typedef uint32_t sdmmc_cmd_def_t |
Value to define a SD/MMC/SDIO command.
Definition at line 109 of file sd_mmc_protocol.h.