Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GUI_X_RTX.c Source File

GUI_X_RTX.c

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH                         *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2018  SEGGER Microcontroller GmbH                *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.48 - Graphical user interface for embedded applications **
00013 All  Intellectual Property rights  in the Software belongs to  SEGGER.
00014 emWin is protected by  international copyright laws.  Knowledge of the
00015 source code may not be used to write a similar product.  This file may
00016 only be used in accordance with the following terms:
00017 
00018 The software  has been licensed to  Cypress Semiconductor Corporation,
00019 whose registered  office is situated  at 198 Champion Ct. San Jose, CA 
00020 95134 USA  solely for the  purposes of creating  libraries for Cypress
00021 PSoC3 and  PSoC5 processor-based devices,  sublicensed and distributed
00022 under  the  terms  and  conditions  of  the  Cypress  End User License
00023 Agreement.
00024 Full source code is available at: www.segger.com
00025 
00026 We appreciate your understanding and fairness.
00027 ----------------------------------------------------------------------
00028 Licensing information
00029 Licensor:                 SEGGER Microcontroller Systems LLC
00030 Licensed to:              Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
00031 Licensed SEGGER software: emWin
00032 License number:           GUI-00319
00033 License model:            Services and License Agreement, signed June 10th, 2009
00034 Licensed platform:        Any Cypress platform (Initial targets are: PSoC3, PSoC5)
00035 ----------------------------------------------------------------------
00036 Support and Update Agreement (SUA)
00037 SUA period:               2009-06-12 - 2022-07-27
00038 Contact to extend SUA:    sales@segger.com
00039 ----------------------------------------------------------------------
00040 File        : GUI_X.C
00041 Purpose     : Config / System dependent externals for GUI
00042 ---------------------------END-OF-HEADER------------------------------
00043 */
00044 
00045 #include <RTL.h>
00046 #include "GUI.h"
00047 
00048 /*********************************************************************
00049 *
00050 *       Global data
00051 */
00052 volatile GUI_TIMER_TIME OS_TimeMS;
00053 
00054 /*********************************************************************
00055 *
00056 *      Timing:
00057 *                 GUI_X_GetTime()
00058 *                 GUI_X_Delay(int)
00059 
00060   Some timing dependent routines require a GetTime
00061   and delay function. Default time unit (tick), normally is
00062   1 ms.
00063 */
00064 
00065 GUI_TIMER_TIME GUI_X_GetTime(void) { 
00066   return OS_TimeMS; 
00067 }
00068 
00069 void GUI_X_Delay(int ms) { 
00070   while (ms > 0xFFFE) {
00071     ms -= 0xFFFE;
00072     os_dly_wait(0xFFFE);
00073   }
00074   os_dly_wait(ms);
00075 }
00076 
00077 /*********************************************************************
00078 *
00079 *       GUI_X_Init()
00080 *
00081 * Note:
00082 *     GUI_X_Init() is called from GUI_Init is a possibility to init
00083 *     some hardware which needs to be up and running before the GUI.
00084 *     If not required, leave this routine blank.
00085 */
00086 
00087 __task void SysTick_Task (void);
00088 
00089 void GUI_X_Init(void) {
00090   os_tsk_create(SysTick_Task, 1);
00091 }
00092 
00093 /*********************************************************************
00094 *
00095 *       GUI_X_ExecIdle
00096 *
00097 * Note:
00098 *  Called if WM is in idle state
00099 */
00100 
00101 void GUI_X_ExecIdle(void) {
00102   os_dly_wait(1);
00103 }
00104 
00105 /*********************************************************************
00106 *
00107 *      Logging: OS dependent
00108 
00109 Note:
00110   Logging is used in higher debug levels only. The typical target
00111   build does not use logging and does therefor not require any of
00112   the logging routines below. For a release build without logging
00113   the routines below may be eliminated to save some space.
00114   (If the linker is not function aware and eliminates unreferenced
00115   functions automatically)
00116 
00117 */
00118 
00119 void GUI_X_Log     (const char *s) { GUI_USE_PARA(s); }
00120 void GUI_X_Warn    (const char *s) { GUI_USE_PARA(s); }
00121 void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); }
00122 
00123 /*********************************************************************
00124 *
00125 *      Multitasking:
00126 *
00127 *                 GUI_X_InitOS()
00128 *                 GUI_X_GetTaskId()
00129 *                 GUI_X_Lock()
00130 *                 GUI_X_Unlock()
00131 *
00132 * Note:
00133 *   The following routines are required only if emWin is used in a
00134 *   true multi task environment, which means you have more than one
00135 *   thread using the emWin API.
00136 *   In this case the
00137 *                       #define GUI_OS 1
00138 *  needs to be in GUIConf.h
00139 */
00140 
00141 OS_SEM GUI_Semaphore;
00142 
00143 void GUI_X_InitOS(void)    { os_sem_init(GUI_Semaphore, 1); }
00144 void GUI_X_Unlock(void)    { os_sem_send(GUI_Semaphore); }
00145 void GUI_X_Lock(void)      { os_sem_wait(GUI_Semaphore, 0xFFFF); }
00146 U32  GUI_X_GetTaskId(void) { return os_tsk_self(); }
00147 
00148 /*********************************************************************
00149 *
00150 *      Event driving (optional with multitasking)
00151 *
00152 *                 GUI_X_WaitEvent()
00153 *                 GUI_X_WaitEventTimed()
00154 *                 GUI_X_SignalEvent()
00155 */
00156 
00157 OS_TID GUI_Task;
00158 
00159 void GUI_X_WaitEvent(void) {
00160   GUI_Task = os_tsk_self();
00161   os_evt_wait_or (0x0001, 0xFFFF); 
00162 }
00163 
00164 void GUI_X_WaitEventTimed(int Period) {
00165   GUI_Task = os_tsk_self();
00166   os_evt_wait_or (0x0001, (Period > 0xFFFE) ? 0xFFFE : Period); 
00167 }
00168 
00169 void GUI_X_SignalEvent(void) {
00170   if (GUI_Task) {
00171     os_evt_set (0x0001, GUI_Task);
00172   }
00173 }
00174 
00175 /*********************************************************************
00176 *
00177 *       SysTick_Task
00178 *
00179 */
00180 
00181 __task void SysTick_Task (void) {
00182 
00183   os_itv_set(10);
00184   for (;;) {
00185     os_itv_wait();
00186     OS_TimeMS += 10;
00187   }
00188 }
00189 
00190 /*************************** End of file ****************************/