summaryrefslogtreecommitdiff
path: root/bsp/simulator/drivers
diff options
context:
space:
mode:
authorprife <[email protected]>2013-01-22 23:48:52 +0800
committerprife <[email protected]>2013-01-22 23:48:52 +0800
commitf5fea40c5e615eab5bdb4176398ea6101bdfbf5b (patch)
tree8c9b195a2ebc93848cebdc15dd0d0fc24ef24cfc /bsp/simulator/drivers
parenta4d661dcf182f40ceaca8b15a7d08d0259302044 (diff)
add sd_erase in sd_sim.c, just erase MBR in SDCARD
Diffstat (limited to 'bsp/simulator/drivers')
-rwxr-xr-xbsp/simulator/drivers/sd_sim.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c
index 1f39843d3e..a01b275593 100755
--- a/bsp/simulator/drivers/sd_sim.c
+++ b/bsp/simulator/drivers/sd_sim.c
@@ -185,9 +185,25 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
#ifdef RT_USING_FINSH
#include <finsh.h>
-void eraseall(void)
+int sd_erase(void)
{
- printf("had not implemented yet!\n");
+ rt_uint32_t index;
+ char * buffer;
+ struct rt_device *device;
+ device = &_sdcard.parent;
+ if ((buffer = rt_malloc(SECTOR_SIZE)) == RT_NULL)
+ {
+ rt_kprintf("out of memory\n");
+ return -1;
+ }
+
+ memset(buffer, 0, SECTOR_SIZE);
+ /* just erase the MBR! */
+ for (index = 0; index < 2; index ++)
+ {
+ rt_sdcard_write(device, index, buffer, SECTOR_SIZE);
+ }
+ return 0;
}
-FINSH_FUNCTION_EXPORT(eraseall, erase all block in SPI flash);
+FINSH_FUNCTION_EXPORT(sd_erase, erase all block in SPI flash);
#endif