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)
downloadrockbox-4b0c43da8f251a34feb127d15fc6c402527fc317.tar.gz
rockbox-4b0c43da8f251a34feb127d15fc6c402527fc317.zip
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
381 GPIOB_PIN(5) = (1-drive) << 5; 381 GPIOB_PIN(5) = (1-drive) << 5;
382 active_card = drive; 382 active_card = drive;
383 } 383 }
384
385 MCI_COMMAND = cmd | CMD_CARD_NO(drive);
386#else
387 (void) drive;
388 MCI_COMMAND = cmd;
389#endif 384#endif
390 385
391 if(flags & MCI_RESP) 386#define TRANSFER_CMD (cmd == SD_READ_MULTIPLE_BLOCK || \
392 { 387 cmd == SD_WRITE_MULTIPLE_BLOCK)
393 MCI_COMMAND |= CMD_RESP_EXP_BIT;
394 if(flags & MCI_LONG_RESP)
395 MCI_COMMAND |= CMD_RESP_LENGTH_BIT;
396 }
397
398 if(cmd == SD_READ_MULTIPLE_BLOCK || cmd == SD_WRITE_MULTIPLE_BLOCK)
399 {
400 MCI_COMMAND |= CMD_WAIT_PRV_DAT_BIT | CMD_DATA_EXP_BIT;
401 if(cmd == SD_WRITE_MULTIPLE_BLOCK)
402 MCI_COMMAND |= CMD_RW_BIT | CMD_CHECK_CRC_BIT;
403 }
404 388
405 MCI_ARGUMENT = arg; 389 MCI_ARGUMENT = arg;
406 MCI_COMMAND |= CMD_DONE_BIT; 390
391 /* Construct MCI_COMMAND */
392 MCI_COMMAND =
393 /*b5:0*/ cmd
394 /*b6 */ | ((flags & MCI_RESP) ? CMD_RESP_EXP_BIT: 0)
395 /*b7 */ | ((flags & MCI_LONG_RESP) ? CMD_RESP_LENGTH_BIT: 0)
396 /*b8 | CMD_CHECK_CRC_BIT unused */
397 /*b9 */ | (TRANSFER_CMD ? CMD_DATA_EXP_BIT: 0)
398 /*b10 */ | ((cmd == SD_WRITE_MULTIPLE_BLOCK) ? CMD_RW_BIT: 0)
399 /*b11 | CMD_TRANSMODE_BIT unused */
400 /*b12 | CMD_SENT_AUTO_STOP_BIT unused */
401 /*b13 */ | (TRANSFER_CMD ? CMD_WAIT_PRV_DAT_BIT: 0)
402 /*b14 | CMD_ABRT_CMD_BIT unused */
403 /*b15 | CMD_SEND_INIT_BIT unused */
404 /*b20:16 */ | CMD_CARD_NO(drive)
405 /*b21 | CMD_SEND_CLK_ONLY unused */
406 /*b22 | CMD_READ_CEATA unused */
407 /*b23 | CMD_CCS_EXPECTED unused */
408 /*b31 */ | CMD_DONE_BIT;
407 409
408 int max = 0x40000; 410 int max = 0x40000;
409 while(MCI_COMMAND & CMD_DONE_BIT) 411 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
412 return false; 414 return false;
413 } 415 }
414 416
415 417 /* TODO Check crc values to determine if the response was valid */
416 if(flags & MCI_RESP) 418 if(flags & MCI_RESP)
417 { 419 {
418 int i = 0xff; while(i--) ; 420 int i = 0xff; while(i--) ;