提交 ac812f69 编写于 作者: qiuyiuestc's avatar qiuyiuestc

fix data align bug

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1039 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 6e4a697d
...@@ -243,7 +243,7 @@ RECMD3: ...@@ -243,7 +243,7 @@ RECMD3:
rt_uint8_t sd_readblock(rt_uint32_t address, rt_uint8_t* buf) rt_uint8_t sd_readblock(rt_uint32_t address, rt_uint8_t* buf)
{ {
int status; rt_uint32_t status, tmp;
rd_cnt=0; rd_cnt=0;
SDIFSTA = SDIFSTA | (1<<16); SDIFSTA = SDIFSTA | (1<<16);
...@@ -271,7 +271,8 @@ RERDCMD: ...@@ -271,7 +271,8 @@ RERDCMD:
status = SDIFSTA; status = SDIFSTA;
if((status & 0x1000) == 0x1000) if((status & 0x1000) == 0x1000)
{ {
*(rt_uint32_t *)buf = SDIDAT; tmp = SDIDAT;
rt_memcpy(buf, &tmp, sizeof(rt_uint32_t));
rd_cnt++; rd_cnt++;
buf += 4; buf += 4;
} }
...@@ -291,7 +292,7 @@ RERDCMD: ...@@ -291,7 +292,7 @@ RERDCMD:
rt_uint8_t sd_writeblock(rt_uint32_t address, rt_uint8_t* buf) rt_uint8_t sd_writeblock(rt_uint32_t address, rt_uint8_t* buf)
{ {
int status; rt_uint32_t status, tmp;
wt_cnt=0; wt_cnt=0;
SDIFSTA = SDIFSTA | (1 << 16); SDIFSTA = SDIFSTA | (1 << 16);
...@@ -311,7 +312,8 @@ REWTCMD: ...@@ -311,7 +312,8 @@ REWTCMD:
status = SDIFSTA; status = SDIFSTA;
if((status & 0x2000) == 0x2000) if((status & 0x2000) == 0x2000)
{ {
SDIDAT=*(rt_uint32_t*)buf; rt_memcpy(&tmp, buf, sizeof(rt_uint32_t));
SDIDAT = tmp;
wt_cnt++; wt_cnt++;
buf += 4; buf += 4;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册