diff options
| author | bernard <[email protected]> | 2013-09-17 11:07:36 +0800 |
|---|---|---|
| committer | bernard <[email protected]> | 2013-09-17 11:07:36 +0800 |
| commit | 0bf7ed76cff8071718f50ebeb68ba3bb2544a7cb (patch) | |
| tree | 81db6eaa0424dc1c10355b5b4c8fe56c763c1cfd /bsp/simulator/drivers | |
| parent | 77096894f9d53cb0742adb5330fed4966e956cd1 (diff) | |
| parent | 47c152ee7fdcf8b101a08bacebbafb52d2c8d3a7 (diff) | |
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'bsp/simulator/drivers')
| -rw-r--r-- | bsp/simulator/drivers/SConscript | 14 | ||||
| -rwxr-xr-x | bsp/simulator/drivers/sdl_fb.c | 18 |
2 files changed, 29 insertions, 3 deletions
diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript index d939535da8..eb491b810e 100644 --- a/bsp/simulator/drivers/SConscript +++ b/bsp/simulator/drivers/SConscript @@ -3,10 +3,19 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') +LIBS = [] +LIBPATH = [] +CPPPATH = [cwd] # remove no need file. if GetDepend('RT_USING_RTGUI') == False: SrcRemove(src, 'sdl_fb.c') +else: + LIBS.append('SDL') + if sys.platform == 'win32': + LIBPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/lib/x86'))) + CPPPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/include'))) + if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_ELMFAT') == False: SrcRemove(src, 'sd_sim.c') if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NAND') == False: @@ -20,8 +29,7 @@ if GetDepend('RT_USING_MODULE') == False: if sys.platform[0:5]=="linux": #check whether under linux SrcRemove(src, ['module_win32.c', 'dfs_win32.c']) -CPPPATH = [cwd] - -group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) +group = DefineGroup('Drivers', src, depend = [''], + CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH) Return('group') diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c index d7ebbc8245..78bca6f07f 100755 --- a/bsp/simulator/drivers/sdl_fb.c +++ b/bsp/simulator/drivers/sdl_fb.c @@ -152,8 +152,12 @@ static void sdlfb_hw_init(void) #ifdef _WIN32 static HANDLE sdl_ok_event = NULL; + static DWORD WINAPI sdl_loop(LPVOID lpParam) #else +static pthread_mutex_t sdl_ok_mutex; +static pthread_cond_t sdl_ok_event; + static void *sdl_loop(void *lpParam) #endif { @@ -167,14 +171,19 @@ static void *sdl_loop(void *lpParam) /* set the getchar without buffer */ sigfillset(&sigmask); pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask); + pthread_mutex_lock(&sdl_ok_mutex); #endif sdlfb_hw_init(); device = rt_device_find("sdl"); + RT_ASSERT(device); rtgui_graphic_set_device(device); #ifdef _WIN32 SetEvent(sdl_ok_event); +#else + pthread_cond_signal(&sdl_ok_event); + pthread_mutex_unlock(&sdl_ok_mutex); #endif /* handle SDL event */ while (!quit) @@ -338,11 +347,20 @@ void rt_hw_sdl_start(void) /* Linux */ pthread_t pid; int res; + + pthread_mutex_init(&sdl_ok_mutex, NULL); + pthread_cond_init(&sdl_ok_event, NULL); + res = pthread_create(&pid, NULL, &sdl_loop, NULL); if (res) { printf("pthread create sdl thread faild, <%d>\n", res); exit(EXIT_FAILURE); } + pthread_mutex_lock(&sdl_ok_mutex); + pthread_cond_wait(&sdl_ok_event, &sdl_ok_mutex); + + pthread_mutex_destroy(&sdl_ok_mutex); + pthread_cond_destroy(&sdl_ok_event); #endif } |
