aboutsummaryrefslogtreecommitdiffstats
path: root/src/gos
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-08-12 16:45:06 +1000
committerinmarket <andrewh@inmarket.com.au>2014-08-12 16:45:06 +1000
commit5460a923ab25d27e522fe175563633665c477e02 (patch)
treee43734965f66092d3d076a599b3b8a188b005bc0 /src/gos
parent0e74c164c3eac14f6e99d1a5cc4e0563faeff5d0 (diff)
parent10902154aec652a3fcdf028b2c6ff16743464973 (diff)
downloaduGFX-5460a923ab25d27e522fe175563633665c477e02.tar.gz
uGFX-5460a923ab25d27e522fe175563633665c477e02.tar.bz2
uGFX-5460a923ab25d27e522fe175563633665c477e02.zip
Merge branch 'master' into newmouse
Diffstat (limited to 'src/gos')
-rw-r--r--src/gos/gfx_chibios.c (renamed from src/gos/chibios.c)27
-rw-r--r--src/gos/gfx_chibios.h (renamed from src/gos/chibios.h)0
-rw-r--r--src/gos/gfx_ecos.c (renamed from src/gos/ecos.c)7
-rw-r--r--src/gos/gfx_ecos.h (renamed from src/gos/ecos.h)0
-rw-r--r--src/gos/gfx_freertos.c (renamed from src/gos/freertos.c)8
-rw-r--r--src/gos/gfx_freertos.h (renamed from src/gos/freertos.h)12
-rw-r--r--src/gos/gfx_linux.c (renamed from src/gos/linux.c)1
-rw-r--r--src/gos/gfx_linux.h (renamed from src/gos/linux.h)0
-rw-r--r--src/gos/gfx_osx.c (renamed from src/gos/osx.c)1
-rw-r--r--src/gos/gfx_osx.h (renamed from src/gos/osx.h)0
-rw-r--r--src/gos/gfx_raw32.c (renamed from src/gos/raw32.c)6
-rw-r--r--src/gos/gfx_raw32.h (renamed from src/gos/raw32.h)22
-rw-r--r--src/gos/gfx_rawrtos.c83
-rw-r--r--src/gos/gfx_rawrtos.h77
-rw-r--r--src/gos/gfx_win32.c (renamed from src/gos/win32.c)2
-rw-r--r--src/gos/gfx_win32.h (renamed from src/gos/win32.h)0
-rw-r--r--src/gos/sys_defs.h16
-rw-r--r--src/gos/sys_make.mk15
-rw-r--r--src/gos/sys_options.h14
-rw-r--r--src/gos/sys_rules.h4
20 files changed, 254 insertions, 41 deletions
diff --git a/src/gos/chibios.c b/src/gos/gfx_chibios.c
index 468c012c..9d1a86da 100644
--- a/src/gos/chibios.c
+++ b/src/gos/gfx_chibios.c
@@ -33,18 +33,21 @@
void _gosInit(void)
{
- /* Don't initialise if the user already has */
-
- #if CH_KERNEL_MAJOR == 2
- if (!chThdSelf()) {
- halInit();
- chSysInit();
- }
- #elif CH_KERNEL_MAJOR == 3
- if (!chThdGetSelfX()) {
- halInit();
- chSysInit();
- }
+ #if !GFX_NO_OS_INIT
+ /* Don't Initialize if the user already has */
+ #if CH_KERNEL_MAJOR == 2
+ if (!chThdSelf()) {
+ halInit();
+ chSysInit();
+ }
+ #elif CH_KERNEL_MAJOR == 3
+ if (!chThdGetSelfX()) {
+ halInit();
+ chSysInit();
+ }
+ #endif
+ #else
+ #warning "GOS: Operating System initialization has been turned off. Make sure you call halInit() and chSysInit() before gfxInit() in your application!"
#endif
}
diff --git a/src/gos/chibios.h b/src/gos/gfx_chibios.h
index a07c72ab..a07c72ab 100644
--- a/src/gos/chibios.h
+++ b/src/gos/gfx_chibios.h
diff --git a/src/gos/ecos.c b/src/gos/gfx_ecos.c
index 5b94497a..16ce821b 100644
--- a/src/gos/ecos.c
+++ b/src/gos/gfx_ecos.c
@@ -11,8 +11,11 @@
void _gosInit(void)
{
- /* Don't initialise if the user already has */
- //cyg_scheduler_start();
+ #if !GFX_NO_OS_INIT
+ #error "GOS: Operating System initialization for eCos is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h"
+ #else
+ #warning "GOS: Operating System initialization has been turned off. Make sure you call cyg_scheduler_start() before gfxInit() in your application!"
+ #endif
}
void _gosDeinit(void)
diff --git a/src/gos/ecos.h b/src/gos/gfx_ecos.h
index be9037b6..be9037b6 100644
--- a/src/gos/ecos.h
+++ b/src/gos/gfx_ecos.h
diff --git a/src/gos/freertos.c b/src/gos/gfx_freertos.c
index f2c03eec..dbdfd22e 100644
--- a/src/gos/freertos.c
+++ b/src/gos/gfx_freertos.c
@@ -18,13 +18,17 @@
#error "GOS: configUSE_MUTEXES must be defined in FreeRTOSConfig.h"
#endif
-#if configUSE_COUNTING_SEMAPHORES != 1
+#if configUSE_COUNTING_SEMAPHORES != 1
#error "GOS: configUSE_COUNTING_SEMAPHORES must be defined in FreeRTOSConfig.h"
#endif
void _gosInit(void)
{
- // The user must call vTaskStartScheduler() himself before he calls gfxInit().
+ #if !GFX_NO_OS_INIT
+ #error "GOS: Operating System initialization for FreeRTOS is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h"
+ #else
+ #warning "GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler() before gfxInit() in your application!"
+ #endif
}
void _gosDeinit(void)
diff --git a/src/gos/freertos.h b/src/gos/gfx_freertos.h
index ccda4cbd..34ef548e 100644
--- a/src/gos/freertos.h
+++ b/src/gos/gfx_freertos.h
@@ -24,6 +24,18 @@
/* Type definitions */
/*===========================================================================*/
+/* Additional types are required when FreeRTOS 7.x is used */
+#if !defined(tskKERNEL_VERSION_MAJOR) && !tskKERNEL_VERSION_MAJOR == 8
+ typedef signed char int8_t
+ typedef unsigned char uint8_t
+ typedef signed int int16_t
+ typedef unsigned int uint16_t
+ typedef signed long int int32_t
+ typedef unsigned long int uint32_t
+ typedef signed long long int int64_t
+ typedef unsigned long long int uint64_t
+#endif
+
/**
* bool_t,
* int8_t, uint8_t,
diff --git a/src/gos/linux.c b/src/gos/gfx_linux.c
index d127fbe1..59b7f9c8 100644
--- a/src/gos/linux.c
+++ b/src/gos/gfx_linux.c
@@ -18,6 +18,7 @@ static gfxMutex SystemMutex;
void _gosInit(void)
{
+ /* No initialization of the operating system itself is needed */
gfxMutexInit(&SystemMutex);
}
diff --git a/src/gos/linux.h b/src/gos/gfx_linux.h
index 9ead9c0e..9ead9c0e 100644
--- a/src/gos/linux.h
+++ b/src/gos/gfx_linux.h
diff --git a/src/gos/osx.c b/src/gos/gfx_osx.c
index dccd49c9..50b06530 100644
--- a/src/gos/osx.c
+++ b/src/gos/gfx_osx.c
@@ -35,6 +35,7 @@ void get_ticks(mach_timespec_t *mts){
void _gosInit(void)
{
+ /* No initialization of the operating system itself is needed */
gfxMutexInit(&SystemMutex);
}
diff --git a/src/gos/osx.h b/src/gos/gfx_osx.h
index 635a8934..635a8934 100644
--- a/src/gos/osx.h
+++ b/src/gos/gfx_osx.h
diff --git a/src/gos/raw32.c b/src/gos/gfx_raw32.c
index c75342d4..22c753aa 100644
--- a/src/gos/raw32.c
+++ b/src/gos/gfx_raw32.c
@@ -24,6 +24,12 @@ static void _gosThreadsInit(void);
void _gosInit(void)
{
+ /* No initialization of the operating system itself is needed as there isn't one.
+ * On the other hand the C runtime should still already be initialized before
+ * getting here!
+ */
+ #warning "GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!"
+
// Set up the heap allocator
_gosHeapInit();
diff --git a/src/gos/raw32.h b/src/gos/gfx_raw32.h
index 6eb5f26e..5a6a2aa7 100644
--- a/src/gos/raw32.h
+++ b/src/gos/gfx_raw32.h
@@ -42,14 +42,20 @@
/*===========================================================================*/
typedef unsigned char bool_t;
-typedef char int8_t;
-typedef unsigned char uint8_t;
-typedef short int16_t;
-typedef unsigned short uint16_t;
-typedef int int32_t;
-typedef unsigned int uint32_t;
-
-typedef uint32_t size_t;
+
+#ifndef _STDINT_H
+ typedef char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int16_t;
+ typedef unsigned short uint16_t;
+ typedef int int32_t;
+ typedef unsigned int uint32_t;
+#endif
+
+#if !defined (__need_size_t) && !defined (_STDDEF_H_)
+ typedef uint32_t size_t;
+#endif
+
typedef uint32_t delaytime_t;
typedef uint32_t systemticks_t;
typedef short semcount_t;
diff --git a/src/gos/gfx_rawrtos.c b/src/gos/gfx_rawrtos.c
new file mode 100644
index 00000000..cd684208
--- /dev/null
+++ b/src/gos/gfx_rawrtos.c
@@ -0,0 +1,83 @@
+#include "gfx.h"
+
+#if GFX_USE_OS_RAWRTOS
+
+#include <string.h>
+#include "raw_api.h"
+#include "raw_config.h"
+
+#if CONFIG_RAW_MUTEX != 1
+ #error "GOS: CONFIG_RAW_MUTEX must be defined in raw_config.h"
+#endif
+
+#if CONFIG_RAW_SEMAPHORE != 1
+ #error "GOS: CONFIG_RAW_SEMAPHORE must be defined in raw_config.h"
+#endif
+
+
+void _gosInit(void)
+{
+ #if !GFX_NO_OS_INIT
+ #error "GOS: Operating System initialization for RawRTOS is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h"
+ #else
+ #warning "GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!"
+ #endif
+}
+
+void _gosDeinit(void)
+{
+}
+
+
+void gfxSleepMilliseconds(delaytime_t ms)
+{
+ systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
+ if(!ticks)ticks = 1;
+ raw_sleep(ticks);
+}
+
+void gfxSleepMicroseconds(delaytime_t us)
+{
+ systemticks_t ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
+ if(!ticks)ticks = 1;
+ raw_sleep(ticks);
+}
+
+bool_t gfxSemWait(gfxSem* psem, delaytime_t ms)
+{
+ systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
+ if(!ticks)ticks=1;
+ if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS)
+ return TRUE;
+ return FALSE;
+}
+
+bool_t gfxSemWaitI(gfxSem* psem)
+{
+ if(raw_semaphore_get((psem), TIME_IMMEDIATE)==RAW_SUCCESS)
+ return TRUE;
+ return FALSE;
+}
+
+gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
+{
+ RAW_U16 ret;
+ gfxThreadHandle taskobj;
+
+ taskobj = gfxAlloc(sizeof(RAW_TASK_OBJ));
+ ret = raw_task_create(taskobj, (RAW_U8 *)"uGFX_TASK", param,
+ prio, 0, stackarea,
+ stacksz/sizeof(PORT_STACK) , fn, 1);
+
+ if (ret != RAW_SUCCESS) {
+ for (;;);
+ }
+
+ return (taskobj);
+}
+
+
+#endif
+
+
+
diff --git a/src/gos/gfx_rawrtos.h b/src/gos/gfx_rawrtos.h
new file mode 100644
index 00000000..eeb5119d
--- /dev/null
+++ b/src/gos/gfx_rawrtos.h
@@ -0,0 +1,77 @@
+#ifndef _GOS_RAWRTOS_H
+#define _GOS_RAWRTOS_H
+
+#if GFX_USE_OS_RAWRTOS
+
+#include "raw_api.h"
+#include <stdint.h>
+
+#define TIME_IMMEDIATE (RAW_NO_WAIT)
+#define TIME_INFINITE (RAW_WAIT_FOREVER)
+typedef int8_t bool_t;
+typedef uint32_t delaytime_t;
+typedef RAW_TICK_TYPE systemticks_t;
+typedef int32_t semcount_t;
+typedef uint32_t threadreturn_t;
+typedef RAW_U8 threadpriority_t;
+typedef uint32_t size_t;
+
+#define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
+#define LOW_PRIORITY (CONFIG_RAW_PRIO_MAX-2)
+#define NORMAL_PRIORITY (CONFIG_RAW_PRIO_MAX/2)
+#define HIGH_PRIORITY 1
+
+typedef RAW_SEMAPHORE gfxSem;
+typedef RAW_MUTEX gfxMutex;
+typedef RAW_TASK_OBJ* gfxThreadHandle;
+
+#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
+#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[sz];
+
+#define gfxHalt(msg) for(;;)
+#define gfxExit() for(;;)
+#define gfxAlloc(sz) raw_malloc(sz)
+#define gfxRealloc(p,osz,nsz) raw_calloc(p, nsz)
+#define gfxFree(ptr) raw_free(ptr)
+#define gfxYield() raw_sleep(0)
+#define gfxSystemTicks() raw_system_time_get()
+#define gfxMillisecondsToTicks(ms) (ms*RAW_TICKS_PER_SECOND/1000)
+#define gfxSystemLock() {}
+#define gfxSystemUnlock() {}
+#define gfxMutexInit(pmutex) raw_mutex_create(pmutex, (RAW_U8 *)"", RAW_MUTEX_INHERIT_POLICY, 3)
+#define gfxMutexDestroy(pmutex) raw_mutex_delete(pmutex)
+#define gfxMutexEnter(pmutex) raw_mutex_get(pmutex, TIME_INFINITE)
+#define gfxMutexExit(pmutex) raw_mutex_put(pmutex)
+#define gfxSemInit(psem, val, limit) raw_semaphore_create(psem, "", val)
+#define gfxSemDestroy(psem) raw_semaphore_delete(psem)
+#define gfxSemSignal(psem) raw_semaphore_put((psem))
+#define gfxSemSignalI(psem) raw_semaphore_put_all((psem))
+#define gfxSemCounterI(psem) ((psem)->count)
+#define gfxThreadMe() {(unsigned int)raw_task_identify()}
+#define gfxThreadClose(thread) {}
+
+extern RAW_VOID *raw_malloc(RAW_U32 size);
+extern RAW_VOID raw_free(void *ptr);
+extern RAW_VOID *raw_calloc(RAW_U32 nmemb, RAW_U32 size);
+
+extern RAW_U16 raw_sleep(RAW_TICK_TYPE dly);
+extern RAW_TICK_TYPE raw_system_time_get(void);
+
+extern RAW_U16 raw_mutex_create(RAW_MUTEX *mutex_ptr, RAW_U8 *name_ptr, RAW_U8 policy, RAW_U8 ceiling_prio);
+extern RAW_U16 raw_mutex_delete(RAW_MUTEX *mutex_ptr);
+extern RAW_U16 raw_mutex_get(RAW_MUTEX *mutex_ptr, RAW_TICK_TYPE wait_option);
+extern RAW_U16 raw_mutex_put(RAW_MUTEX *mutex_ptr);
+extern RAW_U16 raw_semaphore_create(RAW_SEMAPHORE *semaphore_ptr, RAW_U8 *name_ptr, RAW_U32 initial_count);
+extern RAW_U16 raw_semaphore_delete(RAW_SEMAPHORE *semaphore_ptr);
+extern RAW_U16 raw_semaphore_get(RAW_SEMAPHORE *semaphore_ptr, RAW_TICK_TYPE wait_option);
+extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
+
+void gfxSleepMilliseconds(delaytime_t ms);
+void gfxSleepMicroseconds(delaytime_t us);
+bool_t gfxSemWait(gfxSem* psem, delaytime_t ms);
+bool_t gfxSemWaitI(gfxSem* psem);
+gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
+
+#endif
+
+#endif
diff --git a/src/gos/win32.c b/src/gos/gfx_win32.c
index 3a3f2517..ffa7fac5 100644
--- a/src/gos/win32.c
+++ b/src/gos/gfx_win32.c
@@ -19,7 +19,7 @@ static HANDLE SystemMutex;
void _gosInit(void)
{
-
+ /* No initialization of the operating system itself is needed */
}
void _gosDeinit(void)
diff --git a/src/gos/win32.h b/src/gos/gfx_win32.h
index 4a198200..4a198200 100644
--- a/src/gos/win32.h
+++ b/src/gos/gfx_win32.h
diff --git a/src/gos/sys_defs.h b/src/gos/sys_defs.h
index 9da9dff0..d116826f 100644
--- a/src/gos/sys_defs.h
+++ b/src/gos/sys_defs.h
@@ -439,20 +439,22 @@
* All the above was just for the doxygen documentation. All the implementation of the above
* (without any of the documentation overheads) is in the files below.
*/
+#elif GFX_USE_OS_RAWRTOS
+ #include "src/gos/gfx_rawrtos.h"
#elif GFX_USE_OS_CHIBIOS
- #include "src/gos/chibios.h"
+ #include "src/gos/gfx_chibios.h"
#elif GFX_USE_OS_FREERTOS
- #include "src/gos/freertos.h"
+ #include "src/gos/gfx_freertos.h"
#elif GFX_USE_OS_WIN32
- #include "src/gos/win32.h"
+ #include "src/gos/gfx_win32.h"
#elif GFX_USE_OS_LINUX
- #include "src/gos/linux.h"
+ #include "src/gos/gfx_linux.h"
#elif GFX_USE_OS_OSX
- #include "src/gos/osx.h"
+ #include "src/gos/gfx_osx.h"
#elif GFX_USE_OS_RAW32
- #include "src/gos/raw32.h"
+ #include "src/gos/gfx_raw32.h"
#elif GFX_USE_OS_ECOS
- #include "src/gos/ecos.h"
+ #include "src/gos/gfx_ecos.h"
#else
#error "Your operating system is not supported yet"
#endif
diff --git a/src/gos/sys_make.mk b/src/gos/sys_make.mk
index 9e24f875..5efa7f80 100644
--- a/src/gos/sys_make.mk
+++ b/src/gos/sys_make.mk
@@ -1,8 +1,9 @@
-GFXSRC += $(GFXLIB)/src/gos/chibios.c \
- $(GFXLIB)/src/gos/freertos.c \
- $(GFXLIB)/src/gos/win32.c \
- $(GFXLIB)/src/gos/linux.c \
- $(GFXLIB)/src/gos/osx.c \
- $(GFXLIB)/src/gos/raw32.c \
- $(GFXLIB)/src/gos/ecos.c
+GFXSRC += $(GFXLIB)/src/gos/gfx_chibios.c \
+ $(GFXLIB)/src/gos/gfx_freertos.c \
+ $(GFXLIB)/src/gos/gfx_win32.c \
+ $(GFXLIB)/src/gos/gfx_linux.c \
+ $(GFXLIB)/src/gos/gfx_osx.c \
+ $(GFXLIB)/src/gos/gfx_raw32.c \
+ $(GFXLIB)/src/gos/gfx_ecos.c \
+ $(GFXLIB)/src/gos/gfx_rawrtos.c
diff --git a/src/gos/sys_options.h b/src/gos/sys_options.h
index 7937e082..ead1f3f7 100644
--- a/src/gos/sys_options.h
+++ b/src/gos/sys_options.h
@@ -76,6 +76,20 @@
* @{
*/
/**
+ * @brief Should uGFX avoid initializing the operating system
+ * @details Defaults to FALSE
+ * @note This is not relevant to all operating systems eg Win32 never initializes the
+ * operating system as uGFX runs as an application outside the boot process.
+ * @note Operating system initialization is not necessarily implemented for all
+ * operating systems yet even when it is relevant. These operating systems
+ * will display a compile warning reminding you to initialize the operating
+ * system in your application code. Note that on these operating systems the
+ * demo applications will not work without modification.
+ */
+ #ifndef GFX_NO_OS_INIT
+ #define GFX_NO_OS_INIT FALSE
+ #endif
+ /**
* @brief Should uGFX stuff be added to the FreeRTOS+Tracer
* @details Defaults to FALSE
*/
diff --git a/src/gos/sys_rules.h b/src/gos/sys_rules.h
index 0da01ff2..6d6c7845 100644
--- a/src/gos/sys_rules.h
+++ b/src/gos/sys_rules.h
@@ -16,7 +16,7 @@
#ifndef _GOS_RULES_H
#define _GOS_RULES_H
-#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS
+#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS
#if GFX_DISPLAY_RULE_WARNINGS
#warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
#endif
@@ -24,7 +24,7 @@
#define GFX_USE_OS_CHIBIOS TRUE
#endif
-#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS != 1 * TRUE
+#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS != 1 * TRUE
#error "GOS: More than one operation system has been defined as TRUE."
#endif