diff options
| author | qiuyiuestc <[email protected]> | 2010-11-05 15:08:51 +0000 |
|---|---|---|
| committer | qiuyiuestc <[email protected]> | 2010-11-05 15:08:51 +0000 |
| commit | ac812f693d58d2db066182ba8e8b47523b7d0422 (patch) | |
| tree | f682e345b9d2af5a85061502c418e957c38a49e1 | |
| parent | 6e4a697d0c78e4c1de353466d7934ee721170d32 (diff) | |
fix data align bug
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1039 bbd45198-f89e-11dd-88c7-29a3b14d5316
| -rw-r--r-- | bsp/mini2440/sdcard.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bsp/mini2440/sdcard.c b/bsp/mini2440/sdcard.c index 516e728138..5dfc45a2f7 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;
}
|
