Skip to content

Commit 56f5d5e

Browse files
add Arduino 101
1 parent 8686cb6 commit 56f5d5e

File tree

5 files changed

+54
-29
lines changed

5 files changed

+54
-29
lines changed

Boards.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
See file LICENSE.txt for further informations on licensing terms.
1111
12-
Last updated November 5th, 2015
12+
Last updated December 19th, 2015
1313
*/
1414

1515
#ifndef Firmata_Boards_h
@@ -265,6 +265,26 @@ writePort(port, value, bitmask): Write an 8 bit port.
265265
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4
266266

267267

268+
// Arduino 101
269+
#elif defined(_VARIANT_ARDUINO_101_X_)
270+
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS
271+
#define TOTAL_PINS NUM_DIGITAL_PINS // 15 digital (including ATN pin) + 6 analog
272+
#define VERSION_BLINK_PIN LED_BUILTIN
273+
#define PIN_SERIAL1_RX 0
274+
#define PIN_SERIAL1_TX 1
275+
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 20)
276+
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
277+
#define IS_PIN_PWM(p) digitalPinHasPWM(p) // 3, 5, 6, 9
278+
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4
279+
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) // SDA = 18, SCL = 19
280+
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
281+
#define IS_PIN_SERIAL(p) ((p) == 0 || (p) == 1)
282+
#define PIN_TO_DIGITAL(p) (p)
283+
#define PIN_TO_ANALOG(p) ((p) - 14)
284+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
285+
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4
286+
287+
268288
// Teensy 1.0
269289
#elif defined(__AVR_AT90USB162__)
270290
#define TOTAL_ANALOG_PINS 0

Firmata.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
#define MAX_DATA_BYTES 64 // max number of data bytes in incoming messages
2727

28+
// Arduino 101 also defines SET_PIN_MODE as a macro in scss_registers.h
29+
#ifdef SET_PIN_MODE
30+
#undef SET_PIN_MODE
31+
#endif
32+
2833
// message command bytes (128-255/0x80-0xFF)
2934
#define DIGITAL_MESSAGE 0x90 // send data for a digital port (collection of 8 pins)
3035
#define ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void setup()
743743

744744
Firmata.begin(57600);
745745
while (!Serial) {
746-
; // wait for serial port to connect. Only needed for ATmega32u4-based boards (Leonardo, etc).
746+
; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101
747747
}
748748
systemResetCallback(); // reset to default config
749749
}

examples/StandardFirmataEthernetPlus/StandardFirmataEthernetPlus.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated by Jeff Hoefs: December 9th, 2015
23+
Last updated by Jeff Hoefs: December 19th, 2015
2424
*/
2525

2626
/*
@@ -59,10 +59,10 @@
5959
#include <Wire.h>
6060
#include <Firmata.h>
6161

62-
// SoftwareSerial is only supported for AVR-based boards
63-
// The second condition checks if the IDE is in the 1.0.x series, if so, include SoftwareSerial
62+
// SoftwareSerial is currently only supported for AVR-based boards and the Arduino 101
63+
// The third condition checks if the IDE is in the 1.0.x series, if so, include SoftwareSerial
6464
// since it should be available to all boards in that IDE.
65-
#if defined(ARDUINO_ARCH_AVR) || (ARDUINO >= 100 && ARDUINO < 10500)
65+
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ARC32) || (ARDUINO >= 100 && ARDUINO < 10500)
6666
#include <SoftwareSerial.h>
6767
#endif
6868
#include "utility/serialUtils.h"
@@ -859,12 +859,12 @@ void sysexCallback(byte command, byte argc, byte *argv)
859859
case SERIAL_CONFIG:
860860
{
861861
long baud = (long)argv[1] | ((long)argv[2] << 7) | ((long)argv[3] << 14);
862-
byte txPin, rxPin;
862+
byte swTxPin, swRxPin;
863863
serial_pins pins;
864864

865865
if (portId > 7 && argc > 4) {
866-
rxPin = argv[4];
867-
txPin = argv[5];
866+
swRxPin = argv[4];
867+
swTxPin = argv[5];
868868
}
869869

870870
if (portId < 8) {
@@ -885,29 +885,29 @@ void sysexCallback(byte command, byte argc, byte *argv)
885885
switch (portId) {
886886
case SW_SERIAL0:
887887
if (swSerial0 == NULL) {
888-
swSerial0 = new SoftwareSerial(rxPin, txPin);
888+
swSerial0 = new SoftwareSerial(swRxPin, swTxPin);
889889
}
890890
break;
891891
case SW_SERIAL1:
892892
if (swSerial1 == NULL) {
893-
swSerial1 = new SoftwareSerial(rxPin, txPin);
893+
swSerial1 = new SoftwareSerial(swRxPin, swTxPin);
894894
}
895895
break;
896896
case SW_SERIAL2:
897897
if (swSerial2 == NULL) {
898-
swSerial2 = new SoftwareSerial(rxPin, txPin);
898+
swSerial2 = new SoftwareSerial(swRxPin, swTxPin);
899899
}
900900
break;
901901
case SW_SERIAL3:
902902
if (swSerial3 == NULL) {
903-
swSerial3 = new SoftwareSerial(rxPin, txPin);
903+
swSerial3 = new SoftwareSerial(swRxPin, swTxPin);
904904
}
905905
break;
906906
}
907907
serialPort = getPortFromId(portId);
908908
if (serialPort != NULL) {
909-
setPinModeCallback(rxPin, PIN_MODE_SERIAL);
910-
setPinModeCallback(txPin, PIN_MODE_SERIAL);
909+
setPinModeCallback(swRxPin, PIN_MODE_SERIAL);
910+
setPinModeCallback(swTxPin, PIN_MODE_SERIAL);
911911
((SoftwareSerial*)serialPort)->begin(baud);
912912
}
913913
#endif

examples/StandardFirmataPlus/StandardFirmataPlus.ino

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated by Jeff Hoefs: December 9th, 2015
23+
Last updated by Jeff Hoefs: December 19th, 2015
2424
*/
2525

