Skip to content

Commit 3b748e8

Browse files
add Boards.h definition for Arduino Zero
1 parent b7a5b1a commit 3b748e8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Boards.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,29 @@ writePort(port, value, bitmask): Write an 8 bit port.
242242
#define PIN_TO_SERVO(p) ((p) - 2)
243243

244244

245+
// Arduino Zero
246+
// Note this will work with an Arduino Zero Pro, but not with an Arduino M0 Pro
247+
// Arduino M0 Pro does not properly map pins to the board labeled pin numbers
248+
#elif defined(_VARIANT_ARDUINO_ZERO_)
249+
#define TOTAL_ANALOG_PINS 6
250+
#define TOTAL_PINS 25 // 14 digital + 6 analog + 2 i2c + 3 spi
251+
#define TOTAL_PORTS 3 // set when TOTAL_PINS > num digitial I/O pins
252+
#define VERSION_BLINK_PIN LED_BUILTIN
253+
#define DAC_RESOLUTION 10
254+
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 19)
255+
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
256+
#define IS_PIN_PWM(p) (digitalPinHasPWM(p) || (p) == 14) // use DAC0 as a PWM pin
257+
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4
258+
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) // SDA = 20, SCL = 21
259+
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK) // SS = A2
260+
#define IS_PIN_SERIAL(p) ((p) == 0 || (p) == 1)
261+
#define IS_PIN_DAC(p) ((p) == 14)
262+
#define PIN_TO_DIGITAL(p) (p)
263+
#define PIN_TO_ANALOG(p) ((p) - 14)
264+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
265+
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4
266+
267+
245268
// Teensy 1.0
246269
#elif defined(__AVR_AT90USB162__)
247270
#define TOTAL_ANALOG_PINS 0
@@ -575,6 +598,11 @@ writePort(port, value, bitmask): Write an 8 bit port.
575598
#define IS_PIN_SERIAL(p) 0
576599
#endif
577600

601+
#ifndef IS_PIN_DAC
602+
#define IS_PIN_DAC(p) 0
603+
#define DAC_RESOLUTION 8
604+
#endif
605+
578606
/*==============================================================================
579607
* readPort() - Read an 8 bit port
580608
*============================================================================*/

0 commit comments

Comments
 (0)