📄 app.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* uC/TCP-IP
* uC/TTCP
*
* (c) Copyright 1992-2003, Micrium, Inc., Weston, FL
* All Rights Reserved
*
* EXAMPLE #1
*
*
* Description: An example application that utilizes uC/TCP-IP and uC/TTCP.
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
static OS_STK AppTaskStartStk [APP_TASK_START_STK_SIZE];
static OS_STK AppTaskUserIFStk [APP_TASK_USER_IF_STK_SIZE];
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
static void AppTaskCreate(void);
static void AppTaskStart(void *p_arg);
static void AppTaskUserIF(void *p_arg);
/*
*********************************************************************************************************
* main()
*
* Description: This is the 'standard' C startup entry point. main() does the following:
*
* 1) Outputs a 'sign on' message on the serial port
* 2) Initialize uC/OS-II
* 3) Create a single task which will create the other application tasks.
* 4) Start uC/OS-II
*
* Arguments : None
*
* Returns : main() should NEVER return
*
* Note(s) : 1) It is assumed that interrupts are DISABLED when main() is called. Interrupts will
* be enabled by the first task that uC/OS-II starts.
*********************************************************************************************************
*/
int main (void)
{
CPU_INT08U err;
BSP_IntDisAll(); /* Make sure interrupts are disabled */
OSInit(); /* Initialize uC/OS-II */
OSTaskCreateExt(AppTaskStart,
(void *)0,
&AppTaskStartStk[APP_TASK_START_STK_SIZE - 1],
APP_TASK_START_PRIO,
APP_TASK_START_ID,
&AppTaskStartStk[0],
APP_TASK_START_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskNameSet(APP_TASK_START_PRIO, "Start Task", &err);
OSStart(); /* Start multitasking */
}
/*$PAGE*/
/*
*********************************************************************************************************
* AppTaskStart()
*
* Description: This is the first task executed by uC/OS-II following OSStart(). It call
* Arguments : p_arg Argument passed to this task when task is created. The argument is not used.
*
* Returns : None
*********************************************************************************************************
*/
static void AppTaskStart (void *p_arg)
{
CPU_INT08U i;
(void)p_arg; /* Prevent compiler warning by doing something with argument */
BSP_Init(); /* Initialize the board */
#if OS_TASK_STAT_EN > 0
OSStatInit(); /* Initialize uC/OS-II's statistics */
#endif
AppTaskCreate(); /* Create application tasks */
while (OS_TRUE) { /* Task body, always written as an infinite loop. */
for (i = 6; i < 17; i++) {
LED_Off(0);
LED_On(i);
OSTimeDlyHMSM(0,0,0,50);
}
for (i = 16; i > 5; i--) {
LED_Off(0);
LED_On(i);
OSTimeDlyHMSM(0,0,0,50);
}
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* USER INTERFACE TASK
*********************************************************************************************************
*/
static void AppTaskUserIF (void *p_arg)
{
// INT8U s[20];
// INT8U user_if_state;
// BOOLEAN b1; /* State of Push Button #1 */
// BOOLEAN b1_prev;
// BOOLEAN b2;
// BOOLEAN b2_prev;
// INT32U value;
while (1) {
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* CREATE APPLICATION TASKS
*********************************************************************************************************
*/
static void AppTaskCreate (void)
{
INT8U err;
OSTaskCreateExt(AppTaskUserIF,
(void *)0,
(OS_STK *)&AppTaskUserIFStk[APP_TASK_USER_IF_STK_SIZE - 1],
APP_TASK_USER_IF_PRIO,
APP_TASK_USER_IF_PRIO,
(OS_STK *)&AppTaskUserIFStk[0],
APP_TASK_USER_IF_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_TASK_NAME_SIZE > 13
OSTaskNameSet(APP_TASK_USER_IF_PRIO, "User I/F", &err);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -