diff options
author | inmarket <inmarket@ugfx.org> | 2017-03-04 15:02:55 +1000 |
---|---|---|
committer | inmarket <inmarket@ugfx.org> | 2017-03-04 15:02:55 +1000 |
commit | 5d8705b6e0338b0fd631f27e80b94efea96201d0 (patch) | |
tree | eb5dbf709d06aad8834902cb5462462fb04c6e1b /src/gos/gos_freertos.c | |
parent | 5497e2ed1fe86d0f8e89ca67c7bf40f08e927c3b (diff) | |
download | uGFX-5d8705b6e0338b0fd631f27e80b94efea96201d0.tar.gz uGFX-5d8705b6e0338b0fd631f27e80b94efea96201d0.tar.bz2 uGFX-5d8705b6e0338b0fd631f27e80b94efea96201d0.zip |
FEATURE: Significantly improved the FreeRTOS port
FEATURE: Added support for operating system initialisation in FreeRTOS
FEATURE: Added GFX_OS_CALL_UGFXMAIN configuration option to allow uGFXMain() to be automatically called
FEATURE: Added GFX_OS_UGFXMAIN_STACKSIZE configuration option to control uGFXMain() stack size
Diffstat (limited to 'src/gos/gos_freertos.c')
-rw-r--r-- | src/gos/gos_freertos.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/gos/gos_freertos.c b/src/gos/gos_freertos.c index 9708c05f..1f0d8dac 100644 --- a/src/gos/gos_freertos.c +++ b/src/gos/gos_freertos.c @@ -22,18 +22,41 @@ #error "GOS: configUSE_COUNTING_SEMAPHORES must be defined in FreeRTOSConfig.h" #endif +#if !GFX_OS_NO_INIT && INCLUDE_xTaskGetSchedulerState != 1 && configUSE_TIMERS != 1 + #error "GOS: Either INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be defined in FreeRTOSConfig.h" +#endif + +#if !GFX_OS_NO_INIT && !GFX_OS_CALL_UGFXMAIN + #error "GOS: Either GFX_OS_NO_INIT or GFX_OS_CALL_UGFXMAIN must be defined for FreeRTOS" +#endif + void _gosInit(void) { - #if !GFX_OS_NO_INIT - #error "GOS: Operating System initialization for FreeRTOS is not yet implemented in uGFX. Please set GFX_OS_NO_INIT to TRUE in your gfxconf.h" + #if GFX_OS_NO_INIT && !GFX_OS_INIT_NO_WARNING + #warning "GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler()." #endif - #if !GFX_OS_INIT_NO_WARNING - #warning "GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler() before gfxInit() in your application!" +} + +#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN + extern threadreturn_t uGFXMain(void *param); +#endif + +void _gosPostInit(void) +{ + #if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN + if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) { + gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, NORMAL_PRIORITY, uGFXMain, 0); + vTaskStartScheduler(); + gfxHalt("Unable to start FreeRTOS scheduler. Out of memory?"); + } #endif } void _gosDeinit(void) { + #if !GFX_OS_NO_INIT + vTaskDelete(0); + #endif } void* gfxRealloc(void *ptr, size_t oldsz, size_t newsz) @@ -131,4 +154,11 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_ return task; } +#if INCLUDE_eTaskGetState == 1 + threadreturn_t gfxThreadWait(gfxThreadHandle thread) { + while (eTaskGetState(thread) != eDeleted) + gfxYield(); + } +#endif + #endif /* GFX_USE_OS_FREERTOS */ |