Add support for ChibiOS V5 - Thanks Vrollei
This commit is contained in:
parent
41271d632b
commit
e2fb6820d0
@ -25,6 +25,7 @@ FIX: Fixed UC1610 driver private area initialisation
|
||||
FIX: Fixed ST7735 driver and added kapacuk changes
|
||||
FEATURE: Added keyboard support to radio buttons (by Steffan)
|
||||
FEATURE: Added internal use only GFX_COMPILESTAGE (used to control compilation)
|
||||
FEATURE: Added support for ChibiOS Kernel V5
|
||||
|
||||
|
||||
*** Release 2.8 ***
|
||||
|
@ -11,38 +11,36 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR < 2 || CH_KERNEL_MAJOR > 5
|
||||
#error "GOS: Unsupported version of ChibiOS"
|
||||
#endif
|
||||
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
#if !CH_USE_MUTEXES
|
||||
#error "GOS: CH_USE_MUTEXES must be defined in chconf.h"
|
||||
#endif
|
||||
#if !CH_USE_SEMAPHORES
|
||||
#error "GOS: CH_USE_SEMAPHORES must be defined in chconf.h"
|
||||
#endif
|
||||
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
|
||||
#else
|
||||
#if !CH_CFG_USE_MUTEXES
|
||||
#error "GOS: CH_CFG_USE_MUTEXES must be defined in chconf.h"
|
||||
#endif
|
||||
#if !CH_CFG_USE_SEMAPHORES
|
||||
#error "GOS: CH_CFG_USE_SEMAPHORES must be defined in chconf.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "GOS: Unsupported version of ChibiOS"
|
||||
#endif
|
||||
|
||||
void _gosInit(void)
|
||||
{
|
||||
#if !GFX_OS_NO_INIT
|
||||
/* Don't Initialize if the user already has */
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
if (!chThdSelf()) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
}
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
if (!chThdGetSelfX()) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
@ -108,9 +106,9 @@ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
|
||||
|
||||
psem->limit = limit;
|
||||
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
chSemInit(&psem->sem, val);
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
chSemObjectInit(&psem->sem, val);
|
||||
#endif
|
||||
}
|
||||
@ -122,27 +120,27 @@ void gfxSemDestroy(gfxSem *psem)
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms)
|
||||
{
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != RDY_TIMEOUT;
|
||||
case TIME_INFINITE: chSemWait(&psem->sem); return gTrue;
|
||||
default: return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != RDY_TIMEOUT;
|
||||
default: return chSemWaitTimeout(&psem->sem, gfxMillisecondsToTicks(ms)) != RDY_TIMEOUT;
|
||||
}
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT;
|
||||
case TIME_INFINITE: chSemWait(&psem->sem); return gTrue;
|
||||
default: return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != MSG_TIMEOUT;
|
||||
default: return chSemWaitTimeout(&psem->sem, gfxMillisecondsToTicks(ms)) != MSG_TIMEOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem *psem)
|
||||
{
|
||||
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
if (psem->sem.s_cnt <= 0)
|
||||
return gFalse;
|
||||
#elif (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
if (psem->sem.cnt <= 0)
|
||||
return gFalse;
|
||||
#endif
|
||||
@ -154,10 +152,10 @@ void gfxSemSignal(gfxSem *psem)
|
||||
{
|
||||
chSysLock();
|
||||
|
||||
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
if (psem->sem.s_cnt < psem->limit)
|
||||
chSemSignalI(&psem->sem);
|
||||
#elif (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
if (psem->sem.cnt < psem->limit)
|
||||
chSemSignalI(&psem->sem);
|
||||
#endif
|
||||
@ -168,10 +166,10 @@ void gfxSemSignal(gfxSem *psem)
|
||||
|
||||
void gfxSemSignalI(gfxSem *psem)
|
||||
{
|
||||
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
if (psem->sem.s_cnt < psem->limit)
|
||||
chSemSignalI(&psem->sem);
|
||||
#elif (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
if (psem->sem.cnt < psem->limit)
|
||||
chSemSignalI(&psem->sem);
|
||||
#endif
|
||||
@ -181,9 +179,9 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
|
||||
{
|
||||
if (!stackarea) {
|
||||
if (!stacksz) stacksz = 256;
|
||||
#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
return chThdCreateFromHeap(0, stacksz, prio, (tfunc_t)fn, param);
|
||||
#elif CH_KERNEL_MAJOR == 4
|
||||
#else
|
||||
return chThdCreateFromHeap(0, stacksz, "ugfx", prio, (tfunc_t)fn, param);
|
||||
#endif
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ typedef tprio_t threadpriority_t;
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
typedef struct {
|
||||
Semaphore sem;
|
||||
semcount_t limit;
|
||||
@ -53,7 +53,7 @@ typedef tprio_t threadpriority_t;
|
||||
|
||||
typedef Mutex gfxMutex;
|
||||
typedef Thread* gfxThreadHandle;
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
#undef DECLARE_THREAD_STACK
|
||||
#define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
||||
|
||||
@ -72,24 +72,29 @@ typedef tprio_t threadpriority_t;
|
||||
/*===========================================================================*/
|
||||
|
||||
// First the kernel version specific ones
|
||||
#if CH_KERNEL_MAJOR == 2
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
#define gfxSystemTicks() chTimeNow()
|
||||
#define gfxMutexInit(pmutex) chMtxInit(pmutex)
|
||||
#define gfxMutexExit(pmutex) chMtxUnlock()
|
||||
#define gfxExit() chSysHalt()
|
||||
#define gfxHalt(msg) { chDbgPanic(msg); chSysHalt(); }
|
||||
#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)
|
||||
#else
|
||||
#define gfxSystemTicks() chVTGetSystemTimeX()
|
||||
#define gfxMutexInit(pmutex) chMtxObjectInit(pmutex)
|
||||
#define gfxMutexExit(pmutex) chMtxUnlock(pmutex)
|
||||
#define gfxExit() osalSysHalt("gfx_exit")
|
||||
#define gfxHalt(msg) { chSysHalt(msg); }
|
||||
#define gfxHalt(msg) { chSysHalt(msg); }
|
||||
#endif
|
||||
|
||||
#if CH_KERNEL_MAJOR <= 4
|
||||
#define gfxMillisecondsToTicks(ms) MS2ST(ms)
|
||||
#else
|
||||
#define gfxMillisecondsToTicks(ms) TIME_MS2I(ms)
|
||||
#endif
|
||||
|
||||
#define gfxAlloc(sz) chHeapAlloc(0, sz)
|
||||
#define gfxFree(ptr) chHeapFree(ptr)
|
||||
#define gfxYield() chThdYield()
|
||||
#define gfxMillisecondsToTicks(ms) MS2ST(ms)
|
||||
#define gfxSystemLock() chSysLock()
|
||||
#define gfxSystemUnlock() chSysUnlock()
|
||||
#define gfxMutexDestroy(pmutex) (void)pmutex
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
# Requirements:
|
||||
#
|
||||
# CHIBIOS_VERSION Which version of ChibiOS is this (2, 3, 16, git) - default is 16
|
||||
# CHIBIOS_VERSION Which version of ChibiOS is this (2, 3, 4, 5, 16, git) - default is 16
|
||||
# Note the 'git' option is one we try to keep up to date with the ChibiOS master
|
||||
# If you find the 'git' option requires update please let us know.
|
||||
#
|
||||
@ -19,6 +19,10 @@ ifeq ($(CHIBIOS_VERSION),2)
|
||||
include $(GFXLIB)/tools/gmake_scripts/os_chibios_2.mk
|
||||
else ifeq ($(CHIBIOS_VERSION),3)
|
||||
include $(GFXLIB)/tools/gmake_scripts/os_chibios_3.mk
|
||||
else ifeq ($(CHIBIOS_VERSION),4)
|
||||
include $(GFXLIB)/tools/gmake_scripts/os_chibios_3.mk
|
||||
else ifeq ($(CHIBIOS_VERSION),5)
|
||||
include $(GFXLIB)/tools/gmake_scripts/os_chibios_3.mk
|
||||
else ifeq ($(CHIBIOS_VERSION),16)
|
||||
include $(GFXLIB)/tools/gmake_scripts/os_chibios_3.mk
|
||||
else ifeq ($(CHIBIOS_VERSION),git)
|
||||
|
Loading…
Reference in New Issue
Block a user