1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
/**
* The raw32 GOS implementation supports any 32 bit processor with or without an
* underlying operating system. It uses cooperative multi-tasking. Be careful
* when writing device drivers not to disturb the assumptions this creates by performing
* call-backs to uGFX code unless you define the INTERRUPTS_OFF() and INTERRUPTS_ON() macros.
* It still requires some C runtime library support...
* enough startup to initialise the stack, interrupts, static data etc and call main().
* setjmp() and longjmp() - for threading
* memcpy() - for heap and threading
* malloc(), realloc and free() - if GOS_RAW_HEAP_SIZE == 0
*
* You must also define the following routines in your own code so that timing functions will work...
* systemticks_t gfxSystemTicks(void);
* systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
*/
#ifndef _GOS_RAW32_H
#define _GOS_RAW32_H
#if GFX_USE_OS_RAW32
/*===========================================================================*/
/* Special Macros just for a Raw implementation */
/*===========================================================================*/
/**
* @brief Set the maximum size of the heap.
* @note If set to 0 then the C runtime library malloc() and free() are used.
*/
#ifndef GOS_RAW_HEAP_SIZE
#define GOS_RAW_HEAP_SIZE 0
#endif
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
typedef unsigned char bool_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;
typedef int threadreturn_t;
typedef int threadpriority_t;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[sz];
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((delaytime_t)-1)
#define MAX_SEMAPHORE_COUNT 0x7FFF
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 2
typedef struct {
semcount_t cnt;
semcount_t limit;
} gfxSem;
typedef uint32_t gfxMutex;
typedef void * gfxThreadHandle;
#define gfxThreadClose(thread)
#define gfxMutexDestroy(pmutex)
#define gfxSemDestroy(psem)
#define gfxSemCounter(psem) ((psem)->cnt)
#define gfxSemCounterI(psem) ((psem)->cnt)
#ifdef __cplusplus
extern "C" {
#endif
#if GOS_RAW_HEAP_SIZE != 0
void gfxAddHeapBlock(void *ptr, size_t sz);
#endif
void gfxHalt(const char *msg);
void gfxExit(void);
void *gfxAlloc(size_t sz);
void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
void gfxFree(void *ptr);
void gfxYield(void);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t ms);
systemticks_t gfxSystemTicks(void);
systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
void gfxMutexInit(gfxMutex *pmutex);
void gfxMutexEnter(gfxMutex *pmutex);
void gfxMutexExit(gfxMutex *pmutex);
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
bool_t gfxSemWaitI(gfxSem *psem);
void gfxSemSignal(gfxSem *psem);
void gfxSemSignalI(gfxSem *psem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadMe(void);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_OS_RAW32 */
#endif /* _GOS_RAW32_H */
|