野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4643|回复: 1

[ucos] 指南者上移植ucos-ii(注意是ucos-ii)同时移植STemwin,但在GUI_Delay()卡主了,怎...

[复制链接]
发表于 2017-4-4 17:58:12 | 显示全部楼层 |阅读模式
/*
*********************************************************************************************************
*                                                uC/GUI
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              ?C/GUI is protected by international 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 a license and should not be redistributed
*              in any way. We appreciate your understanding and fairness.
*
---Author-Explanation
*
* 1.00.00 020519 JJL    First release of uC/GUI to uC/OS-II interface
*
*
* Known problems or limitations with current version
*
*    None.
*
*
* Open issues
*
*    None
*********************************************************************************************************
*/

#include <includes.h>
#include "GUI_Private.H"
#include "stdio.H"


/*
*********************************************************************************************************
*                                         GLOBAL VARIABLES
*********************************************************************************************************
*/

static  OS_EVENT  *DispSem;
static  OS_EVENT  *EventMbox;

static  OS_EVENT  *KeySem;
static  int        KeyPressed;
static  char       KeyIsInited;


/*
*********************************************************************************************************
*                                        TIMING FUNCTIONS
*
* Notes: Some timing dependent routines of uC/GUI require a GetTime and delay funtion.
*        Default time unit (tick), normally is 1 ms.
*********************************************************************************************************
*/

int GUI_X_GetTime(void)
{

   return ((int)OSTimeGet());

}

void GUI_X_Delay(int period)
{

  INT32U  ticks;
  ticks=(period*1000)/OS_TICKS_PER_SEC;
  OSTimeDly((INT16U)ticks);

}


/*
*********************************************************************************************************
*                                          GUI_X_ExecIdle()
*********************************************************************************************************
*/
void GUI_X_ExecIdle(void)
{

// OS_X_Delay(1);
  OSTimeDly(1);   //把1改为50也不行,ucos的服务全开了

}



/*
*********************************************************************************************************
*                                    MULTITASKING INTERFACE FUNCTIONS
*
* Note(1): 1) The following routines are required only if uC/GUI is used in a true multi task environment,
*             which means you have more than one thread using the uC/GUI API.  In this case the #define
*             GUI_OS 1   needs to be in GUIConf.h
*********************************************************************************************************
*/

void GUI_X_InitOS (void)
{
  
    DispSem = OSSemCreate(1);           //??????????????????
    EventMbox = OSMboxCreate((void *)0);//???????????

}


void GUI_X_Lock(void)
{
  
  INT8U err;
  OSSemPend(DispSem,0,&err);

}


void GUI_X_Unlock(void)
{
  
  OSSemPost(DispSem);

}


U32 GUI_X_GetTaskId(void)
{
  
  return ((U32)(OSTCBCur->OSTCBPrio));

}

/*
*********************************************************************************************************
*                                        GUI_X_WaitEvent()
*                                        GUI_X_SignalEvent()
*********************************************************************************************************
*/


void GUI_X_WaitEvent(void)
{

   INT8U err;
   (void)OSMboxPend(EventMbox,0,&err);

}


void GUI_X_SignalEvent(void)
{

  (void)OSMboxPost(EventMbox,(void *)1);

}

/*
*********************************************************************************************************
*                                      KEYBOARD INTERFACE FUNCTIONS
*
* Purpose: The keyboard routines are required only by some widgets.
*          If widgets are not used, they may be eliminated.
*
* Note(s): If uC/OS-II is used, characters typed into the log window will be placedin the keyboard buffer.
*          This is a neat feature which allows you to operate your target system without having to use or
*          even to have a keyboard connected to it. (useful for demos !)
*********************************************************************************************************
*/

static void CheckInit(void)
{

  if(KeyIsInited==DEF_FALSE)
    {

      KeyIsInited = DEF_TRUE;
      GUI_X_Init();
     
}

}


/*??GUI_Init()????,??????????ЩGUI???????????????,??????????????????.????????????,???????*/
void GUI_X_Init(void)
{

  KeySem = OSSemCreate(0);

}


int GUI_X_GetKey(void)
{

    int r;
    r = KeyPressed;
    CheckInit();
    KeyPressed = 0;
    return (r);

}


int GUI_X_WaitKey(void)
{

    int  r;
    INT8U  err;
    CheckInit();
    if(KeyPressed==0)
      {

        OSSemPend(KeySem,0,&err); //????????
      
}
    r= KeyPressed;
    KeyPressed = 0;
    return (r);

}


void GUI_X_StoreKey(int k)
{

    KeyPressed = k;
    OSSemPost(KeySem); //????????

}

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); }

/********************end****************************/


static  void  App_TasKDisplay (void  *p_arg)         //5
{
   
    (void)p_arg;

   LCD_BK_EN;          //开液晶屏背光  
  CreateWindow_M_S();
  macLED2_ON();
  GUI_Delay(20);       //就是在这里被卡主了2灯亮,1灯不亮
    macLED1_ON();
    while (DEF_TRUE) {
   
   OSTimeDlyHMSM(0, 0, 10, 0);
      
    }
}


有哪位好心人解答下。。

回复

使用道具 举报

发表于 2017-4-5 08:48:47 | 显示全部楼层
参考一下我们的综合例程来移植
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-15 06:53 , Processed in 0.029420 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表