Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

See file LICENSE.txt for further informations on licensing terms.

Last updated November 5th, 2015
Last updated December 19th, 2015
*/

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


// Arduino 101
#elif defined(_VARIANT_ARDUINO_101_X_)
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS
#define TOTAL_PINS NUM_DIGITAL_PINS // 15 digital (including ATN pin) + 6 analog
#define VERSION_BLINK_PIN LED_BUILTIN
#define PIN_SERIAL1_RX 0
#define PIN_SERIAL1_TX 1
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 20)
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
#define IS_PIN_PWM(p) digitalPinHasPWM(p) // 3, 5, 6, 9
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) // SDA = 18, SCL = 19
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define IS_PIN_SERIAL(p) ((p) == 0 || (p) == 1)
#define PIN_TO_DIGITAL(p) (p)
#define PIN_TO_ANALOG(p) ((p) - 14)
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4


// Teensy 1.0
#elif defined(__AVR_AT90USB162__)
#define TOTAL_ANALOG_PINS 0
Expand Down
5 changes: 5 additions & 0 deletions Firmata.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

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

// Arduino 101 also defines SET_PIN_MODE as a macro in scss_registers.h
#ifdef SET_PIN_MODE
#undef SET_PIN_MODE
#endif

// message command bytes (128-255/0x80-0xFF)
#define DIGITAL_MESSAGE 0x90 // send data for a digital port (collection of 8 pins)
#define ANALOG_MESSAGE 0xE0 // send data for an analog pin (or PWM)
Expand Down
2 changes: 1 addition & 1 deletion examples/StandardFirmata/StandardFirmata.ino
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void setup()

Firmata.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Only needed for ATmega32u4-based boards (Leonardo, etc).
; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101
}
systemResetCallback(); // reset to default config
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

See file LICENSE.txt for further informations on licensing terms.

Last updated by Jeff Hoefs: December 9th, 2015
Last updated by Jeff Hoefs: December 19th, 2015
*/

/*
Expand Down Expand Up @@ -59,10 +59,10 @@
#include <Wire.h>
#include <Firmata.h>

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

if (portId > 7 && argc > 4) {
rxPin = argv[4];
txPin = argv[5];
swRxPin = argv[4];
swTxPin = argv[5];
}

if (portId < 8) {
Expand All @@ -885,29 +885,29 @@ void sysexCallback(byte command, byte argc, byte *argv)
switch (portId) {
case SW_SERIAL0:
if (swSerial0 == NULL) {
swSerial0 = new SoftwareSerial(rxPin, txPin);
swSerial0 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL1:
if (swSerial1 == NULL) {
swSerial1 = new SoftwareSerial(rxPin, txPin);
swSerial1 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL2:
if (swSerial2 == NULL) {
swSerial2 = new SoftwareSerial(rxPin, txPin);
swSerial2 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL3:
if (swSerial3 == NULL) {
swSerial3 = new SoftwareSerial(rxPin, txPin);
swSerial3 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
}
serialPort = getPortFromId(portId);
if (serialPort != NULL) {
setPinModeCallback(rxPin, PIN_MODE_SERIAL);
setPinModeCallback(txPin, PIN_MODE_SERIAL);
setPinModeCallback(swRxPin, PIN_MODE_SERIAL);
setPinModeCallback(swTxPin, PIN_MODE_SERIAL);
((SoftwareSerial*)serialPort)->begin(baud);
}
#endif
Expand Down
28 changes: 14 additions & 14 deletions examples/StandardFirmataPlus/StandardFirmataPlus.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

See file LICENSE.txt for further informations on licensing terms.

Last updated by Jeff Hoefs: December 9th, 2015
Last updated by Jeff Hoefs: December 19th, 2015
*/

/*
Expand All @@ -45,10 +45,10 @@
#include <Wire.h>
#include <Firmata.h>

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

if (portId > 7 && argc > 4) {
rxPin = argv[4];
txPin = argv[5];
swRxPin = argv[4];
swTxPin = argv[5];
}

if (portId < 8) {
Expand All @@ -821,29 +821,29 @@ void sysexCallback(byte command, byte argc, byte *argv)
switch (portId) {
case SW_SERIAL0:
if (swSerial0 == NULL) {
swSerial0 = new SoftwareSerial(rxPin, txPin);
swSerial0 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL1:
if (swSerial1 == NULL) {
swSerial1 = new SoftwareSerial(rxPin, txPin);
swSerial1 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL2:
if (swSerial2 == NULL) {
swSerial2 = new SoftwareSerial(rxPin, txPin);
swSerial2 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
case SW_SERIAL3:
if (swSerial3 == NULL) {
swSerial3 = new SoftwareSerial(rxPin, txPin);
swSerial3 = new SoftwareSerial(swRxPin, swTxPin);
}
break;
}
serialPort = getPortFromId(portId);
if (serialPort != NULL) {
setPinModeCallback(rxPin, PIN_MODE_SERIAL);
setPinModeCallback(txPin, PIN_MODE_SERIAL);
setPinModeCallback(swRxPin, PIN_MODE_SERIAL);
setPinModeCallback(swTxPin, PIN_MODE_SERIAL);
((SoftwareSerial*)serialPort)->begin(baud);
}
#endif
Expand Down Expand Up @@ -1051,7 +1051,7 @@ void setup()

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