?? app.c
字號:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1998-2004, Micrium, Weston, FL
* All Rights Reserved
*
*
* ARM Sample code
*
* File : APP.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
OS_STK AppStartTaskStk[APP_TASK_STK_SIZE];
#define TASK_STK_SIZE 100 /* Size of each task's stacks (# of WORDs) */
#define TIMEOUT 20
#if OS_MBOX_EN > 0
OS_EVENT *Mbox;
#endif
OS_STK Task1Stk[TASK_STK_SIZE];
OS_STK Task2Stk[TASK_STK_SIZE];
void TaskPend(void *pdata);
void TaskPost(void *pdata);
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppStartTask(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;
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreateExt(AppStartTask,
(void *)0,
(OS_STK *)&AppStartTaskStk[APP_TASK_STK_SIZE - 1],
APP_TASK_START_PRIO,
APP_TASK_START_PRIO,
(OS_STK *)&AppStartTaskStk[0],
APP_TASK_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if OS_MBOX_EN > 0
Mbox = OSMboxCreate((void *)1);
#endif
OSTaskCreate(TaskPend, (void *)0, &Task1Stk[TASK_STK_SIZE - 1], 5);
OSTaskCreate(TaskPost, (void *)0, &Task2Stk[TASK_STK_SIZE - 1], 6);
#if OS_TASK_NAME_SIZE > 11
OSTaskNameSet(APP_TASK_START_PRIO, "Start Task", &err);
OSTaskNameSet(5, "TaskPend", &err);
OSTaskNameSet(6, "TaskPost", &err);
#endif
#if OS_TASK_NAME_SIZE > 14
OSTaskNameSet(OS_IDLE_PRIO, "uC/OS-II Idle", &err);
#endif
#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
OSTaskNameSet(OS_STAT_PRIO, "uC/OS-II Stat", &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)
{
INT8U i;
(void)p_arg;
BSP_Init(); /* Initialize BSP functions */
#if OS_TASK_STAT_EN > 0
OSStatInit(); /* Determine CPU capacity */
#endif
LED_Off(0); /* Turn OFF all the LEDs */
while (TRUE) { /* Task body, always written as an infinite loop. */
LED_On(8);
OSTimeDlyHMSM(0, 0, 0, 100);
LED_Off(8);
}
}
void TaskPost(void *pdata)
{
for(;;)
{
OSMboxPost(Mbox,"\rMessage sent from TaskPost to TaskPend.\n");
// LED_Blink(3);
puts("TaskPost is running.\n");
OSTimeDly(60);
}
}
void TaskPend(void *pdata)
{
INT8U err;
char *msg;
for(;;)
{
msg=OSMboxPend(Mbox,TIMEOUT,&err);
// LED_Blink(1);
puts(msg);
OSTimeDly(60);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -