Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dma.h File Reference

Public APIs for the DMA drivers. More...

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/syscalls/dma.h>

Go to the source code of this file.

Data Structures

struct  dma_block_config
 DMA block configuration structure. More...
 
struct  dma_config
 DMA configuration structure. More...
 
struct  dma_status
 DMA runtime status structure. More...
 
struct  dma_context
 DMA context structure Note: the dma_context shall be the first member of DMA client driver Data, got by dev->data. More...
 

Macros

#define DMA_STATUS_COMPLETE   0
 The DMA callback event has occurred at the completion of a transfer list.
 
#define DMA_STATUS_BLOCK   1
 The DMA callback has occurred at the completion of a single transfer block in a transfer list.
 
#define DMA_MAGIC   0x47494749
 Magic code to identify context content.
 
#define DMA_BUF_ADDR_ALIGNMENT(node)
 Get the device tree property describing the buffer address alignment.
 
#define DMA_BUF_SIZE_ALIGNMENT(node)
 Get the device tree property describing the buffer size alignment.
 
#define DMA_COPY_ALIGNMENT(node)
 Get the device tree property describing the minimal chunk of data possible to be copied.
 

Typedefs

typedef void(* dma_callback_t) (const struct device *dev, void *user_data, uint32_t channel, int status)
 Callback function for DMA transfer completion.
 

Enumerations

enum  dma_channel_direction {
  MEMORY_TO_MEMORY = 0x0 , MEMORY_TO_PERIPHERAL , PERIPHERAL_TO_MEMORY , PERIPHERAL_TO_PERIPHERAL ,
  HOST_TO_MEMORY , MEMORY_TO_HOST , DMA_CHANNEL_DIRECTION_COMMON_COUNT , DMA_CHANNEL_DIRECTION_PRIV_START = DMA_CHANNEL_DIRECTION_COMMON_COUNT ,
  DMA_CHANNEL_DIRECTION_MAX = 0x7
}
 DMA channel direction. More...
 
enum  dma_addr_adj { DMA_ADDR_ADJ_INCREMENT , DMA_ADDR_ADJ_DECREMENT , DMA_ADDR_ADJ_NO_CHANGE }
 DMA address adjustment. More...
 
enum  dma_channel_filter { DMA_CHANNEL_NORMAL , DMA_CHANNEL_PERIODIC }
 DMA channel attributes. More...
 
enum  dma_attribute_type { DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT , DMA_ATTR_BUFFER_SIZE_ALIGNMENT , DMA_ATTR_COPY_ALIGNMENT , DMA_ATTR_MAX_BLOCK_COUNT }
 DMA attributes. More...
 

Functions

static int dma_config (const struct device *dev, uint32_t channel, struct dma_config *config)
 Configure individual channel for DMA transfer.
 
static int dma_reload (const struct device *dev, uint32_t channel, uint32_t src, uint32_t dst, size_t size)
 Reload buffer(s) for a DMA channel.
 
int dma_start (const struct device *dev, uint32_t channel)
 Enables DMA channel and starts the transfer, the channel must be configured beforehand.
 
int dma_stop (const struct device *dev, uint32_t channel)
 Stops the DMA transfer and disables the channel.
 
int dma_suspend (const struct device *dev, uint32_t channel)
 Suspend a DMA channel transfer.
 
int dma_resume (const struct device *dev, uint32_t channel)
 Resume a DMA channel transfer.
 
int dma_request_channel (const struct device *dev, void *filter_param)
 request DMA channel.
 
void dma_release_channel (const struct device *dev, uint32_t channel)
 release DMA channel.
 
int dma_chan_filter (const struct device *dev, int channel, void *filter_param)
 DMA channel filter.
 
static int dma_get_status (const struct device *dev, uint32_t channel, struct dma_status *stat)
 get current runtime status of DMA transfer
 
static int dma_get_attribute (const struct device *dev, uint32_t type, uint32_t *value)
 get attribute of a dma controller
 
static uint32_t dma_width_index (uint32_t size)
 Look-up generic width index to be used in registers.
 
static uint32_t dma_burst_index (uint32_t burst)
 Look-up generic burst index to be used in registers.
 

Detailed Description

Public APIs for the DMA drivers.