For sufficiently large cyw43 PIO SPI transfers, sleep via async_context before entering busy wait. #2344
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!2344
Loading…
Reference in a new issue
No description provided.
Delete branch "esky-software/cyw43-pio-sleep-min"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@ -55,2 +55,4 @@#endif// PICO_CONFIG: CYW43_PIO_SLEEP_MIN_US, For PIO SPI transfers longer than this (in microseconds), sleep via async_context before entering busy wait, type=int, default=disabled, group=pico_cyw43_driver#if CYW43_PIO_SLEEP_MIN_USPerhaps 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? 😉 )@ -55,2 +55,4 @@#endif// PICO_CONFIG: CYW43_PIO_SLEEP_MIN_US, For PIO SPI transfers longer than this (in microseconds), sleep via async_context before entering busy wait, type=int, default=disabled, group=pico_cyw43_driver#if CYW43_PIO_SLEEP_MIN_USThe default value is 0/undefined, which preserves the present functionality.
@ -55,2 +55,4 @@#endif// PICO_CONFIG: CYW43_PIO_SLEEP_MIN_US, For PIO SPI transfers longer than this (in microseconds), sleep via async_context before entering busy wait, type=int, default=disabled, group=pico_cyw43_driver#if CYW43_PIO_SLEEP_MIN_USit should still have a PICO_CONFIG so people know it exists (it will show up in the docs)
@ -55,2 +55,4 @@#endif// PICO_CONFIG: CYW43_PIO_SLEEP_MIN_US, For PIO SPI transfers longer than this (in microseconds), sleep via async_context before entering busy wait, type=int, default=disabled, group=pico_cyw43_driver#if CYW43_PIO_SLEEP_MIN_USAdded.
@ -54,6 +54,18 @@ void cyw43_set_pio_clkdiv_int_frac8(uint32_t clock_div_int, uint8_t clock_div_fr}Could you add
type=int,in here (just before thedefault) please? (apologies for the late feedback)@ -54,6 +54,18 @@ void cyw43_set_pio_clkdiv_int_frac8(uint32_t clock_div_int, uint8_t clock_div_fr}Done.
Not sure why this shows as 'esky software dismissed peterharperuk's stale review...' with my update.
Did I do something wrongly?
It's a mystery - don't worry about it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.