任务调用示例
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);}
通过分析电路可知
- 引脚为P05和P34
- 当引脚为高电平时,行成电时差,LED会被点亮
编程思路
- Driver中创建LED.c文件
- Driver中创建LED.h文件
- User中main.c文件为程序入口,编写子任务函数后在task_main中进行调用