Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Non-Blocking I2C #1730

Closed
Rastloser opened this issue Sep 24, 2023 · 3 comments · Fixed by #2167
Closed

Feature Request: Non-Blocking I2C #1730

Rastloser opened this issue Sep 24, 2023 · 3 comments · Fixed by #2167
Labels
enhancement New feature or request

Comments

@Rastloser
Copy link
Contributor

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...

@earlephilhower
Copy link
Owner

earlephilhower commented Sep 24, 2023

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.

@earlephilhower earlephilhower added the enhancement New feature or request label Sep 24, 2023
@Rastloser
Copy link
Contributor Author

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...

earlephilhower added a commit that referenced this issue May 21, 2024
Fixes #1730

Uses DMA operations to avoid the need to bit-bang or busy wait for I2C operations
that might be very slow.  Optional, adds new API calls to enable.  Simple example
included.
@earlephilhower
Copy link
Owner

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...

earlephilhower added a commit that referenced this issue May 21, 2024
Fixes #1730

Uses DMA operations to avoid the need to bit-bang or busy wait for I2C operations
that might be very slow.  Optional, adds new API calls to enable.  Simple example
included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants