hpdell 发表于 2019-7-26 07:09:05

请教下,使用 v2 封装层貌似速度比较慢 ?



emwin gui_x_os 配置

FreeRTOS V1 封装层:

#include "cmsis_os.h"
#include "FreeRTOS.h"
#include "task.h"

static osMutexId osMutex= NULL;
static osSemaphoreId osSemaphore= NULL;

int GUI_X_GetTime(void)
{
return ((int) osKernelSysTick());
}

void GUI_X_Delay(int ms)
{
osDelay( ms );
}


void GUI_X_Init(void) {
}


void GUI_X_ExecIdle(void) {}


/* Init OS */
void GUI_X_InitOS(void)
{
/* Create Mutex lock */
osMutexDef(MUTEX);
osMutex = osMutexCreate(osMutex(MUTEX));

/* Create Semaphore lock */
osSemaphoreDef(SEM);
osSemaphore= osSemaphoreCreate(osSemaphore(SEM), 1);
}

void GUI_X_Unlock(void)
{
osMutexRelease(osMutex);
}

void GUI_X_Lock(void)
{
        if((osMutex == NULL) || (osSemaphore == NULL))
{
    GUI_X_InitOS();
}
       
osMutexWait(osMutex , osWaitForever) ;
}

/* Get Task handle */
U32 GUI_X_GetTaskId(void)
{
return ((U32) osThreadGetId());
}


void GUI_X_WaitEvent (void)
{
osSemaphoreWait(osSemaphore , osWaitForever) ;
}


void GUI_X_SignalEvent (void)
{
osMutexRelease(osSemaphore);
}


void GUI_X_Log (const char *s) { }
void GUI_X_Warn (const char *s) { }
void GUI_X_ErrorOut(const char *s) { }



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FreeRTOS V2 封装层:

#include "cmsis_os.h"
#include "FreeRTOS.h"
#include "task.h"

static osMutexId osMutex= NULL;
static osSemaphoreId osSemaphore= NULL;

int GUI_X_GetTime(void)
{
return ((int) osKernelSysTick());
}

void GUI_X_Delay(int ms)
{
osDelay( ms );
}


void GUI_X_Init(void) {
}


void GUI_X_ExecIdle(void) {}

/* Init OS */
void GUI_X_InitOS(void)
{
/* Create Mutex lock */
osMutexDef(MUTEX);
osMutex = osMutexNew(osMutex(MUTEX));
       
/* Create Semaphore lock */
//        osSemaphoreDef(SEM);
//        osSemaphore = osSemaphoreNew (1, 0, osSemaphore(SEM));
       
        osSemaphore = osSemaphoreNew (1, 0, NULL);
}

void GUI_X_Unlock(void)
{
osMutexRelease(osMutex);
}

void GUI_X_Lock(void)
{
        if((osMutex == NULL) || (osSemaphore == NULL))
{
    GUI_X_InitOS();
}
       
       
//osMutexWait(osMutex , osWaitForever) ;
        osMutexAcquire(osMutex , osWaitForever) ;
}

/* Get Task handle */
U32 GUI_X_GetTaskId(void)
{
return ((U32) osThreadGetId());
}


void GUI_X_WaitEvent (void)
{
//osSemaphoreWait(osSemaphore , osWaitForever) ;
        osSemaphoreAcquire(osSemaphore , osWaitForever) ;
}


void GUI_X_SignalEvent (void)
{
osMutexRelease(osSemaphore);
}


void GUI_X_Log (const char *s) { }
void GUI_X_Warn (const char *s) { }
void GUI_X_ErrorOut(const char *s) { }


大神帮忙看看是哪里没有搞对吗 ?

v2 封装层的 响应速度没有 v1 快 ????


eric2013 发表于 2019-7-26 10:31:30

