aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2018-07-07 17:05:18 +1000
committerinmarket <andrewh@inmarket.com.au>2018-07-07 17:05:18 +1000
commite2fb6820d013420bf9a69ac5b8955f9ebb6af4f0 (patch)
treed1df5479f32a0e47f8db07031a48bb88f0fc3a27
parent41271d632b74f5cf47c30d3b699eb6b2786f2136 (diff)
downloaduGFX-e2fb6820d013420bf9a69ac5b8955f9ebb6af4f0.tar.gz
uGFX-e2fb6820d013420bf9a69ac5b8955f9ebb6af4f0.tar.bz2
uGFX-e2fb6820d013420bf9a69ac5b8955f9ebb6af4f0.zip
Add support for ChibiOS V5 - Thanks Vrollei
-rw-r--r--changelog.txt1
-rw-r--r--src/gos/gos_chibios.c44
-rw-r--r--src/gos/gos_chibios.h17
-rw-r--r--tools/gmake_scripts/os_chibios.mk6
4 files changed, 38 insertions, 30 deletions
diff --git a/changelog.txt b/changelog.txt
index 4ec4d020..e782b7c7 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -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 ***
diff --git a/src/gos/gos_chibios.c b/src/gos/gos_chibios.c
index 725a8763..4d2358b5 100644
--- a/src/gos/gos_chibios.c
+++ b/src/gos/gos_chibios.c
@@ -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
}
diff --git a/src/gos/gos_chibios.h b/src/gos/gos_chibios.h
index 7c0d1447..d97d1e9f 100644
--- a/src/gos/gos_chibios.h
+++ b/src/gos/gos_chibios.h
@@ -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
diff --git a/tools/gmake_scripts/os_chibios.mk b/tools/gmake_scripts/os_chibios.mk
index 31e450fc..82a102d7 100644
--- a/tools/gmake_scripts/os_chibios.mk
+++ b/tools/gmake_scripts/os_chibios.mk
@@ -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)