int main(void)
{
OS_ERR err;
CPU_SR_ALLOC();
nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);
BSP_Init();
Hardware_Init();
OSInit(&err);
OS_CRITICAL_ENTER();
OSTaskCreate((OS_TCB * )&StartTaskTCB,
(CPU_CHAR * )"start task",
(OS_TASK_PTR )start_task,
(void * )0,
(OS_PRIO )START_TASK_PRIO,
(CPU_STK * )&START_TASK_STK[0],
(CPU_STK_SIZE)START_STK_SIZE/10,
(CPU_STK_SIZE)START_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OS_CRITICAL_EXIT();
OSStart(&err);
while(1);
}
void start_task(void *p_arg)
{
OS_ERR err;
CPU_SR_ALLOC();
p_arg = p_arg;
CPU_Init();
Mem_Init();
#if OS_CFG_STAT_TASK_EN > 0u
OSStatTaskCPUUsageInit(&err);
#endif
#ifdef CPU_CFG_INT_DIS_MEAS_EN
CPU_IntDisMeasMaxCurReset();
#endif
#if OS_CFG_SCHED_ROUND_ROBIN_EN
OSSchedRoundRobinCfg(DEF_ENABLED,1,&err);
#endif
OS_CRITICAL_ENTER();
OSTaskCreate((OS_TCB * )&Led1TaskTCB,
(CPU_CHAR * )"led1 task",
(OS_TASK_PTR )led1_task,
(void * )0,
(OS_PRIO )LED1_TASK_PRIO,
(CPU_STK * )&LED1_TASK_STK[0],
(CPU_STK_SIZE)LED1_STK_SIZE/10,
(CPU_STK_SIZE)LED1_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OSTaskCreate((OS_TCB * )&Led2TaskTCB,
(CPU_CHAR * )"led2 task",
(OS_TASK_PTR )led2_task,
(void * )0,
(OS_PRIO )LED2_TASK_PRIO,
(CPU_STK * )&LED2_TASK_STK[0],
(CPU_STK_SIZE)LED2_STK_SIZE/10,
(CPU_STK_SIZE)LED2_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OSTaskCreate((OS_TCB * )&Led3TaskTCB,
(CPU_CHAR * )"led3 task",
(OS_TASK_PTR )led3_task,
(void * )0,
(OS_PRIO )LED3_TASK_PRIO,
(CPU_STK * )&LED3_TASK_STK[0],
(CPU_STK_SIZE)LED3_STK_SIZE/10,
(CPU_STK_SIZE)LED3_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OSTaskCreate((OS_TCB * )&Led4TaskTCB,
(CPU_CHAR * )"led4 task",
(OS_TASK_PTR )led4_task,
(void * )0,
(OS_PRIO )LED4_TASK_PRIO,
(CPU_STK * )&LED4_TASK_STK[0],
(CPU_STK_SIZE)LED4_STK_SIZE/10,
(CPU_STK_SIZE)LED4_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OSTaskCreate((OS_TCB * )&Led5TaskTCB,
(CPU_CHAR * )"led5 task",
(OS_TASK_PTR )led5_task,
(void * )0,
(OS_PRIO )LED5_TASK_PRIO,
(CPU_STK * )&LED5_TASK_STK[0],
(CPU_STK_SIZE)LED5_STK_SIZE/10,
(CPU_STK_SIZE)LED5_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OSTaskCreate((OS_TCB * )&Led6TaskTCB,
(CPU_CHAR * )"led6 task",
(OS_TASK_PTR )led6_task,
(void * )0,
(OS_PRIO )LED6_TASK_PRIO,
(CPU_STK * )&LED6_TASK_STK[0],
(CPU_STK_SIZE)LED6_STK_SIZE/10,
(CPU_STK_SIZE)LED6_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void * )0,
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR,
(OS_ERR * )&err);
OS_TaskSuspend((OS_TCB*)&StartTaskTCB,&err);
OS_CRITICAL_EXIT();
}
void led1_task(void *p_arg)
{
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
LED1_TOGGLE();
OSTimeDlyHMSM(0,0,0,900,OS_OPT_TIME_PERIODIC,&err);
LED1_TOGGLE();
OSTimeDlyHMSM(0,0,0,100,OS_OPT_TIME_PERIODIC,&err);
}
}
void led2_task(void *p_arg)
{
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
LED2_TOGGLE();
OSTimeDlyHMSM(0,0,0,400,OS_OPT_TIME_PERIODIC,&err);
LED2_TOGGLE();
OSTimeDlyHMSM(0,0,0,100,OS_OPT_TIME_PERIODIC,&err);
}
}
uint8_t temp_String[1024];
void led3_task(void *p_arg)
{
uint16_t i;
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
if(USART0String_flag)
{
for(i=0;i<1024;i++){
if((USART0_String[i]<0x20)||(USART0_String[i]>0x7e)) break;
}
CopyString(temp_String,USART0_String,i);
SendArray(USART1,temp_String,i);
ClearnString(USART0_String,1024);
ClearnString(temp_String,1024);
}
OSTimeDlyHMSM(0,0,0,20,OS_OPT_TIME_PERIODIC,&err);
}
}
void led4_task(void *p_arg)
{
uint16_t i;
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
if(USART1String_flag)
{
for(i=0;i<1024;i++){
if((USART1_String[i]<0x20)||(USART1_String[i]>0x7e)) break;
}
CopyString(temp_String,USART1_String,i);
SendArray(USART0,temp_String,i);
ClearnString(USART1_String,1024);
ClearnString(temp_String,1024);
}
OSTimeDlyHMSM(0,0,0,20,OS_OPT_TIME_PERIODIC,&err);
}
}
void led5_task(void *p_arg)
{
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
OSTimeDlyHMSM(0,0,10,0,OS_OPT_TIME_PERIODIC,&err);
}
}
void led6_task(void *p_arg)
{
OS_ERR err;
p_arg = p_arg;
while(1)
{
//put your C code
USART_RXD_Delay_cnt();
OSTimeDlyHMSM(0,0,0,5,OS_OPT_TIME_PERIODIC,&err);
}
}
123456789012345678901234567890123456789012345678901234567890