11 #if GFX_USE_OS_FREERTOS
13 #if INCLUDE_vTaskDelay != 1
14 #error "GOS: INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h"
17 #if configUSE_MUTEXES != 1
18 #error "GOS: configUSE_MUTEXES must be defined in FreeRTOSConfig.h"
21 #if configUSE_COUNTING_SEMAPHORES != 1
22 #error "GOS: configUSE_COUNTING_SEMAPHORES must be defined in FreeRTOSConfig.h"
25 #if !GFX_OS_NO_INIT && INCLUDE_xTaskGetSchedulerState != 1 && configUSE_TIMERS != 1
26 #error "GOS: Either INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be defined in FreeRTOSConfig.h"
29 #if !GFX_OS_NO_INIT && !GFX_OS_CALL_UGFXMAIN
30 #error "GOS: Either GFX_OS_NO_INIT or GFX_OS_CALL_UGFXMAIN must be defined for FreeRTOS"
35 #if GFX_OS_NO_INIT && !GFX_OS_INIT_NO_WARNING
36 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
37 #warning "GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler()."
38 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
39 COMPILER_WARNING(
"GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler().")
44 #if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
51 void _gosPostInit(
void)
53 #if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
54 if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
56 vTaskStartScheduler();
57 gfxHalt(
"Unable to start FreeRTOS scheduler. Out of memory?");
69 void*
gfxRealloc(
void *ptr, gMemSize oldsz, gMemSize newsz)
81 memcpy(np, ptr, oldsz);
103 *pmutex = xSemaphoreCreateMutex();
104 #if GFX_FREERTOS_USE_TRACE
105 vTraceSetMutexName(*pmutex,
"uGFXMutex");
114 *psem = xSemaphoreCreateCounting(limit,val);
115 #if GFX_FREERTOS_USE_TRACE
116 vTraceSetSemaphoreName(*psem,
"uGFXSema");
129 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
131 if (xSemaphoreTakeFromISR(*psem, &xHigherPriorityTaskWoken) == pdTRUE)
138 xSemaphoreGive(*psem);
144 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
146 xSemaphoreGiveFromISR(*psem,&xHigherPriorityTaskWoken);
155 stacksz /=
sizeof(StackType_t);
157 if (stacksz < configMINIMAL_STACK_SIZE)
158 stacksz = configMINIMAL_STACK_SIZE;
161 if (xTaskCreate(fn,
"uGFX_TASK", stacksz, param, prio, &task) != pdPASS)
167 #if INCLUDE_eTaskGetState == 1
169 while (eTaskGetState(thread) != eDeleted)
void GFXUSERFN uGFXMain(void)
The user supplied function containing all the user uGFX application code.
gThreadreturn gfxThreadWait(gThread thread)
Wait for a thread to finish.
#define GFX_OS_UGFXMAIN_STACKSIZE
When uGFXMain() is started as a thread, what stack size should be used.
void gfxSemSignal(gSem *psem)
Signal a semaphore.
void * gThread
A thread handle.
void gfxYield(void)
Yield the current thread.
#define GFX_THREAD_FUNCTION(fnName, param)
Declare a thread function.
gTicks gfxMillisecondsToTicks(gDelay ms)
Convert a given number of millseconds to a number of operating system ticks.
gBool gfxSemWait(gSem *psem, gDelay ms)
Wait on a semaphore.
void gfxSleepMicroseconds(gDelay us)
Put the current thread to sleep for the specified period in microseconds.
void * gfxAlloc(gMemSize sz)
Allocate memory.
void gfxMutexInit(gMutex *pmutex)
Initialise a mutex to protect a region of code from other threads.
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
gBool gfxSemWaitI(gSem *psem)
Test if a wait on a semaphore can be satisfied immediately.
void gfxHalt(const char *msg)
Halt the GFX application due to an error.
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
Initialise a Counted Semaphore.
void * gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz)
Re-allocate memory.
void gfxFree(void *ptr)
Free memory.
void gfxSemSignalI(gSem *psem)
Signal a semaphore.
void gfxSleepMilliseconds(gDelay ms)
Put the current thread to sleep for the specified period in milliseconds.