Microchip® Advanced Software Framework

dma.h File Reference

SAM Direct Memory Access Controller Driver.

Copyright (c) 2014-2020 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include "conf_dma.h"

Data Structures

struct  dma_descriptor_config
 DMA transfer descriptor configuration. More...
 
struct  dma_events_config
 Configurations for DMA events. More...
 
struct  dma_resource
 Structure for DMA transfer resource. More...
 
struct  dma_resource_config
 DMA configurations for transfer. More...
 

Macros

#define DMA_INVALID_CHANNEL   0xff
 DMA invalid channel number. More...
 

Typedefs

typedef void(* dma_callback_t )(struct dma_resource *const resource)
 Type definition for a DMA resource callback function. More...
 

Enumerations

enum  dma_address_increment_stepsize {
  DMA_ADDRESS_INCREMENT_STEP_SIZE_1 = 0,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_2,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_4,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_8,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_16,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_32,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_64,
  DMA_ADDRESS_INCREMENT_STEP_SIZE_128
}
 Address increment step size. More...
 
enum  dma_beat_size {
  DMA_BEAT_SIZE_BYTE = 0,
  DMA_BEAT_SIZE_HWORD,
  DMA_BEAT_SIZE_WORD
}
 The basic transfer unit in DMAC is a beat, which is defined as a single bus access. More...
 
enum  dma_block_action {
  DMA_BLOCK_ACTION_NOACT = 0,
  DMA_BLOCK_ACTION_INT,
  DMA_BLOCK_ACTION_SUSPEND,
  DMA_BLOCK_ACTION_BOTH
}
 Block action definitions. More...
 
enum  dma_callback_type {
  DMA_CALLBACK_TRANSFER_ERROR,
  DMA_CALLBACK_TRANSFER_DONE,
  DMA_CALLBACK_CHANNEL_SUSPEND,
  DMA_CALLBACK_N
}
 Callback types for DMA callback driver. More...
 
enum  dma_event_input_action {
  DMA_EVENT_INPUT_NOACT,
  DMA_EVENT_INPUT_TRIG,
  DMA_EVENT_INPUT_CTRIG,
  DMA_EVENT_INPUT_CBLOCK,
  DMA_EVENT_INPUT_SUSPEND,
  DMA_EVENT_INPUT_RESUME,
  DMA_EVENT_INPUT_SSKIP
}
 DMA input actions. More...
 
enum  dma_event_output_selection {
  DMA_EVENT_OUTPUT_DISABLE = 0,
  DMA_EVENT_OUTPUT_BLOCK,
  DMA_EVENT_OUTPUT_RESERVED,
  DMA_EVENT_OUTPUT_BEAT
}
 Event output selection. More...
 
enum  dma_priority_level {
  DMA_PRIORITY_LEVEL_0,
  DMA_PRIORITY_LEVEL_1,
  DMA_PRIORITY_LEVEL_2,
  DMA_PRIORITY_LEVEL_3
}
 DMA priority level. More...
 
enum  dma_step_selection {
  DMA_STEPSEL_DST = 0,
  DMA_STEPSEL_SRC
}
 DMA step selection. More...
 
enum  dma_transfer_trigger_action {
  DMA_TRIGGER_ACTION_BLOCK = DMAC_CHCTRLB_TRIGACT_BLOCK_Val,
  DMA_TRIGGER_ACTION_BEAT = DMAC_CHCTRLB_TRIGACT_BEAT_Val,
  DMA_TRIGGER_ACTION_TRANSACTION = DMAC_CHCTRLB_TRIGACT_TRANSACTION_Val
}
 DMA trigger action type. More...
 

Functions

void dma_abort_job (struct dma_resource *resource)
 Abort a DMA transfer. More...
 
enum status_code dma_add_descriptor (struct dma_resource *resource, DmacDescriptor *descriptor)
 Add a DMA transfer descriptor to a DMA resource. More...
 
enum status_code dma_allocate (struct dma_resource *resource, struct dma_resource_config *config)
 Allocate a DMA with configurations. More...
 
void dma_descriptor_create (DmacDescriptor *descriptor, struct dma_descriptor_config *config)
 Create a DMA transfer descriptor with configurations. More...
 
static void dma_descriptor_get_config_defaults (struct dma_descriptor_config *config)
 Initializes DMA transfer configuration with predefined default values. More...
 
static void dma_disable_callback (struct dma_resource *resource, enum dma_callback_type type)
 Disable a callback function for a dedicated DMA resource. More...
 
static void dma_enable_callback (struct dma_resource *resource, enum dma_callback_type type)
 Enable a callback function for a dedicated DMA resource. More...
 
enum status_code dma_free (struct dma_resource *resource)
 Free an allocated DMA resource. More...
 
void dma_get_config_defaults (struct dma_resource_config *config)
 Initializes config with predefined default values. More...
 
static enum status_code dma_get_job_status (struct dma_resource *resource)
 Get DMA resource status. More...
 
static bool dma_is_busy (struct dma_resource *resource)
 Check if the given DMA resource is busy. More...
 
static void dma_register_callback (struct dma_resource *resource, dma_callback_t callback, enum dma_callback_type type)
 Register a callback function for a dedicated DMA resource. More...
 
static void dma_reset_descriptor (struct dma_resource *resource)
 Reset DMA descriptor. More...
 
void dma_resume_job (struct dma_resource *resource)
 Resume a suspended DMA transfer. More...
 
enum status_code dma_start_transfer_job (struct dma_resource *resource)
 Start a DMA transfer. More...
 
void dma_suspend_job (struct dma_resource *resource)
 Suspend a DMA transfer. More...
 
static void dma_trigger_transfer (struct dma_resource *resource)
 Will set a software trigger for resource. More...
 
static void dma_unregister_callback (struct dma_resource *resource, enum dma_callback_type type)
 Unregister a callback function for a dedicated DMA resource. More...
 
static void dma_update_descriptor (struct dma_resource *resource, DmacDescriptor *descriptor)
 Update DMA descriptor. More...
 

Variables

DmacDescriptor descriptor_section [CONF_MAX_USED_CHANNEL_NUM]
 ExInitial description section. More...
 
uint8_t g_chan_interrupt_flag [CONF_MAX_USED_CHANNEL_NUM]