在Arduino中使用ProtoThread创建多线程系统.docVIP

  • 170
  • 0
  • 约6.46千字
  • 约 7页
  • 2017-05-26 发布于河南
  • 举报

在Arduino中使用ProtoThread创建多线程系统.doc

在Arduino中使用ProtoThread创建多线程系统

原文地址: /thread-610-1-1.html 一个非常强大的多任务库,非常适合arduino这种资源非常有限的单片机优点 1、超轻量级,他的库基本上都是些宏定义,大小可以忽略不计,而且每个线程只占用2个字节 2、无机器码,纯c实现,所以可移植性很好 3、无堆栈 4、简单使用可以只把他当个调度程序,复杂点也能把他当操作系统来使 PT作者的首页http://www.sics.se/~adam/pt/ 先上一段简单的代码look look #include pt.h static int counter1,counter2,state1=0,state2=0; static int protothread1(struct pt *pt) {?? ??PT_BEGIN(pt);?? ??while(1) ??{?? ? ? PT_WAIT_UNTIL(pt, counter1==1); ? ? digitalWrite(12,state1); ? ? state1=!state1; ? ? counter1=0;? ? ??} ??PT_END(pt); } static int protothread2(struct pt *pt) { ??PT_BEGIN(pt); ??while(1) {? ? ? ? PT_WAIT_UNTIL(pt, count

文档评论(0)

1亿VIP精品文档

相关文档