📄 test.c
字号:
static void AppTask6 (void *pdata)
{
INT8U err;
char *pmsg;
char s[30];
pdata = pdata;
while (TRUE) {
AppTask6Ctr++;
#if OS_Q_EN > 0
pmsg = (char *)OSQPend(EventQ1, 0, &err);
strcpy(s, pmsg);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #7
*********************************************************************************************************
*/
static void AppTask7 (void *pdata)
{
INT8U err;
char *pmsg;
char s[30];
pdata = pdata;
while (TRUE) {
AppTask7Ctr++;
#if OS_Q_EN > 0
pmsg = (char *)OSQPend(EventQ2, 0, &err);
strcpy(s, pmsg);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #8
*********************************************************************************************************
*/
static void AppTask8 (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTask8Ctr++;
#if OS_FLAG_EN > 0
OSFlagPost(FlagGrp1, 0x000F, OS_FLAG_SET, &err);
OSTimeDly(100);
OSFlagPost(FlagGrp1, 0x00F0, OS_FLAG_SET, &err);
OSTimeDly(100);
OSFlagPost(FlagGrp1, 0x0F00, OS_FLAG_SET, &err);
OSTimeDly(100);
OSFlagPost(FlagGrp1, 0xF000, OS_FLAG_SET, &err);
OSTimeDly(100);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #9
*********************************************************************************************************
*/
static void AppTask9 (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTask9Ctr++;
#if OS_FLAG_EN > 0
OSFlagPend(FlagGrp1, 0x00FF, OS_FLAG_WAIT_SET_ALL + OS_FLAG_CONSUME, 100, &err);
#endif
OSTimeDly(100);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #A
*********************************************************************************************************
*/
static void AppTaskA (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTaskACtr++;
#if OS_FLAG_EN > 0
OSFlagPend(FlagGrp1, 0xFF00, OS_FLAG_WAIT_SET_ALL + OS_FLAG_CONSUME, 100, &err);
#endif
OSTimeDly(100);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #B
*********************************************************************************************************
*/
static void AppTaskB (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTaskBCtr++;
#if OS_FLAG_EN > 0
OSFlagPend(FlagGrp1, 0x0FF0, OS_FLAG_WAIT_SET_ALL + OS_FLAG_CONSUME, 100, &err);
#endif
OSTimeDly(100);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #A
*********************************************************************************************************
*/
static void AppTaskC (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTaskCCtr++;
#if OS_MUTEX_EN > 0
OSMutexPend(EventMutex1, 0, &err);
OSTimeDly(100);
OSMutexPost(EventMutex1);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #D
*********************************************************************************************************
*/
static void AppTaskD (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTaskDCtr++;
#if OS_MUTEX_EN > 0
OSMutexPend(EventMutex1, 0, &err);
OSTimeDly(100);
OSMutexPost(EventMutex1);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #E
*********************************************************************************************************
*/
static void AppTaskE (void *pdata)
{
INT8U err;
pdata = pdata;
while (TRUE) {
AppTaskECtr++;
#if OS_MBOX_EN > 0
OSMboxPost(EventMbox1, (void *)"Msg #1");
OSTimeDly(100);
OSMboxPost(EventMbox1, (void *)"Msg #2");
OSTimeDly(100);
OSMboxPost(EventMbox1, (void *)"Msg #3");
OSTimeDly(100);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TASK #F
*********************************************************************************************************
*/
static void AppTaskF (void *pdata)
{
INT8U err;
char *pmsg;
char s[30];
pdata = pdata;
while (TRUE) {
AppTaskFCtr++;
#if OS_MBOX_EN > 0
pmsg = (char *)OSMboxPend(EventMbox1, 0, &err);
strcpy(s, pmsg);
#endif
OSTimeDly(1);
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is used to initialize one of the eight 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 and also OS_CPU_A.S)
* to 0..7 depending on which output compare to use.
* OS_TICK_OC set to 0 chooses output compare #0 as the ticker source
* 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
* OS_TICK_OC set to 6 chooses output compare #6 as the ticker source
* OS_TICK_OC set to 7 chooses output compare #7 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 68HC12.
* 2) CPU registers are define in 6812dp256.h (see Metrowerks codewarrior compiler)
*********************************************************************************************************
*/
static void AppTickInit (void)
{
TSCR1 = 0x80; /* Enable timer*/
#if OS_TICK_OC == 0
TIOS |= 0x01; /* Make channel an output compare */
TC0 = TCNT + OS_TICK_OC_CNTS; /* Set TC0 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x01; /* set timer control reg */
TIE |= 0x01; /* Enable OC0 interrupt. */
#endif
#if OS_TICK_OC == 1
TIOS |= 0x02; /* Make channel an output compare */
TC1 = TCNT + OS_TICK_OC_CNTS; /* Set TC1 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x02; /* set timer control reg */
TIE |= 0x02; /* Enable OC1 interrupt. */
#endif
#if OS_TICK_OC == 2
TIOS |= 0x04; /* Make channel an output compare */
TC2 = TCNT + OS_TICK_OC_CNTS; /* Set TC2 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x04; /* set timer control reg */
TIE |= 0x04; /* Enable OC2 interrupt. */
#endif
#if OS_TICK_OC == 3
TIOS |= 0x08; /* Make channel an output compare */
TC3 = TCNT + OS_TICK_OC_CNTS; /* Set TC3 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x08; /* set timer control reg */
TIE |= 0x08; /* Enable OC3 interrupt. */
#endif
#if OS_TICK_OC == 4
TIOS |= 0x10; /* Make channel an output compare */
TC4 = TCNT + OS_TICK_OC_CNTS; /* Set TC4 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x10; /* set timer control reg */
TIE |= 0x10; /* Enable OC4 interrupt. */
#endif
#if OS_TICK_OC == 5
TIOS |= 0x20; /* Make channel an output compare */
TC5 = TCNT + OS_TICK_OC_CNTS; /* Set TC5 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x20; /* set timer control reg */
TIE |= 0x20; /* Enable OC5 interrupt. */
#endif
#if OS_TICK_OC == 6
TIOS |= 0x40; /* Make channel an output compare */
TC6 = TCNT + OS_TICK_OC_CNTS; /* Set TC6 to present time + OS_TICK_OC_CNTS */
TCTL1 |= 0x40; /* set timer control reg */
TIE |= 0x40; /* Enable OC6 interrupt. */
#endif
#if OS_TICK_OC == 7
TIOS |= 0x80; /* Make channel an output compare */
TC7 = TCNT + OS_TICK_OC_CNTS;
TCTL1 |= 0x80; /* set timer control reg */
TIE |= 0x80; /* Enable OC7 interrupt. */
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -