Arduino Zero - full access

Hey folks,

I got a few questions concerning the Arduino Zero. I designed my own circuit board but used the same micro-controller (SAMD21G18) that is embedded on the Arduino Zero. Now, I would like to use the same Arduino Zero libraries but on a completely different pin map. (I am aware that pins possess a multitude of functions which change from pin to pin; I carefully studied the datasheet and ensured that my pins can cope with my peripherals.) I also possess a JLink programmer which allows me to program the SAMD. My question is really about using the Arduino Zero libraries with custom hardware that has different pin configurations than the Arduino Zero development board. Therefore my questions are:

  • Where are the SAMD21G18 specific header files declaring the pin configuration of the Arduino Zero development board?
  • Can I make changes to the pin definitions in the header file and still expect to use the libraries without modifying them? or
  • Are some libraries pin specific to the development board?

I appreciate your support. Kindest regards.

Where are the SAMD21G18 specific header files declaring the pin configuration of the Arduino Zero development board?

The arduino specific pin configs are in ArduinoCore-samd/variants at master · arduino/ArduinoCore-samd · GitHub (this will show up inside the samd "package" on your system, usually in some hidden "library" directory mandated by modern desktop OSes. Inspect the verbose compilation output to see exactly where it is.)

Can I make changes to the pin definitions in the header file and still expect to use the libraries without modifying them? or

It depends on which libraries. Many will work; there are in fact SAMD21 boards with somewhat different pinouts.
Moving SPI or Serial to a different SerCom port might be "risky", and an occasional library might have even greater dependencies... The builtin Rx/Tx LEDs for USB comm might be a problem.
OTOH, Adafruit just ported the whole thing to a 64-pin SAMD51, and others have done "other SAMDxx" parts. many of the libraries are common to SAMD, SAM3, AVR, and more...

Are some libraries pin specific to the development board?

I feel pretty confident in saying "some libraries are awful and overly dependent on the Zero layout."
I have no idea which ones. If you're talking about the Core Arduino-provided libraries, such incompatibilities MIGHT get treated as bugs by "the powers that be."

Hopefully most libraries would use the standard SCK, MOSI, MISO names to identify SPI pins rather than specific numbers. The problem I see is with the CS pin changing.

I think it's best to always use an existing pin mapping unless you have a very good reason not to. Writing a custom variant is work. Maintaining a custom variant and the hardware package to go with it is work. Why not take advantage of the hard work someone else already did/does for you? The large number of pin mappings for the ATmega1284P is a real problem for the Arduino community. Compare that to the boards using ATmega328P (and family), which all use the same standard pin mapping created by Arduino.

Thank you for your responses. I think I made my mind up. If I want to use Arduino libraries on customized hardware, I better stick to the development board's pin mapping. It seems too much of a hassle to make changes to the pin definitions and libraries. The risk to create incomplete and buggy libraries is by far too high.

Cheers guys.