# 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.
![screenshot](https://dl.dropboxusercontent.com/u/993383/Cosa/screenshots/Screenshot%20from%202016-01-29%2015%3A24%3A17.png)
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个
需积分: 26 20 下载量 121 浏览量
2021-05-11
16:13:23
上传
评论 2
收藏 6.72MB ZIP 举报
温馨提示
DIY-DRONE [在工作中] DIY无人机-从头开始构建 关于 这是一个学生项目。 我们的意图是使任何人都有机会(几乎)从头开始建造自己的无人机。 我们这样做是因为它很有趣。 项目 该项目分为多个部分/子文件夹: PCB :电路板的Altium项目文件 CODE :用于µ控制器的软件 BODY:3D打印的文件(身体等) APP :用于控制无人机的移动应用 其他:构建指南,手册,工具和零件清单 贡献 您有个好主意或发现了问题? 分叉我们的存储库或转到问题选项卡。 我们始终愿意改进。
资源详情
资源评论
资源推荐
收起资源包目录
diy-drone-master.zip (50个子文件)
diy-drone-master
CODE
Libraries
ArduinoSchedulerATmega328P
Scheduler
Semaphore.h 1KB
Channel.h 3KB
Queue.h 3KB
README.md 4KB
library.properties 436B
Scheduler.h 5KB
Scheduler.cpp 4KB
README.md 1KB
DIY_DRONE
Motor.cpp 600B
sketch.json 372B
MotorHandler.h 1KB
Ultrasonic.h 963B
Motor.h 998B
Gyrosensor.cpp 59B
Ultrasonic.cpp 334B
MotorHandler.cpp 628B
DIY_DRONE.ino 942B
Gyrosensor.h 389B
OTHER
banner.afdesign 2.43MB
part_list.md 2KB
README.md 43B
banner.png 219KB
LICENSE 34KB
README.md 770B
.gitignore 10KB
PCB
Datasheets
HC-SR04
hc-sr04_ultrasonic_module_user_guidejohn .pdf 1.47MB
Arduino Tutorial
code
HC-SR04.zip 3KB
SR04_Example
SR04_Example.ino 358B
Ultrasonic Sensor Module Arduino Tutorial .pdf 803KB
H-Bridge-motordrive
H-Bridge-motordriver.PDF 600KB
Arduino-Nano-Rev3.2
Arduino_Nano-Rev3.2-SCH.pdf 79KB
schematics.png 145KB
Project
diy-drone.PrjPCB 37KB
diy-drone.PrjPCBStructure 50B
PCB.PcbDoc 682KB
schematic.SchDoc 202KB
Libraries
L293D
L293D.LibPkg 40KB
L293D.lia 13KB
L293D.SchLib 9KB
L293D.PcbLib 101KB
L293D.IntLib 22KB
ArduinoNano
ARDUINO_NANO.PcbLib 131KB
ARDUINO_NANO.SchLib 14KB
ARDUINO_NANO.LibPkg 40KB
ARDUINO_NANO.IntLib 6KB
Miscellaneous Connectors
Miscellaneous Connectors.IntLib 137KB
README.md 1KB
brainstorm.png 521KB
APP
README.md 87B
BODY
README.md 48B
共 50 条
- 1
男爵兔
- 粉丝: 42
- 资源: 4591
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0