LPCOpen Platform  v1.03
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 GmbH & Co. KG *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (c) 1996 - 2012 SEGGER Microcontroller GmbH & Co. KG *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 
12 ** emWin V5.18 - Graphical user interface for embedded applications **
13 All Intellectual Property rights in the Software belongs to SEGGER.
14 emWin is protected by international copyright laws. Knowledge of the
15 source code may not be used to write a similar product. This file may
16 only be used in accordance with the following terms:
17 
18 The software has been licensed to NXP Semiconductors USA, Inc. whose
19 registered office is situated at 1109 McKay Dr, M/S 76, San Jose,
20 CA 95131, USA solely for the purposes of creating libraries for
21 NXPs M0, M3/M4 and ARM7/9 processor-based devices, sublicensed and
22 distributed under the terms and conditions of the NXP End User License
23 Agreement.
24 Full source code is available at: www.segger.com
25 
26 We appreciate your understanding and fairness.
27 ----------------------------------------------------------------------
28 File : GUI_X_uCOS.C
29 Purpose : Config / System dependent externals for GUI
30 ---------------------------END-OF-HEADER------------------------------
31 */
32 
33 #include "GUI.h"
34 
35 /* uCOS-iii include files */
36 #include "os.h"
37 
38 #include "debug_frmwrk.h"
39 
40 /*********************************************************************
41 *
42 * Global data
43 */
44 static struct os_mutex xQueueMutex;
45 static struct os_sem xSemaTxDone;
46 
47 /*********************************************************************
48 *
49 * Timing:
50 * GUI_X_GetTime()
51 * GUI_X_Delay(int)
52 
53  Some timing dependent routines require a GetTime
54  and delay function. Default time unit (tick), normally is
55 1 ms.
56 */
57 
58 int GUI_X_GetTime(void)
59 {
60  OS_ERR err;
61  return ((int) OSTimeGet(&err));
62 }
63 
64 void GUI_X_Delay(int ms)
65 {
66  OS_ERR err;
67  OSTimeDlyHMSM( 0, 0, (ms / 1000), (ms % 1000), OS_OPT_TIME_HMSM_STRICT, &err);
68 }
69 
70 /*********************************************************************
71 *
72 * GUI_X_Init()
73 *
74 * Note:
75 * GUI_X_Init() is called from GUI_Init is a possibility to init
76 * some hardware which needs to be up and running before the GUI.
77 * If not required, leave this routine blank.
78 */
79 
80 void GUI_X_Init(void) {
81 }
82 
83 
84 /*********************************************************************
85 *
86 * GUI_X_ExecIdle
87 *
88 * Note:
89 * Called if WM is in idle state
90 */
91 
92 void GUI_X_ExecIdle(void) {}
93 
94 /*********************************************************************
95 *
96 * Multitasking:
97 *
98 * GUI_X_InitOS()
99 * GUI_X_GetTaskId()
100 * GUI_X_Lock()
101 * GUI_X_Unlock()
102 *
103 * Note:
104 * The following routines are required only if emWin is used in a
105 * true multi task environment, which means you have more than one
106 * thread using the emWin API.
107 * In this case the
108 * #define GUI_OS 1
109 * needs to be in GUIConf.h
110 */
111 
112 /* Init OS */
113 void GUI_X_InitOS(void)
114 {
115  OS_ERR err;
116 
117  /* Create Mutex lock */
118  OSMutexCreate(&xQueueMutex, "QueueMutex", &err);
119  //configASSERT (err == OS_ERR_NONE);
120 
121  /* Queue Semaphore */
122  OSSemCreate( &xSemaTxDone, "TxDoneSem", 0, &err);
123  //configASSERT ( err == OS_ERR_NONE );
124 }
125 
126 void GUI_X_Unlock(void)
127 {
128  OS_ERR os_err;
129  OSMutexPost(&xQueueMutex, OS_OPT_POST_NONE, &os_err);
130 }
131 
132 void GUI_X_Lock(void)
133 {
134  CPU_TS ts;
135  OS_ERR os_err;
136 
137  OSMutexPend(&xQueueMutex, 0, OS_OPT_PEND_BLOCKING, &ts, &os_err);
138 }
139 
140 /* Get Task handle */
141 U32 GUI_X_GetTaskId(void)
142 {
143  return ((U32) OSTCBCurPtr);
144 }
145 
146 void GUI_X_WaitEvent (void)
147 {
148  CPU_TS ts;
149  OS_ERR os_err;
150 
151  OSSemPend(&xSemaTxDone, 0, OS_OPT_PEND_BLOCKING, &ts, &os_err);
152 }
153 
154 
155 void GUI_X_SignalEvent (void)
156 {
157  OS_ERR ucErr;
158  OSSemPost(&xSemaTxDone, OS_OPT_POST_ALL, &ucErr);
159 }
160 
161 /*********************************************************************
162 *
163 * Logging: OS dependent
164 
165 Note:
166  Logging is used in higher debug levels only. The typical target
167  build does not use logging and does therefor not require any of
168  the logging routines below. For a release build without logging
169  the routines below may be eliminated to save some space.
170  (If the linker is not function aware and eliminates unreferenced
171  functions automatically)
172 
173 */
174 
175 void GUI_X_Log (const char *s) { DEBUGOUT(s); }
176 void GUI_X_Warn (const char *s) { DEBUGOUT(s); }
177 void GUI_X_ErrorOut(const char *s) { DEBUGOUT(s); }
178 
179 /*************************** End of file ****************************/