/*********************************************************************
*                  SEGGER Microcontroller GmbH                     *
*      Solutions for real time microcontroller applications      *
**********************************************************************
*                                                                  *
*      (c) 1996 - 2019SEGGER Microcontroller GmbH                *
*                                                                  *
*      Internet: www.segger.com    Support:support@segger.com    *
*                                                                  *
**********************************************************************

** emWin V5.50 - Graphical user interface for embedded applications **
AllIntellectual Property rightsin the Software belongs toSEGGER.
emWin is protected byinternational copyright laws.Knowledge of the
source code may not be used to write a similar product.This file may
only be used in accordance with the following terms:

The software has been licensed toARM LIMITED whose registered office
is situated at110 Fulbourn Road,Cambridge CB1 9NJ,England solely
forthepurposesofcreatinglibrariesforARM7, ARM9, Cortex-M
series,and   Cortex-R4   processor-baseddevices,sublicensedand
distributed as part of theMDK-ARMProfessionalunder the terms and
conditionsofthe   EndUserLicensesuppliedwiththeMDK-ARM
Professional.
Full source code is available at: www.segger.com

We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor:               SEGGER Software GmbH
Licensed to:            ARM Ltd, 110 Fulbourn Road, CB1 9NJ Cambridge, UK
Licensed SEGGER software: emWin
License number:         GUI-00181
License model:            LES-SLA-20007, Agreement, effective since October 1st 2011
Licensed product:         MDK-ARM Professional
Licensed platform:      ARM7/9, Cortex-M/R4
Licensed number of seats: -
----------------------------------------------------------------------
File      : GUI_X_RTE.c
Purpose   : Config / System dependent externals for GUI
---------------------------END-OF-HEADER------------------------------
*/

#include "RTE_Components.h"
#ifdef RTE_CMSIS_RTOS2
#include "cmsis_os2.h"
#else
#include "cmsis_os.h"
#endif

#include "GUI.h"

/*********************************************************************
*
*       Global data
*/

#ifndef RTE_CMSIS_RTOS2
static volatile GUI_TIMER_TIME OS_TimeMS;
#endif

/*********************************************************************
*
*       GUI Tick (executed each ms)
*/

#ifndef RTE_CMSIS_RTOS2
static void GUI_Tick (void const *argument) {
(void)argument;
OS_TimeMS++;
}
#endif

/*********************************************************************
*
*      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) {
#ifdef RTE_CMSIS_RTOS2
return ((GUI_TIMER_TIME)(osKernelGetTickCount()));
#else
return OS_TimeMS;
#endif
}

void GUI_X_Delay(int ms) {
osDelay((uint32_t)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.
*/

#ifndef RTE_CMSIS_RTOS2
osTimerDef(GUI_Timer, GUI_Tick);
static osTimerId GUI_TimerId;
#endif

#ifdef RTE_Graphics_Touchscreen
extern void GUI_TOUCH_Initialize(void);
extern void GUI_TOUCH_Exec(void);
#ifdef RTE_CMSIS_RTOS2
static osTimerId_t GUI_TOUCH_TimerId;
static void GUI_TOUCH_Tick(void *argument)       { (void)argument; GUI_TOUCH_Exec(); }
#else
static osTimerId   GUI_TOUCH_TimerId;
static void GUI_TOUCH_Tick(void const *argument) { (void)argument; GUI_TOUCH_Exec(); }
osTimerDef (GUI_TOUCH_Timer, GUI_TOUCH_Tick);
#endif
#endif

#ifdef RTE_Graphics_Joystick
extern void GUI_JOYSTICK_Initialize(void);
extern void GUI_JOYSTICK_Exec(void);
#ifdef RTE_CMSIS_RTOS2
static osTimerId_t GUI_JOYSTICK_TimerId;
static void GUI_JOYSTICK_Tick(void *argument)       { (void)argument; GUI_JOYSTICK_Exec(); }
#else
static osTimerId   GUI_JOYSTICK_TimerId;
static void GUI_JOYSTICK_Tick(void const *argument) { (void)argument; GUI_JOYSTICK_Exec(); }
osTimerDef (GUI_JOYSTICK_Timer, GUI_JOYSTICK_Tick);
#endif
#endif

void GUI_X_Init(void) {

#ifndef RTE_CMSIS_RTOS2
GUI_TimerId = osTimerCreate(osTimer(GUI_Timer), osTimerPeriodic, NULL);
osTimerStart(GUI_TimerId, 1);
#endif

#ifdef RTE_Graphics_Touchscreen
GUI_TOUCH_Initialize();
#ifdef RTE_CMSIS_RTOS2
GUI_TOUCH_TimerId = osTimerNew(&GUI_TOUCH_Tick, osTimerPeriodic, NULL, NULL);
#else
GUI_TOUCH_TimerId = osTimerCreate(osTimer(GUI_TOUCH_Timer), osTimerPeriodic, NULL);
#endif
osTimerStart(GUI_TOUCH_TimerId, 20U);
#endif

#ifdef RTE_Graphics_Joystick
GUI_JOYSTICK_Initialize();
#ifdef RTE_CMSIS_RTOS2
GUI_JOYSTICK_TimerId = osTimerNew(&GUI_JOYSTICK_Tick, osTimerPeriodic, NULL, NULL);
#else
GUI_JOYSTICK_TimerId = osTimerCreate(osTimer(GUI_JOYSTICK_Timer), osTimerPeriodic, NULL);
#endif
osTimerStart(GUI_JOYSTICK_TimerId, 50U);
#endif

}

/*********************************************************************
*
*       GUI_X_ExecIdle
*
* Note:
*Called if WM is in idle state
*/

void GUI_X_ExecIdle(void) {
osDelay(1U);
}

/*********************************************************************
*
*      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
*/

#ifdef RTE_CMSIS_RTOS2
static osMutexId_t      GUI_MutexId;
static osEventFlagsId_t GUI_EventId;
#else
osMutexDef(GUI_Mutex);
static osMutexId      GUI_MutexId;
#endif

void GUI_X_InitOS(void) {
#ifdef RTE_CMSIS_RTOS2
GUI_MutexId = osMutexNew(NULL);
GUI_EventId = osEventFlagsNew(NULL);
#else
GUI_MutexId = osMutexCreate(osMutex(GUI_Mutex));
#endif
}

void GUI_X_Unlock(void) {
osMutexRelease(GUI_MutexId);
}

void GUI_X_Lock(void) {
#ifdef RTE_CMSIS_RTOS2
osMutexAcquire(GUI_MutexId, osWaitForever);
#else
osMutexWait   (GUI_MutexId, osWaitForever);
#endif
}

U32GUI_X_GetTaskId(void) {
return ((U32)(osThreadGetId()));
}

/*********************************************************************
*
*      Event driving (optional with multitasking)
*
*               GUI_X_WaitEvent()
*               GUI_X_WaitEventTimed()
*               GUI_X_SignalEvent()
*/

#ifndef RTE_CMSIS_RTOS2
static osThreadId GUI_ThreadId = NULL;
#endif

void GUI_X_WaitEvent(void) {
#ifdef RTE_CMSIS_RTOS2
osEventFlagsWait(GUI_EventId, 0x00000001U, osFlagsWaitAny, osWaitForever);
#else
GUI_ThreadId = osThreadGetId();
osSignalWait(0x00000001, osWaitForever);
#endif
}

void GUI_X_WaitEventTimed(int Period) {
#ifdef RTE_CMSIS_RTOS2
osEventFlagsWait(GUI_EventId, 0x00000001U, osFlagsWaitAny, (uint32_t)Period);
#else
GUI_ThreadId = osThreadGetId();
osSignalWait(0x00000001, (uint32_t)Period);
#endif
}

void GUI_X_SignalEvent(void) {
#ifdef RTE_CMSIS_RTOS2
osEventFlagsSet (GUI_EventId, 0x00000001U);
#else
if (GUI_ThreadId) {
    osSignalSet(GUI_ThreadId, 0x00000001);
}
#endif
}

/*************************** End of file ****************************/


hpdell 发表于 2019-7-27 09:37:15

本帖最后由 hpdell 于 2019-7-27 10:08 编辑

eric2013 发表于 2019-7-26 10:31

是我吧问题想的太简单了啊,原来需要这么的搞, 多谢多谢大神了啊
另外这个 emwin v5.5的在哪里可以下载啊 ??
页: [1]
查看完整版本: 请教下,使用 v2 封装层貌似速度比较慢 ?