2626
/*
@@ -45,10 +45,10 @@
4545
#include <Wire.h>
4646
#include <Firmata.h>
4747

48-
// SoftwareSerial is only supported for AVR-based boards
49-
// The second condition checks if the IDE is in the 1.0.x series, if so, include SoftwareSerial
48+
// SoftwareSerial is currently only supported for AVR-based boards and the Arduino 101
49+
// The third condition checks if the IDE is in the 1.0.x series, if so, include SoftwareSerial
5050
// since it should be available to all boards in that IDE.
51-
#if defined(ARDUINO_ARCH_AVR) || (ARDUINO >= 100 && ARDUINO < 10500)
51+
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ARC32) || (ARDUINO >= 100 && ARDUINO < 10500)
5252
#include <SoftwareSerial.h>
5353
#endif
5454
#include "utility/serialUtils.h"
@@ -795,12 +795,12 @@ void sysexCallback(byte command, byte argc, byte *argv)
795795
case SERIAL_CONFIG:
796796
{
797797
long baud = (long)argv[1] | ((long)argv[2] << 7) | ((long)argv[3] << 14);
798-
byte txPin, rxPin;
798+
byte swTxPin, swRxPin;
799799
serial_pins pins;
800800

801801
if (portId > 7 && argc > 4) {
802-
rxPin = argv[4];
803-
txPin = argv[5];
802+
swRxPin = argv[4];
803+
swTxPin = argv[5];
804804
}
805805

806806
if (portId < 8) {
@@ -821,29 +821,29 @@ void sysexCallback(byte command, byte argc, byte *argv)
821821
switch (portId) {
822822
case SW_SERIAL0:
823823
if (swSerial0 == NULL) {
824-
swSerial0 = new SoftwareSerial(rxPin, txPin);
824+
swSerial0 = new SoftwareSerial(swRxPin, swTxPin);
825825
}
826826
break;
827827
case SW_SERIAL1:
828828
if (swSerial1 == NULL) {
829-
swSerial1 = new SoftwareSerial(rxPin, txPin);
829+
swSerial1 = new SoftwareSerial(swRxPin, swTxPin);
830830
}
831831
break;
832832
case SW_SERIAL2:
833833
if (swSerial2 == NULL) {
834-
swSerial2 = new SoftwareSerial(rxPin, txPin);
834+
swSerial2 = new SoftwareSerial(swRxPin, swTxPin);
835835
}
836836
break;
837837
case SW_SERIAL3:
838838
if (swSerial3 == NULL) {
839-
swSerial3 = new SoftwareSerial(rxPin, txPin);
839+
swSerial3 = new SoftwareSerial(swRxPin, swTxPin);
840840
}
841841
break;
842842
}
843843
serialPort = getPortFromId(portId);
844844
if (serialPort != NULL) {
845-
setPinModeCallback(rxPin, PIN_MODE_SERIAL);
846-
setPinModeCallback(txPin, PIN_MODE_SERIAL);
845+
setPinModeCallback(swRxPin, PIN_MODE_SERIAL);
846+
setPinModeCallback(swTxPin, PIN_MODE_SERIAL);
847847
((SoftwareSerial*)serialPort)->begin(baud);
848848
}
849849
#endif
@@ -1051,7 +1051,7 @@ void setup()
10511051

10521052
Firmata.begin(57600);
10531053
while (!Serial) {
1054-
; // wait for serial port to connect. Only needed for ATmega32u4-based boards (Leonardo, etc).
1054+
; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101
10551055
}
10561056
systemResetCallback(); // reset to default config
10571057
}

0 commit comments

Comments
 (0)