dma.h File Reference
#include "pico.h"
#include "hardware/structs/dma.h"
#include "hardware/regs/dreq.h"
#include "pico/assert.h"
Include dependency graph for dma.h:

Go to the source code of this file.

Data Structures

struct  dma_channel_config
 

Macros

#define DREQ_DMA_TIMER0   DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER0
 
#define DREQ_DMA_TIMER1   DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER1
 
#define DREQ_DMA_TIMER2   DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER2
 
#define DREQ_DMA_TIMER3   DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER3
 
#define DREQ_FORCE   DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_PERMANENT
 
#define PARAM_ASSERTIONS_ENABLED_DMA   0
 

Enumerations

enum  dma_channel_transfer_size { DMA_SIZE_8 = 0, DMA_SIZE_16 = 1, DMA_SIZE_32 = 2 }
 Enumeration of available DMA channel transfer sizes. More...
 

Functions

static void check_dma_channel_param (__unused uint channel)
 
static void check_dma_timer_param (__unused uint timer_num)
 
static dma_channel_hw_tdma_channel_hw_addr (uint channel)
 
void dma_channel_claim (uint channel)
 Mark a dma channel as used. More...
 
void dma_claim_mask (uint32_t channel_mask)
 Mark multiple dma channels as used. More...
 
void dma_channel_unclaim (uint channel)
 Mark a dma channel as no longer used. More...
 
void dma_unclaim_mask (uint32_t channel_mask)
 Mark multiple dma channels as no longer used. More...
 
int dma_claim_unused_channel (bool required)
 Claim a free dma channel. More...
 
bool dma_channel_is_claimed (uint channel)
 Determine if a dma channel is claimed. More...
 
static void channel_config_set_read_increment (dma_channel_config *c, bool incr)
 Set DMA channel read increment in a channel configuration object. More...
 
static void channel_config_set_write_increment (dma_channel_config *c, bool incr)
 Set DMA channel write increment in a channel configuration object. More...
 
static void channel_config_set_dreq (dma_channel_config *c, uint dreq)
 Select a transfer request signal in a channel configuration object. More...
 
static void channel_config_set_chain_to (dma_channel_config *c, uint chain_to)
 Set DMA channel chain_to channel in a channel configuration object. More...
 
static void channel_config_set_transfer_data_size (dma_channel_config *c, enum dma_channel_transfer_size size)
 Set the size of each DMA bus transfer in a channel configuration object. More...
 
static void channel_config_set_ring (dma_channel_config *c, bool write, uint size_bits)
 Set address wrapping parameters in a channel configuration object. More...
 
static void channel_config_set_bswap (dma_channel_config *c, bool bswap)
 Set DMA byte swapping config in a channel configuration object. More...
 
static void channel_config_set_irq_quiet (dma_channel_config *c, bool irq_quiet)
 Set IRQ quiet mode in a channel configuration object. More...
 
static void channel_config_set_high_priority (dma_channel_config *c, bool high_priority)
 Set the channel priority in a channel configuration object. More...
 
static void channel_config_set_enable (dma_channel_config *c, bool enable)
 Enable/Disable the DMA channel in a channel configuration object. More...
 
static void channel_config_set_sniff_enable (dma_channel_config *c, bool sniff_enable)
 Enable access to channel by sniff hardware in a channel configuration object. More...
 
static dma_channel_config dma_channel_get_default_config (uint channel)
 Get the default channel configuration for a given channel. More...
 
static dma_channel_config dma_get_channel_config (uint channel)
 Get the current configuration for the specified channel. More...
 
static uint32_t channel_config_get_ctrl_value (const dma_channel_config *config)
 Get the raw configuration register from a channel configuration. More...
 
static void dma_channel_set_config (uint channel, const dma_channel_config *config, bool trigger)
 Set a channel configuration. More...
 
static void dma_channel_set_read_addr (uint channel, const volatile void *read_addr, bool trigger)
 Set the DMA initial read address. More...
 
static void dma_channel_set_write_addr (uint channel, volatile void *write_addr, bool trigger)
 Set the DMA initial write address. More...
 
static void dma_channel_set_trans_count (uint channel, uint32_t trans_count, bool trigger)
 Set the number of bus transfers the channel will do. More...
 
static void dma_channel_configure (uint channel, const dma_channel_config *config, volatile void *write_addr, const volatile void *read_addr, uint transfer_count, bool trigger)
 Configure all DMA parameters and optionally start transfer. More...
 
static void dma_channel_transfer_from_buffer_now (uint channel, const volatile void *read_addr, uint32_t transfer_count)
 Start a DMA transfer from a buffer immediately. More...
 
static void dma_channel_transfer_to_buffer_now (uint channel, volatile void *write_addr, uint32_t transfer_count)
 Start a DMA transfer to a buffer immediately. More...
 
static void dma_start_channel_mask (uint32_t chan_mask)
 Start one or more channels simultaneously. More...
 
static void dma_channel_start (uint channel)
 Start a single DMA channel. More...
 
static void dma_channel_abort (uint channel)
 Stop a DMA transfer. More...
 
static void dma_channel_set_irq0_enabled (uint channel, bool enabled)
 Enable single DMA channel's interrupt via DMA_IRQ_0. More...
 
static void dma_set_irq0_channel_mask_enabled (uint32_t channel_mask, bool enabled)
 Enable multiple DMA channels' interrupts via DMA_IRQ_0. More...
 
static void dma_channel_set_irq1_enabled (uint channel, bool enabled)
 Enable single DMA channel's interrupt via DMA_IRQ_1. More...
 
static void dma_set_irq1_channel_mask_enabled (uint32_t channel_mask, bool enabled)
 Enable multiple DMA channels' interrupts via DMA_IRQ_1. More...
 
static void dma_irqn_set_channel_enabled (uint irq_index, uint channel, bool enabled)
 Enable single DMA channel interrupt on either DMA_IRQ_0 or DMA_IRQ_1. More...
 
static void dma_irqn_set_channel_mask_enabled (uint irq_index, uint32_t channel_mask, bool enabled)
 Enable multiple DMA channels' interrupt via either DMA_IRQ_0 or DMA_IRQ_1. More...
 
static bool dma_channel_get_irq0_status (uint channel)
 Determine if a particular channel is a cause of DMA_IRQ_0. More...
 
static bool dma_channel_get_irq1_status (uint channel)
 Determine if a particular channel is a cause of DMA_IRQ_1. More...
 
static bool dma_irqn_get_channel_status (uint irq_index, uint channel)
 Determine if a particular channel is a cause of DMA_IRQ_N. More...
 
static void dma_channel_acknowledge_irq0 (uint channel)
 Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_0. More...
 
static void dma_channel_acknowledge_irq1 (uint channel)
 Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_1. More...
 
static void dma_irqn_acknowledge_channel (uint irq_index, uint channel)
 Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_N. More...
 
static bool dma_channel_is_busy (uint channel)
 Check if DMA channel is busy. More...
 
static void dma_channel_wait_for_finish_blocking (uint channel)
 Wait for a DMA channel transfer to complete. More...
 
static void dma_sniffer_enable (uint channel, uint mode, bool force_channel_enable)
 Enable the DMA sniffing targeting the specified channel. More...
 
static void dma_sniffer_set_byte_swap_enabled (bool swap)
 Enable the Sniffer byte swap function. More...
 
static void dma_sniffer_set_output_invert_enabled (bool invert)
 Enable the Sniffer output invert function. More...
 
static void dma_sniffer_set_output_reverse_enabled (bool reverse)
 Enable the Sniffer output bit reversal function. More...
 
static void dma_sniffer_disable (void)
 Disable the DMA sniffer.
 
static void dma_sniffer_set_data_accumulator (uint32_t seed_value)
 Set the sniffer's data accumulator with initial value. More...
 
static uint32_t dma_sniffer_get_data_accumulator (void)
 Get the sniffer's data accumulator value. More...
 
void dma_timer_claim (uint timer)
 Mark a dma timer as used. More...
 
void dma_timer_unclaim (uint timer)
 Mark a dma timer as no longer used. More...
 
int dma_claim_unused_timer (bool required)
 Claim a free dma timer. More...
 
bool dma_timer_is_claimed (uint timer)
 Determine if a dma timer is claimed. More...
 
static void dma_timer_set_fraction (uint timer, uint16_t numerator, uint16_t denominator)
 Set the divider for the given DMA timer. More...
 
static uint dma_get_timer_dreq (uint timer_num)
 Return the DREQ number for a given DMA timer. More...
 
void print_dma_ctrl (dma_channel_hw_t *channel)