summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJack Halpin <jack.halpin@gmail.com>2010-03-26 17:00:25 +0000
committerJack Halpin <jack.halpin@gmail.com>2010-03-26 17:00:25 +0000
commit4b0c43da8f251a34feb127d15fc6c402527fc317 (patch)
tree63f356a0a43e1d838cd8d83a9d1fb1bc30f42fda /firmware
parentd3312b7f16ecc5e774c1d6240f79be396940a993 (diff)
sd-as3525v2.c Organize construction of MCI_COMMAND so it is more apparent which bits are being set and why.
I have also made the CMD_CHECK_CRC_BIT unused for now since we do not check any response crc values yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25343 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 273507c495..44ac731133 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -381,29 +381,31 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
GPIOB_PIN(5) = (1-drive) << 5;
active_card = drive;
}
-
- MCI_COMMAND = cmd | CMD_CARD_NO(drive);
-#else
- (void) drive;
- MCI_COMMAND = cmd;
#endif
- if(flags & MCI_RESP)
- {
- MCI_COMMAND |= CMD_RESP_EXP_BIT;
- if(flags & MCI_LONG_RESP)
- MCI_COMMAND |= CMD_RESP_LENGTH_BIT;
- }
-
- if(cmd == SD_READ_MULTIPLE_BLOCK || cmd == SD_WRITE_MULTIPLE_BLOCK)
- {
- MCI_COMMAND |= CMD_WAIT_PRV_DAT_BIT | CMD_DATA_EXP_BIT;
- if(cmd == SD_WRITE_MULTIPLE_BLOCK)
- MCI_COMMAND |= CMD_RW_BIT | CMD_CHECK_CRC_BIT;
- }
+#define TRANSFER_CMD (cmd == SD_READ_MULTIPLE_BLOCK || \
+ cmd == SD_WRITE_MULTIPLE_BLOCK)
MCI_ARGUMENT = arg;
- MCI_COMMAND |= CMD_DONE_BIT;
+
+ /* Construct MCI_COMMAND */
+ MCI_COMMAND =
+ /*b5:0*/ cmd
+ /*b6 */ | ((flags & MCI_RESP) ? CMD_RESP_EXP_BIT: 0)
+ /*b7 */ | ((flags & MCI_LONG_RESP) ? CMD_RESP_LENGTH_BIT: 0)
+ /*b8 | CMD_CHECK_CRC_BIT unused */
+ /*b9 */ | (TRANSFER_CMD ? CMD_DATA_EXP_BIT: 0)
+ /*b10 */ | ((cmd == SD_WRITE_MULTIPLE_BLOCK) ? CMD_RW_BIT: 0)
+ /*b11 | CMD_TRANSMODE_BIT unused */
+ /*b12 | CMD_SENT_AUTO_STOP_BIT unused */
+ /*b13 */ | (TRANSFER_CMD ? CMD_WAIT_PRV_DAT_BIT: 0)
+ /*b14 | CMD_ABRT_CMD_BIT unused */
+ /*b15 | CMD_SEND_INIT_BIT unused */
+ /*b20:16 */ | CMD_CARD_NO(drive)
+ /*b21 | CMD_SEND_CLK_ONLY unused */
+ /*b22 | CMD_READ_CEATA unused */
+ /*b23 | CMD_CCS_EXPECTED unused */
+ /*b31 */ | CMD_DONE_BIT;
int max = 0x40000;
while(MCI_COMMAND & CMD_DONE_BIT)
@@ -412,7 +414,7 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
return false;
}
-
+ /* TODO Check crc values to determine if the response was valid */
if(flags & MCI_RESP)
{
int i = 0xff; while(i--) ;