Repository: raspberrypi/pico-sdk
File: src/rp2_common/hardware_dma/include/hardware/dma.h (C/C++)

Code before:
 * \if rp2040_specific
 * On RP2040 self-triggering DMA is not supported, so this method may not be used
 * \endif
 *
 * \if rp2350_specific
 * On RP2350 the valid range is 0 -> 2^28 - 1
 * \endif
 * \return the encoded_transfer_count
 * \sa dma_channel_set_transfer_count
 * \sa dma_channel_configure
 * \sa dma_channel_transfer_from_buffer_now
 * \sa dma_channel_transfer_to_buffer_now
 */
static inline uint32_t dma_encode_transfer_count_with_self_trigger(uint transfer_count) {
#if PICO_RP2040
    panic_unsupported();
#else
    return dma_encode_transfer_count(transfer_count) | (DMA_CH0_TRANS_COUNT_MODE_VALUE_TRIGGER_SELF << DMA_CH0_TRANS_COUNT_MODE_LSB);
#endif
}

/*! \brief  Return an endless transfer as an "encoded_transfer_length" value suitable for the referenced methods
 *  \ingroup hardware_dma
 *
 * \if rp2040_specific
 * On RP2040 endless DMA transfers are not supported, so this method may not be used
 * \endif
 * \return the encoded_transfer_count
 * \sa dma_channel_set_transfer_count
 * \sa dma_channel_configure
 * \sa dma_channel_transfer_from_buffer_now
 * \sa dma_channel_transfer_to_buffer_now
 */
static inline uint32_t dma_encode_endless_transfer_count(void) {
#if PICO_RP2040
    panic_unsupported();
#else
    static_assert(DMA_CH0_TRANS_COUNT_MODE_VALUE_ENDLESS == 0xf);
    static_assert(DMA_CH0_TRANS_COUNT_MODE_LSB == 28);
    return 0xffffffffu;
#endif
}

/*! \brief  Set the number of bus transfers the channel will do
 *  \ingroup hardware_dma
 *
 * \param channel DMA channel
 * \param encoded_transfer_count The encoded transfer count
 *
 * \if rp2040_specific
 * On RP2040 this is just the number of transfers (NOT bytes, see \ref channel_config_set_transfer_data_size) from 0 -> 2^32 - 1.

Review comment (suggestion):
```suggestion
 * On RP2040 endless DMA transfers are not supported, so this method must not be used
```

Code after:
}

/*! \brief  Encode the specified transfer length, along with a flag to indicate the DMA transfer should be self-triggering, into an "encoded_transfer_length" value suitable for the referenced methods
 *  \ingroup hardware_dma
 * \param transfer_count the number of transfers (NOT bytes, see \ref channel_config_set_transfer_data_size)
 *
 * \if rp2040_specific
 * On RP2040 self-triggering DMA is not supported, so this method should not be used
 * \endif
 *
 * \if rp2350_specific
 * On RP2350 the valid range is 0 -> 2^28 - 1
 * \endif
 * \return the encoded_transfer_count
 * \sa dma_channel_set_transfer_count
 * \sa dma_channel_configure
 * \sa dma_channel_transfer_from_buffer_now
 * \sa dma_channel_transfer_to_buffer_now
 */
static inline uint32_t dma_encode_transfer_count_with_self_trigger(uint transfer_count) {
#if PICO_RP2040
    panic_unsupported();
#else
    return dma_encode_transfer_count(transfer_count) | (DMA_CH0_TRANS_COUNT_MODE_VALUE_TRIGGER_SELF << DMA_CH0_TRANS_COUNT_MODE_LSB);
#endif
}

/*! \brief  Return an endless transfer as an "encoded_transfer_length" value suitable for the referenced methods
 *  \ingroup hardware_dma
 *
 * \if rp2040_specific
 * On RP2040 endless DMA transfers are not supported, so this method should not be used
 * \endif
 * \return the encoded_transfer_count
 * \sa dma_channel_set_transfer_count
 * \sa dma_channel_configure
 * \sa dma_channel_transfer_from_buffer_now
 * \sa dma_channel_transfer_to_buffer_now
 */
static inline uint32_t dma_encode_endless_transfer_count(void) {
#if PICO_RP2040
    panic_unsupported();
#else
    static_assert(DMA_CH0_TRANS_COUNT_MODE_VALUE_ENDLESS == 0xf);
    static_assert(DMA_CH0_TRANS_COUNT_MODE_LSB == 28);
    return 0xffffffffu;
#endif
}

/*! \brief  Set the number of bus transfers the channel will do
 *  \ingroup hardware_dma