# Arduino-Scheduler-ATmega328P
The original library with examples, etc. can be found at [github.com/mikaelpatel/Arduino-Scheduler](https://github.com/mikaelpatel/Arduino-Scheduler).
Arduino-Scheduler-ATmega328P has small code additiona in order to make the library work with an _ATmega328P_:
Scheduler.h:127:
``` c++
#elif defined(__AVR_ATmega328P__)
/** Default stack size. Stack max dynamically checked against heap end. */
static const size_t DEFAULT_STACK_SIZE = 128;
static const size_t DEFAULT_MAIN_STACK_SIZE = 256;
```
Scheduler.cpp:38:
``` c++
#elif defined(__AVR_ATmega328P__)
extern int __heap_start, *__brkval;
extern char* __malloc_heap_end;
extern size_t __malloc_margin;
```
Scheduler.cpp:105:
``` c++
#elif defined(__AVR_ATmega328P__)
// Check that the task can be allocated
int HEAPEND = (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
int STACKSTART = ((int) stack) - stackSize;
HEAPEND += __malloc_margin;
if (STACKSTART < HEAPEND) return (false);
// Adjust heap limit
__malloc_heap_end = (char*) STACKSTART;
```
# Arduino-Scheduler
This library implements an extended sub-set of the Arduino Scheduler
class. Multiple loop() functions, tasks, may be started and run in a
collaborative multi-tasking style. The tasks are run until they call
yield() or delay(). The Arduino yield() function is replaced by an
implementation in the library that allows context switching.
Tasks should be viewed as static and continuous. This implementation
does not allocate tasks on the heap. They are allocated on the normal
stack and linked into a cyclic run queue. One-shot tasks are not
supported. Instead the task start function is extended with a setup
function reference. Tasks are started with:
````
Scheduler.start(taskSetup, taskLoop [,taskStackSize]).
````
The tasks will start execution when the main task yields. The
_taskSetup_ is called first and once by the task followed by repeated
calls to _taskLoop_. This works just as the Arduino setup() and loop()
functions. There is also an optional parameter, _taskStackSize_. The
default value depends on the architecture (128 bytes for AVR and 1024
bytes for SAM/SAMD/Teensy 3.X).
````
Scheduler.startLoop(taskLoop [,taskStackSize]).
````
A short hand version of start() is available when the taskSetup is NULL.
The Scheduler is a single-ton and the library creates the single
instance.

This library also includes support for task synchronization and
communication; Semaphores, Queues and Channels. There is also
built-in support for checking the amount of stack head room,
i.e. untouched stack space.
````
int bytes = Scheduler.stack();
````
The Scheduler member function stack() will scan the running task stack
and determine the minimum amount of remaining stack during the
execution so far. The example sketch SchedulerBlinkMax shows how this
can be used.
## Install
Download and unzip the Arduino-Scheduler library into your sketchbook
libraries directory. Rename from Arduino-Scheduler-master to Arduino-Scheduler.
The Scheduler library and examples should be found in the Arduino IDE
File>Examples menu.
## Performance
There are several benchmark sketches in the examples directory. Below
are some of the results.
### Context Switch
Board | us | cycles
------|----|-------
Arduino Mega 2560 (16 MHz) | 12.64 | 203
Arduino Uno, Nano, Pro-Mini, etc (16 MHz) | 11.00 | 176
Sparkfun SAMD21 (48 MHz) | 2.60 | 125
Arduino Due (84 MHz) | 1.36 | 115
Teensy 3.1 (72 MHz) | 1.10 | 80
Teensy 3.6 (180 MHz) | 0.43 | 78
没有合适的资源?快使用搜索试试~ 我知道了~
diy-drone:DIY无人机-从头开始构建

共50个文件
md:8个
h:8个
cpp:5个

需积分: 50 22 下载量 116 浏览量
2021-05-11
16:13:23
上传
评论 2
收藏 6.72MB ZIP 举报
温馨提示
DIY-DRONE [在工作中] DIY无人机-从头开始构建 关于 这是一个学生项目。 我们的意图是使任何人都有机会(几乎)从头开始建造自己的无人机。 我们这样做是因为它很有趣。 项目 该项目分为多个部分/子文件夹: PCB :电路板的Altium项目文件 CODE :用于µ控制器的软件 BODY:3D打印的文件(身体等) APP :用于控制无人机的移动应用 其他:构建指南,手册,工具和零件清单 贡献 您有个好主意或发现了问题? 分叉我们的存储库或转到问题选项卡。 我们始终愿意改进。
资源详情
资源评论
资源推荐
收起资源包目录









































































共 50 条
- 1






























男爵兔
- 粉丝: 53
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 大数据视角下的语文课堂提问方法探究.docx
- 云计算市场与技术发展趋势.doc
- 通信工程施工管理概述.doc
- 关于强电线路对通信线路的影响及其防护.doc
- 集团大数据平台安全方案规划.docx
- Matlab基于腐蚀和膨胀的边缘检测.doc
- 网络监控系统解决方案酒店.doc
- 电动机智能软起动控制系统的研究与方案设计书(PLC).doc
- jAVA2程序设计基础第十三章.ppt
- 基于PLC的机械手控制设计.doc
- 医院his计算机信息管理系统故障应急预案.doc
- 企业运用移动互联网进行青年职工思想政治教育路径.docx
- 数据挖掘的六大主要功能.doc
- 大数据行政尚在跑道入口.docx
- 用Proteus和Keil建立单片机仿真工程的步骤.doc
- Internet技术与应用网络——资源管理与开发.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

评论0