@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
channel_config
hardware_dma

DMA channel configuration. More...

## Data Structures

struct | dma_channel_config_t
| Opaque representation of a DMA channel configuration that can be later applied to a hardware DMA channel. More...

## Functions

static void | channel_config_set_read_address_update_type (dma_channel_config_t *c, dma_address_update_type_t update_type)
| Set DMA channel read address update type in a channel configuration object.
static void | channel_config_set_write_address_update_type (dma_channel_config_t *c, dma_address_update_type_t update_type)
| Set DMA channel write address update type in a channel configuration object.
static void | channel_config_set_read_increment (dma_channel_config_t *c, bool incr)
| Set DMA channel read increment in a channel configuration object.
static void | channel_config_set_write_increment (dma_channel_config_t *c, bool incr)
| Set DMA channel write increment in a channel configuration object.
static void | channel_config_set_dreq (dma_channel_config_t *c, uint dreq)
| Select a transfer request signal in a channel configuration object.
static void | channel_config_set_chain_to (dma_channel_config_t *c, uint chain_to)
| Set DMA channel chain_to channel in a channel configuration object.
static void | channel_config_set_transfer_data_size (dma_channel_config_t *c, dma_channel_transfer_size_t size)
| Set the size of each DMA bus transfer in a channel configuration object.
static void | channel_config_set_ring (dma_channel_config_t *c, bool write, uint size_bits)
| Set address wrapping parameters in a channel configuration object.
static void | channel_config_set_bswap (dma_channel_config_t *c, bool bswap)
| Set DMA byte swapping config in a channel configuration object.
static void | channel_config_set_irq_quiet (dma_channel_config_t *c, bool irq_quiet)
| Set IRQ quiet mode in a channel configuration object.
static void | channel_config_set_high_priority (dma_channel_config_t *c, bool high_priority)
| Set the channel priority in a channel configuration object.
static void | channel_config_set_enable (dma_channel_config_t *c, bool enable)
| Enable/Disable the DMA channel in a channel configuration object.
static void | channel_config_set_sniff_enable (dma_channel_config_t *c, bool sniff_enable)
| Enable access to channel by sniff hardware in a channel configuration object.
static dma_channel_config_t | dma_channel_get_default_config (uint channel)
| Get the default channel configuration for a given channel.
static dma_channel_config_t | dma_get_channel_config (uint channel)
| Get the current configuration for the specified channel.
static uint32_t | channel_config_get_ctrl_value (const dma_channel_config_t *config)
| Get the raw configuration register from a channel configuration.

## Detailed Description

DMA channel configuration.

A DMA channel needs to be configured, these functions provide handy helpers to set up configuration structures. See dma_channel_config

## Function Documentation

## channel_config_get_ctrl_value()

uint32_t channel_config_get_ctrl_value | ( | const dma_channel_config_t * | config | ) |

inline static

Get the raw configuration register from a channel configuration.

Parameters

  config | Pointer to a config structure.

Returns
  Register content

## channel_config_set_bswap()

void channel_config_set_bswap | ( | dma_channel_config_t * | c,
|  | bool | bswap )

inline static

Set DMA byte swapping config in a channel configuration object.

No effect for byte data, for halfword data, the two bytes of each halfword are swapped. For word data, the four bytes of each word are swapped to reverse their order.

Parameters

  c | Pointer to channel configuration object
  bswap | True to enable byte swapping

## channel_config_set_chain_to()

void channel_config_set_chain_to | ( | dma_channel_config_t * | c,
|  | uint | chain_to )

inline static

Set DMA channel chain_to channel in a channel configuration object.

When this channel completes, it will trigger the channel indicated by chain_to. Disable by setting chain_to to itself (the same channel)

Parameters

  c | Pointer to channel configuration object
  chain_to | Channel to trigger when this channel completes.

## channel_config_set_dreq()

void channel_config_set_dreq | ( | dma_channel_config_t * | c,
|  | uint | dreq )

