version 2.8
gos_rawrtos.h
1 #ifndef _GOS_RAWRTOS_H
2 #define _GOS_RAWRTOS_H
3 
4 #if GFX_USE_OS_RAWRTOS
5 
6 #include "raw_api.h"
7 #include <stdint.h>
8 
9 #define TIME_IMMEDIATE (RAW_NO_WAIT)
10 #define TIME_INFINITE (RAW_WAIT_FOREVER)
11 typedef int8_t bool_t;
12 typedef uint32_t delaytime_t;
13 typedef RAW_TICK_TYPE systemticks_t;
14 typedef int32_t semcount_t;
15 typedef uint32_t threadreturn_t;
16 typedef RAW_U8 threadpriority_t;
17 typedef uint32_t size_t;
18 
19 #define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
20 #define LOW_PRIORITY (CONFIG_RAW_PRIO_MAX-2)
21 #define NORMAL_PRIORITY (CONFIG_RAW_PRIO_MAX/2)
22 #define HIGH_PRIORITY 1
23 
24 typedef RAW_SEMAPHORE gfxSem;
25 typedef RAW_MUTEX gfxMutex;
26 typedef RAW_TASK_OBJ* gfxThreadHandle;
27 
28 #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
29 #define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
30 #define THREAD_RETURN(retval) return retval
31 
32 #define gfxHalt(msg) for(;;)
33 #define gfxExit() for(;;)
34 #define gfxAlloc(sz) raw_malloc(sz)
35 #define gfxRealloc(p,osz,nsz) raw_calloc(p, nsz)
36 #define gfxFree(ptr) raw_free(ptr)
37 #define gfxYield() raw_sleep(0)
38 #define gfxSystemTicks() raw_system_time_get()
39 #define gfxMillisecondsToTicks(ms) (ms*RAW_TICKS_PER_SECOND/1000)
40 #define gfxSystemLock() {}
41 #define gfxSystemUnlock() {}
42 #define gfxMutexInit(pmutex) raw_mutex_create(pmutex, (RAW_U8 *)"", RAW_MUTEX_INHERIT_POLICY, 3)
43 #define gfxMutexDestroy(pmutex) raw_mutex_delete(pmutex)
44 #define gfxMutexEnter(pmutex) raw_mutex_get(pmutex, TIME_INFINITE)
45 #define gfxMutexExit(pmutex) raw_mutex_put(pmutex)
46 #define gfxSemInit(psem, val, limit) raw_semaphore_create(psem, "", val)
47 #define gfxSemDestroy(psem) raw_semaphore_delete(psem)
48 #define gfxSemSignal(psem) raw_semaphore_put((psem))
49 #define gfxSemSignalI(psem) raw_semaphore_put_all((psem))
50 #define gfxThreadMe() {(unsigned int)raw_task_identify()}
51 #define gfxThreadClose(thread) {}
52 
53 extern RAW_VOID *raw_malloc(RAW_U32 size);
54 extern RAW_VOID raw_free(void *ptr);
55 extern RAW_VOID *raw_calloc(RAW_U32 nmemb, RAW_U32 size);
56 
57 extern RAW_U16 raw_sleep(RAW_TICK_TYPE dly);
58 extern RAW_TICK_TYPE raw_system_time_get(void);
59 
60 extern RAW_U16 raw_mutex_create(RAW_MUTEX *mutex_ptr, RAW_U8 *name_ptr, RAW_U8 policy, RAW_U8 ceiling_prio);
61 extern RAW_U16 raw_mutex_delete(RAW_MUTEX *mutex_ptr);
62 extern RAW_U16 raw_mutex_get(RAW_MUTEX *mutex_ptr, RAW_TICK_TYPE wait_option);
63 extern RAW_U16 raw_mutex_put(RAW_MUTEX *mutex_ptr);
64 extern RAW_U16 raw_semaphore_create(RAW_SEMAPHORE *semaphore_ptr, RAW_U8 *name_ptr, RAW_U32 initial_count);
65 extern RAW_U16 raw_semaphore_delete(RAW_SEMAPHORE *semaphore_ptr);
66 extern RAW_U16 raw_semaphore_get(RAW_SEMAPHORE *semaphore_ptr, RAW_TICK_TYPE wait_option);
67 extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
68 
69 void gfxSleepMilliseconds(delaytime_t ms);
70 void gfxSleepMicroseconds(delaytime_t us);
71 bool_t gfxSemWait(gfxSem* psem, delaytime_t ms);
72 bool_t gfxSemWaitI(gfxSem* psem);
73 gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
74 
75 #endif
76 
77 #endif
void * gfxThreadHandle
A thread handle.
Definition: gos.h:117
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)
Wait on a semaphore.
A semaphore.
Definition: gos.h:105
#define DECLARE_THREAD_FUNCTION(fnName, param)
Declare a thread function.
Definition: gos.h:62
void gfxSleepMicroseconds(delaytime_t us)
Put the current thread to sleep for the specified period in microseconds.
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
A mutex.
Definition: gos.h:111
void gfxSleepMilliseconds(delaytime_t ms)
Put the current thread to sleep for the specified period in milliseconds.
bool_t gfxSemWaitI(gfxSem *psem)
Test if a wait on a semaphore can be satisfied immediately.