Update docs, and add methods for new RP2350 DMA features #2588
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!2588
Loading…
Reference in a new issue
No description provided.
Delete branch "dma_extras"
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 #2059
fixes #2444
@ -144,3 +143,4 @@typedef enum dma_channel_transfer_size {DMA_SIZE_8 = 0, ///< Byte transfer (8 bits)DMA_SIZE_16 = 1, ///< Half word transfer (16 bits)DMA_SIZE_32 = 2 ///< Word transfer (32 bits)Given that this function is named
channel_config_set_write_address_update_type, was this supposed to say:?
@ -144,3 +143,4 @@typedef enum dma_channel_transfer_size {DMA_SIZE_8 = 0, ///< Byte transfer (8 bits)DMA_SIZE_16 = 1, ///< Half word transfer (16 bits)DMA_SIZE_32 = 2 ///< Word transfer (32 bits)The above line had a copy'n'paste error, so maybe this line is wrong too? (Perhaps it was supposed to say "...for memory to peripheral transfers")
Would this flag a
transfer_countof 0 as an invalid_param? The doxygen comment above implies that 0 is in the valid range? Also, I think that perhaps this should be using<rather than&(with the comparison-value obviously modified as appropriate), because otherwise a value above 2^28 that has some of the lower bits also set, would still count as "valid"? 🤔If the valid range for RP2040 is 0 -> 2^32 - 1, should this be
?
Perhaps it's worth naming this function
dma_channel_set_encoded_transfer_countjust to make it more obvious?It appears in multiple places, but I wonder if "non-zero values of the top 4 bits are used to" could be shortened to "the top 4 bits are used to", since you'd never indicate anything with a zero-value?
@ -154,0 +184,4 @@#else#define DMA_ADDRESS_UPDATE_TYPE_TO_DMA_CH_CTRL_WRITE_BITS(u) \((((u)&1) << DMA_CH0_CTRL_TRIG_INCR_WRITE_LSB) | \(((u)&2) << (DMA_CH0_CTRL_TRIG_INCR_WRITE_REV_LSB - 1)))Bit-twiddling isn't my strong point, but
(DMA_CH0_CTRL_TRIG_INCR_READ_REV_LSB - 1) == DMA_CH0_CTRL_TRIG_INCR_READ_LSB, so does that mean that this is equivalent to:@ -154,0 +184,4 @@#else#define DMA_ADDRESS_UPDATE_TYPE_TO_DMA_CH_CTRL_WRITE_BITS(u) \((((u)&1) << DMA_CH0_CTRL_TRIG_INCR_WRITE_LSB) | \(((u)&2) << (DMA_CH0_CTRL_TRIG_INCR_WRITE_REV_LSB - 1)))Yeah, I deliberately put the bits next to each other so you could do that. Graham's code is better because it doesn't rely on that assumption. We usually expect these to be used with constants so there is no additional cost
@ -144,3 +143,4 @@typedef enum dma_channel_transfer_size {DMA_SIZE_8 = 0, ///< Byte transfer (8 bits)DMA_SIZE_16 = 1, ///< Half word transfer (16 bits)DMA_SIZE_32 = 2 ///< Word transfer (32 bits)Do we usually put a typedef on enums?
yes this is also swapped, should say
memory to peripheralwritee address->write addressThat would be more explicit. We expect 32-bit ints on both Arm and RISC-V though.
The test is correct.
invalid_params_ifis a negative assert, so it flags inputs which have any of the top 4 bits set. MODE_BITS is0xf << 28Ahhh! I thought that it was positive-comparing against COUNT_BITS, I hadn't twigged that it was negative-comparing against MODE_BITS. In which case please ignore my earlier comment 😂
yeah; i went with
uinthere vsuint32_tfor the encoded, as the encoded is a register value whereas this is a "user value" - seemed like a distinction in my head, but all a bit hypotheticalgood suggestion, but i think i'll leave it
what is the distinction here - FYI you can still use it, it doesn't work
@ -154,0 +184,4 @@#else#define DMA_ADDRESS_UPDATE_TYPE_TO_DMA_CH_CTRL_WRITE_BITS(u) \((((u)&1) << DMA_CH0_CTRL_TRIG_INCR_WRITE_LSB) | \(((u)&2) << (DMA_CH0_CTRL_TRIG_INCR_WRITE_REV_LSB - 1)))yeah, i think i got squirly after getting bitten by the READ/WRITE being different distances apart on RP2040 vs RP2350 (i had a shift between them in there at first but it broke on RP2040)
Okay, perhaps "should" then? IMHO "should" feels more active (i.e. something the user does) whereas "may" feels more passive (i.e. something the SDK does) ? 🤷♂️
@ -162,3 +247,4 @@channel_config_set_read_address_update_type(c, incr ? DMA_ADDRESS_UPDATE_INCREMENT : DMA_ADDRESS_UPDATE_NONE);}/*! \brief Set DMA channel write increment in a channel configuration objectYou've changed
writee address incrementstoaddress increments- did you mean to change it towrite address increments? (which would also be consistent with thechannel_config_set_read_incrementdocstring that saysread address incrementsrather thanaddress increments)@ -144,3 +143,4 @@typedef enum dma_channel_transfer_size {DMA_SIZE_8 = 0, ///< Byte transfer (8 bits)DMA_SIZE_16 = 1, ///< Half word transfer (16 bits)DMA_SIZE_32 = 2 ///< Word transfer (32 bits)yes, i have added. I also made
dma_channel_config_tthe preferred name fordma_channel_confignote, there are a few straggler un-typedef-ed enums elsewhere outside of dma.h, but I'm leaving those for now, as i may do some more rationalization of where things are typedef-ed in future releases
@ -140,36 +140,128 @@ bool dma_channel_is_claimed(uint channel);*Small nitpick, but this is probably more readable as
or
@ -162,3 +247,4 @@channel_config_set_read_address_update_type(c, incr ? DMA_ADDRESS_UPDATE_INCREMENT : DMA_ADDRESS_UPDATE_NONE);}/*! \brief Set DMA channel write increment in a channel configuration objecti did not mean to can you suggest fix; easier flow for me
@ -140,36 +140,128 @@ bool dma_channel_is_claimed(uint channel);*I'm going to "resolve" this as it's a duplicate of another suggestion (which has now evolved into a discussion).
i dont think i care enough to spend more time
if you make "should" as a suggestion, i'll incorporate it tho
@ -140,36 +140,128 @@ bool dma_channel_is_claimed(uint channel);*@ -419,21 +511,110 @@ static inline void dma_channel_set_write_addr(uint channel, volatile void *write}@ -419,21 +511,110 @@ static inline void dma_channel_set_write_addr(uint channel, volatile void *write}