arduino icon indicating copy to clipboard operation
arduino copied to clipboard

Adafruit Metro M4 (SAMD51) support

Open Dorme opened this issue 6 years ago • 6 comments

Hi guys,

Is it possible to implement support for the Adafruit Metro M4 board (https://www.adafruit.com/product/3382)? I'm trying to edit the boards.h file, but I keep on getting the error: "Please edit Boards.h with a hardware abstraction for this board".

#elif defined(ADAFRUIT_METRO_M4__SAMD51_)

Dorme avatar Jan 23 '19 14:01 Dorme

Can you provide a link to the pins_arduino.h and variant.h files for this board?

soundanalogous avatar Jan 23 '19 16:01 soundanalogous

I was able to solve the error I received: #elif defined(_VARIANT_METRO_M4_)

Tried to complete the rest of the boards.h file:

#elif defined(_VARIANT_METRO_M4_)
#define TOTAL_ANALOG_PINS       NUM_ANALOG_INPUTS // 8
#define TOTAL_PINS              NUM_DIGITAL_PINS // 20
#define VERSION_BLINK_PIN       LED_BUILTIN // 13
#define IS_PIN_DIGITAL(p)       ((p) >= 0 && (p) <= 13) // 0..13 - Digital pins
#define IS_PIN_ANALOG(p)        ((p) >= 14 && (p) < 19) // 14..19 - Analog pins
#define IS_PIN_PWM(p)           (IS_PIN_DIGITAL(p) && digitalPinHasPWM(p))
#define IS_PIN_I2C(p)           ((p) == PIN_WIRE_SDA || (p) == PIN_WIRE_SCL) // SDA=22, SCL=23
#define IS_PIN_SERIAL(p)        ((p) == PIN_SERIAL1_RX || (p) == PIN_SERIAL1_TX) // RX=0, TX=1
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        (p-A0)
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)

But then I get this error:

C:\Program Files (x86)\Arduino\libraries\Servo\src\samd\Servo.cpp:44:60: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'

 #define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.STATUS.bit.SYNCBUSY);

Link to the pins_arduino.h and variant.h files: metro_m4.zip

Dorme avatar Jan 24 '19 07:01 Dorme

Seems there is an incompatibility in the Servo class. This has happened in the past with a few boards. Try commenting out the Servo functionality in StandardFirmata and see if it then compiles. You can also check if that Servo library is up-to-date.

soundanalogous avatar Jan 25 '19 06:01 soundanalogous

I've upgraded the Servo library to the latest version available (1.1.3) but it does not solve the issue.

...\Servo.cpp: In function 'void Servo_Handler(timer16_Sequence_t, Tc*, uint8_t, uint8_t)':
...\Servo.cpp:44:60: error: 'volatile struct TC_STATUS_Type::<anonymous>' has no member named 'SYNCBUSY'
 #define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.STATUS.bit.SYNCBUSY);

After commenting out the Servo functionality I'm able to compile StandardFirmata and upload it to the Metro M4.

Dorme avatar Jan 25 '19 08:01 Dorme

Hello @Dorme ! How did you get it work? Which sections did you comment out?

ManOnPajamas avatar Oct 08 '19 20:10 ManOnPajamas

Nvm. Got it! :)

ManOnPajamas avatar Oct 09 '19 17:10 ManOnPajamas