inline static

Select a transfer request signal in a channel configuration object.

The channel uses the transfer request signal to pace its data transfer rate. Sources for TREQ signals are internal (TIMERS) or external (DREQ, a Data Request from the system). 0x0 to 0x3a -> select DREQ n as TREQ 0x3b -> Select Timer 0 as TREQ 0x3c -> Select Timer 1 as TREQ 0x3d -> Select Timer 2 as TREQ (Optional) 0x3e -> Select Timer 3 as TREQ (Optional) 0x3f -> Permanent request, for unpaced transfers.

Parameters

  c | Pointer to channel configuration data
  dreq | Source (see description)

## channel_config_set_enable()

void channel_config_set_enable | ( | dma_channel_config_t * | c,
|  | bool | enable )

inline static

Enable/Disable the DMA channel in a channel configuration object.

When false, the channel will ignore triggers, stop issuing transfers, and pause the current transfer sequence (i.e. BUSY will remain high if already high)

Parameters

  c | Pointer to channel configuration object
  enable | True to enable the DMA channel. When enabled, the channel will respond to triggering events, and start transferring data.

## channel_config_set_high_priority()

void channel_config_set_high_priority | ( | dma_channel_config_t * | c,
|  | bool | high_priority )

inline static

Set the channel priority in a channel configuration object.

When true, gives a channel preferential treatment in issue scheduling: in each scheduling round, all high priority channels are considered first, and then only a single low priority channel, before returning to the high priority channels.

This only affects the order in which the DMA schedules channels. The DMA's bus priority is not changed. If the DMA is not saturated then a low priority channel will see no loss of throughput.

Parameters

  c | Pointer to channel configuration object
  high_priority | True to enable high priority

## channel_config_set_irq_quiet()

void channel_config_set_irq_quiet | ( | dma_channel_config_t * | c,
|  | bool | irq_quiet )

inline static

Set IRQ quiet mode in a channel configuration object.

In QUIET mode, the channel does not generate IRQs at the end of every transfer block. Instead, an IRQ is raised when NULL is written to a trigger register, indicating the end of a control block chain.

Parameters

  c | Pointer to channel configuration object
  irq_quiet | True to enable quiet mode, false to disable.

## channel_config_set_read_address_update_type()

void channel_config_set_read_address_update_type | ( | dma_channel_config_t * | c,
|  | dma_address_update_type_t | update_type )

inline static

Set DMA channel read address update type in a channel configuration object.

Parameters

  c | Pointer to channel configuration object
  update_type | The type of adjustment to make to the read address after each transfer. Usually set to DMA_ADDRESS_UPDATE_NONE for peripheral to memory transfers

See also
  channel_config_set_read_increment

## channel_config_set_read_increment()

void channel_config_set_read_increment | ( | dma_channel_config_t * | c,
|  | bool | incr )

inline static

Set DMA channel read increment in a channel configuration object.

Note
  this method is equivalent to
  channel_config_set_read_address_update_type(c, incr ? DMA_ADDRESS_UPDATE_INCREMENT : DMA_ADDRESS_UPDATE_NONE)
  channel_config_set_read_address_update_type
  static void channel_config_set_read_address_update_type(dma_channel_config_t *c, dma_address_update_type_t update_type)
  Set DMA channel read address update type in a channel configuration object.
  Definition dma.h:215
  DMA_ADDRESS_UPDATE_NONE
  @ DMA_ADDRESS_UPDATE_NONE
  The address remains the same after each transfer.
  Definition dma.h:153
  DMA_ADDRESS_UPDATE_INCREMENT
  @ DMA_ADDRESS_UPDATE_INCREMENT
  The address is incremented by the transfer size after each transfer.
  Definition dma.h:154

Parameters

  c | Pointer to channel configuration object
  incr | True to enable read address increments, whereby the read address increments by the transfer size with each transfer. False to perform each read from the same address. Usually disabled for peripheral to memory transfers

See also
  channel_config_set_read_address_update_type

## channel_config_set_ring()

void channel_config_set_ring | ( | dma_channel_config_t * | c,
|  | bool | write,
|  | uint | size_bits )

inline static

Set address wrapping parameters in a channel configuration object.

Size of address wrap region. If 0, don’t wrap. For values n > 0, only the lower n bits of the address will change. This wraps the address on a (1 << n) byte boundary, facilitating access to naturally-aligned ring buffers. Ring sizes between 2 and 32768 bytes are possible (size_bits from 1 - 15)

0x0 -> No wrapping.

Parameters

  c | Pointer to channel configuration object
  write | True to apply to write addresses, false to apply to read addresses
  size_bits | 0 to disable wrapping. Otherwise the size in bits of the changing part of the address. Effectively wraps the address on a (1 << size_bits) byte boundary.

## channel_config_set_sniff_enable()

void channel_config_set_sniff_enable | ( | dma_channel_config_t * | c,
|  | bool | sniff_enable )

inline static

Enable access to channel by sniff hardware in a channel configuration object.

Sniff HW must be enabled and have this channel selected.

Parameters

  c | Pointer to channel configuration object
  sniff_enable | True to enable the Sniff HW access to this DMA channel.

## channel_config_set_transfer_data_size()

void channel_config_set_transfer_data_size | ( | dma_channel_config_t * | c,
|  | dma_channel_transfer_size_t | size )

inline static

Set the size of each DMA bus transfer in a channel configuration object.

Set the size of each bus transfer (byte/halfword/word). The read and write addresses advance by the specific amount (1/2/4 bytes) with each transfer.

Parameters

  c | Pointer to channel configuration object
  size | See enum for possible values.

## channel_config_set_write_address_update_type()

void channel_config_set_write_address_update_type | ( | dma_channel_config_t * | c,
|  | dma_address_update_type_t | update_type )

inline static

Set DMA channel write address update type in a channel configuration object.

Parameters

  c | Pointer to channel configuration object
  update_type | The type of adjustment to make to the write address after each transfer. Usually set to DMA_ADDRESS_UPDATE_NONE for memory to peripheral transfers

See also
  channel_config_set_write_increment

## channel_config_set_write_increment()

void channel_config_set_write_increment | ( | dma_channel_config_t * | c,
|  | bool | incr )

inline static

Set DMA channel write increment in a channel configuration object.

Note
  this method is equivalent to
  channel_config_set_write_address_update_type(c, incr ? DMA_ADDRESS_UPDATE_INCREMENT : DMA_ADDRESS_UPDATE_NONE)
  channel_config_set_write_address_update_type
  static void channel_config_set_write_address_update_type(dma_channel_config_t *c, dma_address_update_type_t update_type)
  Set DMA channel write address update type in a channel configuration object.
  Definition dma.h:228

Parameters

  c | Pointer to channel configuration object
  incr | True to enable write address increments, whereby the write address increments by the transfer size with each transfer. False to perform each write to the same address. Usually disabled for memory to peripheral transfers

See also
  channel_config_set_write_address_update_type

## dma_channel_get_default_config()

dma_channel_config_t dma_channel_get_default_config | ( | uint | channel | ) |

inline static

Get the default channel configuration for a given channel.

Setting | Default
--- | ---
Read Increment | true
Write Increment | false
DReq | DREQ_FORCE
Chain to | self
Data size | DMA_SIZE_32
Ring | write=false, size=0 (i.e. off)
Byte Swap | false
Quiet IRQs | false
High Priority | false
Channel Enable | true
Sniff Enable | false

Parameters

  channel | DMA channel

Returns
  the default configuration which can then be modified.

## dma_get_channel_config()

dma_channel_config_t dma_get_channel_config | ( | uint | channel | ) |

inline static

Get the current configuration for the specified channel.

Parameters

  channel | DMA channel

Returns
  The current configuration as read from the HW register (not cached)