Atmel Software Framework

dma.h File Reference

AVR XMEGA Direct Memory Access Controller driver definitions.

Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.

#include <compiler.h>
#include <interrupt.h>
#include <hugemem.h>
#include <pmic.h>

Data Structures

struct  dma_channel_config
 DMA channel configuration struct. More...
 

Macros

#define dma_get_channel_address_from_num(num)   ((DMA_CH_t *)((uintptr_t)(&DMA.CH0) + (sizeof(DMA_CH_t) * num)))
 Helper macro to get the channel offset given the channel number. More...
 
#define DMA_NUMBER_OF_CHANNELS   2
 Number of available DMA channels, device dependent. More...
 

Typedefs

typedef uint8_t dma_channel_num_t
 DMA channel number type. More...
 

Enumerations

enum  dma_channel_status {
  DMA_CH_FREE = 0,
  DMA_CH_PENDING,
  DMA_CH_BUSY,
  DMA_CH_TRANSFER_COMPLETED,
  DMA_CH_TRANSFER_ERROR
}
 DMA channel status. More...
 
enum  dma_int_level_t {
  DMA_INT_LVL_OFF = 0x00,
  DMA_INT_LVL_LO = 0x01,
  DMA_INT_LVL_MED = 0x02,
  DMA_INT_LVL_HI = 0x03
}
 DMA interrupt levels. More...
 

Functions

void dma_disable (void)
 Disable DMA controller. More...
 
void dma_enable (void)
 Enable DMA controller. More...
 
DMA Controller Management
static void dma_set_priority_mode (DMA_PRIMODE_t primode)
 Set DMA channel priority mode. More...
 
static void dma_set_double_buffer_mode (DMA_DBUFMODE_t dbufmode)
 Set DMA channel double buffering mode. More...
 
DMA Channel Direct Configuration Functions

These functions allows direct configuration on the DMA channels, not going through a dma_channel_config struct.

This allows update of the most commonly changed DMA channel properties.

static void dma_channel_write_burst_length (dma_channel_num_t num, DMA_CH_BURSTLEN_t burst_length)
 Write DMA channel burst length to hardware. More...
 
static void dma_channel_write_transfer_count (dma_channel_num_t num, uint16_t count)
 Write DMA channel transfer count to hardware. More...
 
static void dma_channel_write_repeats (dma_channel_num_t num, uint8_t repeats)
 Write DMA channel number of transfer repeats to hardware. More...
 
static void dma_channel_write_destination (dma_channel_num_t num, uint16_t destination)
 Write DMA channel 16-bit destination address to hardware. More...
 
static void dma_channel_write_source (dma_channel_num_t num, uint16_t source)
 Write DMA channel 16-bit source address to hardware. More...
 
DMA Channel Configuration Helper Functions
static void dma_channel_set_burst_length (struct dma_channel_config *config, DMA_CH_BURSTLEN_t burst_length)
 Set DMA channel burst length. More...
 
static void dma_channel_set_single_shot (struct dma_channel_config *config)
 Set DMA channel in single shot transfer mode. More...
 
static void dma_channel_unset_single_shot (struct dma_channel_config *config)
 Unset DMA channel from single shot transfer mode. More...
 
static void dma_channel_set_interrupt_level (struct dma_channel_config *config, enum dma_int_level_t level)
 Set DMA channel interrupt level. More...
 
static void dma_channel_set_src_reload_mode (struct dma_channel_config *config, DMA_CH_SRCRELOAD_t mode)
 Set DMA channel source address reload mode. More...
 
static void dma_channel_set_dest_reload_mode (struct dma_channel_config *config, DMA_CH_DESTRELOAD_t mode)
 Set DMA channel destination address reload mode. More...
 
static void dma_channel_set_src_dir_mode (struct dma_channel_config *config, DMA_CH_SRCDIR_t mode)
 Set DMA channel source addressing mode. More...
 
static void dma_channel_set_dest_dir_mode (struct dma_channel_config *config, DMA_CH_DESTDIR_t mode)
 Set DMA channel destination addressing mode. More...
 
static void dma_channel_set_trigger_source (struct dma_channel_config *config, DMA_CH_TRIGSRC_t source)
 Set DMA channel trigger source. More...
 
static void dma_channel_set_transfer_count (struct dma_channel_config *config, uint16_t count)
 Set DMA channel transfer count. More...
 
static void dma_channel_set_repeats (struct dma_channel_config *config, uint8_t repeats)
 Set DMA channel number of transfer repeats. More...
 
static void dma_channel_set_destination_address (struct dma_channel_config *config, uint16_t destination)
 Set DMA channel 16-bit destination address. More...
 
static void dma_channel_set_source_address (struct dma_channel_config *config, uint16_t source)
 Set DMA channel 16-bit source address. More...
 

DMA Channel Management

typedef void(* dma_callback_t )(enum dma_channel_status status)
 Callback definition for DMA channel interrupts. More...
 
void dma_channel_write_config (dma_channel_num_t num, struct dma_channel_config *config)
 Write DMA channel configuration to hardware. More...
 
void dma_channel_read_config (dma_channel_num_t num, struct dma_channel_config *config)
 Read DMA channel configuration from hardware. More...
 
static void dma_channel_enable (dma_channel_num_t num)
 Enable a DMA channel. More...
 
static void dma_channel_disable (dma_channel_num_t num)
 Disable a DMA channel. More...
 
static bool dma_channel_is_enabled (dma_channel_num_t num)
 Check if DMA channel is enabled. More...
 
static bool dma_channel_is_busy (dma_channel_num_t num)
 Check if DMA channel is busy. More...
 
static enum dma_channel_status dma_get_channel_status (dma_channel_num_t num)
 Get channel status. More...
 
static void dma_channel_trigger_block_transfer (dma_channel_num_t num)
 DMA channel trigger block transfer. More...
 
static void dma_channel_reset (dma_channel_num_t num)
 Reset a DMA channel. More...
 
void dma_set_callback (dma_channel_num_t num, dma_callback_t callback)
 Set callback for given DMA channel. More...