mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-19 02:13:32 +08:00
the unit of read/write offset and buffer size is changed to the block size in block device driver read/write interface.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@795 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
b669237ae4
commit
731711f74f
@ -374,11 +374,10 @@ static rt_err_t rt_sdcard_close(rt_device_t dev)
|
||||
static rt_size_t rt_sdcard_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
|
||||
{
|
||||
bool status;
|
||||
rt_uint32_t nr = size / SD_SECTOR_SIZE;
|
||||
|
||||
status = LPC17xx_SD_ReadSector(part.offset + pos/SECTOR_SIZE, buffer, nr);
|
||||
status = LPC17xx_SD_ReadSector(part.offset + pos, buffer, size);
|
||||
|
||||
if (status == true) return nr * SECTOR_SIZE;
|
||||
if (status == true) return size;
|
||||
|
||||
rt_kprintf("read failed: %d, pos 0x%08x, size %d\n", status, pos, size);
|
||||
return 0;
|
||||
@ -387,11 +386,10 @@ static rt_size_t rt_sdcard_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_
|
||||
static rt_size_t rt_sdcard_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
|
||||
{
|
||||
bool status;
|
||||
rt_uint32_t nr = size / SD_SECTOR_SIZE;
|
||||
|
||||
status = LPC17xx_SD_WriteSector(part.offset + pos/SECTOR_SIZE, buffer, nr);
|
||||
status = LPC17xx_SD_WriteSector(part.offset + pos, buffer, size);
|
||||
|
||||
if (status == true) return nr * SECTOR_SIZE;
|
||||
if (status == true) return size;
|
||||
|
||||
rt_kprintf("write failed: %d, pos 0x%08x, size %d\n", status, pos, size);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user