GUI_X_uCOS.c
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ---Author-Explanation
15 *
16 * 1.00.00 020519 JJL First release of uC/GUI to uC/OS-II interface
17 *
18 *
19 * Known problems or limitations with current version
20 *
21 * None.
22 *
23 *
24 * Open issues
25 *
26 * None
27 *********************************************************************************************************
28 */
29
30 #include "os.h"
31 #include "os_Cfg_app.h"
32 #include "GUI_Private.H"
33 #include "stdio.H"
34
35
36 /*
37 *********************************************************************************************************
38 * GLOBAL VARIABLES
39 *********************************************************************************************************
40 */
41
42 static int KeyPressed;
43 static char KeyIsInited;
44
45 static OS_SEM dispSem;
46 static OS_SEM eventSem;
47 static OS_SEM keySem;
48
49 /*
50 *********************************************************************************************************
51 * TIMING FUNCTIONS
52 *
53 * Notes: Some timing dependent routines of uC/GUI require a GetTime and delay funtion.
54 * Default time unit (tick), normally is 1 ms.
55 *********************************************************************************************************
56 */
57
58 int GUI_X_GetTime(void)
59 {
60 OS_ERR err;
61
62 return ((int)OSTimeGet( (OS_ERR *)&err));
63 }
64
65 void GUI_X_Delay(int period)
66 {
67 OS_TICK ticks;
68 OS_ERR err;
69
70 ticks = period * OS_CFG_TICK_RATE_HZ / 1000;
71 OSTimeDly( (OS_TICK )ticks,
72 (OS_OPT )OS_OPT_TIME_DLY,
73 (OS_ERR *)&err);
74 }
75
76
77 /*
78 *********************************************************************************************************
79 * GUI_X_ExecIdle()
80 *********************************************************************************************************
81 */
82 /*WM空闲时调用*/
83 void GUI_X_ExecIdle(void)
84 {
85 OS_ERR err;
86
87 OSTimeDly( (OS_TICK )50,
88 (OS_OPT )OS_OPT_TIME_DLY,
89 (OS_ERR *)&err);
90 }
91
92
93 /*
94 *********************************************************************************************************
95 * MULTITASKING INTERFACE FUNCTIONS
96 *
97 * Note(1): 1) The following routines are required only if uC/GUI is used in a true multi task environment,
98 * which means you have more than one thread using the uC/GUI API. In this case the #define
99 * GUI_OS 1 needs to be in GUIConf.h
100 *********************************************************************************************************
101 */
102
103 void GUI_X_InitOS (void)
104 {
105 OS_ERR err;
106
107 OSSemCreate( (OS_SEM *)&dispSem, //建立一个互斥型信号量
108 (CPU_CHAR *)"dispSem",
109 (OS_SEM_CTR )1,
110 (OS_ERR *)&err );
111
112 OSSemCreate( (OS_SEM *)&eventSem,
113 (CPU_CHAR *)"eventSem",
114 (OS_SEM_CTR )1,
115 (OS_ERR *)&err );
116 }
117
118
119 void GUI_X_Lock(void)
120 {
121 OS_ERR err;
122 CPU_TS ts;
123
124 OSSemPend( (OS_SEM *)&dispSem,
125 (OS_TICK )0,
126 (OS_OPT )OS_OPT_PEND_BLOCKING,
127 (CPU_TS *)&ts,
128 (OS_ERR *)&err);
129 }
130
131
132 void GUI_X_Unlock(void)
133 {
134 OS_ERR err;
|