创建单次任务:
#define STARTUP_TASK_PRIO 8
#define STARTUP_TASK_STK_SIZE 80
void 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 ) {
printf ( "hello\r\n" );
OSTaskDel ( OS_PRIO_SELF );
}
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;
}