├── extras ├── docs │ ├── images │ │ ├── direct.png │ │ ├── normal.png │ │ ├── direct_pin.png │ │ ├── direct_port.png │ │ ├── due_direct.png │ │ ├── due_normal.png │ │ ├── normal_port.png │ │ ├── samd_direct.png │ │ ├── samd_normal.png │ │ ├── direct_port2.png │ │ ├── due_direct_port.png │ │ ├── due_normal_port.png │ │ └── due_direct_full_port.png │ ├── boards_todo │ ├── avr_benchmarks.md │ └── arm_benchmarks.md └── tools │ └── gen_pins.py ├── examples ├── direct_toggle │ └── direct_toggle.ino ├── direct_io │ └── direct_io.ino ├── direct_io_pin │ └── direct_io_pin.ino ├── normal_io │ └── normal_io.ino ├── direct_io_port │ └── direct_io_port.ino ├── normal_toggle │ └── normal_toggle.ino ├── normal_io_port │ └── normal_io_port.ino └── shift_out │ ├── shift_out.ino │ └── DirectIO_Shift.h ├── include ├── boards │ ├── avr │ │ ├── RGB_Glasses.h │ │ ├── Olimexino_85.h │ │ ├── gemma.h │ │ ├── tiny8.h │ │ ├── ethernet.h │ │ ├── standard.h │ │ ├── Olimexino_328.h │ │ ├── digitalsandbox.h │ │ ├── eightanaloginputs.h │ │ ├── atmega328p-xmini.h │ │ ├── atmega168pb-xmini.h │ │ ├── atmega328pb-xmini.h │ │ ├── ser7seg.h │ │ ├── lilypadusbplus.h │ │ ├── adafruit32u4.h │ │ ├── robot_motor.h │ │ ├── robot_control.h │ │ ├── yun.h │ │ ├── flora.h │ │ ├── micro.h │ │ ├── leonardo.h │ │ ├── promicro.h │ │ ├── feather32u4.h │ │ ├── itsybitsy32u4.h │ │ ├── Olimexino_Nano.h │ │ ├── bluefruitmicro.h │ │ ├── circuitplay32u4.h │ │ ├── minibench.h │ │ ├── Olimexino_32U4.h │ │ ├── rf128.h │ │ ├── mega.h │ │ ├── mega2560pro.h │ │ └── emoro_variants.h │ ├── samd │ │ ├── SparkFun_LilyMini.h │ │ ├── gemma_m0.h │ │ ├── trinket_m0.h │ │ ├── pirkey.h │ │ ├── feather_m4.h │ │ ├── industruino_d21g.h │ │ ├── adi.h │ │ ├── mkr1000.h │ │ ├── mkrzero.h │ │ ├── mkrfox1200.h │ │ ├── mkrgsm1400.h │ │ ├── mkrwifi1010.h │ │ ├── itsybitsy_m4.h │ │ ├── circuitplay.h │ │ ├── mkrwan1300.h │ │ ├── zero_radio.h │ │ ├── metro_m0.h │ │ ├── feather_m0_express.h │ │ ├── hallowing_m0_express.h │ │ ├── itsybitsy_m0.h │ │ ├── SparkFun_ProRF.h │ │ ├── arduino_mzero.h │ │ ├── arduino_zero.h │ │ ├── SparkFun_9DoF_M0.h │ │ ├── SparkFun_SAMD21_Dev.h │ │ ├── SparkFun_SAMD_Mini.h │ │ ├── feather_m0.h │ │ ├── metro_m4.h │ │ ├── Fox.h │ │ ├── Fox3.h │ │ ├── Lion.h │ │ └── Dragonfly.h │ └── sam │ │ └── arduino_due_x.h ├── ports.h ├── base.h ├── analog.h ├── ports_sam.h ├── pin.h ├── ports_samd.h └── ports_avr.h ├── .gitattributes ├── library.properties ├── COPYING.txt ├── DirectIO.h └── README.md /extras/docs/images/direct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/direct.png -------------------------------------------------------------------------------- /extras/docs/images/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/normal.png -------------------------------------------------------------------------------- /extras/docs/images/direct_pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/direct_pin.png -------------------------------------------------------------------------------- /extras/docs/images/direct_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/direct_port.png -------------------------------------------------------------------------------- /extras/docs/images/due_direct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/due_direct.png -------------------------------------------------------------------------------- /extras/docs/images/due_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/due_normal.png -------------------------------------------------------------------------------- /extras/docs/images/normal_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/normal_port.png -------------------------------------------------------------------------------- /extras/docs/images/samd_direct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/samd_direct.png -------------------------------------------------------------------------------- /extras/docs/images/samd_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/samd_normal.png -------------------------------------------------------------------------------- /extras/docs/images/direct_port2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/direct_port2.png -------------------------------------------------------------------------------- /extras/docs/images/due_direct_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/due_direct_port.png -------------------------------------------------------------------------------- /extras/docs/images/due_normal_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/due_normal_port.png -------------------------------------------------------------------------------- /extras/docs/images/due_direct_full_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmarchetti/DirectIO/HEAD/extras/docs/images/due_direct_full_port.png -------------------------------------------------------------------------------- /examples/direct_toggle/direct_toggle.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Output<2> out; 4 | 5 | void setup() {} 6 | 7 | void loop() { 8 | while(1) { 9 | out.toggle(); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /examples/direct_io/direct_io.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Output<2> pin; 4 | 5 | void setup() {} 6 | 7 | void loop() { 8 | while(1) { 9 | pin = HIGH; 10 | pin = LOW; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /examples/direct_io_pin/direct_io_pin.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | OutputPin pin(2); 4 | 5 | void setup() {} 6 | 7 | void loop() { 8 | while(1) { 9 | pin = HIGH; 10 | pin = LOW; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /examples/normal_io/normal_io.ino: -------------------------------------------------------------------------------- 1 | #define PIN 2 2 | 3 | void setup() { 4 | pinMode(PIN, OUTPUT); 5 | } 6 | 7 | void loop() { 8 | boolean val = HIGH; 9 | while(1) { 10 | digitalWrite(PIN, val); 11 | val = ! val; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /include/boards/avr/RGB_Glasses.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for RGB_Glasses 2 | 3 | _define_pin(0, PORT_B, 0); 4 | _define_pin(1, PORT_B, 1); 5 | _define_pin(2, PORT_B, 2); 6 | _define_pin(3, PORT_B, 3); 7 | _define_pin(4, PORT_B, 4); 8 | _define_pin(5, PORT_B, 5); 9 | -------------------------------------------------------------------------------- /examples/direct_io_port/direct_io_port.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | OutputPort port; 4 | 5 | void setup() { 6 | port.setup(); 7 | } 8 | 9 | void loop() { 10 | u8 i = 0; 11 | 12 | while(1) { 13 | port = i++; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /include/boards/avr/Olimexino_85.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Olimexino_85 2 | 3 | _define_pin(0, PORT_B, 0); 4 | _define_pin(1, PORT_B, 1); 5 | _define_pin(2, PORT_B, 2); 6 | _define_pin(3, PORT_B, 3); 7 | _define_pin(4, PORT_B, 4); 8 | _define_pin(5, PORT_B, 5); 9 | -------------------------------------------------------------------------------- /examples/normal_toggle/normal_toggle.ino: -------------------------------------------------------------------------------- 1 | #define PIN 2 2 | 3 | void setup() { 4 | pinMode(PIN, OUTPUT); 5 | } 6 | 7 | void loop() { 8 | boolean val = HIGH; 9 | while(1) { 10 | digitalWrite(PIN, val); 11 | val = ! val; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /include/boards/avr/gemma.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for gemma 2 | 3 | _define_pin(0, PORT_B, 0); 4 | _define_pin(1, PORT_B, 1); 5 | _define_pin(2, PORT_B, 2); 6 | _define_pin(3, PORT_B, 3); 7 | _define_pin(4, PORT_B, 4); 8 | _define_pin(5, PORT_B, 5); 9 | _define_pin(6, PORT_B, 5); 10 | _define_pin(7, PORT_B, 2); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 3); 13 | -------------------------------------------------------------------------------- /include/boards/avr/tiny8.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for tiny8 2 | 3 | _define_pin(0, PORT_B, 0); 4 | _define_pin(1, PORT_B, 1); 5 | _define_pin(2, PORT_B, 2); 6 | _define_pin(3, PORT_B, 3); 7 | _define_pin(4, PORT_B, 4); 8 | _define_pin(5, PORT_B, 5); 9 | _define_pin(6, PORT_B, 5); 10 | _define_pin(7, PORT_B, 2); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 3); 13 | -------------------------------------------------------------------------------- /examples/normal_io_port/normal_io_port.ino: -------------------------------------------------------------------------------- 1 | #define FIRST_PIN 0 2 | 3 | void setup() 4 | { 5 | for(uint8_t i = 0; i < 8; i++) { 6 | pinMode(FIRST_PIN + i, OUTPUT); 7 | } 8 | } 9 | 10 | void loop() { 11 | uint8_t value = 0; 12 | 13 | while(1) { 14 | for(uint8_t i = 0; i < 8; i++) { 15 | digitalWrite(FIRST_PIN + 7 - i, bitRead(value, i)); 16 | } 17 | value++; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /examples/shift_out/shift_out.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DirectIO_Shift.h" 3 | 4 | // define a shift register with data on pin 2 and clock on pin 3, 5 | // and storage register clock on pin 4. 6 | // output size is 8 bits in this example. 7 | ShiftRegister595<2, 3, 4> out; 8 | 9 | void setup() {} 10 | 11 | void loop() { 12 | // every time through the loop we write a unique value 13 | static u8 i = 0; 14 | 15 | out = i; 16 | i++; 17 | } 18 | -------------------------------------------------------------------------------- /include/boards/samd/SparkFun_LilyMini.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for SparkFun_LilyMini 2 | 3 | _define_pin(0, PORT_A, 14); 4 | _define_pin(1, PORT_A, 14); 5 | _define_pin(2, PORT_A, 15); 6 | _define_pin(3, PORT_A, 7); 7 | _define_pin(4, PORT_A, 6); 8 | _define_pin(5, PORT_A, 30); 9 | _define_pin(6, PORT_A, 27); 10 | _define_pin(7, PORT_A, 31); 11 | _define_pin(8, PORT_A, 2); 12 | _define_pin(9, PORT_A, 24); 13 | _define_pin(10, PORT_A, 25); 14 | _define_pin(11, PORT_A, 5); 15 | _define_pin(13, PORT_A, 30); 16 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=DirectIO 2 | version=1.2.0 3 | author=Michael Marchetti 4 | maintainer=Michael Marchetti 5 | sentence=DirectIO is a fast, simple I/O library for AVR, SAM, and SAMD boards. 6 | paragraph=It provides a simple API for doing digital I/O 40-60x faster than the Arduino standard libraries. You can read or write a digital pin in a sinle clock cycle on an AVR-based board. Accelerated support is available for AVR, SAM, and SAMD boards. Other boards are supported in a fallback mode without acceleration. 7 | category=Signal Input/Output 8 | url=https://github.com/mmarchetti/DirectIO 9 | architectures=avr,sam,samd 10 | includes=DirectIO.h 11 | -------------------------------------------------------------------------------- /include/boards/avr/ethernet.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for ethernet 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | -------------------------------------------------------------------------------- /include/boards/avr/standard.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for standard 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | -------------------------------------------------------------------------------- /include/boards/avr/Olimexino_328.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Olimexino_328 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | -------------------------------------------------------------------------------- /include/boards/avr/digitalsandbox.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for digitalsandbox 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | -------------------------------------------------------------------------------- /include/boards/avr/eightanaloginputs.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for eightanaloginputs 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | -------------------------------------------------------------------------------- /include/boards/avr/atmega328p-xmini.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for atmega328p-xmini 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | _define_pin(20, PORT_B, 7); 24 | -------------------------------------------------------------------------------- /include/boards/samd/gemma_m0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for gemma_m0 2 | 3 | _define_pin(0, PORT_A, 4); 4 | _define_pin(1, PORT_A, 2); 5 | _define_pin(2, PORT_A, 5); 6 | _define_pin(3, PORT_A, 0); 7 | _define_pin(4, PORT_A, 1); 8 | _define_pin(5, PORT_A, 28); 9 | _define_pin(6, PORT_A, 24); 10 | _define_pin(7, PORT_A, 25); 11 | _define_pin(8, PORT_A, 2); 12 | _define_pin(9, PORT_A, 5); 13 | _define_pin(10, PORT_A, 4); 14 | _define_pin(11, PORT_A, 30); 15 | _define_pin(12, PORT_A, 31); 16 | _define_pin(13, PORT_A, 23); 17 | _define_pin(14, PORT_A, 10); 18 | _define_pin(15, PORT_A, 11); 19 | _define_pin(16, PORT_A, 6); 20 | _define_pin(17, PORT_A, 14); 21 | _define_pin(18, PORT_A, 15); 22 | _define_pin(19, PORT_A, 16); 23 | _define_pin(20, PORT_A, 17); 24 | -------------------------------------------------------------------------------- /include/boards/avr/atmega168pb-xmini.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for atmega168pb-xmini 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | _define_pin(20, PORT_B, 7); 24 | -------------------------------------------------------------------------------- /include/boards/avr/atmega328pb-xmini.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for atmega328pb-xmini 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | _define_pin(20, PORT_B, 7); 24 | -------------------------------------------------------------------------------- /include/boards/samd/trinket_m0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for trinket_m0 2 | 3 | _define_pin(0, PORT_A, 8); 4 | _define_pin(1, PORT_A, 2); 5 | _define_pin(2, PORT_A, 9); 6 | _define_pin(3, PORT_A, 7); 7 | _define_pin(4, PORT_A, 6); 8 | _define_pin(5, PORT_A, 8); 9 | _define_pin(6, PORT_A, 9); 10 | _define_pin(7, PORT_A, 0); 11 | _define_pin(8, PORT_A, 1); 12 | _define_pin(9, PORT_A, 28); 13 | _define_pin(10, PORT_A, 24); 14 | _define_pin(11, PORT_A, 25); 15 | _define_pin(12, PORT_A, 10); 16 | _define_pin(13, PORT_A, 10); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_A, 9); 19 | _define_pin(16, PORT_A, 8); 20 | _define_pin(17, PORT_A, 7); 21 | _define_pin(18, PORT_A, 6); 22 | _define_pin(19, PORT_A, 30); 23 | _define_pin(20, PORT_A, 31); 24 | _define_pin(21, PORT_A, 14); 25 | _define_pin(22, PORT_A, 15); 26 | -------------------------------------------------------------------------------- /include/boards/avr/ser7seg.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for ser7seg 2 | 3 | _define_pin(0, PORT_D, 0); 4 | _define_pin(1, PORT_D, 1); 5 | _define_pin(2, PORT_D, 2); 6 | _define_pin(3, PORT_D, 3); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_D, 5); 9 | _define_pin(6, PORT_D, 6); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 0); 12 | _define_pin(9, PORT_B, 1); 13 | _define_pin(10, PORT_B, 2); 14 | _define_pin(11, PORT_B, 3); 15 | _define_pin(12, PORT_B, 4); 16 | _define_pin(13, PORT_B, 5); 17 | _define_pin(14, PORT_C, 0); 18 | _define_pin(15, PORT_C, 1); 19 | _define_pin(16, PORT_C, 2); 20 | _define_pin(17, PORT_C, 3); 21 | _define_pin(18, PORT_C, 4); 22 | _define_pin(19, PORT_C, 5); 23 | _define_pin(20, PORT_C, 6); 24 | _define_pin(21, PORT_C, 7); 25 | _define_pin(22, PORT_B, 6); 26 | _define_pin(23, PORT_B, 7); 27 | -------------------------------------------------------------------------------- /include/boards/avr/lilypadusbplus.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for lilypadusbplus 2 | 3 | _define_pin(0, PORT_D, 5); 4 | _define_pin(1, PORT_B, 0); 5 | _define_pin(2, PORT_D, 4); 6 | _define_pin(3, PORT_F, 7); 7 | _define_pin(4, PORT_B, 4); 8 | _define_pin(5, PORT_F, 4); 9 | _define_pin(6, PORT_B, 7); 10 | _define_pin(7, PORT_D, 7); 11 | _define_pin(8, PORT_B, 5); 12 | _define_pin(9, PORT_F, 6); 13 | _define_pin(10, PORT_D, 0); 14 | _define_pin(11, PORT_D, 1); 15 | _define_pin(12, PORT_B, 6); 16 | _define_pin(13, PORT_C, 6); 17 | _define_pin(14, PORT_C, 7); 18 | _define_pin(15, PORT_E, 6); 19 | _define_pin(16, PORT_F, 0); 20 | _define_pin(17, PORT_F, 1); 21 | _define_pin(18, PORT_F, 5); 22 | _define_pin(19, PORT_D, 3); 23 | _define_pin(20, PORT_D, 2); 24 | _define_pin(21, PORT_B, 1); 25 | _define_pin(22, PORT_B, 2); 26 | _define_pin(23, PORT_B, 3); 27 | _define_pin(24, PORT_D, 6); 28 | _define_pin(25, PORT_E, 2); 29 | -------------------------------------------------------------------------------- /include/boards/avr/adafruit32u4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for adafruit32u4 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | -------------------------------------------------------------------------------- /include/boards/avr/robot_motor.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for robot_motor 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | -------------------------------------------------------------------------------- /include/boards/avr/robot_control.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for robot_control 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | -------------------------------------------------------------------------------- /include/boards/avr/yun.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for yun 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/flora.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for flora 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/micro.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for micro 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/leonardo.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for leonardo 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/promicro.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for promicro 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/feather32u4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for feather32u4 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/samd/pirkey.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for pirkey 2 | 3 | _define_pin(0, PORT_A, 0); 4 | _define_pin(1, PORT_A, 1); 5 | _define_pin(2, PORT_A, 28); 6 | _define_pin(3, PORT_A, 30); 7 | _define_pin(4, PORT_A, 31); 8 | _define_pin(5, PORT_A, 14); 9 | _define_pin(6, PORT_A, 15); 10 | _define_pin(7, PORT_A, 27); 11 | _define_pin(8, PORT_A, 24); 12 | _define_pin(9, PORT_A, 25); 13 | _define_pin(10, PORT_A, 2); 14 | _define_pin(11, PORT_A, 9); 15 | _define_pin(12, PORT_A, 8); 16 | _define_pin(13, PORT_A, 7); 17 | _define_pin(14, PORT_A, 6); 18 | _define_pin(15, PORT_A, 6); 19 | _define_pin(16, PORT_A, 6); 20 | _define_pin(17, PORT_A, 6); 21 | _define_pin(18, PORT_A, 6); 22 | _define_pin(19, PORT_A, 6); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 6); 25 | _define_pin(22, PORT_A, 6); 26 | _define_pin(23, PORT_A, 6); 27 | _define_pin(24, PORT_A, 6); 28 | _define_pin(25, PORT_A, 6); 29 | _define_pin(26, PORT_A, 6); 30 | _define_pin(27, PORT_A, 6); 31 | _define_pin(28, PORT_A, 6); 32 | _define_pin(29, PORT_A, 6); 33 | _define_pin(30, PORT_A, 6); 34 | -------------------------------------------------------------------------------- /include/boards/avr/itsybitsy32u4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for itsybitsy32u4 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/Olimexino_Nano.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Olimexino_Nano 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/bluefruitmicro.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for bluefruitmicro 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/circuitplay32u4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for circuitplay32u4 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | -------------------------------------------------------------------------------- /include/boards/avr/minibench.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for minibench 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | _define_pin(31, PORT_E, 2); 35 | -------------------------------------------------------------------------------- /include/boards/avr/Olimexino_32U4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Olimexino_32U4 2 | 3 | _define_pin(0, PORT_D, 2); 4 | _define_pin(1, PORT_D, 3); 5 | _define_pin(2, PORT_D, 1); 6 | _define_pin(3, PORT_D, 0); 7 | _define_pin(4, PORT_D, 4); 8 | _define_pin(5, PORT_C, 6); 9 | _define_pin(6, PORT_D, 7); 10 | _define_pin(7, PORT_E, 6); 11 | _define_pin(8, PORT_B, 4); 12 | _define_pin(9, PORT_B, 5); 13 | _define_pin(10, PORT_B, 6); 14 | _define_pin(11, PORT_B, 7); 15 | _define_pin(12, PORT_D, 6); 16 | _define_pin(13, PORT_C, 7); 17 | _define_pin(14, PORT_B, 3); 18 | _define_pin(15, PORT_B, 1); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 0); 21 | _define_pin(18, PORT_F, 7); 22 | _define_pin(19, PORT_F, 6); 23 | _define_pin(20, PORT_F, 5); 24 | _define_pin(21, PORT_F, 4); 25 | _define_pin(22, PORT_F, 1); 26 | _define_pin(23, PORT_F, 0); 27 | _define_pin(24, PORT_D, 4); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_B, 4); 30 | _define_pin(27, PORT_B, 5); 31 | _define_pin(28, PORT_B, 6); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 5); 34 | _define_pin(31, PORT_E, 2); 35 | -------------------------------------------------------------------------------- /include/boards/samd/feather_m4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for feather_m4 2 | 3 | _define_pin(0, PORT_B, 17); 4 | _define_pin(1, PORT_B, 16); 5 | _define_pin(4, PORT_A, 14); 6 | _define_pin(5, PORT_A, 16); 7 | _define_pin(6, PORT_A, 18); 8 | _define_pin(8, PORT_B, 3); 9 | _define_pin(9, PORT_A, 19); 10 | _define_pin(10, PORT_A, 20); 11 | _define_pin(11, PORT_A, 21); 12 | _define_pin(12, PORT_A, 22); 13 | _define_pin(13, PORT_A, 23); 14 | _define_pin(14, PORT_A, 2); 15 | _define_pin(15, PORT_A, 5); 16 | _define_pin(16, PORT_B, 8); 17 | _define_pin(17, PORT_B, 9); 18 | _define_pin(18, PORT_A, 4); 19 | _define_pin(19, PORT_A, 6); 20 | _define_pin(20, PORT_B, 1); 21 | _define_pin(21, PORT_A, 12); 22 | _define_pin(22, PORT_A, 13); 23 | _define_pin(23, PORT_B, 22); 24 | _define_pin(24, PORT_B, 23); 25 | _define_pin(25, PORT_A, 17); 26 | _define_pin(29, PORT_A, 24); 27 | _define_pin(30, PORT_A, 27); 28 | _define_pin(31, PORT_A, 3); 29 | _define_pin(32, PORT_A, 2); 30 | _define_pin(33, PORT_A, 5); 31 | _define_pin(34, PORT_B, 10); 32 | _define_pin(35, PORT_B, 11); 33 | _define_pin(36, PORT_A, 8); 34 | _define_pin(37, PORT_A, 9); 35 | _define_pin(38, PORT_A, 10); 36 | _define_pin(39, PORT_A, 11); 37 | -------------------------------------------------------------------------------- /include/boards/samd/industruino_d21g.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for industruino_d21g 2 | 3 | _define_pin(0, PORT_A, 19); 4 | _define_pin(1, PORT_A, 18); 5 | _define_pin(2, PORT_A, 16); 6 | _define_pin(3, PORT_A, 17); 7 | _define_pin(4, PORT_B, 8); 8 | _define_pin(5, PORT_A, 10); 9 | _define_pin(6, PORT_B, 9); 10 | _define_pin(7, PORT_A, 4); 11 | _define_pin(8, PORT_A, 5); 12 | _define_pin(9, PORT_A, 6); 13 | _define_pin(10, PORT_A, 7); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_A, 11); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 23); 19 | _define_pin(16, PORT_B, 23); 20 | _define_pin(17, PORT_A, 22); 21 | _define_pin(18, PORT_A, 2); 22 | _define_pin(19, PORT_B, 10); 23 | _define_pin(20, PORT_A, 12); 24 | _define_pin(21, PORT_B, 11); 25 | _define_pin(22, PORT_B, 3); 26 | _define_pin(23, PORT_A, 15); 27 | _define_pin(24, PORT_A, 14); 28 | _define_pin(25, PORT_A, 13); 29 | _define_pin(26, PORT_A, 20); 30 | _define_pin(27, PORT_B, 2); 31 | _define_pin(28, PORT_A, 3); 32 | _define_pin(29, PORT_A, 2); 33 | _define_pin(30, PORT_A, 28); 34 | _define_pin(31, PORT_A, 24); 35 | _define_pin(32, PORT_A, 25); 36 | _define_pin(33, PORT_B, 14); 37 | -------------------------------------------------------------------------------- /include/boards/avr/rf128.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for rf128 2 | 3 | _define_pin(0, PORT_E, 0); 4 | _define_pin(1, PORT_E, 1); 5 | _define_pin(2, PORT_E, 2); 6 | _define_pin(3, PORT_E, 3); 7 | _define_pin(4, PORT_E, 4); 8 | _define_pin(5, PORT_E, 5); 9 | _define_pin(6, PORT_E, 6); 10 | _define_pin(7, PORT_E, 7); 11 | _define_pin(8, PORT_B, 5); 12 | _define_pin(9, PORT_B, 4); 13 | _define_pin(10, PORT_B, 0); 14 | _define_pin(11, PORT_B, 2); 15 | _define_pin(12, PORT_B, 3); 16 | _define_pin(13, PORT_B, 1); 17 | _define_pin(14, PORT_D, 1); 18 | _define_pin(15, PORT_D, 0); 19 | _define_pin(16, PORT_G, 0); 20 | _define_pin(17, PORT_G, 1); 21 | _define_pin(18, PORT_G, 2); 22 | _define_pin(19, PORT_G, 5); 23 | _define_pin(20, PORT_D, 2); 24 | _define_pin(21, PORT_D, 3); 25 | _define_pin(22, PORT_D, 4); 26 | _define_pin(23, PORT_D, 5); 27 | _define_pin(24, PORT_D, 6); 28 | _define_pin(25, PORT_D, 7); 29 | _define_pin(26, PORT_F, 0); 30 | _define_pin(27, PORT_F, 1); 31 | _define_pin(28, PORT_F, 2); 32 | _define_pin(29, PORT_F, 3); 33 | _define_pin(30, PORT_F, 4); 34 | _define_pin(31, PORT_F, 5); 35 | _define_pin(32, PORT_F, 6); 36 | _define_pin(33, PORT_F, 7); 37 | _define_pin(34, PORT_B, 6); 38 | _define_pin(35, PORT_B, 7); 39 | -------------------------------------------------------------------------------- /include/boards/samd/adi.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for adi 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_A, 28); 35 | _define_pin(32, PORT_B, 8); 36 | _define_pin(33, PORT_B, 9); 37 | _define_pin(34, PORT_A, 0); 38 | _define_pin(35, PORT_A, 1); 39 | -------------------------------------------------------------------------------- /include/boards/samd/mkr1000.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkr1000 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_A, 28); 35 | _define_pin(32, PORT_B, 8); 36 | _define_pin(33, PORT_B, 9); 37 | _define_pin(34, PORT_A, 0); 38 | _define_pin(35, PORT_A, 1); 39 | -------------------------------------------------------------------------------- /include/boards/samd/mkrzero.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkrzero 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_A, 28); 35 | _define_pin(32, PORT_B, 8); 36 | _define_pin(33, PORT_B, 9); 37 | _define_pin(34, PORT_A, 0); 38 | _define_pin(35, PORT_A, 1); 39 | -------------------------------------------------------------------------------- /include/boards/samd/mkrfox1200.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkrfox1200 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_A, 28); 35 | _define_pin(32, PORT_B, 8); 36 | _define_pin(33, PORT_B, 9); 37 | _define_pin(34, PORT_A, 0); 38 | _define_pin(35, PORT_A, 1); 39 | -------------------------------------------------------------------------------- /include/boards/samd/mkrgsm1400.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkrgsm1400 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_B, 8); 35 | _define_pin(32, PORT_B, 9); 36 | _define_pin(33, PORT_A, 0); 37 | _define_pin(34, PORT_A, 1); 38 | _define_pin(35, PORT_A, 28); 39 | -------------------------------------------------------------------------------- /include/boards/samd/mkrwifi1010.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkrwifi1010 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_B, 8); 35 | _define_pin(32, PORT_B, 9); 36 | _define_pin(33, PORT_A, 0); 37 | _define_pin(34, PORT_A, 1); 38 | _define_pin(35, PORT_A, 28); 39 | -------------------------------------------------------------------------------- /include/boards/samd/itsybitsy_m4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for itsybitsy_m4 2 | 3 | _define_pin(0, PORT_A, 16); 4 | _define_pin(1, PORT_A, 17); 5 | _define_pin(2, PORT_A, 7); 6 | _define_pin(3, PORT_B, 22); 7 | _define_pin(4, PORT_A, 14); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_B, 2); 10 | _define_pin(7, PORT_A, 18); 11 | _define_pin(8, PORT_B, 3); 12 | _define_pin(9, PORT_A, 19); 13 | _define_pin(10, PORT_A, 20); 14 | _define_pin(11, PORT_A, 21); 15 | _define_pin(12, PORT_A, 23); 16 | _define_pin(13, PORT_A, 22); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_A, 5); 19 | _define_pin(16, PORT_B, 8); 20 | _define_pin(17, PORT_B, 9); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 6); 23 | _define_pin(20, PORT_A, 7); 24 | _define_pin(21, PORT_A, 12); 25 | _define_pin(22, PORT_A, 13); 26 | _define_pin(23, PORT_B, 23); 27 | _define_pin(24, PORT_A, 1); 28 | _define_pin(25, PORT_A, 0); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 24); 31 | _define_pin(28, PORT_A, 25); 32 | _define_pin(29, PORT_A, 3); 33 | _define_pin(30, PORT_A, 2); 34 | _define_pin(31, PORT_A, 5); 35 | _define_pin(32, PORT_B, 10); 36 | _define_pin(33, PORT_B, 11); 37 | _define_pin(34, PORT_A, 8); 38 | _define_pin(35, PORT_A, 9); 39 | _define_pin(36, PORT_A, 10); 40 | _define_pin(37, PORT_A, 11); 41 | -------------------------------------------------------------------------------- /extras/docs/boards_todo: -------------------------------------------------------------------------------- 1 | Packages installed: 2 | 3 | arduino/avr/1.6.23 4 | arduino/nrf52/1.0.2 5 | arduino/sam/1.6.11 6 | arduino/samd/1.6.19 7 | arduino/stm32f4/1.0.1 8 | Arrow/samd/2.1.0 9 | atmel-avr-xminis/avr/0.6.0 10 | emoro/avr/3.2.2 11 | industruino/samd/1.0.1 12 | Intel/arc32/2.0.2 13 | Intel/i586/1.6.7+1.0 14 | Intel/i686/1.6.7+1.0 15 | littleBits/avr/1.0.0 16 | 17 | 18 | boards from those packages that are not yet supported: 19 | 20 | 21 | primo.build.board=NRF52_PRIMO 22 | primo.build.variant=arduino_primo 23 | primo_core.build.board=NRF52_PRIMO_CORE 24 | primo_core.build.variant=arduino_primo_core 25 | 26 | star_otto.build.board=STM32_STAR_OTTO 27 | star_otto.build.variant=otto 28 | star_otto.build.variant_system_lib=libstm32f4_otto_gcc_rel.a 29 | 30 | arduino_101.build.board=ARC32_TOOLS 31 | arduino_101.build.variant=arduino_101 32 | arduino_101.build.variant_system_lib=arc32drv_arduino101 33 | 34 | izmir_fd.build.variant=galileo_fab_d 35 | #izmir_fd.build.variant_system_lib=libx86_izmir_gcc_rel.a 36 | izmir_fd.build.board=GALILEO 37 | 38 | izmir_fg.build.variant=galileo_fab_g 39 | #izmir_fg.build.variant_system_lib=libx86_izmir_gcc_rel.a 40 | izmir_fg.build.board=GALILEOGEN2 41 | 42 | izmir_ec.build.variant=edison_fab_c 43 | #izmir_ec.build.variant_system_lib=libx86_izmir_gcc_rel.a 44 | izmir_ec.build.board=EDISON 45 | -------------------------------------------------------------------------------- /include/boards/samd/circuitplay.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for circuitplay 2 | 3 | _define_pin(0, PORT_B, 9); 4 | _define_pin(1, PORT_B, 8); 5 | _define_pin(2, PORT_B, 2); 6 | _define_pin(3, PORT_B, 3); 7 | _define_pin(4, PORT_A, 28); 8 | _define_pin(5, PORT_A, 14); 9 | _define_pin(6, PORT_A, 5); 10 | _define_pin(7, PORT_A, 15); 11 | _define_pin(8, PORT_B, 23); 12 | _define_pin(9, PORT_A, 6); 13 | _define_pin(10, PORT_A, 7); 14 | _define_pin(11, PORT_A, 30); 15 | _define_pin(12, PORT_A, 2); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_A, 5); 19 | _define_pin(16, PORT_A, 6); 20 | _define_pin(17, PORT_A, 7); 21 | _define_pin(18, PORT_B, 3); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_B, 9); 24 | _define_pin(21, PORT_B, 8); 25 | _define_pin(22, PORT_A, 11); 26 | _define_pin(23, PORT_A, 9); 27 | _define_pin(24, PORT_A, 4); 28 | _define_pin(25, PORT_A, 23); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 0); 32 | _define_pin(29, PORT_A, 1); 33 | _define_pin(30, PORT_A, 16); 34 | _define_pin(31, PORT_A, 21); 35 | _define_pin(32, PORT_A, 20); 36 | _define_pin(33, PORT_B, 22); 37 | _define_pin(34, PORT_A, 10); 38 | _define_pin(35, PORT_A, 8); 39 | _define_pin(36, PORT_A, 22); 40 | _define_pin(37, PORT_A, 24); 41 | _define_pin(38, PORT_A, 25); 42 | -------------------------------------------------------------------------------- /include/boards/samd/mkrwan1300.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mkrwan1300 2 | 3 | _define_pin(0, PORT_A, 22); 4 | _define_pin(1, PORT_A, 23); 5 | _define_pin(2, PORT_A, 10); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_B, 10); 8 | _define_pin(5, PORT_B, 11); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 16); 12 | _define_pin(9, PORT_A, 17); 13 | _define_pin(10, PORT_A, 19); 14 | _define_pin(11, PORT_A, 8); 15 | _define_pin(12, PORT_A, 9); 16 | _define_pin(13, PORT_B, 23); 17 | _define_pin(14, PORT_B, 22); 18 | _define_pin(15, PORT_A, 2); 19 | _define_pin(16, PORT_B, 2); 20 | _define_pin(17, PORT_B, 3); 21 | _define_pin(18, PORT_A, 4); 22 | _define_pin(19, PORT_A, 5); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 24); 26 | _define_pin(23, PORT_A, 25); 27 | _define_pin(24, PORT_A, 18); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_A, 13); 31 | _define_pin(28, PORT_A, 14); 32 | _define_pin(29, PORT_A, 15); 33 | _define_pin(30, PORT_A, 27); 34 | _define_pin(31, PORT_A, 28); 35 | _define_pin(32, PORT_B, 8); 36 | _define_pin(33, PORT_B, 9); 37 | _define_pin(34, PORT_A, 0); 38 | _define_pin(35, PORT_A, 1); 39 | _define_pin(36, PORT_A, 12); 40 | _define_pin(37, PORT_A, 13); 41 | _define_pin(38, PORT_A, 15); 42 | -------------------------------------------------------------------------------- /include/ports.h: -------------------------------------------------------------------------------- 1 | /* 2 | ports.h - Define pin to port/bit mappings for Direct IO library 3 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _PORTS_H 21 | #define _PORTS_H 1 22 | 23 | #include "base.h" 24 | 25 | #if defined(ARDUINO_ARCH_AVR) 26 | #include "ports_avr.h" 27 | #elif defined(ARDUINO_ARCH_SAM) 28 | #include "ports_sam.h" 29 | #elif defined(ARDUINO_ARCH_SAMD) 30 | #include "ports_samd.h" 31 | #else 32 | #warning "Unsupported Arduino architecture - falling back to digitalRead and digitalWrite." 33 | #define DIRECTIO_FALLBACK 1 34 | #endif 35 | 36 | #undef _define_pin 37 | #endif // _PORTS_H 38 | -------------------------------------------------------------------------------- /include/boards/samd/zero_radio.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for zero_radio 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(8, PORT_A, 6); 11 | _define_pin(9, PORT_A, 7); 12 | _define_pin(10, PORT_A, 18); 13 | _define_pin(11, PORT_A, 16); 14 | _define_pin(12, PORT_A, 19); 15 | _define_pin(13, PORT_A, 17); 16 | _define_pin(17, PORT_A, 4); 17 | _define_pin(18, PORT_A, 5); 18 | _define_pin(19, PORT_B, 2); 19 | _define_pin(20, PORT_A, 22); 20 | _define_pin(21, PORT_A, 23); 21 | _define_pin(22, PORT_A, 12); 22 | _define_pin(25, PORT_B, 3); 23 | _define_pin(26, PORT_A, 27); 24 | _define_pin(27, PORT_A, 28); 25 | _define_pin(28, PORT_A, 24); 26 | _define_pin(29, PORT_A, 25); 27 | _define_pin(30, PORT_B, 22); 28 | _define_pin(31, PORT_B, 23); 29 | _define_pin(32, PORT_A, 22); 30 | _define_pin(33, PORT_A, 23); 31 | _define_pin(34, PORT_A, 19); 32 | _define_pin(35, PORT_A, 16); 33 | _define_pin(36, PORT_A, 18); 34 | _define_pin(37, PORT_A, 17); 35 | _define_pin(38, PORT_A, 13); 36 | _define_pin(40, PORT_A, 6); 37 | _define_pin(41, PORT_A, 7); 38 | _define_pin(44, PORT_B, 15); 39 | _define_pin(45, PORT_C, 16); 40 | _define_pin(46, PORT_C, 18); 41 | _define_pin(47, PORT_C, 19); 42 | _define_pin(48, PORT_B, 30); 43 | _define_pin(49, PORT_B, 31); 44 | _define_pin(50, PORT_B, 00); 45 | -------------------------------------------------------------------------------- /include/boards/samd/metro_m0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for metro_m0 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 11); 24 | _define_pin(21, PORT_A, 10); 25 | _define_pin(22, PORT_A, 8); 26 | _define_pin(23, PORT_A, 9); 27 | _define_pin(24, PORT_A, 6); 28 | _define_pin(25, PORT_A, 7); 29 | _define_pin(26, PORT_A, 22); 30 | _define_pin(27, PORT_A, 23); 31 | _define_pin(28, PORT_A, 12); 32 | _define_pin(29, PORT_B, 10); 33 | _define_pin(30, PORT_B, 11); 34 | _define_pin(31, PORT_A, 31); 35 | _define_pin(32, PORT_A, 27); 36 | _define_pin(33, PORT_A, 28); 37 | _define_pin(34, PORT_A, 24); 38 | _define_pin(35, PORT_A, 25); 39 | _define_pin(36, PORT_B, 03); 40 | _define_pin(37, PORT_B, 22); 41 | _define_pin(38, PORT_B, 23); 42 | _define_pin(39, PORT_A, 13); 43 | _define_pin(40, PORT_A, 30); 44 | _define_pin(41, PORT_A, 3); 45 | _define_pin(42, PORT_A, 2); 46 | -------------------------------------------------------------------------------- /include/boards/samd/feather_m0_express.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for feather_m0_express 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 6); 24 | _define_pin(21, PORT_A, 7); 25 | _define_pin(22, PORT_A, 8); 26 | _define_pin(23, PORT_A, 9); 27 | _define_pin(24, PORT_A, 11); 28 | _define_pin(25, PORT_A, 10); 29 | _define_pin(26, PORT_A, 22); 30 | _define_pin(27, PORT_A, 23); 31 | _define_pin(28, PORT_A, 12); 32 | _define_pin(29, PORT_B, 10); 33 | _define_pin(30, PORT_B, 11); 34 | _define_pin(31, PORT_B, 3); 35 | _define_pin(32, PORT_A, 27); 36 | _define_pin(33, PORT_A, 28); 37 | _define_pin(34, PORT_A, 24); 38 | _define_pin(35, PORT_A, 25); 39 | _define_pin(36, PORT_A, 14); 40 | _define_pin(37, PORT_A, 8); 41 | _define_pin(38, PORT_A, 9); 42 | _define_pin(39, PORT_A, 13); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 3); 45 | _define_pin(42, PORT_A, 2); 46 | -------------------------------------------------------------------------------- /include/boards/samd/hallowing_m0_express.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for hallowing_m0_express 2 | 3 | _define_pin(0, PORT_A, 9); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 11); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 18); 10 | _define_pin(7, PORT_A, 0); 11 | _define_pin(8, PORT_A, 12); 12 | _define_pin(9, PORT_A, 19); 13 | _define_pin(10, PORT_A, 20); 14 | _define_pin(11, PORT_A, 21); 15 | _define_pin(12, PORT_A, 22); 16 | _define_pin(13, PORT_A, 23); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_A, 6); 23 | _define_pin(20, PORT_B, 2); 24 | _define_pin(21, PORT_B, 3); 25 | _define_pin(22, PORT_A, 8); 26 | _define_pin(23, PORT_A, 9); 27 | _define_pin(24, PORT_A, 10); 28 | _define_pin(25, PORT_A, 11); 29 | _define_pin(26, PORT_A, 16); 30 | _define_pin(27, PORT_A, 17); 31 | _define_pin(28, PORT_B, 03); 32 | _define_pin(29, PORT_B, 22); 33 | _define_pin(30, PORT_B, 23); 34 | _define_pin(31, PORT_A, 24); 35 | _define_pin(32, PORT_A, 25); 36 | _define_pin(33, PORT_A, 13); 37 | _define_pin(34, PORT_B, 10); 38 | _define_pin(35, PORT_B, 11); 39 | _define_pin(36, PORT_A, 7); 40 | _define_pin(37, PORT_A, 27); 41 | _define_pin(38, PORT_A, 28); 42 | _define_pin(39, PORT_A, 1); 43 | _define_pin(40, PORT_A, 12); 44 | _define_pin(41, PORT_A, 3); 45 | _define_pin(42, PORT_A, 2); 46 | -------------------------------------------------------------------------------- /include/boards/samd/itsybitsy_m0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for itsybitsy_m0 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 11); 24 | _define_pin(21, PORT_A, 10); 25 | _define_pin(22, PORT_A, 8); 26 | _define_pin(23, PORT_A, 9); 27 | _define_pin(24, PORT_A, 6); 28 | _define_pin(25, PORT_A, 7); 29 | _define_pin(26, PORT_A, 22); 30 | _define_pin(27, PORT_A, 23); 31 | _define_pin(28, PORT_A, 12); 32 | _define_pin(29, PORT_B, 10); 33 | _define_pin(30, PORT_B, 11); 34 | _define_pin(31, PORT_A, 31); 35 | _define_pin(32, PORT_A, 28); 36 | _define_pin(33, PORT_A, 28); 37 | _define_pin(34, PORT_A, 24); 38 | _define_pin(35, PORT_A, 25); 39 | _define_pin(36, PORT_B, 03); 40 | _define_pin(37, PORT_B, 22); 41 | _define_pin(38, PORT_B, 23); 42 | _define_pin(39, PORT_A, 27); 43 | _define_pin(40, PORT_A, 0); 44 | _define_pin(41, PORT_A, 1); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/SparkFun_ProRF.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for SparkFun_ProRF 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/arduino_mzero.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for arduino_mzero 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 8); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 14); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(15, PORT_A, 3); 18 | _define_pin(16, PORT_A, 22); 19 | _define_pin(17, PORT_A, 23); 20 | _define_pin(18, PORT_A, 12); 21 | _define_pin(20, PORT_B, 11); 22 | _define_pin(21, PORT_B, 10); 23 | _define_pin(24, PORT_A, 2); 24 | _define_pin(25, PORT_B, 8); 25 | _define_pin(26, PORT_B, 9); 26 | _define_pin(27, PORT_A, 4); 27 | _define_pin(28, PORT_A, 5); 28 | _define_pin(29, PORT_B, 2); 29 | _define_pin(30, PORT_B, 3); 30 | _define_pin(31, PORT_A, 27); 31 | _define_pin(32, PORT_A, 28); 32 | _define_pin(33, PORT_A, 24); 33 | _define_pin(34, PORT_A, 25); 34 | _define_pin(35, PORT_B, 22); 35 | _define_pin(36, PORT_B, 23); 36 | _define_pin(37, PORT_A, 22); 37 | _define_pin(38, PORT_A, 23); 38 | _define_pin(39, PORT_A, 19); 39 | _define_pin(40, PORT_A, 16); 40 | _define_pin(41, PORT_A, 18); 41 | _define_pin(42, PORT_A, 17); 42 | _define_pin(43, PORT_A, 13); 43 | _define_pin(44, PORT_A, 21); 44 | _define_pin(45, PORT_A, 6); 45 | _define_pin(46, PORT_A, 7); 46 | _define_pin(47, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/arduino_zero.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for arduino_zero 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/SparkFun_9DoF_M0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for SparkFun_9DoF_M0 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/SparkFun_SAMD21_Dev.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for SparkFun_SAMD21_Dev 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/SparkFun_SAMD_Mini.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for SparkFun_SAMD_Mini 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | -------------------------------------------------------------------------------- /include/boards/samd/feather_m0.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for feather_m0 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 12); 26 | _define_pin(23, PORT_B, 10); 27 | _define_pin(24, PORT_B, 11); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 22); 34 | _define_pin(31, PORT_B, 23); 35 | _define_pin(32, PORT_A, 22); 36 | _define_pin(33, PORT_A, 23); 37 | _define_pin(34, PORT_A, 19); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 18); 40 | _define_pin(37, PORT_A, 17); 41 | _define_pin(38, PORT_A, 13); 42 | _define_pin(39, PORT_A, 21); 43 | _define_pin(40, PORT_A, 6); 44 | _define_pin(41, PORT_A, 7); 45 | _define_pin(42, PORT_A, 3); 46 | _define_pin(43, PORT_A, 2); 47 | _define_pin(44, PORT_A, 6); 48 | _define_pin(45, PORT_A, 7); 49 | -------------------------------------------------------------------------------- /include/boards/samd/metro_m4.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for metro_m4 2 | 3 | _define_pin(0, PORT_A, 23); 4 | _define_pin(1, PORT_A, 22); 5 | _define_pin(2, PORT_B, 17); 6 | _define_pin(3, PORT_B, 16); 7 | _define_pin(4, PORT_B, 13); 8 | _define_pin(5, PORT_B, 14); 9 | _define_pin(6, PORT_B, 15); 10 | _define_pin(7, PORT_B, 12); 11 | _define_pin(8, PORT_A, 21); 12 | _define_pin(9, PORT_A, 20); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 19); 15 | _define_pin(12, PORT_A, 17); 16 | _define_pin(13, PORT_A, 16); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_A, 5); 19 | _define_pin(16, PORT_A, 6); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_B, 8); 22 | _define_pin(19, PORT_B, 9); 23 | _define_pin(20, PORT_B, 2); 24 | _define_pin(21, PORT_B, 3); 25 | _define_pin(22, PORT_B, 2); 26 | _define_pin(23, PORT_B, 3); 27 | _define_pin(24, PORT_A, 14); 28 | _define_pin(25, PORT_A, 13); 29 | _define_pin(26, PORT_A, 12); 30 | _define_pin(27, PORT_B, 6); 31 | _define_pin(28, PORT_A, 27); 32 | _define_pin(29, PORT_B, 7); 33 | _define_pin(30, PORT_A, 24); 34 | _define_pin(31, PORT_A, 25); 35 | _define_pin(32, PORT_A, 18); 36 | _define_pin(33, PORT_A, 19); 37 | _define_pin(34, PORT_A, 17); 38 | _define_pin(35, PORT_A, 16); 39 | _define_pin(36, PORT_A, 3); 40 | _define_pin(37, PORT_A, 2); 41 | _define_pin(38, PORT_A, 5); 42 | _define_pin(39, PORT_A, 16); 43 | _define_pin(40, PORT_B, 22); 44 | _define_pin(41, PORT_B, 10); 45 | _define_pin(42, PORT_B, 11); 46 | _define_pin(43, PORT_A, 8); 47 | _define_pin(44, PORT_A, 9); 48 | _define_pin(45, PORT_A, 10); 49 | _define_pin(46, PORT_A, 11); 50 | -------------------------------------------------------------------------------- /include/boards/samd/Fox.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Fox 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_B, 31); 6 | _define_pin(3, PORT_B, 30); 7 | _define_pin(4, PORT_A, 14); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 19); 26 | _define_pin(23, PORT_A, 16); 27 | _define_pin(24, PORT_A, 17); 28 | _define_pin(25, PORT_A, 18); 29 | _define_pin(26, PORT_B, 3); 30 | _define_pin(27, PORT_B, 1); 31 | _define_pin(28, PORT_A, 28); 32 | _define_pin(29, PORT_A, 24); 33 | _define_pin(30, PORT_A, 25); 34 | _define_pin(31, PORT_A, 8); 35 | _define_pin(32, PORT_A, 9); 36 | _define_pin(33, PORT_B, 12); 37 | _define_pin(34, PORT_B, 13); 38 | _define_pin(35, PORT_B, 14); 39 | _define_pin(36, PORT_B, 15); 40 | _define_pin(37, PORT_B, 16); 41 | _define_pin(38, PORT_B, 17); 42 | _define_pin(39, PORT_B, 22); 43 | _define_pin(40, PORT_B, 23); 44 | _define_pin(41, PORT_B, 0); 45 | _define_pin(42, PORT_A, 27); 46 | _define_pin(43, PORT_A, 3); 47 | _define_pin(44, PORT_A, 2); 48 | _define_pin(45, PORT_A, 12); 49 | _define_pin(46, PORT_B, 11); 50 | _define_pin(47, PORT_B, 10); 51 | _define_pin(48, PORT_A, 13); 52 | _define_pin(49, PORT_B, 06); 53 | _define_pin(50, PORT_B, 4); 54 | _define_pin(51, PORT_B, 5); 55 | -------------------------------------------------------------------------------- /include/boards/samd/Fox3.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Fox3 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 19); 26 | _define_pin(23, PORT_A, 16); 27 | _define_pin(24, PORT_A, 17); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 30); 34 | _define_pin(31, PORT_B, 31); 35 | _define_pin(32, PORT_A, 12); 36 | _define_pin(33, PORT_A, 13); 37 | _define_pin(34, PORT_B, 12); 38 | _define_pin(35, PORT_B, 13); 39 | _define_pin(36, PORT_B, 14); 40 | _define_pin(37, PORT_B, 15); 41 | _define_pin(38, PORT_B, 07); 42 | _define_pin(39, PORT_B, 10); 43 | _define_pin(40, PORT_B, 11); 44 | _define_pin(41, PORT_B, 16); 45 | _define_pin(42, PORT_B, 17); 46 | _define_pin(43, PORT_B, 22); 47 | _define_pin(44, PORT_B, 23); 48 | _define_pin(45, PORT_A, 3); 49 | _define_pin(46, PORT_B, 4); 50 | _define_pin(47, PORT_B, 1); 51 | _define_pin(48, PORT_B, 0); 52 | _define_pin(49, PORT_B, 5); 53 | _define_pin(50, PORT_B, 6); 54 | _define_pin(51, PORT_A, 18); 55 | -------------------------------------------------------------------------------- /include/boards/samd/Lion.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Lion 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 19); 26 | _define_pin(23, PORT_A, 16); 27 | _define_pin(24, PORT_A, 17); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 30); 34 | _define_pin(31, PORT_B, 31); 35 | _define_pin(32, PORT_A, 12); 36 | _define_pin(33, PORT_A, 13); 37 | _define_pin(34, PORT_B, 12); 38 | _define_pin(35, PORT_B, 13); 39 | _define_pin(36, PORT_B, 14); 40 | _define_pin(37, PORT_B, 15); 41 | _define_pin(38, PORT_B, 07); 42 | _define_pin(39, PORT_B, 10); 43 | _define_pin(40, PORT_B, 11); 44 | _define_pin(41, PORT_B, 16); 45 | _define_pin(42, PORT_B, 17); 46 | _define_pin(43, PORT_B, 22); 47 | _define_pin(44, PORT_B, 23); 48 | _define_pin(45, PORT_A, 3); 49 | _define_pin(46, PORT_B, 4); 50 | _define_pin(47, PORT_B, 1); 51 | _define_pin(48, PORT_B, 0); 52 | _define_pin(49, PORT_B, 5); 53 | _define_pin(50, PORT_B, 6); 54 | _define_pin(51, PORT_A, 18); 55 | -------------------------------------------------------------------------------- /include/boards/samd/Dragonfly.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for Dragonfly 2 | 3 | _define_pin(0, PORT_A, 11); 4 | _define_pin(1, PORT_A, 10); 5 | _define_pin(2, PORT_A, 14); 6 | _define_pin(3, PORT_A, 9); 7 | _define_pin(4, PORT_A, 8); 8 | _define_pin(5, PORT_A, 15); 9 | _define_pin(6, PORT_A, 20); 10 | _define_pin(7, PORT_A, 21); 11 | _define_pin(8, PORT_A, 6); 12 | _define_pin(9, PORT_A, 7); 13 | _define_pin(10, PORT_A, 18); 14 | _define_pin(11, PORT_A, 16); 15 | _define_pin(12, PORT_A, 19); 16 | _define_pin(13, PORT_A, 17); 17 | _define_pin(14, PORT_A, 2); 18 | _define_pin(15, PORT_B, 8); 19 | _define_pin(16, PORT_B, 9); 20 | _define_pin(17, PORT_A, 4); 21 | _define_pin(18, PORT_A, 5); 22 | _define_pin(19, PORT_B, 2); 23 | _define_pin(20, PORT_A, 22); 24 | _define_pin(21, PORT_A, 23); 25 | _define_pin(22, PORT_A, 19); 26 | _define_pin(23, PORT_A, 16); 27 | _define_pin(24, PORT_A, 17); 28 | _define_pin(25, PORT_B, 3); 29 | _define_pin(26, PORT_A, 27); 30 | _define_pin(27, PORT_A, 28); 31 | _define_pin(28, PORT_A, 24); 32 | _define_pin(29, PORT_A, 25); 33 | _define_pin(30, PORT_B, 30); 34 | _define_pin(31, PORT_B, 31); 35 | _define_pin(32, PORT_A, 12); 36 | _define_pin(33, PORT_A, 13); 37 | _define_pin(34, PORT_B, 12); 38 | _define_pin(35, PORT_B, 13); 39 | _define_pin(36, PORT_B, 14); 40 | _define_pin(37, PORT_B, 15); 41 | _define_pin(38, PORT_B, 07); 42 | _define_pin(39, PORT_B, 10); 43 | _define_pin(40, PORT_B, 11); 44 | _define_pin(41, PORT_B, 16); 45 | _define_pin(42, PORT_B, 17); 46 | _define_pin(43, PORT_B, 22); 47 | _define_pin(44, PORT_B, 23); 48 | _define_pin(45, PORT_A, 3); 49 | _define_pin(46, PORT_B, 4); 50 | _define_pin(47, PORT_B, 1); 51 | _define_pin(48, PORT_B, 0); 52 | _define_pin(49, PORT_B, 5); 53 | _define_pin(50, PORT_A, 2); 54 | _define_pin(51, PORT_B, 3); 55 | -------------------------------------------------------------------------------- /include/boards/avr/mega.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mega 2 | 3 | _define_pin(0, PORT_E, 0); 4 | _define_pin(1, PORT_E, 1); 5 | _define_pin(2, PORT_E, 4); 6 | _define_pin(3, PORT_E, 5); 7 | _define_pin(4, PORT_G, 5); 8 | _define_pin(5, PORT_E, 3); 9 | _define_pin(6, PORT_H, 3); 10 | _define_pin(7, PORT_H, 4); 11 | _define_pin(8, PORT_H, 5); 12 | _define_pin(9, PORT_H, 6); 13 | _define_pin(10, PORT_B, 4); 14 | _define_pin(11, PORT_B, 5); 15 | _define_pin(12, PORT_B, 6); 16 | _define_pin(13, PORT_B, 7); 17 | _define_pin(14, PORT_J, 1); 18 | _define_pin(15, PORT_J, 0); 19 | _define_pin(16, PORT_H, 1); 20 | _define_pin(17, PORT_H, 0); 21 | _define_pin(18, PORT_D, 3); 22 | _define_pin(19, PORT_D, 2); 23 | _define_pin(20, PORT_D, 1); 24 | _define_pin(21, PORT_D, 0); 25 | _define_pin(22, PORT_A, 0); 26 | _define_pin(23, PORT_A, 1); 27 | _define_pin(24, PORT_A, 2); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 4); 30 | _define_pin(27, PORT_A, 5); 31 | _define_pin(28, PORT_A, 6); 32 | _define_pin(29, PORT_A, 7); 33 | _define_pin(30, PORT_C, 7); 34 | _define_pin(31, PORT_C, 6); 35 | _define_pin(32, PORT_C, 5); 36 | _define_pin(33, PORT_C, 4); 37 | _define_pin(34, PORT_C, 3); 38 | _define_pin(35, PORT_C, 2); 39 | _define_pin(36, PORT_C, 1); 40 | _define_pin(37, PORT_C, 0); 41 | _define_pin(38, PORT_D, 7); 42 | _define_pin(39, PORT_G, 2); 43 | _define_pin(40, PORT_G, 1); 44 | _define_pin(41, PORT_G, 0); 45 | _define_pin(42, PORT_L, 7); 46 | _define_pin(43, PORT_L, 6); 47 | _define_pin(44, PORT_L, 5); 48 | _define_pin(45, PORT_L, 4); 49 | _define_pin(46, PORT_L, 3); 50 | _define_pin(47, PORT_L, 2); 51 | _define_pin(48, PORT_L, 1); 52 | _define_pin(49, PORT_L, 0); 53 | _define_pin(50, PORT_B, 3); 54 | _define_pin(51, PORT_B, 2); 55 | _define_pin(52, PORT_B, 1); 56 | _define_pin(53, PORT_B, 0); 57 | _define_pin(54, PORT_F, 0); 58 | _define_pin(55, PORT_F, 1); 59 | _define_pin(56, PORT_F, 2); 60 | _define_pin(57, PORT_F, 3); 61 | _define_pin(58, PORT_F, 4); 62 | _define_pin(59, PORT_F, 5); 63 | _define_pin(60, PORT_F, 6); 64 | _define_pin(61, PORT_F, 7); 65 | _define_pin(62, PORT_K, 0); 66 | _define_pin(63, PORT_K, 1); 67 | _define_pin(64, PORT_K, 2); 68 | _define_pin(65, PORT_K, 3); 69 | _define_pin(66, PORT_K, 4); 70 | _define_pin(67, PORT_K, 5); 71 | _define_pin(68, PORT_K, 6); 72 | _define_pin(69, PORT_K, 7); 73 | -------------------------------------------------------------------------------- /include/boards/avr/mega2560pro.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for mega2560pro 2 | 3 | _define_pin(0, PORT_E, 0); 4 | _define_pin(1, PORT_E, 1); 5 | _define_pin(2, PORT_E, 4); 6 | _define_pin(3, PORT_E, 5); 7 | _define_pin(4, PORT_G, 5); 8 | _define_pin(5, PORT_E, 3); 9 | _define_pin(6, PORT_H, 3); 10 | _define_pin(7, PORT_H, 4); 11 | _define_pin(8, PORT_H, 5); 12 | _define_pin(9, PORT_H, 6); 13 | _define_pin(10, PORT_B, 4); 14 | _define_pin(11, PORT_B, 5); 15 | _define_pin(12, PORT_B, 6); 16 | _define_pin(13, PORT_B, 7); 17 | _define_pin(14, PORT_J, 1); 18 | _define_pin(15, PORT_J, 0); 19 | _define_pin(16, PORT_H, 1); 20 | _define_pin(17, PORT_H, 0); 21 | _define_pin(18, PORT_D, 3); 22 | _define_pin(19, PORT_D, 2); 23 | _define_pin(20, PORT_D, 1); 24 | _define_pin(21, PORT_D, 0); 25 | _define_pin(22, PORT_A, 0); 26 | _define_pin(23, PORT_A, 1); 27 | _define_pin(24, PORT_A, 2); 28 | _define_pin(25, PORT_A, 3); 29 | _define_pin(26, PORT_A, 4); 30 | _define_pin(27, PORT_A, 5); 31 | _define_pin(28, PORT_A, 6); 32 | _define_pin(29, PORT_A, 7); 33 | _define_pin(30, PORT_C, 7); 34 | _define_pin(31, PORT_C, 6); 35 | _define_pin(32, PORT_C, 5); 36 | _define_pin(33, PORT_C, 4); 37 | _define_pin(34, PORT_C, 3); 38 | _define_pin(35, PORT_C, 2); 39 | _define_pin(36, PORT_C, 1); 40 | _define_pin(37, PORT_C, 0); 41 | _define_pin(38, PORT_D, 7); 42 | _define_pin(39, PORT_G, 2); 43 | _define_pin(40, PORT_G, 1); 44 | _define_pin(41, PORT_G, 0); 45 | _define_pin(42, PORT_L, 7); 46 | _define_pin(43, PORT_L, 6); 47 | _define_pin(44, PORT_L, 5); 48 | _define_pin(45, PORT_L, 4); 49 | _define_pin(46, PORT_L, 3); 50 | _define_pin(47, PORT_L, 2); 51 | _define_pin(48, PORT_L, 1); 52 | _define_pin(49, PORT_L, 0); 53 | _define_pin(50, PORT_B, 3); 54 | _define_pin(51, PORT_B, 2); 55 | _define_pin(52, PORT_B, 1); 56 | _define_pin(53, PORT_B, 0); 57 | _define_pin(54, PORT_F, 0); 58 | _define_pin(55, PORT_F, 1); 59 | _define_pin(56, PORT_F, 2); 60 | _define_pin(57, PORT_F, 3); 61 | _define_pin(58, PORT_F, 4); 62 | _define_pin(59, PORT_F, 5); 63 | _define_pin(60, PORT_F, 6); 64 | _define_pin(61, PORT_F, 7); 65 | _define_pin(62, PORT_K, 0); 66 | _define_pin(63, PORT_K, 1); 67 | _define_pin(64, PORT_K, 2); 68 | _define_pin(65, PORT_K, 3); 69 | _define_pin(66, PORT_K, 4); 70 | _define_pin(67, PORT_K, 5); 71 | _define_pin(68, PORT_K, 6); 72 | _define_pin(69, PORT_K, 7); 73 | -------------------------------------------------------------------------------- /include/base.h: -------------------------------------------------------------------------------- 1 | /* 2 | base.h - Type definitions for Direct IO and other libraries. 3 | Copyright (c) 2015 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _DirectIO_Base_ 21 | #define _DirectIO_Base_ 22 | 23 | #include 24 | 25 | typedef unsigned char u8; 26 | typedef unsigned short u16; 27 | typedef unsigned long u32; 28 | 29 | typedef char i8; 30 | typedef short i16; 31 | typedef long i32; 32 | 33 | // Define std C++ style "<<" operator for writing to output streams. 34 | template inline Print &operator << (Print& obj, T arg) 35 | { 36 | obj.print(arg); return obj; 37 | } 38 | 39 | // bits_type(N) gives the smallest type that will hold N bits (0 <= N <= 32) 40 | #define bits_type(N) typename _nbits_t::bits_t 41 | 42 | // A little ugly infrastructure to make it work 43 | template class _nbits_t {}; 44 | 45 | #define _nbits(N, T) template<> class _nbits_t { public: typedef T bits_t; }; 46 | 47 | _nbits(0, u8); 48 | _nbits(1, u8); 49 | _nbits(2, u8); 50 | _nbits(3, u8); 51 | _nbits(4, u8); 52 | _nbits(5, u8); 53 | _nbits(6, u8); 54 | _nbits(7, u8); 55 | _nbits(8, u8); 56 | _nbits(9, u16); 57 | _nbits(10, u16); 58 | _nbits(11, u16); 59 | _nbits(12, u16); 60 | _nbits(13, u16); 61 | _nbits(14, u16); 62 | _nbits(15, u16); 63 | _nbits(16, u16); 64 | _nbits(17, u32); 65 | _nbits(18, u32); 66 | _nbits(19, u32); 67 | _nbits(20, u32); 68 | _nbits(21, u32); 69 | _nbits(22, u32); 70 | _nbits(23, u32); 71 | _nbits(24, u32); 72 | _nbits(25, u32); 73 | _nbits(26, u32); 74 | _nbits(27, u32); 75 | _nbits(28, u32); 76 | _nbits(29, u32); 77 | _nbits(30, u32); 78 | _nbits(31, u32); 79 | _nbits(32, u32); 80 | 81 | #undef _nbits 82 | #endif // _DirectIO_Base_ 83 | -------------------------------------------------------------------------------- /include/boards/avr/emoro_variants.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for emoro_variants 2 | 3 | _define_pin(0, PORT_A, 0); 4 | _define_pin(1, PORT_A, 1); 5 | _define_pin(2, PORT_A, 2); 6 | _define_pin(3, PORT_A, 3); 7 | _define_pin(4, PORT_A, 4); 8 | _define_pin(5, PORT_A, 5); 9 | _define_pin(6, PORT_A, 6); 10 | _define_pin(7, PORT_A, 7); 11 | _define_pin(8, PORT_C, 0); 12 | _define_pin(9, PORT_C, 1); 13 | _define_pin(10, PORT_C, 2); 14 | _define_pin(11, PORT_C, 3); 15 | _define_pin(12, PORT_C, 4); 16 | _define_pin(13, PORT_C, 5); 17 | _define_pin(14, PORT_C, 6); 18 | _define_pin(15, PORT_C, 7); 19 | _define_pin(16, PORT_F, 0); 20 | _define_pin(17, PORT_F, 1); 21 | _define_pin(18, PORT_F, 2); 22 | _define_pin(19, PORT_F, 3); 23 | _define_pin(20, PORT_K, 0); 24 | _define_pin(21, PORT_K, 1); 25 | _define_pin(22, PORT_K, 2); 26 | _define_pin(23, PORT_K, 3); 27 | _define_pin(24, PORT_L, 0); 28 | _define_pin(25, PORT_L, 1); 29 | _define_pin(26, PORT_L, 2); 30 | _define_pin(27, PORT_L, 3); 31 | _define_pin(28, PORT_L, 4); 32 | _define_pin(29, PORT_L, 5); 33 | _define_pin(30, PORT_L, 6); 34 | _define_pin(31, PORT_L, 7); 35 | _define_pin(32, PORT_K, 7); 36 | _define_pin(33, PORT_H, 7); 37 | _define_pin(34, PORT_J, 0); 38 | _define_pin(35, PORT_H, 6); 39 | _define_pin(36, PORT_J, 1); 40 | _define_pin(37, PORT_H, 5); 41 | _define_pin(38, PORT_J, 2); 42 | _define_pin(39, PORT_H, 4); 43 | _define_pin(40, PORT_J, 3); 44 | _define_pin(41, PORT_H, 3); 45 | _define_pin(42, PORT_J, 4); 46 | _define_pin(43, PORT_H, 2); 47 | _define_pin(44, PORT_J, 5); 48 | _define_pin(45, PORT_H, 1); 49 | _define_pin(46, PORT_J, 6); 50 | _define_pin(47, PORT_H, 0); 51 | _define_pin(48, PORT_G, 5); 52 | _define_pin(49, PORT_B, 7); 53 | _define_pin(50, PORT_E, 3); 54 | _define_pin(51, PORT_E, 4); 55 | _define_pin(52, PORT_B, 5); 56 | _define_pin(53, PORT_B, 6); 57 | _define_pin(54, PORT_D, 7); 58 | _define_pin(55, PORT_D, 0); 59 | _define_pin(56, PORT_D, 1); 60 | _define_pin(57, PORT_D, 2); 61 | _define_pin(58, PORT_D, 3); 62 | _define_pin(59, PORT_D, 4); 63 | _define_pin(60, PORT_D, 5); 64 | _define_pin(61, PORT_D, 6); 65 | _define_pin(62, PORT_E, 5); 66 | _define_pin(63, PORT_E, 6); 67 | _define_pin(64, PORT_E, 7); 68 | _define_pin(65, PORT_G, 0); 69 | _define_pin(66, PORT_G, 1); 70 | _define_pin(67, PORT_G, 2); 71 | _define_pin(68, PORT_G, 3); 72 | _define_pin(69, PORT_G, 4); 73 | _define_pin(70, PORT_K, 5); 74 | _define_pin(71, PORT_K, 6); 75 | _define_pin(72, PORT_J, 7); 76 | _define_pin(73, PORT_E, 2); 77 | _define_pin(74, PORT_B, 4); 78 | _define_pin(75, PORT_B, 0); 79 | _define_pin(76, PORT_B, 2); 80 | _define_pin(77, PORT_B, 3); 81 | _define_pin(78, PORT_B, 1); 82 | -------------------------------------------------------------------------------- /include/boards/sam/arduino_due_x.h: -------------------------------------------------------------------------------- 1 | // DirectIO support for arduino_due_x 2 | 3 | _define_pin(0, PORT_A, 8); 4 | _define_pin(1, PORT_A, 9); 5 | _define_pin(2, PORT_B, 25); 6 | _define_pin(3, PORT_C, 28); 7 | _define_pin(4, PORT_C, 26); 8 | _define_pin(5, PORT_C, 25); 9 | _define_pin(6, PORT_C, 24); 10 | _define_pin(7, PORT_C, 23); 11 | _define_pin(8, PORT_C, 22); 12 | _define_pin(9, PORT_C, 21); 13 | _define_pin(10, PORT_C, 29); 14 | _define_pin(11, PORT_D, 7); 15 | _define_pin(12, PORT_D, 8); 16 | _define_pin(13, PORT_B, 27); 17 | _define_pin(14, PORT_D, 4); 18 | _define_pin(15, PORT_D, 5); 19 | _define_pin(16, PORT_A, 13); 20 | _define_pin(17, PORT_A, 12); 21 | _define_pin(18, PORT_A, 11); 22 | _define_pin(19, PORT_A, 10); 23 | _define_pin(20, PORT_B, 12); 24 | _define_pin(21, PORT_B, 13); 25 | _define_pin(22, PORT_B, 26); 26 | _define_pin(23, PORT_A, 14); 27 | _define_pin(24, PORT_A, 15); 28 | _define_pin(25, PORT_D, 0); 29 | _define_pin(26, PORT_D, 1); 30 | _define_pin(27, PORT_D, 2); 31 | _define_pin(28, PORT_D, 3); 32 | _define_pin(29, PORT_D, 6); 33 | _define_pin(30, PORT_D, 9); 34 | _define_pin(31, PORT_A, 7); 35 | _define_pin(32, PORT_D, 10); 36 | _define_pin(33, PORT_C, 1); 37 | _define_pin(34, PORT_C, 2); 38 | _define_pin(35, PORT_C, 3); 39 | _define_pin(36, PORT_C, 4); 40 | _define_pin(37, PORT_C, 5); 41 | _define_pin(38, PORT_C, 6); 42 | _define_pin(39, PORT_C, 7); 43 | _define_pin(40, PORT_C, 8); 44 | _define_pin(41, PORT_C, 9); 45 | _define_pin(42, PORT_A, 19); 46 | _define_pin(43, PORT_A, 20); 47 | _define_pin(44, PORT_C, 19); 48 | _define_pin(45, PORT_C, 18); 49 | _define_pin(46, PORT_C, 17); 50 | _define_pin(47, PORT_C, 16); 51 | _define_pin(48, PORT_C, 15); 52 | _define_pin(49, PORT_C, 14); 53 | _define_pin(50, PORT_C, 13); 54 | _define_pin(51, PORT_C, 12); 55 | _define_pin(52, PORT_B, 21); 56 | _define_pin(53, PORT_B, 14); 57 | _define_pin(54, PORT_A, 16); 58 | _define_pin(55, PORT_A, 24); 59 | _define_pin(56, PORT_A, 23); 60 | _define_pin(57, PORT_A, 22); 61 | _define_pin(58, PORT_A, 6); 62 | _define_pin(59, PORT_A, 4); 63 | _define_pin(60, PORT_A, 3); 64 | _define_pin(61, PORT_A, 2); 65 | _define_pin(62, PORT_B, 17); 66 | _define_pin(63, PORT_B, 18); 67 | _define_pin(64, PORT_B, 19); 68 | _define_pin(65, PORT_B, 20); 69 | _define_pin(66, PORT_B, 15); 70 | _define_pin(67, PORT_B, 16); 71 | _define_pin(68, PORT_A, 1); 72 | _define_pin(69, PORT_A, 0); 73 | _define_pin(70, PORT_A, 17); 74 | _define_pin(71, PORT_A, 18); 75 | _define_pin(72, PORT_C, 30); 76 | _define_pin(73, PORT_A, 21); 77 | _define_pin(74, PORT_A, 25); 78 | _define_pin(75, PORT_A, 26); 79 | _define_pin(76, PORT_A, 27); 80 | _define_pin(77, PORT_A, 28); 81 | _define_pin(78, PORT_B, 23); 82 | _define_pin(79, PORT_A, 17); 83 | _define_pin(80, PORT_B, 12); 84 | _define_pin(81, PORT_A, 8); 85 | _define_pin(82, PORT_A, 11); 86 | _define_pin(83, PORT_A, 13); 87 | _define_pin(84, PORT_D, 4); 88 | _define_pin(85, PORT_B, 11); 89 | _define_pin(86, PORT_B, 21); 90 | _define_pin(87, PORT_A, 29); 91 | _define_pin(88, PORT_B, 15); 92 | _define_pin(89, PORT_B, 14); 93 | _define_pin(90, PORT_A, 1); 94 | _define_pin(91, PORT_B, 15); 95 | -------------------------------------------------------------------------------- /include/analog.h: -------------------------------------------------------------------------------- 1 | /* 2 | analog.h - AnalogInput and AnalogOutput classes for Arduino. 3 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | template 21 | class AnalogInput { 22 | public: 23 | AnalogInput() {} 24 | 25 | u16 read() { 26 | return analogRead(pin); 27 | } 28 | 29 | operator u16 () { 30 | return read(); 31 | } 32 | }; 33 | 34 | template 35 | class AnalogOutput { 36 | public: 37 | AnalogOutput(u8 initial_value=0) { 38 | write(initial_value); 39 | } 40 | 41 | void write(u8 value) { 42 | analogWrite(pin, value); 43 | } 44 | 45 | AnalogOutput& operator = (u8 value) { 46 | write(value); 47 | return *this; 48 | } 49 | }; 50 | 51 | template<> 52 | class AnalogOutput { 53 | // This specialization of AnalogOutput is used when a module supports 54 | // an optional pin and that pin is not being used. For example, 55 | // the sample LCD project includes a backlight pin which can optionally 56 | // be driven with PWM. Alternatively, it could be wired to Vcc to keep 57 | // the backlight fully on. In that case, we will use this 58 | // type of AnalogOutput which is basically a no-op. 59 | public: 60 | AnalogOutput(u8 initial_value=0) {} 61 | void write(u8 value) {} 62 | 63 | AnalogOutput& operator = (u8 value) { 64 | return *this; 65 | } 66 | }; 67 | 68 | template 69 | class AnalogOutputLow { 70 | public: 71 | AnalogOutputLow(u8 initial_value=0) { 72 | write(initial_value); 73 | } 74 | 75 | void write(u8 value) { 76 | analogWrite(pin, 255 - value); 77 | } 78 | 79 | AnalogOutputLow& operator = (u8 value) { 80 | write(value); 81 | return *this; 82 | } 83 | }; 84 | 85 | template<> 86 | class AnalogOutputLow { 87 | // This specialization of AnalogOutputLow is used when a module supports 88 | // an optional pin and that pin is not being used. 89 | // See AnalogOutput for details. 90 | public: 91 | AnalogOutputLow(u8 initial_value=0) {} 92 | void write(u8 value) {} 93 | 94 | AnalogOutputLow& operator = (u8 value) { 95 | return *this; 96 | } 97 | }; 98 | -------------------------------------------------------------------------------- /include/ports_sam.h: -------------------------------------------------------------------------------- 1 | /* 2 | ports_sam.h - SAM board support for DirectIO and other libraries. 3 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | 21 | #ifndef _PORTS_SAM_H 22 | #define _PORTS_SAM_H 1 23 | 24 | typedef u32 port_data_t; 25 | typedef volatile port_data_t* port_t; 26 | 27 | #define _define_port(NAME, PIO) \ 28 | struct NAME { \ 29 | static const u32 pio = u32(PIO); \ 30 | static inline u32 port_input_read() { return ((Pio*)pio)->PIO_PDSR; } \ 31 | static inline void port_output_write(u32 value) { \ 32 | ((Pio*)pio)->PIO_ODSR = value; \ 33 | } \ 34 | static inline u32 port_output_read() { return ((Pio*)pio)->PIO_ODSR; } \ 35 | static inline void port_enable_outputs(u32 mask) { PIO_Configure((Pio*)pio, PIO_OUTPUT_0, mask, PIO_DEFAULT); } \ 36 | static inline void port_enable_inputs(u32 mask) { PIO_Configure((Pio*)pio, PIO_INPUT, mask, PIO_DEFAULT); } \ 37 | } 38 | 39 | #ifdef PIOA 40 | _define_port(PORT_A, PIOA); 41 | #endif 42 | 43 | #ifdef PIOB 44 | _define_port(PORT_B, PIOB); 45 | #endif 46 | 47 | #ifdef PIOC 48 | _define_port(PORT_C, PIOC); 49 | #endif 50 | 51 | #ifdef PIOD 52 | _define_port(PORT_D, PIOD); 53 | #endif 54 | 55 | // These constants are propagated in a template-friendly way by using (what else? :) templates. 56 | // First, we define a generic template for a class describing the pin data. 57 | // Since this doesn't describe a specific pin, there is no data present. 58 | template struct _pins {}; 59 | 60 | // Next we will create a template specialization for each defined pin number. 61 | // Each specialization will contain the constants for that pin. 62 | // To avoid a lot of repetitive code, we will define the specializations with a macro. 63 | // Also note that each pin inherits the port registers from the 64 | // corresponding port object (defined above). 65 | 66 | #define _define_pin(PIN, PORT, BIT) \ 67 | template <> struct _pins : public PORT { \ 68 | static const u8 bit = BIT; \ 69 | static const u32 mask = u32(1) << bit; \ 70 | static inline boolean input_read() { return (PORT::port_input_read() & mask) != 0; } \ 71 | static inline void output_write(boolean value) { \ 72 | if(value) { \ 73 | ((Pio*)PORT::pio)->PIO_SODR = mask; \ 74 | } else { \ 75 | ((Pio*)PORT::pio)->PIO_CODR = mask; \ 76 | } \ 77 | } \ 78 | static inline boolean output_read() { return (PORT::port_output_read() & mask) != 0; } \ 79 | } 80 | 81 | #define atomic for(boolean _loop_=(__disable_irq(),true);_loop_; _loop_=(__enable_irq(), false)) 82 | 83 | #if defined(ARDUINO_SAM_DUE) 84 | #include "boards/sam/arduino_due_x.h" 85 | #else 86 | #warning "Unsupported Arduino SAM variant - falling back to digitalRead and digitalWrite." 87 | #define DIRECTIO_FALLBACK 1 88 | #endif 89 | 90 | #endif // _PORTS_SAM_H 91 | -------------------------------------------------------------------------------- /extras/tools/gen_pins.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | 4 | from glob import glob 5 | from os.path import basename, dirname, exists, join 6 | import os 7 | import re 8 | import sys 9 | 10 | def usage(msg): 11 | if msg: 12 | print(msg) 13 | print('') 14 | 15 | print('%s: PATH' % sys.argv[0]) 16 | sys.exit(1) 17 | 18 | 19 | errors = 0 20 | 21 | def error(msg): 22 | print('Error:', msg, file=sys.stderr) 23 | global errors 24 | errors += 1 25 | 26 | sam_pin_declaration_start = 'const PinDescription g_APinDescription' 27 | sam_pin_declaration_end = '}' 28 | 29 | 30 | def read_sam_variant(variant_file): 31 | print('reading %s' % variant_file) 32 | reading = False 33 | pins = [] 34 | pin_num = 0 35 | pin_re = re.compile('{(.*)}') 36 | data_re = re.compile('\s*(?:PORT|PIO)([A-L]),\s*(?:PIO_P[A-F])?([0-9]+)') 37 | 38 | with open(variant_file) as f: 39 | for line in f.readlines(): 40 | if line.strip().startswith('//'): 41 | continue 42 | if sam_pin_declaration_start in line: 43 | reading = True 44 | elif line.startswith(sam_pin_declaration_end): 45 | reading = False 46 | elif reading: 47 | # first look for the brackets, which indicate pin data 48 | # then look for the port/pin info contained within. 49 | # Some SAMD variants have empty brackets which indicate a 50 | # pin number that cannot be used. 51 | m = pin_re.search(line) 52 | if m: 53 | data = m.group(1) 54 | m = data_re.match(data) 55 | if m: 56 | pins.append((pin_num, m.groups())) 57 | pin_num += 1 58 | 59 | if not pins: 60 | error('no pins found in %s' % variant_file) 61 | return pins 62 | 63 | 64 | avr_port_declaration_start = 'const uint8_t PROGMEM digital_pin_to_port_PGM[' 65 | avr_pin_declaration_start = 'const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[' 66 | avr_declaration_end = '};' 67 | 68 | 69 | def read_avr_variant(variant_file): 70 | print('reading %s' % variant_file) 71 | reading_ports = False 72 | reading_pins = False 73 | found_include = False 74 | ports = [] 75 | pins = [] 76 | pin_num = 0 77 | port_re = re.compile('\s*P(?:ORT_)?([A-L])') 78 | pin_re = re.compile('\s*_BV\(\s*([0-9]+)\s*\)') 79 | include_re = re.compile('#include "(\.\./[^/]+/pins_arduino.h)"') 80 | 81 | if variant_file.endswith('pins_arduino.c'): 82 | print('Warning: check generated pins for %s; multiple MCU variants may be combined' % variant_file) 83 | 84 | with open(variant_file) as f: 85 | for line_num, line in enumerate(f.readlines()): 86 | if reading_ports: 87 | if line.startswith(avr_declaration_end): 88 | reading_ports = False 89 | 90 | m = port_re.match(line) 91 | if m: 92 | ports.append(m.group(1)) 93 | elif reading_pins: 94 | if line.startswith(avr_declaration_end): 95 | reading_pins = False 96 | 97 | m = pin_re.match(line) 98 | if m: 99 | pins.append(m.group(1)) 100 | 101 | elif line.startswith(avr_port_declaration_start): 102 | reading_ports = True 103 | 104 | elif line.startswith(avr_pin_declaration_start): 105 | reading_pins = True 106 | else: 107 | m = include_re.match(line) 108 | if m: 109 | found_include = True 110 | target = m.group(1) 111 | print('%s -> %s' % (variant_file, target)) 112 | return read_avr_variant(join(dirname(variant_file), target)) 113 | 114 | if len(ports) != len(pins): 115 | error('ports/pins mismatch in %s (%d ports, %d pins)' % (variant_file, len(ports), len(pins))) 116 | return [] 117 | 118 | if not pins and not found_include: 119 | error('no pins or include reference found in %s' % variant_file) 120 | return [] 121 | 122 | return list(enumerate(zip(ports, pins))) 123 | 124 | 125 | def generate_header(variant_name, variant_type, pins): 126 | filename = join('include', 'boards', variant_type, variant_name + '.h') 127 | try: 128 | os.makedirs(dirname(filename)) 129 | except OSError: 130 | pass 131 | 132 | if pins: 133 | with open(filename, 'w') as f: 134 | print('// DirectIO support for %s\n' % variant_name, file=f) 135 | 136 | for pin_num, (port, port_pin) in pins: 137 | print('_define_pin(%d, PORT_%s, %s);' % (pin_num, port, port_pin), file=f) 138 | print('generated %s (%d pins)' % (filename, len(pins))) 139 | 140 | 141 | def main(argv): 142 | base_path = argv[1] 143 | if not exists(base_path): 144 | usage("Can't find base path: %s" % base_path) 145 | 146 | hardware_path = join(base_path, 'packages', 'arduino', 'hardware') 147 | if not exists(hardware_path): 148 | usage("Can't find hardware at: %s" % hardware_path) 149 | 150 | # iterate over all hardware_type/version 151 | # SAM variants use definitions in variants.cpp 152 | variants = {} 153 | 154 | pattern = join(base_path, 'packages', '*', 'hardware', 'sam*', '*', 'variants', '*', 'variant.cpp') 155 | variants.update({v: read_sam_variant(v) for v in glob(pattern)}) 156 | 157 | pattern = join(base_path, 'packages', '*', 'hardware', 'avr', '*', 'variants', '*', 'pins_arduino.*') 158 | variants.update({v: read_avr_variant(v) for v in glob(pattern)}) 159 | 160 | for path, pins in variants.items(): 161 | variant_name = basename(dirname(path)) 162 | variant_type = basename(dirname(dirname(dirname(dirname(path))))) 163 | generate_header(variant_name, variant_type, pins) 164 | 165 | if __name__ == '__main__': 166 | main(sys.argv) 167 | sys.exit(errors) 168 | -------------------------------------------------------------------------------- /examples/shift_out/DirectIO_Shift.h: -------------------------------------------------------------------------------- 1 | /* 2 | DirectIO_Shift.h - Bit shift in/out using Direct IO library 3 | Copyright (c) 2015 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | template 23 | class ClockedInput { 24 | // A DirectIO implementation of shiftIn. Also supports 25 | // a variable number of bits (1-32); shiftIn is always 8 bits. 26 | public: 27 | // Define a type large enough to hold nbits bits (see base.h) 28 | typedef bits_type(nbits) bits_t; 29 | 30 | ClockedInput(bool pullup=true) : data(pullup) {} 31 | 32 | bits_t read() { 33 | // read nbits bits from the input pin and pack them 34 | // into a value of type bits_t. 35 | 36 | bits_t value = 0; 37 | bits_t mask = (bit_order == LSBFIRST) ? 1 : (bits_t(1) << (nbits - 1)); 38 | 39 | for(u8 i = 0; i < nbits; i++) { 40 | clock = HIGH; 41 | 42 | if(data) { 43 | value |= mask; 44 | } 45 | clock = LOW; 46 | 47 | if (bit_order == LSBFIRST) { 48 | mask <<= 1; 49 | } 50 | else { 51 | mask >>= 1; 52 | } 53 | } 54 | return value; 55 | } 56 | 57 | operator bits_t() { 58 | return read(); 59 | } 60 | 61 | private: 62 | Input data; 63 | Output clock; 64 | }; 65 | 66 | template 67 | class ClockedOutput { 68 | // A DirectIO implementation of shiftOut. Also supports 69 | // a variable number of bits (1-32); shiftOut is always 8 bits. 70 | public: 71 | // Define a type large enough to hold nbits bits (see base.h) 72 | typedef bits_type(nbits) bits_t; 73 | 74 | ClockedOutput() {}; 75 | 76 | void write(bits_t val) { 77 | // write nbits bits to the output pin 78 | bits_t mask = (bit_order == LSBFIRST) ? 1 : (bits_t(1) << (nbits - 1)); 79 | 80 | for(u8 i = 0; i < nbits; i++) { 81 | data = (val & mask); 82 | clock.pulse(); 83 | 84 | if (bit_order == LSBFIRST) { 85 | mask <<= 1; 86 | } 87 | else { 88 | mask >>= 1; 89 | } 90 | } 91 | } 92 | 93 | ClockedOutput& operator = (bits_t val) { 94 | write(val); 95 | return *this; 96 | } 97 | 98 | private: 99 | Output data; 100 | Output clock; 101 | }; 102 | 103 | template 105 | class ShiftRegister595 { 106 | // ShiftRegister595 models a serial-in parallel-out shift register 107 | // such as the 74HC595 (or up to 4 of them connected in series). 108 | // The process for putting values onto the output pins is: 109 | // For each bit, write the bit onto the data pin and pulse the 110 | // shift register clock (this is done by ClockedOutput). 111 | // When all bits have been transferred, pulse the storage 112 | // register clock to transfer all bits at once to the storage 113 | // register and output pins. 114 | // Note that the Output Enable pin is optional; if omitted, 115 | // then no Output Enable pin will be used. This is useful 116 | // if you have wired the 595's OE pin to Vcc. 117 | 118 | public: 119 | // define a type just large enough to hold nbits bits 120 | typedef bits_type(nbits) bits_t; 121 | 122 | ShiftRegister595(boolean enabled=true) : output_enable(enabled) {} 123 | 124 | void write(bits_t val) { 125 | // shift bits into the shift register 126 | shift_reg.write(val); 127 | 128 | // shift register contents will be transferred to the 129 | // storage register and output pins on the positive 130 | // edge of the storage clock 131 | storage_clock.pulse(HIGH); 132 | } 133 | 134 | ShiftRegister595& operator = (bits_t val) { 135 | write(val); 136 | return *this; 137 | } 138 | 139 | void enable() { 140 | output_enable = HIGH; 141 | } 142 | 143 | void disable() { 144 | output_enable = LOW; 145 | } 146 | 147 | private: 148 | ClockedOutput shift_reg; 149 | Output storage_clock; 150 | Output output_enable; 151 | }; 152 | -------------------------------------------------------------------------------- /include/pin.h: -------------------------------------------------------------------------------- 1 | /* 2 | pin.h - InputPin and OutputPin classes for AVR and other Arduino variants. 3 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #if defined(ARDUINO_ARCH_AVR) 21 | class InputPin { 22 | // An digital input where the pin isn't known at compile time. 23 | // We cache the port address and bit mask for the pin 24 | // and read() reads directly from port memory. 25 | public: 26 | explicit InputPin(u8 pin, boolean pullup=true); 27 | 28 | boolean read() { 29 | return (*in_port & mask) != 0; 30 | } 31 | operator boolean() { 32 | return read(); 33 | } 34 | 35 | private: 36 | port_t in_port; 37 | port_data_t mask; 38 | }; 39 | 40 | class OutputPin { 41 | // An digital output where the pin isn't known at compile time. 42 | // We cache the port address and bit mask for the pin 43 | // and write() writes directly to port memory. 44 | public: 45 | explicit OutputPin(u8 pin, boolean initial_value=LOW); 46 | 47 | void write(boolean value); 48 | OutputPin& operator =(boolean value) { 49 | write(value); 50 | return *this; 51 | } 52 | void toggle() { 53 | write(! read()); 54 | } 55 | void pulse(boolean value=HIGH) { 56 | write(value); 57 | write(! value); 58 | } 59 | boolean read() { 60 | return (*in_port & on_mask) != 0; 61 | } 62 | operator boolean() { 63 | return read(); 64 | } 65 | 66 | private: 67 | port_t in_port; 68 | port_t out_port; 69 | port_data_t on_mask; 70 | port_data_t off_mask; 71 | }; 72 | 73 | inline InputPin::InputPin(u8 pin, boolean pullup) : 74 | in_port(portInputRegister(digitalPinToPort(pin))), 75 | mask(digitalPinToBitMask(pin)) 76 | { 77 | pinMode(pin, pullup ? INPUT_PULLUP : INPUT); 78 | 79 | // include a call to digitalRead here which will 80 | // turn off PWM on this pin, if needed 81 | (void) digitalRead(pin); 82 | } 83 | 84 | inline OutputPin::OutputPin(u8 pin, boolean initial_state): 85 | in_port(portInputRegister(digitalPinToPort(pin))), 86 | out_port(portOutputRegister(digitalPinToPort(pin))), 87 | on_mask(digitalPinToBitMask(pin)), 88 | off_mask(~on_mask) 89 | { 90 | pinMode(pin, OUTPUT); 91 | 92 | // include a call to digitalWrite here which will 93 | // set the initial state and turn off PWM 94 | // on this pin, if needed. 95 | digitalWrite(pin, initial_state); 96 | } 97 | 98 | inline void OutputPin::write(boolean value) 99 | { 100 | atomic { 101 | if(value) { 102 | *out_port |= on_mask; 103 | } 104 | else { 105 | *out_port &= off_mask; 106 | } 107 | } 108 | } 109 | 110 | #else // ARDUINO_ARCH_AVR 111 | 112 | class InputPin { 113 | // An digital input where the pin isn't known at compile time. 114 | // We cache the port address and bit mask for the pin 115 | // and read() reads directly from port memory. 116 | public: 117 | InputPin(u8 pin, boolean pullup=true); 118 | 119 | boolean read() { 120 | return digitalRead(pin); 121 | } 122 | operator boolean() { 123 | return read(); 124 | } 125 | 126 | private: 127 | u8 pin; 128 | }; 129 | 130 | class OutputPin { 131 | // An digital output where the pin isn't known at compile time. 132 | // We cache the port address and bit mask for the pin 133 | // and write() writes directly to port memory. 134 | public: 135 | OutputPin(u8 pin, boolean initial_value=LOW); 136 | 137 | void write(boolean value) { 138 | digitalWrite(pin, value); 139 | } 140 | OutputPin& operator =(boolean value) { 141 | write(value); 142 | return *this; 143 | } 144 | void toggle() { 145 | write(! read()); 146 | } 147 | void pulse(boolean value=HIGH) { 148 | write(value); 149 | write(! value); 150 | } 151 | boolean read() { 152 | return digitalRead(pin); 153 | } 154 | operator boolean() { 155 | return read(); 156 | } 157 | 158 | private: 159 | u8 pin; 160 | }; 161 | 162 | inline InputPin::InputPin(u8 pin, boolean pullup): 163 | pin(pin) 164 | { 165 | pinMode(pin, pullup ? INPUT_PULLUP : INPUT); 166 | 167 | // include a call to digitalRead here which will 168 | // turn off PWM on this pin, if needed 169 | (void) digitalRead(pin); 170 | } 171 | 172 | inline OutputPin::OutputPin(u8 pin, boolean initial_state): 173 | pin(pin) 174 | { 175 | pinMode(pin, OUTPUT); 176 | 177 | // include a call to digitalWrite here which will 178 | // set the initial state and turn off PWM 179 | // on this pin, if needed. 180 | digitalWrite(pin, initial_state); 181 | } 182 | 183 | #endif // ARDUINO_ARCH_AVR 184 | -------------------------------------------------------------------------------- /extras/docs/avr_benchmarks.md: -------------------------------------------------------------------------------- 1 | 2 | ## AVR Board (Arduino Nano) Benchmarks 3 | 4 | ### Contents 5 | * [Benchmarks](#user-content-benchmarks) 6 | * [Arduino I/O](#user-content-arduino-io) 7 | * [Direct I/O](#user-content-direct-io) 8 | * [Direct I/O with Dynamic Pin Numbers](#user-content-direct-io-with-dynamic-pin-numbers) 9 | * [8-Bit Port using Arduino I/O](#user-content-8-bit-port-using-arduino-io) 10 | * [8-Bit Port using DirectIO](#user-content-8-bit-port-using-directio) 11 | 12 | ### Benchmarks 13 | #### Arduino I/O 14 | 15 | Here's a short sketch that drives an output pin as fast as possible: 16 | 17 | ```C++ 18 | #define PIN 2 19 | 20 | void setup() { 21 | pinMode(PIN, OUTPUT); 22 | } 23 | 24 | void loop() { 25 | while(1) { 26 | digitalWrite(PIN, HIGH); 27 | digitalWrite(PIN, LOW); 28 | } 29 | } 30 | ``` 31 | 32 | This generates the following code: 33 | ``` 34 | 00000234 : 35 | 234: 61 e0 ldi r22, 0x01 ; 1 36 | 236: 82 e0 ldi r24, 0x02 ; 2 37 | 238: 5a c0 rjmp .+180 ; 0x2ee 38 | ``` 39 | 40 | In this loop, each write to the output requires 3 instructions to set up a call to `digitalWrite`. 41 | 42 | ``` 43 | 0000023a : 44 | 23a: 61 e0 ldi r22, 0x01 ; 1 45 | 23c: 82 e0 ldi r24, 0x02 ; 2 46 | 23e: 90 d0 rcall .+288 ; 0x360 47 | 48 | 240: 60 e0 ldi r22, 0x00 ; 0 49 | 242: 82 e0 ldi r24, 0x02 ; 2 50 | 244: 8d d0 rcall .+282 ; 0x360 51 | 52 | 246: f9 cf rjmp .-14 ; 0x23a 53 | ``` 54 | 55 | Each pass through the loop takes 250 cycles. On a 16 Mhz board, this gives an output frequency of 64 KHz. 56 | 57 | ![Trace of Arduino IO case](images/normal.png) 58 | 59 | #### Direct I/O 60 | 61 | Here's the same loop, using the DirectIO library: 62 | 63 | ```C++ 64 | #include 65 | 66 | Output<2> pin; 67 | 68 | void setup() {} 69 | 70 | void loop() { 71 | while(1) { 72 | pin = HIGH; 73 | pin = LOW; 74 | } 75 | } 76 | ``` 77 | 78 | setup() is now empty, and the initialization is done in the constructor of the global variable 'pin': 79 | ``` 80 | 00000254 : 81 | 254: 08 95 ret 82 | 83 | 0000025c <_GLOBAL__sub_I_pin>: 84 | 25c: 61 e0 ldi r22, 0x01 ; 1 85 | 25e: 82 e0 ldi r24, 0x02 ; 2 86 | 260: 56 d0 rcall .+172 ; 0x30e 87 | 88 | 262: 60 e0 ldi r22, 0x00 ; 0 89 | 264: 82 e0 ldi r24, 0x02 ; 2 90 | 266: 8c c0 rjmp .+280 ; 0x380 91 | ``` 92 | 93 | In the new loop, each write to the output is a single instruction. This is what makes the DirectIO library so fast. 94 | 95 | ``` 96 | 00000256 : 97 | 256: 74 9a sbi 0x0e, 4 ; 14 ; sets pin high 98 | 258: 74 98 cbi 0x0e, 4 ; 14 ; sets pin low 99 | 25a: fd cf rjmp .-6 ; 0x256 100 | ``` 101 | 102 | Each pass through the loop takes 6 cycles; on a 16 Mhz board, this 103 | gives an output frequency of 2.66 MHz - over 40x faster than the native 104 | Arduino I/O. 105 | 106 | ![Trace of Direct IO case](images/direct.png) 107 | 108 | #### Direct I/O with Dynamic Pin Numbers 109 | 110 | One more example, using pin numbers specified at runtime. Note that you should only do this if you need dynamic pin numbering; if you have constant pin numbers, use the `Output` class described above. 111 | 112 | ```C++ 113 | #include 114 | 115 | OutputPin pin(2); 116 | 117 | void setup() {} 118 | 119 | void loop() { 120 | while(1) { 121 | pin = HIGH; 122 | pin = LOW; 123 | } 124 | } 125 | ``` 126 | 127 | Each pass through the loop takes 75 cycles; on a 16 Mhz board, this 128 | gives an output frequency of 214 KHz - over 3x faster than the native 129 | Arduino I/O. 130 | 131 | ![Trace of Direct IO dynamic case](images/direct_pin.png) 132 | 133 | #### 8-Bit Port using Arduino I/O 134 | 135 | Here is an example sketch that writes a series of values to an 8-bit output port (on pins 0-7). 136 | 137 | ```C++ 138 | #define FIRST_PIN 0 139 | 140 | void setup() 141 | { 142 | for(uint8_t i = 0; i < 8; i++) { 143 | pinMode(FIRST_PIN + i, OUTPUT); 144 | } 145 | } 146 | 147 | void loop() { 148 | uint8_t value = 0; 149 | 150 | while(1) { 151 | for(uint8_t i = 0; i < 8; i++) { 152 | digitalWrite(FIRST_PIN + 7 - i, bitRead(value, i)); 153 | } 154 | value++; 155 | } 156 | } 157 | ``` 158 | 159 | The low order bit is cycling at 8.36 KHz, so the loop is running at 16.7 KHz. This is due to the large number of calls to `digitalWrite`. 160 | 161 | ![Trace of 8-bit Arduino port](images/normal_port.png) 162 | 163 | #### 8-Bit Port using DirectIO 164 | 165 | Here is the same example using DirectIO: 166 | ```C++ 167 | #include 168 | 169 | OutputPort port; 170 | 171 | void setup() {} 172 | 173 | void loop() { 174 | u8 i = 0; 175 | 176 | while(1) { 177 | port = i++; 178 | } 179 | } 180 | ``` 181 | 182 | First, the code is more readable. Second, it runs faster. A *lot* faster. 183 | 184 | ![Trace of 8-bit Arduino port](images/direct_port.png) 185 | 186 | The low order bit is cycling at 2 MHz, so the loop is executing at 4MHz. This is over 200x as fast as the native Arduino version. Looking at the disassembly reveals why: 187 | ``` 188 | 0000012c : 189 | 12c: 80 e0 ldi r24, 0x00 ; 0 190 | 12e: 8b b9 out 0x0b, r24 ; 11 191 | 130: 8f 5f subi r24, 0xFF ; 255 192 | 132: fd cf rjmp .-6 ; 0x12e 193 | ``` 194 | 195 | It's a 3-instruction loop that takes 4 cycles per iteration. Most of that time is spent incrementing the counter and branching back to the top of the loop. Writing all 8 bits to the port is done by the `out` instruction and takes a single cycle. 196 | -------------------------------------------------------------------------------- /extras/docs/arm_benchmarks.md: -------------------------------------------------------------------------------- 1 | 2 | ## SAM Board (Arduino Due) Benchmarks 3 | 4 | ### Contents 5 | * [Benchmarks](#user-content-benchmarks) 6 | * [Arduino I/O](#user-content-arduino-io) 7 | * [Direct I/O](#user-content-direct-io) 8 | * [Direct I/O with Dynamic Pin Numbers](#user-content-direct-io-with-dynamic-pin-numbers) 9 | * [8-Bit Port using Arduino I/O](#user-content-8-bit-port-using-arduino-io) 10 | * [8-Bit Port using DirectIO](#user-content-8-bit-port-using-directio) 11 | 12 | ### Benchmarks 13 | #### Arduino I/O 14 | 15 | Here's a short sketch that drives an output pin as fast as possible: 16 | 17 | ```C++ 18 | #define PIN 2 19 | 20 | void setup() { 21 | pinMode(PIN, OUTPUT); 22 | } 23 | 24 | void loop() { 25 | while(1) { 26 | digitalWrite(PIN, HIGH); 27 | digitalWrite(PIN, LOW); 28 | } 29 | } 30 | ``` 31 | 32 | This generates the following code: 33 | ``` 34 | 00080148 : 35 | 80148: 2002 movs r0, #2 36 | 8014a: 2101 movs r1, #1 37 | 8014c: f000 bd38 b.w 80bc0 38 | ``` 39 | 40 | In this loop, each write to the output requires 3 instructions to set up a call to `digitalWrite`. 41 | 42 | ``` 43 | 00080150 : 44 | 80150: b508 push {r3, lr} 45 | 80152: 2002 movs r0, #2 46 | 80154: 2101 movs r1, #1 47 | 80156: f000 fdb7 bl 80cc8 48 | 49 | 8015a: 2002 movs r0, #2 50 | 8015c: 2100 movs r1, #0 51 | 8015e: f000 fdb3 bl 80cc8 52 | 53 | 80162: e7f6 b.n 80152 54 | ``` 55 | 56 | Each pass through the loop takes ~350 cycles, which gives an output frequency of ~237 KHz. 57 | 58 | ![Trace of Arduino IO case](images/due_normal.png) 59 | 60 | #### Direct I/O 61 | 62 | Here's the same loop, using the DirectIO library: 63 | 64 | ```C++ 65 | #include 66 | 67 | Output<2> pin; 68 | 69 | void setup() {} 70 | 71 | void loop() { 72 | while(1) { 73 | pin = HIGH; 74 | pin = LOW; 75 | } 76 | } 77 | ``` 78 | 79 | setup() is now empty, and the initialization is done in the constructor of the global variable 'pin': 80 | ``` 81 | 00080148 : 82 | 80148: 4770 bx lr 83 | ... 84 | 85 | 0008015c <_GLOBAL__sub_I_pin>: 86 | 8015c: b508 push {r3, lr} 87 | 8015e: 2002 movs r0, #2 88 | 80160: 2101 movs r1, #1 89 | 80162: f000 fd33 bl 80bcc 90 | 80166: e8bd 4008 ldmia.w sp!, {r3, lr} 91 | 8016a: 2002 movs r0, #2 92 | 8016c: 2100 movs r1, #0 93 | 8016e: f000 bdb1 b.w 80cd4 94 | ``` 95 | 96 | In the new loop, each write to the output is a single instruction. This is what makes the DirectIO library so fast. 97 | 98 | ``` 99 | 0008014c : 100 | 8014c: 4b02 ldr r3, [pc, #8] ; (80158 ) 101 | 8014e: f04f 7200 mov.w r2, #33554432 ; 0x2000000 102 | 103 | 80152: 631a str r2, [r3, #48] ; 0x30 ; sets pin high 104 | 80154: 635a str r2, [r3, #52] ; 0x34 ; sets pin low 105 | 106 | 80156: e7f9 b.n 8014c 107 | 80158: 400e1000 .word 0x400e1000 108 | ``` 109 | 110 | Each pass through the loop takes 8 cycles, which gives an output frequency of 111 | 10.5 MHz - over 40x faster than the native Arduino I/O. 112 | 113 | ![Trace of Direct IO case](images/due_direct.png) 114 | 115 | #### Direct I/O with Dynamic Pin Numbers 116 | 117 | On SAM and SAMD boards, the dynamic pin number classes (InputPin and OutputPin) are not accelerated at this time, so performance is identical to the `digitalRead` and `digitalWrite` case. This is an opportunity for future improvement using the same technique used for the AVR case. 118 | 119 | #### 8-Bit Port using Arduino I/O 120 | 121 | Here is an example sketch that writes a series of values to an 8-bit output port (on pins 0-7). 122 | 123 | ```C++ 124 | #define FIRST_PIN 0 125 | 126 | void setup() 127 | { 128 | for(uint8_t i = 0; i < 8; i++) { 129 | pinMode(FIRST_PIN + i, OUTPUT); 130 | } 131 | } 132 | 133 | void loop() { 134 | uint8_t value = 0; 135 | 136 | while(1) { 137 | for(uint8_t i = 0; i < 8; i++) { 138 | digitalWrite(FIRST_PIN + 7 - i, bitRead(value, i)); 139 | } 140 | value++; 141 | } 142 | } 143 | ``` 144 | 145 | The low order bit is cycling at 27 KHz, so the loop is running at 54 KHz. This is due to the large number of calls to `digitalWrite`. 146 | 147 | ![Trace of 8-bit Arduino port](images/due_normal_port.png) 148 | 149 | #### 8-Bit Port using DirectIO 150 | 151 | Here is the same example using DirectIO: 152 | ```C++ 153 | #include 154 | 155 | OutputPort port; 156 | 157 | void setup() { 158 | port.setup(); 159 | } 160 | 161 | void loop() { 162 | u8 i = 0; 163 | 164 | while(1) { 165 | port = i++; 166 | } 167 | } 168 | ``` 169 | 170 | ![Trace of 8-bit Arduino port](images/due_direct_port.png) 171 | 172 | The low order bit is cycling at 2.3 MHz, so the loop is executing at 4.6MHz. This is around 85x as fast as the native Arduino version. 173 | 174 | ``` 175 | 80158: 2300 movs r3, #0 176 | 8015a: 1c59 adds r1, r3, #1 177 | 8015c: b2c9 uxtb r1, r1 178 | 8015e: b672 cpsid i 179 | 80160: 4a04 ldr r2, [pc, #16] ; (80174 ) 180 | 80162: 6b90 ldr r0, [r2, #56] ; 0x38 181 | 80164: f020 00ff bic.w r0, r0, #255 ; 0xff 182 | 80168: 4303 orrs r3, r0 183 | 8016a: 6393 str r3, [r2, #56] ; 0x38 184 | 8016c: b662 cpsie i 185 | 8016e: 460b mov r3, r1 186 | 80170: e7f3 b.n 8015a 187 | 80172: bf00 nop 188 | 80174: 400e1400 .word 0x400e1400 189 | ``` 190 | 191 | This is a fairly complex loop, because this is a partial I/O port: the SAM/SAMD CPUs have 32-bit I/O ports, and we are only using 8 bits. Many of the instructions here are dedicated to implementing a masked read-modify-write cycle so we don't change the contents of the other port pins. 192 | 193 | It's uncommon to need a full 32-bit port. If we were to use one: 194 | ```C++ 195 | #include 196 | 197 | OutputPort port; 198 | 199 | void setup() { 200 | port.setup(); 201 | } 202 | 203 | void loop() { 204 | u8 i = 0; 205 | 206 | while(1) { 207 | port = i++; 208 | } 209 | } 210 | ``` 211 | 212 | we get a much tighter loop: 213 | 214 | ``` 215 | 8015c: 2300 movs r3, #0 216 | 8015e: 4902 ldr r1, [pc, #8] ; (80168 ) 217 | 80160: 1c5a adds r2, r3, #1 218 | 80162: 638b str r3, [r1, #56] ; 0x38 219 | 80164: b2d3 uxtb r3, r2 220 | 80166: e7fa b.n 8015e 221 | 80168: 400e1400 .word 0x400e1400 222 | ``` 223 | 224 | with the low bit cycling at 4.3 MHz, indicating 8.6M loop iterations per second. 225 | 226 | ![Trace of 32-bit Arduino port](images/due_direct_full_port.png) 227 | -------------------------------------------------------------------------------- /include/ports_samd.h: -------------------------------------------------------------------------------- 1 | /* 2 | ports_sams.h - SAMD board support for DirectIO and other libraries. 3 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _PORTS_SAMD_H 21 | #define _PORTS_SAMD_H 1 22 | 23 | typedef u32 port_data_t; 24 | typedef volatile port_data_t* port_t; 25 | 26 | #define _define_port(NAME, PORTNUM) \ 27 | struct NAME { \ 28 | static inline u32 port_input_read() { return REG_PORT_IN##PORTNUM; } \ 29 | static inline void port_output_write(u32 value) { REG_PORT_OUT##PORTNUM = value; } \ 30 | static inline u32 port_output_read() { return REG_PORT_OUT##PORTNUM; } \ 31 | static inline void port_enable_outputs(u32 mask) { REG_PORT_DIRSET##PORTNUM = mask; } \ 32 | static inline void port_enable_inputs(u32 mask) { REG_PORT_DIRCLR##PORTNUM = mask; } \ 33 | static inline void port_output_set(u32 value) { REG_PORT_OUTSET##PORTNUM = value; } \ 34 | static inline void port_output_clear(u32 value) { REG_PORT_OUTCLR##PORTNUM = value; } \ 35 | } 36 | 37 | #ifdef REG_PORT_DIR0 38 | _define_port(PORT_A, 0); 39 | #endif 40 | 41 | #ifdef REG_PORT_DIR1 42 | _define_port(PORT_B, 1); 43 | #endif 44 | 45 | #ifdef REG_PORT_DIR2 46 | _define_port(PORT_C, 2); 47 | #endif 48 | 49 | #ifdef REG_PORT_DIR3 50 | _define_port(PORT_D, 3); 51 | #endif 52 | 53 | // These constants are propagated in a template-friendly way by using (what else? :) templates. 54 | // First, we define a generic template for a class describing the pin data. 55 | // Since this doesn't describe a specific pin, there is no data present. 56 | template struct _pins {}; 57 | 58 | // Next we will create a template specialization for each defined pin number. 59 | // Each specialization will contain the constants for that pin. 60 | // To avoid a lot of repetitive code, we will define the specializations with a macro. 61 | // Also note that each pin inherits the port registers from the 62 | // corresponding port object (defined above). 63 | 64 | #define _define_pin(PIN, PORT, BIT) \ 65 | template <> struct _pins : public PORT { \ 66 | static const u8 bit = BIT; \ 67 | static const u32 mask = u32(1) << bit; \ 68 | static inline boolean input_read() { return (PORT::port_input_read() & mask) != 0; } \ 69 | static inline void output_write(boolean value) { \ 70 | if(value) { \ 71 | PORT::port_output_set(mask); \ 72 | } else { \ 73 | PORT::port_output_clear(mask); \ 74 | } \ 75 | } \ 76 | static inline boolean output_read() { return (PORT::port_output_read() & mask) != 0; } \ 77 | } 78 | 79 | #define atomic for(boolean _loop_=(__disable_irq(),true);_loop_; _loop_=(__enable_irq(), false)) 80 | 81 | #if defined(ARDUINO_SAM_ZERO) 82 | #include "boards/samd/arduino_zero.h" 83 | #elif defined(ARDUINO_SAMD_ZERO) 84 | // lots of boards define ARDUINO_SAMD_ZERO 85 | #if defined(ADAFRUIT_METRO_M0_EXPRESS) 86 | #include "boards/samd/metro_m0.h" 87 | #elif defined(ADAFRUIT_FEATHER_M0) 88 | #include "boards/samd/feather_m0.h" 89 | #elif USB_VID == 0x1B4F // SparkFun Electronics 90 | #if USB_PID == 0x8D21 91 | // SparkFun SAMD21 Breakout doesn't define anything unique in build.extra_flags 92 | #if NUM_DIGITAL_PINS == 20 93 | #include "boards/samd/SparkFun_SAMD21_Dev.h" 94 | #elif NUM_DIGITAL_PINS == 14 95 | #include "boards/samd/SparkFun_SAMD_Mini.h" 96 | #else 97 | #warning "Unsupported Arduino SFE SAMD21 variant - falling back to digitalRead and digitalWrite." 98 | #define DIRECTIO_FALLBACK 1 99 | #endif // NUM_DIGITAL_PINS 100 | #elif USB_PID == 0x0100 101 | #include "boards/samd/SparkFun_LilyMini.h" 102 | #elif USB_PID == 0x9D0E 103 | #include "boards/samd/SparkFun_9DoF_M0.h" 104 | #elif USB_PID == 0x214F 105 | #include "boards/samd/SparkFun_ProRF.h" 106 | #else 107 | // some other SFE USB_PID 108 | #warning "Unsupported Arduino SFE variant - falling back to digitalRead and digitalWrite." 109 | #define DIRECTIO_FALLBACK 1 110 | #endif // USB_PID 111 | #else 112 | // not a special case board, just plain ARDUINO_SAMD_ZERO (aka arduino_mzero) 113 | #include "boards/samd/arduino_mzero.h" 114 | #endif // ARDUINO_SAMD_ZERO 115 | #elif defined(ARDUINO_SAMD_MKR1000) 116 | #include "boards/samd/mkr1000.h" 117 | #elif defined(ARDUINO_SAMD_MKRZERO) 118 | #include "boards/samd/mkrzero.h" 119 | #elif defined(ARDUINO_SAMD_MKRFox1200) 120 | #include "boards/samd/mkrfox1200.h" 121 | #elif defined(ARDUINO_SAMD_MKRGSM1400) 122 | #include "boards/samd/mkrgsm1400.h" 123 | #elif defined(ARDUINO_SAMD_MKRWAN1300) 124 | #include "boards/samd/mkrwan1300.h" 125 | #elif defined(ARDUINO_SAMD_MKRWIFI1010) 126 | #include "boards/samd/mkrwifi1010.h" 127 | #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) 128 | #include "boards/samd/circuitplay.h" 129 | #elif defined(ARDUINO_SAMD_TIAN) 130 | #include "boards/samd/arduino_mzero.h" 131 | #elif defined(ARDUINO_SAMD_ADI) 132 | #include "boards/samd/adi.h" 133 | #elif defined(ARDUINO_SAMD_INDUSTRUINO_D21G) 134 | #include "boards/samd/industruino_d21g.h" 135 | #elif defined(ARDUINO_SAMD_FEATHER_M0_EXPRESS) 136 | #include "boards/samd/feather_m0_express.h" 137 | #elif defined(ARDUINO_FEATHER_M4) 138 | #include "boards/samd/feather_m4.h" 139 | #elif defined(ARDUINO_METRO_M4) 140 | #include "boards/samd/metro_m4.h" 141 | #elif defined(ARDUINO_GEMMA_M0) 142 | #include "boards/samd/gemma_m0.h" 143 | #elif defined(ARDUINO_TRINKET_M0) 144 | #include "boards/samd/trinket_m0.h" 145 | #elif defined(ARDUINO_ITSYBITSY_M0) 146 | #include "boards/samd/itsybitsy_m0.h" 147 | #elif defined(ARDUINO_ITSYBITSY_M4) 148 | #include "boards/samd/itsybitsy_m4.h" 149 | #elif defined(ARDUINO_SAMD_HALLOWING) 150 | #include "boards/samd/hallowing_m0_express.h" 151 | #elif defined(ARDUINO_PIRKEY) 152 | #include "boards/samd/pirkey.h" 153 | #elif defined(ARDUINO_SAMD_SMARTEVERYTHING_DRAGONFLY) 154 | #include "boards/samd/Dragonfly.h" 155 | #elif defined(ARDUINO_SAMD_SMARTEVERYTHING_LION) 156 | #include "boards/samd/Lion.h" 157 | #elif defined(ARDUINO_SAMD_SMARTEVERYTHING_FOX) 158 | #if defined(ASME3_REVISION) 159 | #include "boards/samd/Fox3.h" 160 | #else 161 | #include "boards/samd/Fox.h" 162 | #endif 163 | #else 164 | #warning "Unsupported Arduino SAMD variant - falling back to digitalRead and digitalWrite." 165 | #define DIRECTIO_FALLBACK 1 166 | #endif 167 | 168 | #endif // _PORTS_SAM_H 169 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /include/ports_avr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ports_avr.h -AVR board support for DirectIO and other libraries. 3 | 4 | Copyright (c) 2015-2018 Michael Marchetti. All right reserved. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _PORTS_AVR_H 22 | #define _PORTS_AVR_H 1 23 | 24 | #undef _AVR_COMMON_H 25 | #undef _AVR_IO_H_ 26 | #undef _AVR_IOXXX_H_ 27 | #undef _AVR_SFR_DEFS_H_ 28 | #undef _SFR_ASM_COMPAT 29 | 30 | // _SFR_ASM_COMPAT enables the port numbers (e.g. PORTA) to be plain integers so they can be used as template parameters. 31 | #define _SFR_ASM_COMPAT 1 32 | #include 33 | 34 | #ifndef _AVR_EEPROM_H_ 35 | // avr/eeprom.h isn't compatible with _SFR_ASM_COMPAT, so prevent its inclusion 36 | #define _AVR_EEPROM_H_ 1 37 | 38 | #include "base.h" 39 | #undef _SFR_ASM_COMPAT 40 | #undef _AVR_EEPROM_H_ 41 | #endif // _AVR_EEPROM_H_ 42 | 43 | // Define port description constants for all the ports defined in the AVR header file for this CPU. 44 | // See the header files in hardware/tools/avr/avr/avr/ for details. 45 | // Note, this relies on the fact that those headers use #define to define these constants. 46 | 47 | typedef u8 port_data_t; 48 | typedef volatile port_data_t* port_t; 49 | 50 | // The constants for each port will be defined in a unique struct. 51 | #define _define_port(NAME, IN_REG, OUT_REG, DIR_REG) \ 52 | struct NAME { \ 53 | static const u16 in = IN_REG; \ 54 | static const u16 out = OUT_REG; \ 55 | static const u16 dir = DIR_REG; \ 56 | static inline u8 port_input_read() { return *port_t(in); } \ 57 | static inline void port_output_write(u8 value) { *port_t(out) = value; } \ 58 | static inline u8 port_output_read() { return *port_t(in); } \ 59 | static inline void port_enable_outputs(u8 mask) { *port_t(dir) |= mask; } \ 60 | static inline void port_enable_inputs(u8 mask) { *port_t(dir) &= ~mask; } \ 61 | } 62 | 63 | #ifdef PINA 64 | _define_port(PORT_A, PINA, PORTA, DDRA); 65 | #endif 66 | 67 | #ifdef PINB 68 | _define_port(PORT_B, PINB, PORTB, DDRB); 69 | #endif 70 | 71 | #ifdef PINC 72 | _define_port(PORT_C, PINC, PORTC, DDRC); 73 | #endif 74 | 75 | #ifdef PIND 76 | _define_port(PORT_D, PIND, PORTD, DDRD); 77 | #endif 78 | 79 | #ifdef PINE 80 | _define_port(PORT_E, PINE, PORTE, DDRE); 81 | #endif 82 | 83 | #ifdef PINF 84 | _define_port(PORT_F, PINF, PORTF, DDRF); 85 | #endif 86 | 87 | #ifdef PING 88 | _define_port(PORT_G, PING, PORTG, DDRG); 89 | #endif 90 | 91 | #ifdef PINH 92 | _define_port(PORT_H, PINH, PORTH, DDRH); 93 | #endif 94 | 95 | #ifdef PINI 96 | // don't think this exists even on Mega 2560, but defining for completeness 97 | _define_port(PORT_I, PINI, PORTI, DDRI); 98 | #endif 99 | 100 | #ifdef PINJ 101 | _define_port(PORT_J, PINJ, PORTJ, DDRJ); 102 | #endif 103 | 104 | #ifdef PINK 105 | _define_port(PORT_K, PINK, PORTK, DDRK); 106 | #endif 107 | 108 | #ifdef PINL 109 | _define_port(PORT_L, PINL, PORTL, DDRL); 110 | #endif 111 | 112 | #undef _define_port 113 | 114 | // These constants are propagated in a template-friendly way by using (what else? :) templates. 115 | // First, we define a generic template for a class describing the pin data. 116 | // Since this doesn't describe a specific pin, there is no data present. 117 | template struct _pins {}; 118 | 119 | // Next we will create a template specialization for each defined pin number. 120 | // Each specialization will contain the constants for that pin. 121 | // To avoid a lot of repetitive code, we will define the specializations with a macro. 122 | // Also note that each pin inherits the port registers from the 123 | // corresponding port object (defined above). 124 | 125 | #define _define_pin(PIN, PORT, BIT) \ 126 | template <> struct _pins : public PORT { \ 127 | static const u8 bit = BIT; \ 128 | static inline boolean input_read() { return bitRead(*port_t(in), bit); } \ 129 | static inline void output_write(boolean value) { bitWrite(*port_t(out), bit, value); } \ 130 | static inline boolean output_read() { return bitRead(*port_t(in), bit); } \ 131 | } 132 | 133 | // Define the correct ports/pins based on the Arduino board selected. 134 | // Arduino IDE 1.5 defines these automatically; if you are using 1.0, you 135 | // must define the correct symbol, e.g.: 136 | // #define ARDUINO_AVR_UNO 1 137 | // #include 138 | 139 | #if defined(ARDUINO_AVR_UNO) || \ 140 | defined(ARDUINO_AVR_DUEMILANOVE) || \ 141 | defined(ARDUINO_AVR_NANO) || \ 142 | defined(ARDUINO_AVR_MINI) || \ 143 | defined(ARDUINO_AVR_FIO) || \ 144 | defined(ARDUINO_AVR_BT) || \ 145 | defined(ARDUINO_AVR_LILYPAD) || \ 146 | defined(ARDUINO_AVR_PRO) || \ 147 | defined(ARDUINO_AVR_NG) || \ 148 | defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || \ 149 | defined(ARDUINO_AVR_FEATHER328P) || \ 150 | defined(ARDUINO_AVR_METRO) || \ 151 | defined(ARDUINO_AVR_PROTRINKET3) || \ 152 | defined(ARDUINO_AVR_PROTRINKET5) || \ 153 | defined(ARDUINO_AVR_PROTRINKET3FTDI) || \ 154 | defined(ARDUINO_AVR_PROTRINKET5FTDI) || \ 155 | defined(ARDUINO_REDBOT) 156 | #include "boards/avr/standard.h" 157 | 158 | #elif defined(ARDUINO_AVR_MEGA2560) || \ 159 | defined(ARDUINO_AVR_MEGA) || \ 160 | defined(ARDUINO_AVR_ADK) 161 | #include "boards/avr/mega.h" 162 | 163 | #elif defined(ARDUINO_AVR_LEONARDO) || \ 164 | defined(ARDUINO_AVR_LEONARDO_ETH) || \ 165 | defined(ARDUINO_AVR_ESPLORA) || \ 166 | defined(ARDUINO_AVR_LILYPAD_USB) 167 | #include "boards/avr/leonardo.h" 168 | 169 | #elif defined(ARDUINO_AVR_MICRO) 170 | #include "boards/avr/micro.h" 171 | 172 | #elif defined(ARDUINO_AVR_ROBOT_CONTROL) 173 | #include "boards/avr/robot_control.h" 174 | 175 | #elif defined(ARDUINO_AVR_ROBOT_MOTOR) 176 | #include "boards/avr/robot_motor.h" 177 | 178 | #elif defined(ARDUINO_AVR_ETHERNET) 179 | #include "boards/avr/ethernet.h" 180 | 181 | #elif defined(ARDUINO_AVR_GEMMA) 182 | #include "boards/avr/gemma.h" 183 | 184 | #elif defined(ARDUINO_AVR_YUN) || \ 185 | defined(ARDUINO_AVR_YUNMINI) || \ 186 | defined(ARDUINO_AVR_INDUSTRIAL101) || \ 187 | defined(ARDUINO_AVR_LININO_ONE) 188 | #include "boards/avr/yun.h" 189 | 190 | #elif defined(ARDUINO_AVR_CIRCUITPLAY) 191 | #include "boards/avr/circuitplay32u4.h" 192 | 193 | #elif defined(ARDUINO_AVR_ATMEL_ATMEGA328P_XMINI) 194 | #include "boards/avr/atmega328p-xmini.h" 195 | 196 | #elif defined(ARDUINO_AVR_ATMEL_ATMEGA328PB_XMINI) 197 | #include "boards/avr/atmega328pb-xmini.h" 198 | 199 | #elif defined(ARDUINO_AVR_ATMEL_ATMEGA168PB_XMINI) 200 | #include "boards/avr/atmega168pb-xmini.h" 201 | 202 | #elif defined(ARDUINO_AVR_EMORO_2560) 203 | #include "boards/avr/emoro_variants.h" 204 | 205 | #elif defined(ARDUINO_AVR_FLORA8) 206 | #include "boards/avr/flora.h" 207 | 208 | #elif defined(ARDUINO_AVR_FEATHER32U4) 209 | #include "boards/avr/feather32u4.h" 210 | 211 | #elif defined(ARDUINO_AVR_TRINKET3) || \ 212 | defined(ARDUINO_AVR_TRINKET5) || \ 213 | defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || \ 214 | defined(ARDUINO_AVR_ITSYBITSY32U4_5V) 215 | #include "boards/avr/tiny8.h" 216 | 217 | #elif defined(ARDUINO_AVR_BLUEFRUITMICRO) 218 | #include "boards/avr/bluefruitmicro.h" 219 | 220 | #elif defined(ARDUINO_AVR_ADAFRUIT32U4) 221 | #include "boards/avr/adafruit32u4.h" 222 | 223 | #elif defined(ARDUINO_AVR_OLIMEXINO_328) 224 | #include "boards/avr/Olimexino_328.h" 225 | 226 | #elif defined(ARDUINO_AVR_OLIMEXINO_32U4) 227 | #include "boards/avr/Olimexino_32U4.h" 228 | 229 | #elif defined(ARDUINO_AVR_OLIMEXINO_Nano) 230 | #include "boards/avr/Olimexino_Nano.h" 231 | 232 | #elif defined(ARDUINO_AVR_OLIMEXINO_85) 233 | #include "boards/avr/Olimexino_85.h" 234 | 235 | #elif defined(ARDUINO_AVR_RGB_GLASSES) 236 | #include "boards/avr/RGB_Glasses.h" 237 | 238 | #elif defined(ARDUINO_AVR_MAKEYMAKEY) || \ 239 | defined(ARDUINO_AVR_PROMICRO) || \ 240 | defined(ARDUINO_AVR_FIOV3) || \ 241 | defined(ARDUINO_AVR_QDUINOMINI) 242 | #include "boards/avr/promicro.h" 243 | 244 | #elif defined(ARDUINO_AVR_DIGITAL_SANDBOX) 245 | #include "boards/avr/digitalsandbox.h" 246 | 247 | #elif defined(ARDUINO_AVR_SERIAL_7_SEGMENT) 248 | #include "boards/avr/ser7seg.h" 249 | 250 | #elif defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) 251 | #include "boards/avr/rf128.h" 252 | 253 | #elif defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD) 254 | #include "boards/avr/lilypadusbplus.h" 255 | 256 | #else 257 | #warning "Unsupported Arduino AVR variant - falling back to digitalRead and digitalWrite. If you are using Arduino IDE 1.0, be sure to #define an Arduino variant (e.g. #define ARDUINO_AVR_UNO 1). See ports.h." 258 | #define DIRECTIO_FALLBACK 1 259 | #endif 260 | 261 | #undef _AVR_COMMON_H 262 | #undef _AVR_IO_H_ 263 | #undef _AVR_IOXXX_H_ 264 | #undef _AVR_SFR_DEFS_H_ 265 | #undef _SFR_ASM_COMPAT 266 | #include 267 | #include 268 | 269 | #include 270 | #define atomic ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 271 | 272 | #endif // _PORTS_AVR_H 273 | -------------------------------------------------------------------------------- /DirectIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | DirectIO.h - Main include file for Direct IO library 3 | Copyright (c) 2015 Michael Marchetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef _DIRECTIO_H 21 | #define _DIRECTIO_H 1 22 | 23 | #include "include/ports.h" 24 | 25 | #ifndef INPUT_PULLUP 26 | // for boards that don't support pullups 27 | #define INPUT_PULLUP INPUT 28 | #endif 29 | 30 | const u8 NO_PIN = 255; 31 | #include "include/pin.h" 32 | #include "include/analog.h" 33 | 34 | #if !defined(DIRECTIO_FALLBACK) 35 | 36 | template 37 | class Input { 38 | // An standard digital input. read() returns true if the signal is asserted (high). 39 | public: 40 | Input(boolean pullup=true) { 41 | pinMode(pin, pullup ? INPUT_PULLUP : INPUT); 42 | } 43 | boolean read() { 44 | return _pins::input_read(); 45 | } 46 | operator boolean() { 47 | return read(); 48 | } 49 | }; 50 | 51 | template 52 | class Output { 53 | // An digital output with direct port I/O 54 | public: 55 | Output(boolean initial_value=LOW) { 56 | pinMode(pin, OUTPUT); 57 | 58 | // include a call to digitalWrite here which will 59 | // turn off PWM on this pin, if needed 60 | digitalWrite(pin, initial_value); 61 | } 62 | void write(boolean value) { 63 | _pins::output_write(value); 64 | } 65 | Output& operator =(boolean value) { 66 | write(value); 67 | return *this; 68 | } 69 | void toggle() { 70 | write(! read()); 71 | } 72 | void pulse(boolean value=HIGH) { 73 | write(value); 74 | write(! value); 75 | } 76 | boolean read() { 77 | return _pins::output_read(); 78 | } 79 | operator boolean() { 80 | return read(); 81 | } 82 | }; 83 | 84 | template 85 | class OutputLow { 86 | // An digital output with direct port I/O 87 | public: 88 | OutputLow(boolean initial_value=HIGH) { 89 | pinMode(pin, OUTPUT); 90 | 91 | // include a call to digitalWrite here which will 92 | // turn off PWM on this pin, if needed 93 | digitalWrite(pin, initial_value); 94 | } 95 | void write(boolean value) { 96 | _pins::output_write(!value); 97 | } 98 | OutputLow& operator =(boolean value) { 99 | write(value); 100 | return *this; 101 | } 102 | void toggle() { 103 | write(! read()); 104 | } 105 | void pulse(boolean value=LOW) { 106 | write(value); 107 | write(! value); 108 | } 109 | boolean read() { 110 | return !_pins::output_read(); 111 | } 112 | operator boolean() { 113 | return read(); 114 | } 115 | }; 116 | 117 | template 118 | class InputPort { 119 | // A set of digital inputs which are contiguous and 120 | // located in a single MCU I/O port. This abandons 121 | // the pin number model for specifying I/O pins, 122 | // in order to gain fast, simultaneous 123 | // multi-bit reads and writes. 124 | public: 125 | InputPort() { 126 | setup(); 127 | } 128 | 129 | void setup() { 130 | // set port pin directions to output 131 | port::port_enable_inputs(mask); 132 | } 133 | 134 | u8 read() { 135 | // mask to select bits of interest, then shift so 136 | // that output can be treated as normal integers. 137 | return (*port_t(port::in) & mask) >> start_bit; 138 | } 139 | operator u8() { 140 | return read(); 141 | } 142 | 143 | private: 144 | static const u8 mask = ((u8(1) << nbits) - 1) << start_bit; 145 | }; 146 | 147 | template 148 | class OutputPort { 149 | // A set of digital outputs which are contiguous and 150 | // located in a single MCU I/O port. This abandons 151 | // the pin number model for specifying I/O pins, 152 | // in order to gain fast, simultaneous 153 | // multi-bit reads and writes. 154 | public: 155 | OutputPort() { 156 | setup(); 157 | } 158 | 159 | void setup() { 160 | // set port pin directions to output 161 | port::port_enable_outputs(mask); 162 | } 163 | 164 | void write(port_data_t value) { 165 | atomic { 166 | // read-modify-write cycle 167 | port_data_t v = port::port_output_read(); 168 | port_data_t shifted = value << start_bit; 169 | v |= shifted & mask; 170 | v &= (shifted | ~mask); 171 | port::port_output_write(v); 172 | } 173 | } 174 | OutputPort& operator =(port_data_t value) { 175 | write(value); 176 | return *this; 177 | } 178 | port_data_t read() { 179 | // mask to select bits of interest, then shift so 180 | // that output can be treated as normal integers. 181 | return (port::port_output_read() & mask) >> start_bit; 182 | } 183 | operator port_data_t() { 184 | return read(); 185 | } 186 | 187 | private: 188 | static const port_data_t mask = ((port_data_t(1) << nbits) - 1) << start_bit; 189 | }; 190 | 191 | template 192 | class OutputPort { 193 | // Specialization for a complete MCU output port. 194 | // This simplifies writes, which no longer require 195 | // a read/modify/write cycle. This reduces the 196 | // bit manipulation required, and also eliminates 197 | // the need to disable/reenable interrupts during writes. 198 | public: 199 | OutputPort() { 200 | setup(); 201 | } 202 | 203 | void setup() { 204 | // set port pin directions to output 205 | port::port_enable_outputs(-1); 206 | } 207 | 208 | void write(u8 value) { 209 | port::port_output_write(value); 210 | } 211 | OutputPort& operator =(u8 value) { 212 | write(value); 213 | return *this; 214 | } 215 | u8 read() { 216 | return port::port_output_read(); 217 | } 218 | operator u8() { 219 | return read(); 220 | } 221 | }; 222 | 223 | #else // DIRECTIO_FALLBACK 224 | 225 | // These classes offer compatilbity with alternate Arduino-compatible devices, so 226 | // that libraries can depend on DirectIO without limiting portability. 227 | // These classes delegate to digitalRead and digitalWrite, so they trade off 228 | // performance for portability. 229 | template 230 | class Input { 231 | // An standard digital input. read() returns true if the signal is asserted (high). 232 | public: 233 | Input(boolean pullup=true) { 234 | pinMode(pin, pullup ? INPUT_PULLUP : INPUT); 235 | } 236 | boolean read() { 237 | return digitalRead(pin); 238 | } 239 | operator boolean() { 240 | return read(); 241 | } 242 | }; 243 | 244 | template 245 | class Output { 246 | // A standard digital output 247 | public: 248 | Output(boolean initial_value=LOW) { 249 | pinMode(pin, OUTPUT); 250 | digitalWrite(pin, initial_value); 251 | } 252 | void write(boolean value) { 253 | digitalWrite(pin, value); 254 | } 255 | Output& operator =(boolean value) { 256 | write(value); 257 | return *this; 258 | } 259 | void toggle() { 260 | write(! read()); 261 | } 262 | void pulse(boolean value=HIGH) { 263 | write(value); 264 | write(! value); 265 | } 266 | boolean read() { 267 | return digitalRead(pin); 268 | } 269 | operator boolean() { 270 | return read(); 271 | } 272 | }; 273 | 274 | template 275 | class OutputLow { 276 | // An digital output with direct port I/O 277 | public: 278 | OutputLow(boolean initial_value=HIGH) { 279 | pinMode(pin, OUTPUT); 280 | digitalWrite(pin, initial_value); 281 | } 282 | void write(boolean value) { 283 | digitalWrite(pin, !value); 284 | } 285 | OutputLow& operator =(boolean value) { 286 | write(value); 287 | return *this; 288 | } 289 | void toggle() { 290 | write(! read()); 291 | } 292 | void pulse(boolean value=LOW) { 293 | write(value); 294 | write(! value); 295 | } 296 | boolean read() { 297 | return !digitalRead(pin); 298 | } 299 | operator boolean() { 300 | return read(); 301 | } 302 | }; 303 | 304 | // TODO: fallbacks for InputPort and OutputPort 305 | 306 | #endif // DIRECTIO_FALLBACK 307 | 308 | template 309 | class InputLow { 310 | // An active low digital input. read() returns true if the signal is asserted (low). 311 | public: 312 | InputLow(boolean pullup=true) : input(pullup) {} 313 | boolean read() { 314 | return ! input.read(); 315 | } 316 | operator boolean() { 317 | return read(); 318 | } 319 | 320 | private: 321 | Input input; 322 | }; 323 | 324 | // This macro lets you temporarily set an output to a value, 325 | // and toggling back at the end of the code block. For example: 326 | // 327 | // Output<2> cs; 328 | // Output<3> data; 329 | // with(cs, LOW) { 330 | // data = HIGH; 331 | // } 332 | // 333 | // is equivalent to: 334 | // cs = LOW; 335 | // data = HIGH; 336 | // cs = HIGH; 337 | 338 | #define with(pin, val) for(boolean _loop_##pin=((pin=val),true);_loop_##pin; _loop_##pin=((pin=!val), false)) 339 | 340 | template <> 341 | class Output { 342 | // This specialization of Output is used when a module supports 343 | // an optional pin and that pin is not being used. For example, 344 | // if a chip supports an Output Enable pin but it is wired 345 | // permanently HIGH in the circuit, there won't be an actual 346 | // output pin connected to it. In the software, we will use this 347 | // type of Output which is basically a no-op. 348 | public: 349 | Output(boolean /*initial_value*/=LOW) {} 350 | void write(boolean /*value*/) {} 351 | Output& operator =(boolean /*value*/) { 352 | return *this; 353 | } 354 | void toggle() {} 355 | void pulse(boolean /*value*/=HIGH) {} 356 | 357 | boolean read() { 358 | return LOW; 359 | } 360 | operator boolean() { 361 | return read(); 362 | } 363 | }; 364 | 365 | #endif // _DIRECTIO_H 366 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ### Contents 3 | * [Why use DirectIO?](#user-content-why-use-directio) 4 | * [Comparison](#user-content-comparison) 5 | * [Performance](#user-content-performance) 6 | * [API](#user-content-api) 7 | * [Input](#user-content-input) 8 | * [Output](#user-content-output) 9 | * [Multi-Bit I/O](#user-content-multi-bit-io) 10 | * [InputPort](#user-content-inputport) 11 | * [OutputPort](#user-content-outputport) 12 | * [Active Low Signals](#user-content-active-low-signals) 13 | * [InputLow](#user-content-inputlow) 14 | * [OutputLow](#user-content-outputlow) 15 | * [Pin Numbers Determined at Runtime](#user-content-pin-numbers-determined-at-runtime) 16 | * [InputPin](#user-content-inputpin) 17 | * [OutputPin](#user-content-outputpin) 18 | * [For Arduino IDE 1.0 Users](#user-content-for-arduino-ide-10-users) 19 | * [Supported Boards](#user-content-supported-boards) 20 | 21 | ### Why use DirectIO? 22 | Two reasons: 23 | * Speed: on AVR boards, writes are 20x to 60x faster than the Arduino libraries. Maximum output frequency is 2.66 MHz, vs 64 KHz for the Arduino libraries. When reading or writing multiple I/O together, even greater performance gains are possible - over 200x for an 8-bit I/O port. On SAM-based systems (Due), writes are 17-40x faster than the Arduino libraries. Maximum frequency is 10.5 MHz vs. 237 KHz for the Arduino libraries. 24 | * Simple API: just create pin objects. Assigning to a pin performs a write, using its value performs a read. 25 | 26 | ### Comparison 27 | The standard Arduino I/O library (Wiring) isn't particularly fast. There are several contributing issues, but they primarily stem from pin numbers being specified at runtime. This can be useful, but for the most part, pin numbers are known at compile time. Key differences between native Arduino I/O and DirectIO include: 28 | 29 | | Arduino I/O | DirectIO 30 | |----------------------------|------------ 31 | | Pin numbers are checked for validity at runtime, on every I/O operation. | Validity checked at compile time, based on the target board selected in the Arduino IDE. 32 | | I/O port address and bit mask are read from program memory on every I/O operation | Port and bit mask are determined at compile time, based on the target board. 33 | | Since port addresses are loaded dynamically, indirect load instructions must be used. | Fast I/O instructions (`sbi` and `cbi`) are used by the compiler. 34 | | Because of indirect addressing, digitalWrite must use a multi-instruction read/modify/write sequence. Since this is not atomic, digitalWrite must turn off interrupts and save/restore the status register. | `sbi` and `cbi` instructions execute atomically, so writes don't need to disable interrupts. 35 | | digitalRead and digitalWrite check/disable PWM on the pin, on every I/O operation. | PWM on the pin is disabled at initialization time. 36 | 37 | ### Performance 38 | 39 | #### AVR boards (Nano) 40 | 41 | | | Arduino I/O (AVR) | DirectIO (AVR) 42 | | ---------------------|----------------------------|---------------------------| 43 | | Init Code Size | 6 bytes per I/O | 12 bytes per I/O | 44 | | Input Code Size | 6 bytes per read | 2 bytes per read | 45 | | Output Code Size | 6 bytes per write | 2 bytes to write a constant
10 bytes to write a variable value | 46 | | Time to Write Output | >120 cycles | 2 cycles to write a constant
6 to 8 cycles to write a variable value | 47 | | Max Output Frequency | 64 KHz | 2.66 MHz | 48 | | RAM usage | none | none | 49 | 50 | [Benchmarks](extras/docs/avr_benchmarks.md) 51 | 52 | #### SAM boards (Due) 53 | 54 | | | Arduino I/O (SAM) | DirectIO (SAM) | 55 | | ---------------------|----------------------------|---------------------------| 56 | | Init Code Size | 8 bytes per I/O | 22 bytes per I/O | 57 | | Input Code Size | 6 bytes per read | 8 bytes per read | 58 | | Output Code Size | 6 bytes per write | 8 bytes to write a constant
14 bytes to write a variable value | 59 | | Time to Write Output | >170 cycles | ~5 cycles to write a constant
~10 cycles to write a variable value | 60 | | Max Output Frequency | 237 KHz | 10.5 MHz | 61 | | RAM usage | none | none | 62 | 63 | [Benchmarks](extras/docs/arm_benchmarks.md) 64 | 65 | ### API 66 | 67 | #### Input 68 | 69 | Input is a class template; the template parameter is simply the pin number. You must specify a number that is known at compile time - a literal number, a number specified via `const u8 my_pin = ...`, or via `#define my_pin ...`. 70 | 71 | ```C++ 72 | template class Input { ... }; 73 | ``` 74 | 75 | For example, to create an input on pin 3 and read its value into a variable: 76 | 77 | ```C++ 78 | Input<3> my_input; 79 | boolean value = my_input; // implicit call to read() 80 | boolean value2 = my_input.read(); // or use an explicit call, if you prefer 81 | ``` 82 | 83 | The Input constructor accepts an optional argument `pullup` specifying whether the port pullup resistors should be enabled. 84 | ```C++ 85 | Input<3> my_input(false); // disable internal pullup on this input 86 | ``` 87 | 88 | #### Output 89 | 90 | Simiar to Input, Output is a class template that requires a pin number to be specified. 91 | 92 | ```C++ 93 | template class Output { ... }; 94 | ``` 95 | 96 | For example, to create an output on pin 2 and turn it on: 97 | 98 | ```C++ 99 | Output<2> my_output; 100 | my_output = HIGH; // implicit call to write() 101 | my_output.write(HIGH); // or use an explicit call, if you prefer 102 | ``` 103 | 104 | The Output constructor accepts an optional argument `initial_value` specifying the initial state of the output (HIGH or LOW). 105 | 106 | ```C++ 107 | Output<2> my_output(HIGH); // output should be initially set to HIGH 108 | ``` 109 | 110 | You can also read the current state of an output - no need to keep a separate state variable. Note that this reads back the value from the I/O port; no additional memory is used. 111 | 112 | ```C++ 113 | my_output = ! my_output; // toggle the output 114 | my_output = ! my_output.read(); // this works too, if you like explicit calls 115 | my_output.toggle(); // or use the nice method provided 116 | ``` 117 | 118 | To emit a pulse of minimum duration (2 cycles, or 125 ns on a 16 Mhz board): 119 | 120 | ```C++ 121 | my_output.pulse(HIGH); // set the output HIGH then LOW 122 | ``` 123 | 124 | or 125 | 126 | ```C++ 127 | my_output.pulse(LOW); // set the output LOW then HIGH 128 | ``` 129 | 130 | #### Multi-Bit I/O 131 | 132 | The Arduino standard library works hard to hide the implementation details of digital I/O, and presents a nicer API based on pin numbers. But there are advantages to breaking this model: 133 | * Speed: you can read or write up to 8 pins with a single instruction (32 pins on SAM and SAMD boards). 134 | * Simultaneity: all pins are read or written simultaneously. 135 | 136 | The DirectIO library provides two classes (`InputPort` and `OutputPort`) that allow port-based I/O, mapping part or all of a processor port to a single port object. 137 | 138 | 1. Determine how many pins you need. 139 | 2. Look at the pinout for your Arduino variant, and identify a set of pins that share a common port and are sequentially numbered in that port. Or, look at the pin definitions for your board under `include/boards`. 140 | 3. Wire your project using those pins. 141 | 4. Define an `InputPort` or `OutputPort` object mapped to the selected port and pins. For example, support you are using a 4-bit port and have decided to use Port C2-C5 (in a standard Arduino sketch, these would be referred to as pins 16-19): 142 | 143 | ```C++ 144 | // Define a 4-bit port starting at port C2. 145 | // This will control C2, C3, C4, C5 (pins 16-19). 146 | OutputPort my_port; 147 | 148 | void setup() 149 | { 150 | my_port.setup(); 151 | } 152 | 153 | void loop() 154 | { 155 | // Turn on C2 (pin 16), and turn off the rest. 156 | my_port = 0x01; 157 | } 158 | ``` 159 | 160 | Note the call to `my_port.setup()`; you must call `setup` on each port from your sketch's setup function. This is required for SAM/SAMD boards so that the pin configuration occurs after Arduino initialization. 161 | 162 | ##### InputPort 163 | 164 | InputPort is a class template that takes 3 parameters: 165 | * The port, as defined in `ports.h`. For example, `PORT_D`. Standard Arduinos use `PORT_D`, `PORT_B`, and `PORT_C`. Arduino Mega boards have ports up through `PORT_L`. 166 | * The starting pin number in the port (default 0) 167 | * The number of pins (default 8). 168 | 169 | ``` 170 | template class InputPort { ... } 171 | ``` 172 | 173 | Like Input objects, InputPorts support reading values implicitly or explicitly: 174 | ``` 175 | InputPort my_port; 176 | 177 | void setup() 178 | { 179 | my_port.setup(); 180 | } 181 | 182 | void loop() 183 | { 184 | u8 value = my_port; // implicit call to read() 185 | u8 value2 = my_port.read(); // or use an explicit call, if you prefer 186 | } 187 | ``` 188 | 189 | `read()` places the bits read from the port into the *n* low order bits of the returned value. 190 | 191 | ##### OutputPort 192 | 193 | OutputPort is a class template. The parameters are the same as `InputPort`. 194 | 195 | ``` 196 | template class OutputPort { ... } 197 | ``` 198 | 199 | Like Output objects, OutputPorts support writing values implicitly or explicitly: 200 | ``` 201 | OutputPort my_port; 202 | 203 | void setup() 204 | { 205 | my_port.setup(); 206 | } 207 | 208 | void loop() 209 | { 210 | my_output = 0x07; // implicit call to write() 211 | my_output.write(0x07); // or use an explicit call, if you prefer 212 | } 213 | ``` 214 | 215 | `read()` places the bits read from the port into the *n* low order bits of the returned value. 216 | 217 | #### Active Low Signals 218 | 219 | In some circuits, the meaning of inputs is reversed - for example, a switch input may be LOW when the switch is closed. This is an *active low* input. It can be helpful in program logic to consider LOW as true and HIGH as false. There are two classes that support active low signals. 220 | 221 | ##### InputLow 222 | 223 | Define an active low input on pin 3 and read its value: 224 | 225 | ```C++ 226 | InputLow<3> switch; 227 | 228 | if(switch) { 229 | // this code will execute when the switch is closed, 230 | // and the input voltage is low. 231 | } 232 | else { 233 | // this code will execute when the switch is open, 234 | // and the input voltage is high. 235 | } 236 | ``` 237 | 238 | 239 | ##### OutputLow 240 | 241 | Suppose we have the cathode of an LED connected to pin 2 (the anode would be connected to +5V through a current limiting resistor). We can define an active low output on pin 2 to control it: 242 | 243 | ```C++ 244 | OutputLow<2> led; 245 | led = true; // turns on the LED by putting low voltage on pin 2 246 | ``` 247 | 248 | We could do the same thing with a normal Output if we didn't mind the backward logic: 249 | 250 | ```C++ 251 | Output<2> led; 252 | led = false; // turns on the LED by putting low voltage on pin 2 253 | ``` 254 | 255 | #### Pin Numbers Determined at Runtime 256 | 257 | Like the easy to use syntax for reading and writing values, but have a case where you really don't know the pin number at compile time? For example, you might define a multi-pin output port and loop over a range of pin numbers writing values to each one. There are two classes that support this: 258 | 259 | ##### InputPin 260 | 261 | ```C++ 262 | boolean DoSomething(u8 pin) 263 | { 264 | InputPin my_input(pin); // note pin number is now a constructor parameter 265 | return my_input; 266 | } 267 | ``` 268 | 269 | `InputPin` looks up and caches the port address and bit mask (using 3 bytes of RAM per instance), in order to boost performance over digitalRead on AVR boards. On SAM/SAMD boards, this class currently delegates to `digitalRead` so there is no speedup. 270 | 271 | ##### OutputPin 272 | 273 | ```C++ 274 | void DoSomething(u8 pin) 275 | { 276 | OutputPin my_output(pin); // note pin number is now a constructor parameter 277 | my_output = HIGH; 278 | } 279 | ``` 280 | 281 | `OutputPin` looks up and caches the port address and bit mask (using 8 bytes of RAM per instance), in order to gain a 3x speedup over digitalWrite on AVR boards. On SAM/SAMD boards, this class currently delegates to `digitalWrite` so there is no speedup. 282 | 283 | #### For Arduino IDE 1.0 Users 284 | In order to map the pin numbers you specify into AVR ports, you need to tell the Direct IO library which Arduino board type you are using. If you are using Arduino IDE v1.5 or higher, the IDE will do this automatically based on the board selected in the Board menu. If you are using IDE 1.0, you will need to define which board you are using. For example, if you have an Uno board: 285 | ```C++ 286 | #define ARDUINO_AVR_UNO 1 287 | #include 288 | ``` 289 | 290 | If you omit this step, you will see a warning during compilation, and a standard Arduino board will be assumed: 291 | ``` 292 | error: #warning "Unsupported Arduino AVR variant. If you are using Arduino IDE 1.0, be sure to #define an Arduino variant (e.g. #define ARDUINO_AVR_UNO 1). See ports.h." 293 | ``` 294 | 295 | ### Supported Boards 296 | Supported Arduino variants include boards with AVR, SAM, and SAMD processors. 297 | 298 | * AVR board variants: 299 | ``` 300 | ARDUINO_AVR_ADAFRUIT32U4 301 | ARDUINO_AVR_ADK 302 | ARDUINO_AVR_ATMEL_ATMEGA168PB_XMINI 303 | ARDUINO_AVR_ATMEL_ATMEGA328PB_XMINI 304 | ARDUINO_AVR_ATMEL_ATMEGA328P_XMINI 305 | ARDUINO_AVR_BLUEFRUITMICRO 306 | ARDUINO_AVR_BT 307 | ARDUINO_AVR_CIRCUITPLAY 308 | ARDUINO_AVR_DIGITAL_SANDBOX 309 | ARDUINO_AVR_DUEMILANOVE 310 | ARDUINO_AVR_EMORO_2560 311 | ARDUINO_AVR_ESPLORA 312 | ARDUINO_AVR_ETHERNET 313 | ARDUINO_AVR_FEATHER328P 314 | ARDUINO_AVR_FEATHER32U4 315 | ARDUINO_AVR_FIO 316 | ARDUINO_AVR_FIOV3 317 | ARDUINO_AVR_FLORA8 318 | ARDUINO_AVR_GEMMA 319 | ARDUINO_AVR_INDUSTRIAL101 320 | ARDUINO_AVR_ITSYBITSY32U4_3V 321 | ARDUINO_AVR_ITSYBITSY32U4_5V 322 | ARDUINO_AVR_LEONARDO 323 | ARDUINO_AVR_LEONARDO_ETH 324 | ARDUINO_AVR_LILYPAD 325 | ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD 326 | ARDUINO_AVR_LILYPAD_USB 327 | ARDUINO_AVR_LININO_ONE 328 | ARDUINO_AVR_MAKEYMAKEY 329 | ARDUINO_AVR_MEGA 330 | ARDUINO_AVR_MEGA2560 331 | ARDUINO_AVR_METRO 332 | ARDUINO_AVR_MICRO 333 | ARDUINO_AVR_MINI 334 | ARDUINO_AVR_NANO 335 | ARDUINO_AVR_NG 336 | ARDUINO_AVR_OLIMEXINO_328 337 | ARDUINO_AVR_OLIMEXINO_32U4 338 | ARDUINO_AVR_OLIMEXINO_85 339 | ARDUINO_AVR_OLIMEXINO_Nano 340 | ARDUINO_AVR_PRO 341 | ARDUINO_AVR_PROMICRO 342 | ARDUINO_AVR_PROTRINKET3 343 | ARDUINO_AVR_PROTRINKET3FTDI 344 | ARDUINO_AVR_PROTRINKET5 345 | ARDUINO_AVR_PROTRINKET5FTDI 346 | ARDUINO_AVR_QDUINOMINI 347 | ARDUINO_AVR_RGB_GLASSES 348 | ARDUINO_AVR_ROBOT_CONTROL 349 | ARDUINO_AVR_ROBOT_MOTOR 350 | ARDUINO_AVR_SERIAL_7_SEGMENT 351 | ARDUINO_AVR_TRINKET3 352 | ARDUINO_AVR_TRINKET5 353 | ARDUINO_AVR_UNO 354 | ARDUINO_AVR_UNO_WIFI_DEV_ED 355 | ARDUINO_AVR_YUN 356 | ARDUINO_AVR_YUNMINI 357 | ``` 358 | 359 | * SAM variants: 360 | 361 | ``` 362 | ARDUINO_SAM_DUE 363 | ``` 364 | 365 | * SAMD variants: 366 | 367 | ``` 368 | ARDUINO_SAMD_ADI 369 | ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS 370 | ARDUINO_SAMD_FEATHER_M0_EXPRESS 371 | ARDUINO_SAMD_HALLOWING 372 | ARDUINO_SAMD_INDUSTRUINO_D21G 373 | ARDUINO_SAMD_MKR1000 374 | ARDUINO_SAMD_MKRFox1200 375 | ARDUINO_SAMD_MKRGSM1400 376 | ARDUINO_SAMD_MKRWAN1300 377 | ARDUINO_SAMD_MKRWIFI1010 378 | ARDUINO_SAMD_MKRZERO 379 | ARDUINO_SAMD_SMARTEVERYTHING_DRAGONFLY 380 | ARDUINO_SAMD_SMARTEVERYTHING_FOX 381 | ARDUINO_SAMD_SMARTEVERYTHING_LION 382 | ARDUINO_SAMD_TIAN 383 | ARDUINO_SAMD_ZERO 384 | ARDUINO_SAM_ZERO 385 | ADAFRUIT_METRO_M0_EXPRESS 386 | ADAFRUIT_FEATHER_M0 387 | SparkFun_SAMD21_Dev 388 | SparkFun_SAMD_Mini 389 | SparkFun_LilyMini 390 | SparkFun_9DoF_M0 391 | SparkFun_ProRF 392 | ``` 393 | 394 | SAMD testing was done on a `SparkFun_SAMD_Mini`. If you use a different board, please open an issue if you encounter any problems (and please report successful tests as well). All of the boards use the same code, but different pin mappings. 395 | 396 | Other boards can be used in a fallback mode, with some limitations: 397 | * DirectIO will not provide any acceleration. Internally, it will call `digitalRead` and `digitalWrite`. 398 | * `InputPort` and `OutputPort` classes are not defined at this time. 399 | --------------------------------------------------------------------------------