📄 test.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1998, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* uBlaze Specific test code
*
* File : TEST.C
* By : Jean J. Labrosse
* Revised: Jorgen Andersson, Nohau Corporation (10/30/02) for uBlaze
*
* Observe that the stack top is set to top-2 (not-1) to make the code run.
* See OSTaskCreate
* See OS_InitTaskIdle call to OSTaskCreateExt
* See OS_InitTaskStat call to OSTaskCreateExt
* Observ that the task stack frame has R13 and R2 pre-assigned for uBlaze
*********************************************************************************************************
*/
#include "includes.h"
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
OS_STK AppStartTaskStk[256];
OS_STK AppTask1Stk[256];
OS_STK AppTask2Stk[256];
INT16U AppTask1Ctr;
INT16U AppTask2Ctr;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppStartTask(void *pdata);
static void AppTask1(void *pdata);
static void AppTask2(void *pdata);
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 68HC12 and C initialization.
* Arguments : none
*********************************************************************************************************
*/
int main (void)
{
INT8U err;
*((volatile INT32U *)(0x14)) = (INT32U)OSTickISR ; //Load interrupt vector
*((volatile INT32U *)(0x14))|= 0xB8080000; //Or in Jump
/*---- 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[254], 0);
OSTaskNameSet(0, "Start Task", &err);
OSTaskNameSet(OS_IDLE_PRIO, "uC/OS-II Idle Task", &err);
OSTaskNameSet(OS_STAT_PRIO, "uC/OS-II Statistic Task", &err);
/*---- 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 : pdata is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
* Notes : 1) The first line of code is used to prevent a compiler warning because 'pdata' is not
* used. The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static void AppStartTask (void *pdata)
{
INT8U err;
pdata = pdata;
AppTickInit(); /* Initialize the ticker */
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
OSTaskCreate(AppTask1, (void *)0, (void *)&AppTask1Stk[254], 10);
OSTaskNameSet(10, "App Task #1", &err);
OSTaskCreate(AppTask2, (void *)0, (void *)&AppTask2Stk[254], 20);
OSTaskNameSet(20, "App Task #2", &err);
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 : pdata is the argument passed to 'AppTask1()' by 'OSTaskCreate()'.
* Notes : 1) The first line of code is used to prevent a compiler warning because 'pdata' 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 *pdata)
{
pdata = pdata;
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
AppTask1Ctr++;
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #2
*
* Description : This is an example of a task.
* Arguments : pdata is the argument passed to 'AppTask2()' by 'OSTaskCreate()'.
* Notes : 1) The first line of code is used to prevent a compiler warning because 'pdata' 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 *pdata)
{
pdata = pdata;
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
AppTask2Ctr++;
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is used to initialize one of the timers to generate an
* interrupt at the desired tick rate.
* Arguments : none
* Notes
*********************************************************************************************************
*/
static void AppTickInit (void)
{
AppTickInitAsm();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -