Nonblocking I2C on the M0 Express

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
feijai0
 
Posts: 5
Joined: Tue Oct 11, 2022 11:17 am

Nonblocking I2C on the M0 Express

Post by feijai0 »

I am trying to port Gizmo, an arduino mega-based MIDI utility device, over to the Feather architecture. Gizmo combines an arduino with a MIDI port on the UART and an Adafruit 16x8 LED matrix driven by I2C, plus some buttons and pots. I'm trying to port it to an M0 Express Feather, a MIDI featherwing on the UART, a 16x8 LED matrix on I2C, possibly ultimately an OLED FeatherWing, and (for testing at the moment) a FeatherJoyWing.

So much of the Feather architecture is I2C-based and this presents a problem. Gizmo is highly timing sensitive, and I2C is not fast. In order to keep things fast enough on the Arduino, I modified the TwoWire.cpp/.h and the nb_twi.cpp/.h files to include a non-blocking option so I could send out on I2C and go about doing other tasks while it was running in the background.

For the life of me I cannot identify where the TwoWire and nb_twi includes are for the MO Express: they seem to be missing. Is there a nonblocking option? If not, where are they and can I modify them? Alternatively, can you get I2C going between the M0 Express and the various featherwings faster than the 400K I was using on the arduino?

Also: it appears that there's a bug in portOutputRegister(...). If I call portOutputRegister(digitalPinToPort(...)), the compiler complains that digitalPinToPort is returning a pointer to a 32-bit number and portOutputRegister is expecting an 8-bit pointer. This doesn't happen with the standard Arduino/AVR tools; indeed this function/macro combination is very common. Any help?

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”