📄 test.c
字号:
/*
*********************************************************************************************************
* uC/OS
* The Real-Time Kernel
*
* (c) Copyright 1992-1995, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* 68HC11 Sample code
*
* File : TEST.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#include "INCLUDES.H"
UBYTE AppStartTaskStk[256];
/*
*********************************************************************************************************
* 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 68HC11 and C initialization.
* Arguments : none
*********************************************************************************************************
*/
void main(void)
{
/*---- Any initialization code prior to calling OSInit() goes HERE --------------------------------*/
OSInit(); /* Initialize "uC/OS, The Real-Time Kernel" */
/*---- Any initialization code before starting multitasking ---------------------------------------*/
OStaskCreate(AppStartTask, (void *)0, (void *)&AppStartTaskStk[256], 0);
/*---- Create any other task you want before we start multitasking --------------------------------*/
OSStart(); /* Start multitasking (i.e. give control to uC/OS) */
}
/*$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.
* 2) Interrupts are enabled once the task start because the I-bit of the CCR register was
* set to 0 by 'OSTaskCreate()'.
*********************************************************************************************************
*/
void OS_FAR AppStartTask(void *pdata)
{
pdata = pdata;
AppTickInit(); /* Initialize the ticker */
/*---- Task initialization code goes HERE! --------------------------------------------------------*/
while (TRUE) { /* Task body, always written as an infinite loop. */
/*---- Task code goes HERE! -------------------------------------------------------------------*/
OSTimeDly(1); /* Delay task execution for one clock tick */
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is used to initialize one of the five output compares to generate an
* interrupt at the desired tick rate. You must decide which output compare you will be
* using by setting the configuration variable OS_TICK_OC (see OS_CFG.H) to 1, 2, 3, 4 or 5
* depending on which output compare to use.
* OS_TICK_OC set to 1 chooses output compare #1 as the ticker source
* OS_TICK_OC set to 2 chooses output compare #2 as the ticker source
* OS_TICK_OC set to 3 chooses output compare #3 as the ticker source
* OS_TICK_OC set to 4 chooses output compare #4 as the ticker source
* OS_TICK_OC set to 5 chooses output compare #5 as the ticker source
* Arguments : none
* Notes : 1) It is assumed that you have set the prescaler rate of the free running timer within
* the first 64 E clock cycles of the 68HC11.
* 2) TCNT, TOC1, TOC2, TOC3, TOC4, TOC5 and TMSK1 are define in IO.H (see Intermetrics
* compiler).
*********************************************************************************************************
*/
void AppTickInit(void)
{
#if OS_TICK_OC == 1
TOC1 = TCNT + OS_TICK_OC_CNTS; /* Set TOC1 to present time + OS_TICK_OC_CNTS */
TMSK1 = 0x80; /* Enable OC1 interrupt. */
#endif
#if OS_TICK_OC == 2
TOC2 = TCNT + OS_TICK_OC_CNTS; /* Set TOC2 to present time + OS_TICK_OC_CNTS */
TMSK1 = 0x40; /* Enable OC2 interrupt. */
#endif
#if OS_TICK_OC == 3
TOC3 = TCNT + OS_TICK_OC_CNTS; /* Set TOC3 to present time + OS_TICK_OC_CNTS */
TMSK1 = 0x20; /* Enable OC3 interrupt. */
#endif
#if OS_TICK_OC == 4
TOC4 = TCNT + OS_TICK_OC_CNTS; /* Set TOC4 to present time + OS_TICK_OC_CNTS */
TMSK1 = 0x10; /* Enable OC4 interrupt. */
#endif
#if OS_TICK_OC == 5
TOC5 = TCNT + OS_TICK_OC_CNTS; /* Set TOC5 to present time + OS_TICK_OC_CNTS */
TMSK1 = 0x08; /* Enable OC5 interrupt. */
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -