📄 app.c
字号:
/****************************************Copyright (c)**************************************************
**
** JiangXing Auto
**
**
**--------------File Info-------------------------------------------------------------------------------
** File name: app.c
** Last modified Date:
** Last Version: 1.0
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Created by: Hexen
** Created date: 2007-03-15
** Version:
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include <includes.h>
/*
**************************************************************************************************************
* CONSTANTS
*
* Note(s) : 1) See OS_CFG.H for the default stack size: 'OS_TASK_STK_SIZE'
**************************************************************************************************************
*/
/*
**************************************************************************************************************
* VARIABLES
**************************************************************************************************************
*/
OS_STK AppTaskStartStk[OS_TASK_START_STK_SIZE];
OS_STK AppTaskMainStk[OS_TASK_MAIN_STK_SIZE];
/*
**************************************************************************************************************
* FUNCTION PROTOTYPES
**************************************************************************************************************
*/
void main(void);
static void AppTaskStart(void *p_arg);
static void AppTaskMain(void *p_arg);
/*
**************************************************************************************************************
* MAIN
*
* Note(s): 1) You SHOULD use OS_TASK_STK_SIZE (see OS_CFG.H) when setting OSTaskStkSize prior to calling
* OSInit() because OS_TASK_IDLE_STK_SIZE and OS_TASK_STAT_STK_SIZE are set to this value in
* OS_CFG.H.
**************************************************************************************************************
*/
void main (void)
{
#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
INT8U err;
#endif
/*---- Any initialization code prior to calling OSInit() goes HERE -------------------------------------*/
/* IMPORTANT: MUST be setup before calling 'OSInit()' */
OSTaskStkSize = OS_TASK_IDLE_STK_SIZE; /* Setup the default stack size */
OSTaskStkSizeHard = OS_TASK_IDLE_STK_SIZE_HARD; /* Setup the default hardware stack size */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
/*---- Any initialization code before starting multitasking --------------------------------------------*/
OSTaskStkSize = OS_TASK_START_STK_SIZE; /* Setup the total stack size */
OSTaskStkSizeHard = OS_TASK_START_STK_SIZE_HARD; /* Setup the hardware stack size */
OSTaskCreateExt(AppTaskStart,
(void *)0,
(OS_STK *)&AppTaskStartStk[OSTaskStkSize - 1],
OS_TASK_START_PRIO,
OS_TASK_START_PRIO,
(OS_STK *)&AppTaskStartStk[OSTaskStkSizeHard],
OSTaskStkSize - OSTaskStkSizeHard,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
OSTaskNameSet(OS_TASK_START_PRIO, "Start Task", &err);
#endif
/*---- Create any other task you want before we start multitasking -------------------------------------*/
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()'.
*
* Notes : 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.
**************************************************************************************************************
*/
static void AppTaskStart (void *p_arg)
{
#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
INT8U err;
#endif
BSP_Init(); /* Initialize the BSP */
USART0_Init(71); /* 波特率9600 */
G_Task_Flag = OSFlagCreate(0, &err);
OSTaskCreate(AppTaskMain,
(void *)0,
(OS_STK *)&AppTaskMainStk[OS_TASK_MAIN_STK_SIZE-1],
OS_TASK_MAIN_PRIO);
#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
OSTaskNameSet(OS_TASK_START_PRIO, "Main Task", &err);
#endif
OSTaskDel(OS_PRIO_SELF);
}
/*
**************************************************************************************************************
* Main TASK
**************************************************************************************************************
*/
static void AppTaskMain(void *p_arg)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
while (TRUE) {
BIT_LED_WORK = 1;
OSTimeDly(100);
BIT_LED_WORK = 0;
OSTimeDly(100);
}
}
/*
**************************************************************************************************************
* END File
**************************************************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -