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

Code before:
 * \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(uint transfer_count) {
#if !PICO_RP2040
    invalid_params_if(HARDWARE_DMA, transfer_count & DMA_CH0_TRANS_COUNT_MODE_BITS);
    return transfer_count & DMA_CH0_TRANS_COUNT_COUNT_BITS;
#else
    return transfer_count;
#endif
}

/*! \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 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

Review comment (suggestion):
```suggestion
 * On RP2040 self-triggering DMA is not supported, so this method should not be used
```

Code after:
 * \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(uint transfer_count) {
#if !PICO_RP2040
    invalid_params_if(HARDWARE_DMA, transfer_count & DMA_CH0_TRANS_COUNT_MODE_BITS);
    return transfer_count & DMA_CH0_TRANS_COUNT_COUNT_BITS;
#else
    return transfer_count;
#endif
}

/*! \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