📄 app-o.c
字号:
*********************************************************************************************************
* App_EventCreate()
*
* Description : Create the application events.
*
* Argument(s) : none.
*
* Return(s) : none.
*********************************************************************************************************
*/
static void App_EventCreate (void)
{
#if (APP_CFG_LCD_EN == DEF_ENABLED)
App_UserIF_Mbox = OSMboxCreate((void *)0); /* Create MBOX for communication between Kbd and UserIF */
#if (OS_EVENT_NAME_SIZE > 12)
OSEventNameSet(App_UserIF_Mbox, (CPU_CHAR *)"User IF Mbox)
#endif
#endif
}
/*
*********************************************************************************************************
* App_TaskKbd()
*
* Description : Monitor the state of the push buttons and passes messages to AppTaskUserIF()
*
* Argument(s) : p_arg Argument passed to 'App_TaskKbd()' by 'OSTaskCreate()'.
*
* Return(s) : none.
*
* Note(s) : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
* used. The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
#if (APP_CFG_LCD_EN == DEF_ENABLED)
static void App_TaskKbd (void *p_arg)
{
CPU_BOOLEAN b1; /* State of Push Button #1 */
CPU_BOOLEAN b1_prev;
CPU_BOOLEAN b2; /* State of Push Button #2 */
CPU_BOOLEAN b2_prev;
CPU_BOOLEAN b3; /* State of Push Button #3 */
CPU_BOOLEAN b3_prev;
CPU_INT08U lcd_scr; /* LCD system state screen iD */
(void)p_arg;
lcd_scr = APP_LCD_SCR_FIRST;
b1_prev = DEF_FALSE;
b2_prev = DEF_FALSE;
b3_prev = DEF_FALSE;
while (DEF_TRUE) {
b1 = BSP_PB_GetStatus(1);
b2 = BSP_PB_GetStatus(2);
b3 = BSP_PB_GetStatus(3);
if (b1 == DEF_TRUE && b1_prev == DEF_FALSE) {
if (lcd_scr == APP_LCD_SCR_LAST) {
lcd_scr = APP_LCD_SCR_FIRST;
} else {
lcd_scr++;
}
OSMboxPost(App_UserIF_Mbox, (void *)lcd_scr);
}
if (b2 == DEF_TRUE && b2_prev == DEF_FALSE) {
BSP_LCD_LightOn();
}
if (b3 == DEF_TRUE && b3_prev == DEF_FALSE) {
BSP_LCD_LightOff();
}
b1_prev = b1;
b2_prev = b2;
b3_prev = b3;
OSTimeDlyHMSM(0, 0, 0, 150);
}
}
#endif
/*
*********************************************************************************************************
* App_TaskUserIF()
*
* Description : Updates LCD.
*
* Argument(s) : p_arg Argument passed to 'App_TaskUserIF()' by 'OSTaskCreate()'.
*
* Return(s) : none.
*
* Note(s) : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
* used. The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
#if (APP_CFG_LCD_EN == DEF_ENABLED)
static void App_TaskUserIF (void *p_arg)
{
CPU_INT32U pstate;
CPU_INT32U nstate;
CPU_INT32U *msg;
CPU_INT08U err;
(void)p_arg;
DispInit(2, 16); /* Initialize the LCD module */
BSP_LCD_LightOn();
App_DispScr_SignOn(); /* Display 'sign on' message */
OSTimeDlyHMSM(0, 0, 1, 0);
pstate = APP_LCD_SCR_FIRST;
nstate = APP_LCD_SCR_FIRST;
while (DEF_TRUE) { /* Task body, always written as an infinite loop. */
msg = (CPU_INT32U *)(OSMboxPend(App_UserIF_Mbox, OS_TICKS_PER_SEC / 3, &err));
if (err == OS_NO_ERR) {
pstate = (CPU_INT32U)msg;
}
if (pstate != nstate) {
nstate = pstate;
DispClrScr();
}
switch (pstate) {
case APP_LCD_SCR_VER_TICK_RATE:
App_DispScr_VerTickRate();
break;
case APP_LCD_SCR_CPU:
App_DispScr_CPU();
break;
case APP_LCD_SCR_CTXSW:
App_DispScr_CtxSw();
break;
case APP_LCD_SCR_BOARD_INFO:
App_DispScr_BoardInfo();
break;
case APP_LCD_SCR_SIGN_ON:
default:
App_DispScr_SignOn();
break;
}
}
}
#endif
/*
*********************************************************************************************************
* DISPLAY SCREENS
*
* Descrition : Display one of the screens used in the demonstration.
*
* Argument(s) : none.
*
* Return(s) : none.
*********************************************************************************************************
*/
#if (APP_CFG_LCD_EN == DEF_ENABLED)
static void App_DispScr_SignOn (void)
{
Str_Copy(App_UserIFLine1, "Micrium uC/OS-II");
Str_Copy(App_UserIFLine2, "IAR LPC2103 SK");
DispStr(0, 0, App_UserIFLine1);
DispStr(1, 0, App_UserIFLine2);
}
static void App_DispScr_VerTickRate (void)
{
CPU_INT32U value;
Str_Copy(App_UserIFLine1, "uC/OS-II: Vx.yy");
value = (CPU_INT32U)OSVersion();
App_UserIFLine1[12] = value / 100 + '0';
App_UserIFLine1[14] = (value % 100) / 10 + '0';
App_UserIFLine1[15] = (value % 10) + '0';
Str_Copy(App_UserIFLine2, "TickRate: xxxx");
value = (CPU_INT32U)OS_TICKS_PER_SEC;
App_FormatDec(&App_UserIFLine2[12], value, 4);
DispStr(0, 0, App_UserIFLine1);
DispStr(1, 0, App_UserIFLine2);
}
static void App_DispScr_CPU (void)
{
CPU_INT32U value;
Str_Copy(App_UserIFLine1, "CPU Usage:xx % ");
value = (CPU_INT32U)OSCPUUsage;
App_UserIFLine1[10] = (value / 10) + '0';
App_UserIFLine1[11] = (value % 10) + '0';
Str_Copy(App_UserIFLine2, "CPU Speed:xx MHz");
value = (CPU_INT32U)BSP_CPU_ClkFreq() / 1000000L;
App_UserIFLine2[10] = (value / 10) + '0';
App_UserIFLine2[11] = (value % 10) + '0';
DispStr(0, 0, App_UserIFLine1);
DispStr(1, 0, App_UserIFLine2);
}
static void App_DispScr_CtxSw (void)
{
CPU_INT32U value;
Str_Copy(App_UserIFLine1, "#Ticks: xxxxxxxx");
value = (CPU_INT32U)OSTime;
App_FormatDec(&App_UserIFLine1[8], value, 8);
Str_Copy(App_UserIFLine2, "#CtxSw: xxxxxxxx");
value = (CPU_INT32U)OSCtxSwCtr;
App_FormatDec(&App_UserIFLine2[8], value, 8);
DispStr(0, 0, App_UserIFLine1);
DispStr(1, 0, App_UserIFLine2);
}
static void App_DispScr_BoardInfo (void)
{
CPU_BOOLEAN b_state;
Str_Copy(App_UserIFLine1, "-- PB STATE -- ");
Str_Copy(App_UserIFLine2, "B1: xxx B2: yyy");
b_state = BSP_PB_GetStatus(2);
if (b_state == DEF_TRUE) {
App_UserIFLine2[4]= 'O';
App_UserIFLine2[5]= 'N';
App_UserIFLine2[6]= ' ';
} else {
App_UserIFLine2[4]= 'O';
App_UserIFLine2[5]= 'F';
App_UserIFLine2[6]= 'F';
}
b_state = BSP_PB_GetStatus(3);
if (b_state == DEF_TRUE) {
App_UserIFLine2[12]= 'O';
App_UserIFLine2[13]= 'N';
App_UserIFLine2[14]= ' ';
} else {
App_UserIFLine2[12]= 'O';
App_UserIFLine2[13]= 'F';
App_UserIFLine2[14]= 'F';
}
DispStr(0, 0, App_UserIFLine1);
DispStr(1, 0, App_UserIFLine2);
}
#endif
/*
*********************************************************************************************************
* App_ProbeInit()
*
* Description : Initializes the uC/Probe and the OS plugin for uC/Probe.
*
* Argument(s) : none.
*
* Return(s) : none.
*
*********************************************************************************************************
*/
#if (APP_CFG_PROBE_COM_EN == DEF_ENABLED)
static void App_ProbeInit (void)
{
#if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED)
(void)App_ProbeCnts;
(void)App_ProbeB1;
(void)App_ProbeB2;
(void)App_ProbeB3;
#if (PROBE_COM_STAT_EN == DEF_TRUE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -