From 5cb02e1258158f87c233103d0a10cb93120593ce Mon Sep 17 00:00:00 2001 From: prife Date: Sat, 2 Mar 2013 14:32:26 +0800 Subject: [PATCH] simulator: make sure LCD driver ready to use after rt_hw_sdl_start is invoked --- bsp/simulator/applications/application.c | 4 ++-- bsp/simulator/drivers/sdl_fb.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c index 86db4113a..7aab9f2db 100755 --- a/bsp/simulator/applications/application.c +++ b/bsp/simulator/applications/application.c @@ -25,11 +25,11 @@ void rt_init_thread_entry(void *parameter) pcap_netif_hw_init(); #endif + rt_platform_init(); + /* initialization RT-Thread Components */ rt_components_init(); - rt_platform_init(); - /* File system Initialization */ #ifdef RT_USING_DFS { diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c index 714d263ba..53779808c 100755 --- a/bsp/simulator/drivers/sdl_fb.c +++ b/bsp/simulator/drivers/sdl_fb.c @@ -151,6 +151,7 @@ static void sdlfb_hw_init(void) #include #ifdef _WIN32 +static HANDLE sdl_ok_event = NULL; static DWORD WINAPI sdl_loop(LPVOID lpParam) #else static void *sdl_loop(void *lpParam) @@ -172,7 +173,9 @@ static void *sdl_loop(void *lpParam) device = rt_device_find("sdl"); rtgui_graphic_set_device(device); - +#ifdef _WIN32 + SetEvent(sdl_ok_event); +#endif /* handle SDL event */ while (!quit) { @@ -307,7 +310,15 @@ void rt_hw_sdl_start(void) #ifdef _WIN32 HANDLE thread; DWORD thread_id; - + sdl_ok_event = CreateEvent(NULL, + FALSE, + FALSE, + NULL); + if (sdl_ok_event == NULL) + { + printf("error, create SDL event failed\n"); + exit(-1); + } /* create thread that loop sdl event */ thread = CreateThread(NULL, 0, @@ -322,6 +333,9 @@ void rt_hw_sdl_start(void) return; } ResumeThread(thread); + + /* wait until SDL LCD device is registered and seted */ + WaitForSingleObject(sdl_ok_event, INFINITE); #else /* Linux */ pthread_t pid; -- GitLab