在任务中创建任务:
#define STARTUP_TASK_PRIO 8
#define STARTUP_TASK_STK_SIZE 80void SysTick_init ( void ) {SysTick_Config ( SystemCoreClock / OS_TICKS_PER_SEC );
}static OS_STK task_testled[STARTUP_TASK_STK_SIZE];
static OS_STK task_testluart[STARTUP_TASK_STK_SIZE];void TestUart ( void *p_arg ) {while ( 1 ) {printf ( "hello\r\n" );OSTimeDlyHMSM ( 0, 0, 2, 0 );}
}void TestLed ( void *p_arg ) {OSTaskCreate ( TestUart, ( void * ) 0, &task_testluart[STARTUP_TASK_STK_SIZE - 1], STARTUP_TASK_PRIO );while ( 1 ) {LED0 = !LED0;OSTimeDlyHMSM ( 0, 0, 0, 500 );}
}int main ( void ) {SysTick_init();LED_Init();uart_init ( 9600 );OSInit();OSTaskCreate ( TestLed, ( void * ) 0, &task_testled[STARTUP_TASK_STK_SIZE - 1], STARTUP_TASK_PRIO - 1 );OSStart();return 0;
}