From ac812f693d58d2db066182ba8e8b47523b7d0422 Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Fri, 5 Nov 2010 15:08:51 +0000 Subject: [PATCH] fix data align bug git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1039 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/mini2440/sdcard.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bsp/mini2440/sdcard.c b/bsp/mini2440/sdcard.c index 516e72813..5dfc45a2f 100644 --- a/bsp/mini2440/sdcard.c +++ b/bsp/mini2440/sdcard.c @@ -243,7 +243,7 @@ RECMD3: rt_uint8_t sd_readblock(rt_uint32_t address, rt_uint8_t* buf) { - int status; + rt_uint32_t status, tmp; rd_cnt=0; SDIFSTA = SDIFSTA | (1<<16); @@ -271,7 +271,8 @@ RERDCMD: status = SDIFSTA; if((status & 0x1000) == 0x1000) { - *(rt_uint32_t *)buf = SDIDAT; + tmp = SDIDAT; + rt_memcpy(buf, &tmp, sizeof(rt_uint32_t)); rd_cnt++; buf += 4; } @@ -291,7 +292,7 @@ RERDCMD: rt_uint8_t sd_writeblock(rt_uint32_t address, rt_uint8_t* buf) { - int status; + rt_uint32_t status, tmp; wt_cnt=0; SDIFSTA = SDIFSTA | (1 << 16); @@ -311,7 +312,8 @@ REWTCMD: status = SDIFSTA; if((status & 0x2000) == 0x2000) { - SDIDAT=*(rt_uint32_t*)buf; + rt_memcpy(&tmp, buf, sizeof(rt_uint32_t)); + SDIDAT = tmp; wt_cnt++; buf += 4; }