📄 test.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1998-1999, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* M683xx Sample code
*
* COSMIC C V4.1
*
* File : TEST.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#include "INCLUDES.H"
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
OS_STK AppStartTaskStk[256];
OS_STK AppTask1Stk[256];
OS_STK AppTask2Stk[256];
static INT16U Task1Ctr;
static INT16U Task2Ctr;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppStartTask(void *p_arg);
static void AppTask1(void *p_arg);
static void AppTask2(void *p_arg);
static void AppTickInit(void);
/*
*********************************************************************************************************
* 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 683xx and C initialization.
* Arguments : none
*********************************************************************************************************
*/
void main (void)
{
/*---- Any initialization code prior to calling OSInit() goes HERE --------------------------------*/
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
/*---- Any initialization code before starting multitasking ---------------------------------------*/
OSTaskCreate(AppStartTask, (void *)0, (void *)&AppStartTaskStk[255], 0);
/*---- Create any other task you want before we start multitasking --------------------------------*/
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)
{
p_arg = p_arg;
AppTickInit(); /* Initialize the ticker */
#if OS_TASK_STAT_EN > 0
OSStatInit(); /* Initialize the statistics task if that feature enabled */
#endif
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
OSTaskCreate(AppTask1, (void *)0, (void *)&AppTask1Stk[255], 5);
OSTaskCreate(AppTask2, (void *)0, (void *)&AppTask2Stk[255], 6);
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #1
*
* Description : This is an example of a task.
* Arguments : p_arg is the argument passed to 'AppTask1()' 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 AppTask1 (void *p_arg)
{
p_arg = p_arg;
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
Task1Ctr++;
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #2
*
* Description : This is an example of a task.
* Arguments : p_arg is the argument passed to 'AppTask2()' 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 AppTask2 (void *p_arg)
{
p_arg = p_arg;
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
Task2Ctr++;
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is called to initialize a periodic time source which will be used as the
* clock tick for uC/OS-II. The interrupt handler MUST point to OSTickISR (see OS_CPU_A.S).
* Note(s) :
*********************************************************************************************************
*/
static void AppTickInit (void)
{
/*---- Tick initialization code goes HERE! --------------------------------------------------------*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -