11 #if GFX_USE_OS_CHIBIOS 42 #if (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4) 46 typedef systime_t delaytime_t;
47 typedef systime_t systemticks_t;
48 typedef cnt_t semcount_t;
49 typedef msg_t threadreturn_t;
50 typedef tprio_t threadpriority_t;
52 #define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1)) 53 #define LOW_PRIORITY LOWPRIO 54 #define NORMAL_PRIORITY NORMALPRIO 55 #define HIGH_PRIORITY HIGHPRIO 57 #define DECLARE_THREAD_STACK(name, sz) WORKING_AREA(name, sz) 58 #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param) 59 #define THREAD_RETURN(retval) return retval 61 #if CH_KERNEL_MAJOR == 2 69 #elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4) 70 #undef DECLARE_THREAD_STACK 71 #define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b) 92 #if CH_KERNEL_MAJOR == 2 93 #define gfxSystemTicks() chTimeNow() 94 #define gfxMutexInit(pmutex) chMtxInit(pmutex) 95 #define gfxMutexExit(pmutex) chMtxUnlock() 96 #define gfxExit() chSysHalt() 97 #define gfxHalt(msg) { chDbgPanic(msg); chSysHalt(); } 98 #elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4) 99 #define gfxSystemTicks() chVTGetSystemTimeX() 100 #define gfxMutexInit(pmutex) chMtxObjectInit(pmutex) 101 #define gfxMutexExit(pmutex) chMtxUnlock(pmutex) 102 #define gfxExit() osalSysHalt("gfx_exit") 103 #define gfxHalt(msg) { chSysHalt(msg); } 106 #define gfxAlloc(sz) chHeapAlloc(0, sz) 107 #define gfxFree(ptr) chHeapFree(ptr) 108 #define gfxYield() chThdYield() 109 #define gfxMillisecondsToTicks(ms) MS2ST(ms) 110 #define gfxSystemLock() chSysLock() 111 #define gfxSystemUnlock() chSysUnlock() 112 #define gfxMutexDestroy(pmutex) (void)pmutex 113 #define gfxMutexEnter(pmutex) chMtxLock(pmutex) 114 void *
gfxRealloc(
void *ptr,
size_t oldsz,
size_t newsz);
124 #define gfxThreadWait(thread) chThdWait(thread) 125 #define gfxThreadMe() chThdSelf() 126 #define gfxThreadClose(thread) (void)thread void * gfxThreadHandle
A thread handle.
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
Initialise a Counted Semaphore.
void gfxSemDestroy(gfxSem *psem)
Destroy a Counted Semaphore.
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)
Wait on a semaphore.
void gfxSemSignalI(gfxSem *psem)
Signal a semaphore.
void * gfxRealloc(void *ptr, size_t oldsz, size_t newsz)
Re-allocate memory.
#define DECLARE_THREAD_FUNCTION(fnName, param)
Declare a thread function.
void gfxSemSignal(gfxSem *psem)
Signal a semaphore.
void gfxSleepMicroseconds(delaytime_t us)
Put the current thread to sleep for the specified period in microseconds.
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
void gfxSleepMilliseconds(delaytime_t ms)
Put the current thread to sleep for the specified period in milliseconds.
bool_t gfxSemWaitI(gfxSem *psem)
Test if a wait on a semaphore can be satisfied immediately.