Hi James. Any progress with making the GD2 library compile on SAMD processors like the M0 (SAMD21) and M4 (SAMD51)? I have developed a number of subsystems based on Arduino IDE-based software and I want to stick with that. No Python for me!
I create interactive systems and interfaces for kids with serious disabilities at a hospital. I now use SAMD processors for almost all of my work so I really hope the GD2 library can work on those very soon.
- the metro has SPI1 hooked to pins 11-12-13, so no SPI dialog will occur with the gameduino shield as it is. SCLK, MISO and MOSI need to be re routed from the ISCP connector of the metro, I just bent pins on the shield and soldered wires on mine. It's the same mod suggested by James for the Leonardo and a few other boards, IIRC. I just had wished it was clearly stated / proposed for the M4, it would have saved a lot of time figuring out why transport wouldn't send anything
- couple of #defines to adjust in the lib so that SPI is initialized properly and to get it compiled
- cranked up SPI speed / freq to 24 MHz, which should work based on the fact SERCOMs are clocked at 48 MHz and there's (IIRC) a division by 2 in the peripheral
- EEPROM.h lib shouldn't be loaded in the sketches (comment), I don't think there's a functional implementation of this for the M4 (maybe... with the onboard QSPI flash but not sure it's 100% compatible with the stock arduino... Calibration storage could be achieved on the SD card regardless)
for now... video demos involving cube rotation and stuff are still crashing (but maybe because I'm on the small screen now and it's a large screen / GD3 demo).
Sprites are working well , widget demo too
Attached the updated lib. It's a crude mod. Hope this helps
to be noted : file loading is the problem currently (sd card). SD init works well, further actions (LBA reading and such) seems to be erratic and resources can't be loaded. Yet have to figure out
I was able to dump the first sector. Tried installing 10 MHz SPI freq, no change : bytes per sector & reserved sector reading is going wrong. Card is 4 GB formatted fat 32
[EDIT] I got it to work, seems the SD card driver doesn't do well with the old 4GB I was testing with. Latest version loads up properly on the Arduino UNO, file load and all. Still hiccups on the Metro, but at least no message resource couldn't be loaded
now all working, latest mod was to update the SPI freq for the M4. It seems my SD card can't be accessed at more than 12 MHz
in GD2.h, line 3#if defined(ESP8266)
SPI.setFrequency(40000000L); #elif defined(ESP32) SPI.setFrequency(25000000L); #elif defined(ARDUINO_ARCH_STM32) SPI.beginTransaction(SPISettings(18000000, MSBFIRST, SPI_MODE0)); #elif defined(__SAMD51J19A__) SPI.beginTransaction(SPISettings(12000000, MSBFIRST, SPI_MODE0)); // We might be able to cranck this up but I think SERCOMS are on 48 MHz and max avail freq is half of this #endif