Closed Rastloser closed 3 months ago
That library may use DMA, but it definitely is blocking on the caller (i.e. a call to i2c-read-write-dma takes exactly as many wall seconds to return as a i2c-read-write-polling call would).
I guess in the case of FreeRTOS that lets you run another task instead of busy waiting, but here we don't have tasks (unless you use FreeRTOS...in which case the library may almost work as-is).
I'm not sure what the API would be here, though, where there are no tasks. You'd need a callback function or something (called ar IRQ time) or a flag your app could poll to see if the I2C op is really done or not.
I'd personally go with a callback, but a polled function/flag would be a solid choice, too. Maybe even preferably since some people might put too much code into the callback-handler... The Teensy-Version uses a finished flag, but does expose IRQ-based callbacks with ample warning not to put lengthy code into it...
If anyone looking at this request could take a look at #2167 and try their hand at using it in their application I'd much appreciate it. I have the TalkingToMyself test running in asynchronous mode stably, but don't seem to have any I2C gadgets to hoop up and try on external HW...
I don't know of a non-blocking or perhaps even DMA I2C-Library for the RP2040-Arduino-Core. There is a DMA-library for FreeRTOS under PICO-I2C-DMA, but it would be great to have something Arduino compatible...