📄 app.c
字号:
/*
*********************************************************************************************************
*
* EXAMPLE CODE
*
* (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* EXAMPLE CODE
*
* Filename : app.c
* Version : V1.00
* Programmer(s) : Brian Nagel
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
OS_STK AppTaskStartStk[APP_TASK_START_STK_SIZE];
#if uC_LCD_MODULE == DEF_ENABLED
OS_STK AppTaskUserIFStk[APP_TASK_USER_IF_STK_SIZE];
#endif
static CPU_INT08U EXTINT_Char;
static OS_EVENT *EXTINT_Mbox;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppTaskCreate(void);
static void AppTaskStart(void *p_arg);
#if uC_LCD_MODULE == DEF_ENABLED
static void AppTaskUserIF(void *p_arg);
#endif
#if OS_VIEW_MODULE > 0
static void AppTerminalRx(CPU_INT08U rx_data);
#endif
static void EXTINT_ISRHandler(void);
static void AppFormatDec (CPU_INT08U *s, CPU_INT32U value, CPU_INT08U digits);
/*
*********************************************************************************************************
* main()
*
* Description : This is the standard entry point for C code.
*
* Arguments : none
*********************************************************************************************************
*/
void main (void)
{
CPU_INT08U err;
BSP_IntDisAll(); /* Disable all interrupts until we are ready to accept them */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreateExt(AppTaskStart, /* Create the start task */
(void *)0,
(OS_STK *)&AppTaskStartStk[APP_TASK_START_STK_SIZE - 1],
APP_TASK_START_PRIO,
APP_TASK_START_PRIO,
(OS_STK *)&AppTaskStartStk[0],
APP_TASK_START_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_TASK_NAME_SIZE > 13
OSTaskNameSet(APP_TASK_START_PRIO, "Start Task", &err);
#endif
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
}
/*
*********************************************************************************************************
* STARTUP TASK
*
* Description : This is an example of a startup task. As mentioned in the book's text, you MUST
* initialize the ticker only once multitasking has started.
* Arguments : p_arg is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
*********************************************************************************************************
*/
static void AppTaskStart (void *p_arg)
{
CPU_INT08U i;
(void)p_arg;
BSP_Init(); /* Initialize BSP functions */
#if OS_TASK_STAT_EN > 0
OSStatInit(); /* Determine CPU capacity */
#endif
#if OS_VIEW_MODULE > 0
OSView_Init(38400);
OSView_TerminalRxSetCallback(AppTerminalRx);
OSView_RxIntEn(); /* Enable Rx Interrupts */
#endif
#if uC_LCD_MODULE == DEF_ENABLED
DispInit(2, 16);
#endif
AppTaskCreate(); /* Create application tasks */
EXTINT_Mbox = OSMboxCreate((void *)0); /* Create mailbox for PB control of user IF */
EXTINT_Init(EXTINT_ISRHandler); /* Initialize EXTIT for PB interrupts */
while (DEF_TRUE) { /* Task body, always written as an infinite loop. */
for (i = 1; i <= 16; i++) {
LED_On(i);
OSTimeDlyHMSM(0, 0, 0, 25);
}
for (i = 0; i < 4; i++) {
LED_On(LED_LINK);
LED_On(LED_STAT);
OSTimeDlyHMSM(0, 0, 0, 50);
LED_Off(LED_LINK);
LED_Off(LED_STAT);
OSTimeDlyHMSM(0, 0, 0, 50);
}
for (i = 16; i >= 1; i--) {
LED_Off(i);
OSTimeDlyHMSM(0, 0, 0, 25);
}
for (i = 0; i < 4; i++) {
LED_On(LED_LINK);
LED_On(LED_STAT);
OSTimeDlyHMSM(0, 0, 0, 50);
LED_Off(LED_LINK);
LED_Off(LED_STAT);
OSTimeDlyHMSM(0, 0, 0, 50);
}
}
}
/*
*********************************************************************************************************
* USER INTERFACE TASK
*********************************************************************************************************
*/
#if uC_LCD_MODULE == DEF_TRUE
static void AppTaskUserIF (void *p_arg)
{
CPU_INT08U s[20];
CPU_INT08U user_if_state;
CPU_INT08U *msg;
CPU_INT32U value;
CPU_BOOLEAN change;
(void)p_arg;
DispInit(2, 16); /* Initialize the LCD module */
DispStr(0, 0, "Micrium uC/OS-II"); /* Display 'sign on' message */
DispStr(1, 0, " ST STR75x ");
OSTimeDlyHMSM(0, 0, 1, 0);
user_if_state = 0;
while (DEF_TRUE) { /* Task body, always written as an infinite loop. */
msg = (CPU_INT08U *)OSMboxAccept(EXTINT_Mbox);
change = DEF_FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -