Skip to content

Added support for Arduino Primo board #360

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
Mar 16, 2017

Conversation

chiararuggeri
Copy link

Hi,
I'm the software developer of the Arduino Primo board. I would like to add the support for this board in your library.
Thanks.

@soundanalogous
Copy link
Member

Do you have a link to the pins_arduino.h file and other pin definitions for the Primo?

Boards.h Outdated
@@ -299,6 +299,22 @@ writePort(port, value, bitmask): Write an 8 bit port.
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p) (p) // deprecated since v2.4

// Arduino Primo
#elif defined(NRF52)
Copy link
Member

@soundanalogous soundanalogous Mar 14, 2017

Choose a reason for hiding this comment

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

Use a more specific name than NRF52, otherwise this block may be defined for other NRF52-based boards in the future. I assume there is a define like "ARDUINO_ARCH_PRIMO" for this board (where "ARCH" should be substituted for the appropriate architecture for this board).

Boards.h Outdated
// Arduino Primo
#elif defined(NRF52)
#define TOTAL_ANALOG_PINS 6
#define TOTAL_PINS 22 //14 digital + 6 analog + 2 i2c
Copy link
Member

Choose a reason for hiding this comment

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

fix the indent here, and for IS_PIN_SPI and IS_PIN_SERIAL

@soundanalogous
Copy link
Member

This will simply add Firmata support for the Primo over a serial transport. A good next step would be to add it to StandardFirmataWiFi and StandardFirmataBLE (separate PRs for each).

@soundanalogous
Copy link
Member

I found the variant.h file.

Boards.h Outdated
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS+2)
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21)
#define IS_PIN_SPI(p) ((p)== MOSI || (p) == MISO || (p == SCK)) // 11, 12, 13
#define IS_PIN_SERIAL(p) ((p) == 0 || (p) == 1)
Copy link
Member

Choose a reason for hiding this comment

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

Do pins 0 and 1 map to Serial or Serial1?

Boards.h Outdated
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS+2)
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21)
#define IS_PIN_SPI(p) ((p)== MOSI || (p) == MISO || (p == SCK)) // 11, 12, 13
Copy link
Member

Choose a reason for hiding this comment

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

Based on variant.h, SPI pins are 27, 24, 26 respectively rather than 11, 12, 13

@chiararuggeri
Copy link
Author

I've added some of the fixes you requested. Regarding SPI pins, they are both 11, 12, 13 and 24, 26, 27. They are the same pins, enumerated twice (one for pin header and one for ICSP connector). Anyway if you prefer I will change them.
In Arduino Primo there is just one Serial connected to 0 and 1 pins. There is no Serial1 port.
Let me know if other modifications are needed.
Thanks

Boards.h Outdated
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS+2)
#define IS_PIN_I2C(p) ((p) == PIN_WIRE_SDA || (p) == PIN_WIRE_SCL) // SDA = 20, SCL = 21
#define IS_PIN_SPI(p) ((p)== MOSI || (p) == MISO || (p == SCK)) // 11, 12, 13
#define IS_PIN_SERIAL(p) ((p) == 0 || (p) == 1)
Copy link
Member

Choose a reason for hiding this comment

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

Remove the IS_PIN_SERIAL macro. This is for the Firmata Serial feature, but it's currently only support for Serial1, Serial2 and Serial3.

@soundanalogous
Copy link
Member

You can keep the SPI pins documented as 11, 12 and 13. This is helpful actually since that was not clear by looking at the variant.h file.

@soundanalogous
Copy link
Member

Also add a comment on the SPI line that SS = 10

@chiararuggeri
Copy link
Author

I've added the SS pin definition that I've forgotten. Missing something else?

@soundanalogous
Copy link
Member

That's it. If you comfortable squashing commits it would be nice to have those 6 commits squashed to a single commit. However if you're not familiar with that process, don't worry about it as it can be tricky.

@chiararuggeri
Copy link
Author

Squashed. Thank you for the support.

@soundanalogous
Copy link
Member

Thank you for your contribution.

@soundanalogous soundanalogous merged commit 260f127 into firmata:master Mar 16, 2017
@chiararuggeri chiararuggeri deleted the ArduinoPrimo branch March 17, 2017 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants