summaryrefslogtreecommitdiff
path: root/bsp/simulator/drivers
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-01-22 08:06:36 -0800
committerBernard Xiong <[email protected]>2013-01-22 08:06:36 -0800
commitba245ae88046d0bd5ad421fe545c83986a69421b (patch)
treeda6afa66e009f81178aa9245858877ffb4a13063 /bsp/simulator/drivers
parentead6922231e807c2ae02f5c69378b041d0a37395 (diff)
parent821d0ac252f9c0f0c931e893ddc2865bbde6c22d (diff)
Merge pull request #20 from prife/simmerge
some bug fix after the recently merge from simmerge branch
Diffstat (limited to 'bsp/simulator/drivers')
-rwxr-xr-xbsp/simulator/drivers/sd_sim.c23
-rwxr-xr-xbsp/simulator/drivers/sdl_fb.c16
2 files changed, 32 insertions, 7 deletions
diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c
index 1f39843d3e..758b5e0417 100755
--- a/bsp/simulator/drivers/sd_sim.c
+++ b/bsp/simulator/drivers/sd_sim.c
@@ -185,9 +185,26 @@ 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);
+ }
+ rt_free(buffer);
+ return 0;
}
-FINSH_FUNCTION_EXPORT(eraseall, erase all block in SPI flash);
+FINSH_FUNCTION_EXPORT(sd_erase, erase all block in SPI flash);
#endif
diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c
index 752a6fb93c..714d263ba0 100755
--- a/bsp/simulator/drivers/sdl_fb.c
+++ b/bsp/simulator/drivers/sdl_fb.c
@@ -141,6 +141,7 @@ static void sdlfb_hw_init(void)
#include <mmsystem.h>
#else
#include <pthread.h>
+#include <signal.h>
#endif
#include <stdio.h>
@@ -158,8 +159,15 @@ static void *sdl_loop(void *lpParam)
int quit = 0;
SDL_Event event;
int button_state = 0;
-
rt_device_t device;
+
+#ifndef _WIN32
+ sigset_t sigmask, oldmask;
+ /* set the getchar without buffer */
+ sigfillset(&sigmask);
+ pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
+#endif
+
sdlfb_hw_init();
device = rt_device_find("sdl");
@@ -315,14 +323,14 @@ void rt_hw_sdl_start(void)
}
ResumeThread(thread);
#else
- /* Linux */
- pthread_t pid;
+ /* Linux */
+ pthread_t pid;
int res;
res = pthread_create(&pid, NULL, &sdl_loop, NULL);
if (res)
{
printf("pthread create sdl thread faild, <%d>\n", res);
exit(EXIT_FAILURE);
- }
+ }
#endif
}