Skip to content

Add support for Arduino MKRZero #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2016

Conversation

sandeepmistry
Copy link
Contributor

Adds support for the new Arduino MKRZero board.

This board has some gaps in the usable pins, the built-in LED is on pin 32 and the ADC for the battery is on pin 33. Pins 22 - 31 are used for USB, AREF, the SD card reader (SPI), and a pad on the bottom of the board.

@sandeepmistry
Copy link
Contributor Author

I forgot to mention, this will work with the next SAMD core release. As the v1.6.9 release of the SAMD core incorrectly has the board define for the MKRZero set to MKR1000 (arduino/ArduinoCore-samd@84ccd31).

cc/ @cmaglie

#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS) // deprecated since v2.4
#define IS_PIN_I2C(p) ((p) == 11 || (p) == 12) // SDA = 11, SCL = 12
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define IS_PIN_SERIAL(p) ((p) == PIN_SERIAL1_RX || (p) == PIN_SERIAL1_TX) //defined in variant.h RX = 13, TX = 14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do PIN_SERIAL1_RX and _TX correlate to Serial or Serial1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serial1 just like the MKR1000, Serial correlates to native USB.

// Arduino MKRZero
#elif defined(ARDUINO_SAMD_MKRZERO)
#define TOTAL_ANALOG_PINS 7
#define TOTAL_PINS 34 // 8 digital + 3 spi + 2 i2c + 2 uart + 7 analog + 3 usb + 1 aref + 5 sd + 1 bottom pad + 1 led + 1 battery adc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that this number is the highest addressable pin number rather than the total number of usable pins. The name TOTAL_PINS is actually misleading for this reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkrzero/variant.cpp has entries for a 32768Hz crystal on pins 34 and 35, but I don't think Firmata users need to access them (MKR1000 also has those entries).

So the highest pin number that needs to be addressed is 33 for the Battery voltage ADC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. 34 is correct then since TOTAL_PINS would be last addressable pin number + 1 (because pin count starts at 0).

@soundanalogous
Copy link
Member

Thanks for the PR. This is super helpful!

@soundanalogous soundanalogous merged commit ae028fb into firmata:master Dec 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants