📄 app.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1998-2003, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
*
* ARM Sample code
*
* File : app.c
*
* By : Eric Shufro
*********************************************************************************************************
*/
#include "includes.h"
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
const INT16U SEVSEG_PATTERN[16] = {0x003F, 0x0006, 0x005B, 0x004F, /* 0, 1, 2, 3, */
0x0066, 0x006D, 0x007D, 0x0027, /* 4, 5, 6, 7, */
0x007F, 0x006F, 0x0077, 0x007C, /* 8, 9, A, b, */
0x0039, 0x005E, 0x0079, 0x0071}; /* C, d, E, F */
const INT16U SEVSEG_WHEEL[6] = {0x0001, 0x0002, 0x0004, 0x0008, /* Wheel Effect */
0x0010, 0x0020};
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
OS_STK AppStartTaskStk[TASK_STK_SIZE];
OS_STK AppTask1Stk[TASK_STK_SIZE];
OS_STK AppTask2Stk[TASK_STK_SIZE];
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppStartTask(void *p_arg);
static void AppTaskCreate(void);
static void AppTask1(void *p_arg);
static void AppTask2(void *p_arg);
/*
*********************************************************************************************************
* main()
*
* Description : This is the standard entry point for C code. It is assumed that your code will call
* main() once you have performed all necessary 68HC12 and C initialization.
* Arguments : none
*********************************************************************************************************
*/
void main (void)
{
INT8U err;
BSP_Dis_Int(); /* Disable interrupts */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreateExt(AppStartTask,
(void *)0,
(OS_STK *)&AppStartTaskStk[TASK_STK_SIZE-1],
TASK_START_PRIO,
TASK_START_PRIO,
(OS_STK *)&AppStartTaskStk[0],
TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_TASK_NAME_SIZE > 15
OSTaskNameSet(TASK_START_PRIO, "Start Task", &err);
#endif
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
}
/*$PAGE*/
/*
*********************************************************************************************************
* 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.
* 2) Interrupts are enabled once the task start because the I-bit of the CCR register was
* set to 0 by 'OSTaskCreate()'.
*********************************************************************************************************
*/
static void AppStartTask (void *p_arg)
{
(void)p_arg;
BSP_Init(); /* Initialize the ticker, and other BSP related functions */
#if OS_TASK_STAT_EN > 0
OSStatInit();
#endif
AppTaskCreate();
while (TRUE) { /* Task body, always written as an infinite loop. */
OSTimeDlyHMSM(0, 0, 5, 0);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* CREATE APPLICATION TASKS
*
* Description : none
* Arguments : none
* Notes : none
*********************************************************************************************************
*/
static void AppTaskCreate (void)
{
INT8U err;
OSTaskCreateExt(AppTask1,
(void *)0,
(OS_STK *)&AppTask1Stk[TASK_STK_SIZE-1],
TASK_1_PRIO,
TASK_1_PRIO,
(OS_STK *)&AppTask1Stk[0],
TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskNameSet(TASK_1_PRIO, "Task #1", &err);
OSTaskCreateExt(AppTask2,
(void *)0,
(OS_STK *)&AppTask2Stk[TASK_STK_SIZE-1],
TASK_2_PRIO,
TASK_2_PRIO,
(OS_STK *)&AppTask2Stk[0],
TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskNameSet(TASK_2_PRIO, "Task #2", &err);
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #1
*********************************************************************************************************
*/
static void AppTask1 (void *p_arg)
{
while (TRUE) {
LED_On(0);
LED_On(1);
LED_On(2);
OSTimeDlyHMSM(0, 0, 0, 200);
LED_Off(0);
LED_Off(1);
LED_Off(2);
OSTimeDlyHMSM(0, 0, 0, 200);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #2
*********************************************************************************************************
*/
static void AppTask2 (void *p_arg)
{
INT8U i;
INT8U j;
while (TRUE) {
for (i = 0; i < 16; i++) {
SevenSegment_Show(SEVSEG_PATTERN[i]);
OSTimeDlyHMSM(0, 0, 0, 100);
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 6; j++) {
SevenSegment_Show(SEVSEG_WHEEL[j]);
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -