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

For sufficiently large cyw43 PIO SPI transfers, sleep via async_context before entering busy wait. #2344

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

esky-software
Copy link
Contributor

Fixes #2343

The function cyw43_spi_transfer() busy waits on the transfer DMA channel(s), even for large transfers.
This is far from optimal in an RTOS or other asynchronous environment.

We might use DMA interrupts to handle the completion of the transfer, but this would require some restructuring of the driver code.

More simply, we can estimate the duration of the transfer, and if it's larger than a threshold call cyw43_delay_us() to sleep via the async context before starting the busy wait for the end of the transfer.

Define CYW43_PIO_SLEEP_MIN_US as the threshold duration (microseconds) to enable the feature.

@@ -54,6 +54,17 @@ void cyw43_set_pio_clkdiv_int_frac8(uint32_t clock_div_int, uint8_t clock_div_fr
}
#endif

#if CYW43_PIO_SLEEP_MIN_US
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should have a // PICO_CONFIG: metadata-comment? See https://github.com/search?q=repo%3Araspberrypi%2Fpico-sdk%20PICO_CONFIG&type=code for other examples. (although I guess that means you probably want to decide on a sensible "default" value for this too? 😉 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value is 0/undefined, which preserves the present functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants