|

楼主 |
发表于 2020-9-10 09:55:17
|
显示全部楼层
找到了,附件中。
他这里的处理方式是,emwin GUI初始化时,创建一个cmsis_os的独立定时器,1ms的周期,作为emwin的时钟。
- #include "cmsis_os.h"
- #include "GUI.h"
- /*********************************************************************
- *
- * Global data
- */
- volatile GUI_TIMER_TIME OS_TimeMS;
- /*********************************************************************
- *
- * GUI Tick (executed each ms)
- */
- static void GUI_Tick (void const *argument) {
- OS_TimeMS++;
- }
- /*********************************************************************
- *
- * Timing:
- * GUI_X_GetTime()
- * GUI_X_Delay(int)
- Some timing dependent routines require a GetTime
- and delay function. Default time unit (tick), normally is
- 1 ms.
- */
- GUI_TIMER_TIME GUI_X_GetTime(void) {
- return OS_TimeMS;
- }
- void GUI_X_Delay(int ms) {
- osDelay(ms);
- }
- /*********************************************************************
- *
- * GUI_X_Init()
- *
- * Note:
- * GUI_X_Init() is called from GUI_Init is a possibility to init
- * some hardware which needs to be up and running before the GUI.
- * If not required, leave this routine blank.
- */
- osTimerDef(GUI_Timer, GUI_Tick);
- osTimerId GUI_TimerId;
- void GUI_X_Init(void) {
- GUI_TimerId = osTimerCreate(osTimer(GUI_Timer), osTimerPeriodic, NULL);
- osTimerStart(GUI_TimerId, 1);
- }
- /*********************************************************************
- *
- * GUI_X_ExecIdle
- *
- * Note:
- * Called if WM is in idle state
- */
- void GUI_X_ExecIdle(void) {
- osDelay(1);
- }
- /*********************************************************************
- *
- * Logging: OS dependent
- Note:
- Logging is used in higher debug levels only. The typical target
- build does not use logging and does therefor not require any of
- the logging routines below. For a release build without logging
- the routines below may be eliminated to save some space.
- (If the linker is not function aware and eliminates unreferenced
- functions automatically)
- */
- void GUI_X_Log (const char *s) { GUI_USE_PARA(s); }
- void GUI_X_Warn (const char *s) { GUI_USE_PARA(s); }
- void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); }
- /*********************************************************************
- *
- * Multitasking:
- *
- * GUI_X_InitOS()
- * GUI_X_GetTaskId()
- * GUI_X_Lock()
- * GUI_X_Unlock()
- *
- * Note:
- * The following routines are required only if emWin is used in a
- * true multi task environment, which means you have more than one
- * thread using the emWin API.
- * In this case the
- * #define GUI_OS 1
- * needs to be in GUIConf.h
- */
- osMutexDef(GUI_Mutex);
- osMutexId GUI_MutexId;
- void GUI_X_InitOS(void) { GUI_MutexId = osMutexCreate(osMutex(GUI_Mutex)); }
- void GUI_X_Unlock(void) { osMutexRelease(GUI_MutexId); }
- void GUI_X_Lock(void) { osMutexWait (GUI_MutexId, osWaitForever); }
- U32 GUI_X_GetTaskId(void) { return ((U32)osThreadGetId()); }
- /*********************************************************************
- *
- * Event driving (optional with multitasking)
- *
- * GUI_X_WaitEvent()
- * GUI_X_WaitEventTimed()
- * GUI_X_SignalEvent()
- */
- osThreadId GUI_ThreadId;
- void GUI_X_WaitEvent(void) {
- GUI_ThreadId = osThreadGetId();
- osSignalWait(0x00000001, osWaitForever);
- }
- void GUI_X_WaitEventTimed(int Period) {
- GUI_ThreadId = osThreadGetId();
- osSignalWait(0x00000001, Period);
- }
- void GUI_X_SignalEvent(void) {
- if (GUI_ThreadId) {
- osSignalSet(GUI_ThreadId, 0x00000001);
- }
- }
- /*************************** End of file ****************************/
复制代码
|
|