Support for rawrtos real time operating system
This commit is contained in:
parent
ed14e4ca56
commit
f08f35a9e4
@ -18,7 +18,7 @@ FEATURE: Added Raspberry Pi board support
|
||||
FEATURE: Added R61505U gdisp driver
|
||||
FIX: Fix threading issues in GEvent for callbacks
|
||||
FEATURE: Added geventEventComplete()
|
||||
|
||||
FEATURE: Added support for the rawrtos real time operating system
|
||||
|
||||
*** Release 2.1 ***
|
||||
FIX: Significant improvements to the way the MCU touch driver works.
|
||||
|
79
src/gos/rawrtos.c
Normal file
79
src/gos/rawrtos.c
Normal file
@ -0,0 +1,79 @@
|
||||
#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)
|
||||
{
|
||||
// The user must call raw_os_start() himself before he calls gfxInit().
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
77
src/gos/rawrtos.h
Normal file
77
src/gos/rawrtos.h
Normal file
@ -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
|
@ -439,6 +439,8 @@
|
||||
* 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/rawrtos.h"
|
||||
#elif GFX_USE_OS_CHIBIOS
|
||||
#include "src/gos/chibios.h"
|
||||
#elif GFX_USE_OS_FREERTOS
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user