?RTX 51 TNY 可做多任务调度,API较为简单。
/* 接口API */
// 创建任务
extern unsigned char os_create_task (unsigned char task_id);
// 结束任务
extern unsigned char os_delete_task (unsigned char task_id);
// 等待
extern unsigned char os_wait (unsigned char typ,
unsigned char ticks,
unsigned int dummy);
extern unsigned char os_wait1 (unsigned char typ);
extern unsigned char os_wait2 (unsigned char typ,
unsigned char ticks);
// 发送信号
extern unsigned char os_send_signal (unsigned char task_id);
extern unsigned char os_clear_signal (unsigned char task_id);
/* 用法 */
void task_led() _task_ 任务代码{
}
void task_main() _task_ 任务代号{
//开启子任务
os_create_task(task_led);
// 结束入口任务
os_delete_task(task_main);
}