|
发表于 2015-12-23 10:11:17
|
显示全部楼层
本帖最后由 zsmbj 于 2015-12-23 10:15 编辑
看看freertos的协程写法:
main里建立一个协程任务,优先级为0
#include "task.h"
#include "croutine.h"
#define PRIORITY_0 0
void main( void )
{
// In this case the index is not used and is passed
// in as 0.
xCoRoutineCreate( vFlashCoRoutine, PRIORITY_0, 0 );
// NOTE: Tasks can also be created here!
// Start the RTOS scheduler.
vTaskStartScheduler();
}
任务的写法:
void vFlashCoRoutine( CoRoutineHandle_t xHandle,
UBaseType_t uxIndex )
{
// Co-routines must start with a call to crSTART().
crSTART( xHandle );
for( ;; )
{
// Delay for a fixed period.
crDELAY( xHandle, 10 );
// Flash an LED.
vParTestToggleLED( 0 );
}
// Co-routines must end with a call to crEND().
crEND();
} |
|