diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-11 22:34:40 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-11 22:34:40 +0000 |
commit | 69cda776015079252639b7b4d623f79547335e56 (patch) | |
tree | f2e236cbf2d5d8e366ed4d515cb766266427908c /nuttx | |
parent | 5c7e3957a2fc4331a084f952e69c577baa469e1c (diff) | |
download | px4-nuttx-69cda776015079252639b7b4d623f79547335e56.tar.gz px4-nuttx-69cda776015079252639b7b4d623f79547335e56.tar.bz2 px4-nuttx-69cda776015079252639b7b4d623f79547335e56.zip |
Incremental update to STM32 MMCSD driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2246 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_sdio.c | 4 | ||||
-rwxr-xr-x | nuttx/include/nuttx/sdio.h | 176 |
2 files changed, 98 insertions, 82 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index 8d0985a71..7d9eafcef 100644 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -431,14 +431,14 @@ static void stm32_sendcmd(FAR struct sdio_dev_s *dev, uint32 cmd, putreg32(arg, STM32_SDIO_ARG); - /* Clear CMDINDEX, WAITRESP, WAITINT, WAITPEND, CPSMEN bits */
+ /* Clear CMDINDEX, WAITRESP, WAITINT, WAITPEND, and CPSMEN bits */
regval = getreg32(STM32_SDIO_CMD);
regval &= ~(SDIO_CMD_CMDINDEX_MASK|SDIO_CMD_WAITRESP_MASK| SDIO_CMD_WAITINT|SDIO_CMD_WAITPEND|SDIO_CMD_CPSMEN); /* Set WAITRESP bits */ -#warning VERIFY + switch ((cmd & MMCSD_RESPONSE_MASK) >> MMCSD_RESPONSE_SHIFT) { case MMCSD_NO_RESPONSE: diff --git a/nuttx/include/nuttx/sdio.h b/nuttx/include/nuttx/sdio.h index bacb1db70..dd86c1723 100755 --- a/nuttx/include/nuttx/sdio.h +++ b/nuttx/include/nuttx/sdio.h @@ -63,10 +63,11 @@ /* Commands are bit-encoded to provide as much information to the SDIO driver as * possible in 32-bits. The encoding is as follows: * - * ---- ---- ---- ---- ---- --RR RRCC CCCC + * ---- ---- ---- ---- ---T TTRR RRCC CCCC * - * CCCCCC - Bits 0-5: 6-bit command index (Range 9-63) - * RRRR - Bits 6-9: 4-bit response code (R1, R1B, R2-5) + * CCCCCC - Bits 0-5: 6-bit command index (Range 9-63) + * RRRR - Bits 6-9: 4-bit response code (R1, R1B, R2-5) + * TTT - Bits 10-12: Data transfer type */ /* MMC, SD, SDIO Common Indices */ @@ -115,7 +116,7 @@ # define MMC_CMDIDX20 20 /* WRITE_DAT_UNTIL_STOP: (MMC) * -Addressed data transfer command, R1 response 31:0=DADR R1 */ # define MMC_CMDIDX23 23 /* SET_BLOCK_COUNT: (MMC) - * -Addressed data transfer command, R1 response 31:0=DADR */ + * -Addressed command, R1 response 31:0=DADR */ # define MMCSD_CMDIDX24 24 /* WRITE_BLOCK: Writes a block of the selected size * -Addressed data transfer command, R1 response 31:0=DADR */ # define MMCSD_CMDIDX25 25 /* WRITE_MULTIPLE_BLOCK: Continuously writes blocks of data @@ -190,82 +191,97 @@ #define MMCSD_RESPONSE_SHIFT (6) #define MMCSD_RESPONSE_MASK (15 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_NO_RESPONSE (0 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R1_RESPONSE (1 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R1B_RESPONSE (2 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R2_RESPONSE (3 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R3_RESPONSE (4 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R4_RESPONSE (5 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R5_RESPONSE (6 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R6_RESPONSE (7 << MMCSD_RESPONSE_SHIFT) -# define MMCSD_R7_RESPONSE (8 << MMCSD_RESPONSE_SHIFT) +# define MMCSD_NO_RESPONSE (0) +# define MMCSD_R1_RESPONSE (1 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R1B_RESPONSE (2 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R2_RESPONSE (3 << MMCSD_RESPONSE_SHIFT) /* 128-bit */ +# define MMCSD_R3_RESPONSE (4 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R4_RESPONSE (5 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R5_RESPONSE (6 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R6_RESPONSE (7 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ +# define MMCSD_R7_RESPONSE (8 << MMCSD_RESPONSE_SHIFT) /* 48-bit */ + +/* Data Transfer Type */ + +#define MMCSD_DATAXFR_SHIFT (10) +#define MMCSD_DATAXFR_MASK (7 << MMCSD_DATAXFR_SHIFT) +# define MMCSD_DATAXFR (1 << MMCSD_DATAXFR_SHIFT) +# define MMCSD_STREAM (2 << MMCSD_DATAXFR_SHIFT) +# define MMCSD_WRXFR (4 << MMCSD_DATAXFR_SHIFT) + +# define MMCSD_NODATAXFR (0) +# define MMCSD_RDSTREAM (MMCSD_STREAM) +# define MMCSD_WRSTREAM (MMCSD_STREAM|MMCSD_WRXFR) +# define MMCSD_RDDATAXFR (MMCSD_DATAXFR) +# define MMCSD_WRDATAXFR (MMCSD_DATAXFR|MMCSD_WRXFR) /* Fully decorated MMC, SD, SDIO commands */ -#define MMCSD_CMD0 (MMCSD_CMDIDX0 |MMCSD_NO_RESPONSE) -#define MMC_CMD1 (MMC_CMDIDX1 |MMCSD_R3_RESPONSE) -#define MMCSD_CMD2 (MMCSD_CMDIDX2 |MMCSD_R2_RESPONSE) -#define MMC_CMD3 (MMC_CMDIDX3 |MMCSD_R1_RESPONSE) -#define SD_CMD3 (SD_CMDIDX3 |MMCSD_R6_RESPONSE) -#define MMCSD_CMD4 (MMCSD_CMDIDX4 |MMCSD_NO_RESPONSE) -#define SDIO_CMD5 (SDIO_CMDIDX5 |MMCSD_R4_RESPONSE) -#define MMCSD_CMD6 (MMCSD_CMDIDX6 |MMCSD_R1_RESPONSE) -#define MMCSD_CMD7S (MMCSD_CMDIDX7 |MMCSD_R1B_RESPONSE) -#define MMCSD_CMD7D (MMCSD_CMDIDX7 |MMCSD_NO_RESPONSE) /* No response when de-selecting card */ -#define SD_CMD8 (SD_CMDIDX8 |MMCSD_R7_RESPONSE) -#define MMCSD_CMD9 (MMCSD_CMDIDX9 |MMCSD_R2_RESPONSE) -#define MMCSD_CMD10 (MMCSD_CMDIDX10|MMCSD_R2_RESPONSE) -#define MMC_CMD11 (MMC_CMDIDX11 |MMCSD_R1_RESPONSE) -#define MMCSD_CMD12 (MMCSD_CMDIDX12|MMCSD_R1B_RESPONSE) -#define MMCSD_CMD13 (MMCSD_CMDIDX13|MMCSD_R1_RESPONSE) -#define MMCSD_CMD14 (MMCSD_CMDIDX14|MMCSD_R1_RESPONSE) -#define MMCSD_CMD15 (MMCSD_CMDIDX15|MMCSD_R1_RESPONSE) -#define MMCSD_CMD16 (MMCSD_CMDIDX16|MMCSD_R1_RESPONSE) -#define MMCSD_CMD17 (MMCSD_CMDIDX17|MMCSD_R1_RESPONSE) -#define MMCSD_CMD18 (MMCSD_CMDIDX18|MMCSD_R1_RESPONSE) -#define MMCSD_CMD19 (MMCSD_CMDIDX19|MMCSD_R1_RESPONSE) -#define MMC_CMD23 (MMC_CMDIDX23 |MMCSD_R1_RESPONSE) -#define MMCSD_CMD24 (MMCSD_CMDIDX24|MMCSD_R1_RESPONSE) -#define MMCSD_CMD25 (MMCSD_CMDIDX25|MMCSD_R1_RESPONSE) -#define MMCSD_CMD26 (MMCSD_CMDIDX26|MMCSD_R1_RESPONSE) -#define MMCSD_CMD27 (MMCSD_CMDIDX27|MMCSD_R1_RESPONSE) -#define MMCSD_CMD28 (MMCSD_CMDIDX28|MMCSD_R1B_RESPONSE) -#define MMCSD_CMD29 (MMCSD_CMDIDX29|MMCSD_R1B_RESPONSE) -#define MMCSD_CMD30 (MMCSD_CMDIDX30|MMCSD_R1_RESPONSE) -#define SD_CMD32 (SD_CMDIDX32 |MMCSD_R1_RESPONSE) -#define SD_CMD33 (SD_CMDIDX33 |MMCSD_R1_RESPONSE) -#define MMC_CMD34 (MMC_CMDIDX34 |MMCSD_R1_RESPONSE) -#define MMC_CMD35 (MMC_CMDIDX35 |MMCSD_R1_RESPONSE) -#define MMC_CMD36 (MMC_CMDIDX36 |MMCSD_R1_RESPONSE) -#define MMC_CMD37 (MMC_CMDIDX37 |MMCSD_R1_RESPONSE) -#define MMCSD_CMD38 (MMCSD_CMDIDX38|MMCSD_R1B_RESPONSE) -#define MMC_CMD39 (MMC_CMDIDX39 |MMCSD_R4_RESPONSE) -#define MMC_CMD40 (MMC_CMDIDX40 |MMCSD_R5_RESPONSE) -#define MMCSD_CMD42 (MMCSD_CMDIDX42|MMCSD_R1B_RESPONSE) -#define SD_CMD55 (SD_CMDIDX55 |MMCSD_R1_RESPONSE) -#define MMCSD_CMD56 (MMCSD_CMDIDX56|MMCSD_R1_RESPONSE) +#define MMCSD_CMD0 (MMCSD_CMDIDX0 |MMCSD_NO_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD1 (MMC_CMDIDX1 |MMCSD_R3_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD2 (MMCSD_CMDIDX2 |MMCSD_R2_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD3 (MMC_CMDIDX3 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_CMD3 (SD_CMDIDX3 |MMCSD_R6_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD4 (MMCSD_CMDIDX4 |MMCSD_NO_RESPONSE |MMCSD_NODATAXFR) +#define SDIO_CMD5 (SDIO_CMDIDX5 |MMCSD_R4_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD6 (MMCSD_CMDIDX6 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD7S (MMCSD_CMDIDX7 |MMCSD_R1B_RESPONSE|MMCSD_NODATAXFR) +#define MMCSD_CMD7D (MMCSD_CMDIDX7 |MMCSD_NO_RESPONSE |MMCSD_NODATAXFR) /* No response when de-selecting card */ +#define SD_CMD8 (SD_CMDIDX8 |MMCSD_R7_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD9 (MMCSD_CMDIDX9 |MMCSD_R2_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD10 (MMCSD_CMDIDX10|MMCSD_R2_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD11 (MMC_CMDIDX11 |MMCSD_R1_RESPONSE |MMCSD_RDSTREAM ) +#define MMCSD_CMD12 (MMCSD_CMDIDX12|MMCSD_R1B_RESPONSE|MMCSD_NODATAXFR) +#define MMCSD_CMD13 (MMCSD_CMDIDX13|MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD14 (MMCSD_CMDIDX14|MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD15 (MMCSD_CMDIDX15|MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD16 (MMCSD_CMDIDX16|MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD17 (MMCSD_CMDIDX17|MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define MMCSD_CMD18 (MMCSD_CMDIDX18|MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define MMCSD_CMD19 (MMCSD_CMDIDX19|MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD20 (MMC_CMDIDX20 |MMCSD_R1B_RESPONSE|MMCSD_WRSTREAM ) +#define MMC_CMD23 (MMC_CMDIDX23 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD24 (MMCSD_CMDIDX24|MMCSD_R1_RESPONSE |MMCSD_WRDATAXFR) +#define MMCSD_CMD25 (MMCSD_CMDIDX25|MMCSD_R1_RESPONSE |MMCSD_WRDATAXFR) +#define MMCSD_CMD26 (MMCSD_CMDIDX26|MMCSD_R1_RESPONSE |MMCSD_WRDATAXFR) +#define MMCSD_CMD27 (MMCSD_CMDIDX27|MMCSD_R1_RESPONSE |MMCSD_WRDATAXFR) +#define MMCSD_CMD28 (MMCSD_CMDIDX28|MMCSD_R1B_RESPONSE|MMCSD_NODATAXFR) +#define MMCSD_CMD29 (MMCSD_CMDIDX29|MMCSD_R1B_RESPONSE|MMCSD_NODATAXFR) +#define MMCSD_CMD30 (MMCSD_CMDIDX30|MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define SD_CMD32 (SD_CMDIDX32 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_CMD33 (SD_CMDIDX33 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD34 (MMC_CMDIDX34 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD35 (MMC_CMDIDX35 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD36 (MMC_CMDIDX36 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD37 (MMC_CMDIDX37 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD38 (MMCSD_CMDIDX38|MMCSD_R1B_RESPONSE|MMCSD_NODATAXFR) +#define MMC_CMD39 (MMC_CMDIDX39 |MMCSD_R4_RESPONSE |MMCSD_NODATAXFR) +#define MMC_CMD40 (MMC_CMDIDX40 |MMCSD_R5_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD42 (MMCSD_CMDIDX42|MMCSD_R1B_RESPONSE|MMCSD_WRDATAXFR) +#define SD_CMD55 (SD_CMDIDX55 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define MMCSD_CMD56 (MMCSD_CMDIDX56|MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) /* SD/SDIO APP commands (must be preceded by CMD55) */ -#define SD_ACMD6 (SD_ACMDIDX6 |MMCSD_R1_RESPONSE) -#define SD_ACMD13 (SD_ACMDIDX13 |MMCSD_R1_RESPONSE) -#define SD_ACMD18 (SD_ACMDIDX18 |MMCSD_R1_RESPONSE) -#define SD_ACMD22 (SD_ACMDIDX22 |MMCSD_R1_RESPONSE) -#define SD_ACMD23 (SD_ACMDIDX23 |MMCSD_R1_RESPONSE) -#define SD_ACMD25 (SD_ACMDIDX25 |MMCSD_R1_RESPONSE) -#define SD_ACMD38 (SD_ACMDIDX38 |MMCSD_R1_RESPONSE) -#define SD_ACMD41 (SD_ACMDIDX41 |MMCSD_R3_RESPONSE) -#define SD_ACMD42 (SD_ACMDIDX42 |MMCSD_R1_RESPONSE) -#define SD_ACMD43 (SD_ACMDIDX43 |MMCSD_R1_RESPONSE) -#define SD_ACMD44 (SD_ACMDIDX44 |MMCSD_R1_RESPONSE) -#define SD_ACMD45 (SD_ACMDIDX45 |MMCSD_R1_RESPONSE) -#define SD_ACMD46 (SD_ACMDIDX46 |MMCSD_R1_RESPONSE) -#define SD_ACMD47 (SD_ACMDIDX47 |MMCSD_R1_RESPONSE) -#define SD_ACMD48 (SD_ACMDIDX48 |MMCSD_R1_RESPONSE) -#define SD_ACMD49 (SD_ACMDIDX49 |MMCSD_R1_RESPONSE) -#define SD_ACMD51 (SD_ACMDIDX51 |MMCSD_R1_RESPONSE) -#define SDIO_ACMD52 (SDIO_ACMDIDX52|MMCSD_R5_RESPONSE) -#define SDIO_ACMD53 (SDIO_ACMDIDX53|MMCSD_R5_RESPONSE) +#define SD_ACMD6 (SD_ACMDIDX6 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD13 (SD_ACMDIDX13 |MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define SD_ACMD18 (SD_ACMDIDX18 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD22 (SD_ACMDIDX22 |MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define SD_ACMD23 (SD_ACMDIDX23 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD25 (SD_ACMDIDX25 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD38 (SD_ACMDIDX38 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD41 (SD_ACMDIDX41 |MMCSD_R3_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD42 (SD_ACMDIDX42 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD43 (SD_ACMDIDX43 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD44 (SD_ACMDIDX44 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD45 (SD_ACMDIDX45 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD46 (SD_ACMDIDX46 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD47 (SD_ACMDIDX47 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD48 (SD_ACMDIDX48 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD49 (SD_ACMDIDX49 |MMCSD_R1_RESPONSE |MMCSD_NODATAXFR) +#define SD_ACMD51 (SD_ACMDIDX51 |MMCSD_R1_RESPONSE |MMCSD_RDDATAXFR) +#define SDIO_ACMD52 (SDIO_ACMDIDX52|MMCSD_R5_RESPONSE |MMCSD_NODATAXFR) +#define SDIO_ACMD53 (SDIO_ACMDIDX53|MMCSD_R5_RESPONSE |MMCSD_NODATAXFR) /**************************************************************************** * Name: SDIO_RESET @@ -429,12 +445,12 @@ * ****************************************************************************/ -#define SDIO_RECVR1(dev,buffer) ((dev)->recvR1(dev,buffer)) -#define SDIO_RECVR2(dev,buffer) ((dev)->recvR2(dev,buffer)) -#define SDIO_RECVR3(dev,buffer) ((dev)->recvR3(dev,buffer)) -#define SDIO_RECVR4(dev,buffer) ((dev)->recvR4(dev,buffer)) -#define SDIO_RECVR5(dev,buffer) ((dev)->recvR5(dev,buffer)) -#define SDIO_RECVR6(dev,buffer) ((dev)->recvR6(dev,buffer)) +#define SDIO_RECVR1(dev,buffer) ((dev)->recvR1(dev,buffer)) /* 48-bit */ +#define SDIO_RECVR2(dev,buffer) ((dev)->recvR2(dev,buffer)) /* 128-bit */ +#define SDIO_RECVR3(dev,buffer) ((dev)->recvR3(dev,buffer)) /* 48-bit */ +#define SDIO_RECVR4(dev,buffer) ((dev)->recvR4(dev,buffer)) /* 48-bit */ +#define SDIO_RECVR5(dev,buffer) ((dev)->recvR5(dev,buffer)) /* 48-bit */ +#define SDIO_RECVR6(dev,buffer) ((dev)->recvR6(dev,buffer)) /* 48-bit */ /**************************************************************************** * Name: SDIO_RECVDATA |