📄 task.c
字号:
//---------------------------------------------------------------
//
// Copyright (c) 2006-2007 E-compass electronic Co.,Ltd.
// All Right Reserved.
//
// $Author walnutcy
// $Email walnutcy@gmail.com
// $Version v1.0
// $FileName
// $Since
// $Log
//
// DESCRIPTION
//
// History:
// <author> <time> <version > <desc>
//---------------------------------------------------------------
//#include "task.h"
#include "includes.h"
volatile U16 sysTimeTick; // system time tick : 1ms
U8 gLedDelayTime;
void MCUInit() REENTRANT
{
PCON &= 0xEF;
IT1 = 1;
if (0==IT1)
{ ISRAdrFun();
}
SRL_Init();
IR_Init();
// WDT_CONTR = 0x3C;
IP = 0x00;//51;//0:PCA:ADC:S:T1:X1:T0:X0
IPH = 0x00;//10;
IE = _INTERRUPT_ALL;
/////////////////
TMOD |= 0x01;// timer 0, 16-bit mode 1,
TCON |= 0x05; // TR0 = 0; IT1 = 1;
TR0 = 1;
gLedDelayTime = 250;
}
void Task_IR(void) REENTRANT
{
U8 buf[4];
UartReq();
OsShedLOCK();
UartPrint("task_IR: 01");
OsShedUnLOCK();
UartFree();
while (1)
{
if (IR_GetRevState())
{
if (IR_GetRevData(buf))
{
UartReq();
OsShedLOCK();
SRL_SendPack(IR_EVENT,buf,3);
OsShedUnLOCK();
UartFree();
}
}
// WDT_CONTR = 0x3C;
OsWaitMsg();
}
}
extern IU8 gTaskIoCtrl[35];
void Task_Uart(void) REENTRANT
{
U8 buf[10];
U8 tmp ;
UartReq();
OsShedLOCK();
UartPrint("task_uart: 02");
OsShedUnLOCK();
UartFree();
while (1)
{
tmp = 0;
if (SRL_GetRevStatus())
{
SRL_GetRevPack(&tmp,buf);
if (0x00==tmp)
{ return;
}
switch (tmp)
{
case VERSION_EVENT: //0x50
*buf = SOFT_VERSION;
UartReq();
OsShedLOCK();
SRL_SendPack(VERSION_EVENT,buf,1);
OsShedUnLOCK();
UartFree();
break;
case 0x80:
if(C_TRUE==OsTaskKill(*buf))
{
gLedDelayTime = *(buf+1);
OsTaskCreate(TASK_IO_CTRL,Task_LED2,(U8)gTaskIoCtrl);
}
else
{
UartReq();
OsShedLOCK();
UartPrint("0123456");
OsShedUnLOCK();
UartFree();
}
break;
case 0x81:
if(C_TRUE==OsTaskKill(*buf))
{
OsTaskCreate(TASK_IO_CTRL,Task_LED1,(U8)gTaskIoCtrl);
}
else
{
UartReq();
OsShedLOCK();
UartPrint("0123456");
OsShedUnLOCK();
UartFree();
}
break;
case 0x82:
if(C_TRUE==OsTaskKill(*buf))
{
OsTaskCreate(TASK_IO_CTRL,Task_LED3,(U8)gTaskIoCtrl);
}
else
{
UartReq();
OsShedLOCK();
UartPrint("0123456");
OsShedUnLOCK();
UartFree();
}
break;
default:
UartReq();
OsShedLOCK();
UartPrint(buf);
OsShedUnLOCK();
UartFree();
break;
}
}
OsWaitMsg();
}
}
void Task_LED1(void) REENTRANT
{
UartReq();
OsShedUnLOCK();
UartPrint("task_LED1: 03");
OsShedUnLOCK();
UartFree();
while (1)
{
pinLed = ~pinLed;
OsDelay(LED_DELAY);
}
}
void Task_LED2(void) REENTRANT
{
UartReq();
OsShedUnLOCK();
UartPrint("task_LED2: 03");
OsShedUnLOCK();
UartFree();
while (1)
{
pinLed = ~pinLed;
OsDelay(gLedDelayTime);
}
}
BOOL ledFlg;
void Led3TimerProc (void) REENTRANT
{
KillTimer(Led3TimerProc);
pinLed = ~pinLed;
ledFlg = 1;
}
void Task_LED3(void) REENTRANT
{
UartReq();
OsShedUnLOCK();
UartPrint("task_LED3: 03");
OsShedUnLOCK();
UartFree();
pinLed = 1;
ledFlg = 1;
while (1)
{
if (ledFlg)
{
ledFlg = 0;
SetTimer(Led3TimerProc,100); //1s
}
OsDelay(LED_DELAY);
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -