LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
GUI_X_uCOS.c
Go to the documentation of this file.
1 /*********************************************************************
2 * SEGGER MICROCONTROLLER SYSTEME GmbH *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (C) 1996 SEGGER Microcontroller Systeme GmbH *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 
12 ----------------------------------------------------------------------
13 File : GUI_X.C
14 Purpose : Config / System dependent externals for GUI
15 ---------------------------END-OF-HEADER------------------------------
16 */
17 
18 #include "GUI.h"
19 
20 /* uCOS-iii include files */
21 #include "os.h"
22 
23 #include "debug_frmwrk.h"
24 
25 /*********************************************************************
26 *
27 * Global data
28 */
29 volatile int TimeMS;
30 static struct os_mutex xQueueMutex;
31 static struct os_sem xSemaTxDone;
32 
33 /*********************************************************************
34 *
35 * Timing:
36 * GUI_X_GetTime()
37 * GUI_X_Delay(int)
38 
39  Some timing dependent routines require a GetTime
40  and delay function. Default time unit (tick), normally is
41 1 ms.
42 */
43 
44 int GUI_X_GetTime(void)
45 {
46  OS_ERR err;
47  return ((int) OSTimeGet(&err));
48 }
49 
50 void GUI_X_Delay(int ms)
51 {
52  OS_ERR err;
53  OSTimeDlyHMSM( 0, 0, (ms / 1000), (ms % 1000), OS_OPT_TIME_HMSM_STRICT, &err);
54 }
55 
56 /*********************************************************************
57 *
58 * GUI_X_Init()
59 *
60 * Note:
61 * GUI_X_Init() is called from GUI_Init is a possibility to init
62 * some hardware which needs to be up and running before the GUI.
63 * If not required, leave this routine blank.
64 */
65 
66 void GUI_X_Init(void) {
67  TimeMS = 0;
68 }
69 
70 
71 /*********************************************************************
72 *
73 * GUI_X_ExecIdle
74 *
75 * Note:
76 * Called if WM is in idle state
77 */
78 
79 void GUI_X_ExecIdle(void) {}
80 
81 /*********************************************************************
82 *
83 * Multitasking:
84 *
85 * GUI_X_InitOS()
86 * GUI_X_GetTaskId()
87 * GUI_X_Lock()
88 * GUI_X_Unlock()
89 *
90 * Note:
91 * The following routines are required only if emWin is used in a
92 * true multi task environment, which means you have more than one
93 * thread using the emWin API.
94 * In this case the
95 * #define GUI_OS 1
96 * needs to be in GUIConf.h
97 */
98 
99 /* Init OS */
100 void GUI_X_InitOS(void)
101 {
102  OS_ERR err;
103 
104  /* Create Mutex lock */
105  OSMutexCreate(&xQueueMutex, "QueueMutex", &err);
106  //configASSERT (err == OS_ERR_NONE);
107 
108  /* Queue Semaphore */
109  OSSemCreate( &xSemaTxDone, "TxDoneSem", 0, &err);
110  //configASSERT ( err == OS_ERR_NONE );
111 }
112 
113 void GUI_X_Unlock(void)
114 {
115  OS_ERR os_err;
116  OSMutexPost(&xQueueMutex, OS_OPT_POST_NONE, &os_err);
117 }
118 
119 void GUI_X_Lock(void)
120 {
121  CPU_TS ts;
122  OS_ERR os_err;
123 
124  OSMutexPend(&xQueueMutex, 0, OS_OPT_PEND_BLOCKING, &ts, &os_err);
125 }
126 
127 /* Get Task handle */
128 U32 GUI_X_GetTaskId(void)
129 {
130  return ((U32) OSTCBCurPtr);
131 }
132 
133 void GUI_X_WaitEvent (void)
134 {
135  CPU_TS ts;
136  OS_ERR os_err;
137 
138  OSSemPend(&xSemaTxDone, 0, OS_OPT_PEND_BLOCKING, &ts, &os_err);
139 }
140 
141 
142 void GUI_X_SignalEvent (void)
143 {
144  OS_ERR ucErr;
145  OSSemPost(&xSemaTxDone, OS_OPT_POST_ALL, &ucErr);
146 }
147 
148 /*********************************************************************
149 *
150 * Logging: OS dependent
151 
152 Note:
153  Logging is used in higher debug levels only. The typical target
154  build does not use logging and does therefor not require any of
155  the logging routines below. For a release build without logging
156  the routines below may be eliminated to save some space.
157  (If the linker is not function aware and eliminates unreferenced
158  functions automatically)
159 
160 */
161 
162 void GUI_X_Log (const char *s) { lpc_printf(s); }
163 void GUI_X_Warn (const char *s) { lpc_printf(s); }
164 void GUI_X_ErrorOut(const char *s) { lpc_printf(s); }
165 
166 /*************************** End of file ****************************/