add support for ChibiOS RT 4 kernel
This commit is contained in:
parent
f8dac95e93
commit
1d2c15ce81
2 changed files with 16 additions and 7 deletions
|
@ -20,7 +20,7 @@
|
||||||
#error "GOS: CH_USE_SEMAPHORES must be defined in chconf.h"
|
#error "GOS: CH_USE_SEMAPHORES must be defined in chconf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
|
|
||||||
#if !CH_CFG_USE_MUTEXES
|
#if !CH_CFG_USE_MUTEXES
|
||||||
#error "GOS: CH_CFG_USE_MUTEXES must be defined in chconf.h"
|
#error "GOS: CH_CFG_USE_MUTEXES must be defined in chconf.h"
|
||||||
|
@ -42,7 +42,7 @@ void _gosInit(void)
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
chSysInit();
|
||||||
}
|
}
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
if (!chThdGetSelfX()) {
|
if (!chThdGetSelfX()) {
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
@ -102,7 +102,7 @@ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
|
||||||
|
|
||||||
#if CH_KERNEL_MAJOR == 2
|
#if CH_KERNEL_MAJOR == 2
|
||||||
chSemInit(&psem->sem, val);
|
chSemInit(&psem->sem, val);
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
chSemObjectInit(&psem->sem, val);
|
chSemObjectInit(&psem->sem, val);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)
|
||||||
case TIME_INFINITE: chSemWait(&psem->sem); return TRUE;
|
case TIME_INFINITE: chSemWait(&psem->sem); return TRUE;
|
||||||
default: return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != RDY_TIMEOUT;
|
default: return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != RDY_TIMEOUT;
|
||||||
}
|
}
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
switch(ms) {
|
switch(ms) {
|
||||||
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT;
|
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT;
|
||||||
case TIME_INFINITE: chSemWait(&psem->sem); return TRUE;
|
case TIME_INFINITE: chSemWait(&psem->sem); return TRUE;
|
||||||
|
@ -158,7 +158,11 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
|
||||||
{
|
{
|
||||||
if (!stackarea) {
|
if (!stackarea) {
|
||||||
if (!stacksz) stacksz = 256;
|
if (!stacksz) stacksz = 256;
|
||||||
|
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||||
return chThdCreateFromHeap(0, stacksz, prio, (tfunc_t)fn, param);
|
return chThdCreateFromHeap(0, stacksz, prio, (tfunc_t)fn, param);
|
||||||
|
#elif CH_KERNEL_MAJOR == 4
|
||||||
|
return chThdCreateFromHeap(0, stacksz, "ugfx", prio, (tfunc_t)fn, param);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stacksz)
|
if (!stacksz)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#if !defined(TRUE)
|
#if !defined(TRUE)
|
||||||
#define TRUE -1
|
#define TRUE -1
|
||||||
#endif
|
#endif
|
||||||
#if CH_KERNEL_MAJOR == 3
|
#if (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
typedef char bool_t;
|
typedef char bool_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ typedef tprio_t threadpriority_t;
|
||||||
|
|
||||||
typedef Mutex gfxMutex;
|
typedef Mutex gfxMutex;
|
||||||
typedef Thread* gfxThreadHandle;
|
typedef Thread* gfxThreadHandle;
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
#undef DECLARE_THREAD_STACK
|
#undef DECLARE_THREAD_STACK
|
||||||
#define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
#define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ extern "C" {
|
||||||
#define gfxMutexExit(pmutex) chMtxUnlock()
|
#define gfxMutexExit(pmutex) chMtxUnlock()
|
||||||
#define gfxExit() chSysHalt()
|
#define gfxExit() chSysHalt()
|
||||||
#define gfxHalt(msg) { chDbgPanic(msg); chSysHalt(); }
|
#define gfxHalt(msg) { chDbgPanic(msg); chSysHalt(); }
|
||||||
#elif CH_KERNEL_MAJOR == 3
|
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||||
#define gfxSystemTicks() chVTGetSystemTimeX()
|
#define gfxSystemTicks() chVTGetSystemTimeX()
|
||||||
#define gfxMutexInit(pmutex) chMtxObjectInit(pmutex)
|
#define gfxMutexInit(pmutex) chMtxObjectInit(pmutex)
|
||||||
#define gfxMutexExit(pmutex) chMtxUnlock(pmutex)
|
#define gfxMutexExit(pmutex) chMtxUnlock(pmutex)
|
||||||
|
@ -120,8 +120,13 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
|
||||||
bool_t gfxSemWaitI(gfxSem *psem);
|
bool_t gfxSemWaitI(gfxSem *psem);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gfxSem *psem);
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gfxSem *psem);
|
||||||
|
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||||
#define gfxSemCounterI(psem) ((psem)->sem.s_cnt)
|
#define gfxSemCounterI(psem) ((psem)->sem.s_cnt)
|
||||||
#define gfxSemCounter(psem) ((psem)->sem.s_cnt)
|
#define gfxSemCounter(psem) ((psem)->sem.s_cnt)
|
||||||
|
#elif (CH_KERNEL_MAJOR == 4)
|
||||||
|
#define gfxSemCounterI(psem) ((psem)->sem.cnt)
|
||||||
|
#define gfxSemCounter(psem) ((psem)->sem.cnt)
|
||||||
|
#endif
|
||||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
#define gfxThreadWait(thread) chThdWait(thread)
|
#define gfxThreadWait(thread) chThdWait(thread)
|
||||||
#define gfxThreadMe() chThdSelf()
|
#define gfxThreadMe() chThdSelf()
|
||||||
|
|
Loading…
Add table
Reference in a new issue