mikaelpatel / Arduino-Scheduler

Portable Cooperative Multi-tasking Scheduler for Arduino
https://mikaelpatel.github.io/Arduino-Scheduler/
164 stars 41 forks source link

SAMD compatibility #4

Closed malachib closed 8 years ago

malachib commented 8 years ago

If you're at all interested. Pretty minimal and incomplete changes

mikaelpatel commented 8 years ago

Is this specifically for the Sparkfun or does it also apply for Arduino Zero?

malachib commented 8 years ago

This is specifically on the Sparkfun; I bet this will work with the Zero provided you've got it connected to the right USB plug.

mikaelpatel commented 8 years ago

Then it might also apply to the Arduino Due when using the Native USB port. Is there a specific board target symbol defined for the Sparkfun (a board.txt)? Or does it simply use the Zero board settings?

mikaelpatel commented 8 years ago

I have downloaded and installed the board support for Sparkfun SAMD21. Unfortunately there is no easy way detect this board. Using ARDUINO_ARCH_SAMD will give some conflicts for Arduino Zero (which should not have an issue with Serial as that is Programming Port, same as Arduino Due).

mikaelpatel commented 8 years ago

Please see commit https://github.com/mikaelpatel/Arduino-Scheduler/commit/5db5edf778e891ad053ea1255823e559b8c4d0bd. To force check of SparkFun I had to come up with the following test.

#if defined(ARDUINO_ARCH_SAMD) && (USB_PID == 0x8D21)
#define Serial SerialUSB
#endif

All example sketches (with Serial) are updated in the commit.

malachib commented 8 years ago

My understanding is interfacing with the zero is done in either of two ways, either by its native port or programming port. The Sparkfun device is like using the Zero with only the native port - I program mine with the zeroUSB platformio.org profile see ref: (http://docs.platformio.org/en/latest/platforms/atmelsam.html)

Being that one can physically use either port on the Zero, I could see the difficulty in autodetecting how to compile. Whether you compile target native or programming in Arduino IDE, both assign PID as 0x804d and define the same #define's including USBCON.