summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2004-10-04 17:53:53 +0000
committerJens Arnold <amiconn@rockbox.org>2004-10-04 17:53:53 +0000
commit36813086e6fa4bfe75484db20bedbf564b5a2420 (patch)
treea094ccdd137b35991feef51943624e62d74ae61f
parent0bc2c6cc2cb2e2ff75626f35bfa33e0a8af15355 (diff)
downloadrockbox-36813086e6fa4bfe75484db20bedbf564b5a2420.zip
rockbox-36813086e6fa4bfe75484db20bedbf564b5a2420.tar.gz
rockbox-36813086e6fa4bfe75484db20bedbf564b5a2420.tar.bz2
rockbox-36813086e6fa4bfe75484db20bedbf564b5a2420.tar.xz
MMC: 10 % faster reading and 15 % faster writing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5161 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata_mmc.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 18864cd..b4006c6 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -198,32 +198,40 @@ static void setup_sci1(int bitrate_register)
static void write_transfer(const unsigned char *buf, int len)
{
const unsigned char *buf_end = buf + len;
+ register unsigned char data;
/* TODO: DMA */
while (buf < buf_end)
{
+ data = fliptable[(signed char)(*buf++)]; /* bitswap */
while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
- TDR1 = fliptable[(signed char)(*buf++)]; /* write byte */
+ TDR1 = data; /* write byte */
SSR1 = 0; /* start transmitting */
}
}
+/* don't call this with len == 0 */
static void read_transfer(unsigned char *buf, int len)
{
- unsigned char *buf_end = buf + len;
+ unsigned char *buf_end = buf + len - 1;
+ register signed char data;
/* TODO: DMA */
while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
TDR1 = 0xFF; /* send do-nothing data in parallel */
+ SSR1 = 0; /* start receiving first byte */
while (buf < buf_end)
{
- SSR1 = 0; /* start receiving */
- while (!(SSR1 & SCI_RDRF)); /* wait for data */
- *buf++ = fliptable[(signed char)(RDR1)]; /* read byte */
+ while (!(SSR1 & SCI_RDRF)); /* wait for data */
+ data = RDR1; /* read byte */
+ SSR1 = 0; /* start receiving */
+ *buf++ = fliptable[data]; /* bitswap */
}
+ while (!(SSR1 & SCI_RDRF)); /* wait for last byte */
+ *buf = fliptable[(signed char)(RDR1)]; /* read & bitswap */
}
/* timeout is in bytes */