#713 Improve SPI set-up: Don't change the config whilst it is enabled (not merged) #1158
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!1158
Loading…
Reference in a new issue
No description provided.
Delete branch "develop"
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?
Three SDK functions potentially attempt to change the SPI configuration while it is enabled. I hacked it to disable the module then change the configuration. It will attempt to re-enable the SPI if enabled. I do not save and restore other settings. I am not sure if this is required or not.
Tested with the following code: (Quick and dirty)
FYI, do not use more the 1Mbps with that test. It can be modified to support 10Mbps.
@kilograham Any chance of this on 1.4.1?
This is one approach to solving this. This is the best path without increasing the major version?
Thanks - looks good to me.
re-opened as #1227
Hi @daveythacher I think your change looks plausible. But, I do have to ask:
Thanks.
I based this on documentation from ARM SPI, which stated explicitly not to do this. This change allows the API to be used without register programming. In #713 I found a way to use the SDK to implement this with register programming. (Not documented in SDK to my knowledge.)
There are few possible issues which could happen depending on the SPI implementation. However I am assuming that this is not the case. This is not mentioned in the ARM documentation and I do not recall it being an issue in other SPI implementations. Switching from master to slave while enabled is almost always forbidden.
In a version 2.0 of the SDK, the SPI API may need more work. However for the time being this is likely fine, in my opinion. Addressing this with documentation should also work. Not all features are exposed by the SPI API but that is not a major issue. My personal preference is for a disable, configure and enable workflow. However this likely is not required and would actually be annoying if required. With this approach this can be left to the programmer to decide/handle.
One thing that my change does not do and this probably should be documented, is waiting for idle. If the SPI port needs to change roles, a pending transfer could be aborted. However this should be handled in application logic as the SDK should not be expected to handle DMA. A note for the programmer to see in the SDK, should handle this.