RT-Thread RTOS
An open source embedded real-time operating system
rt_dma_controller_ops Struct Reference

#include <dma.h>

Data Fields

struct rt_dma_chan *(* request_chan )(struct rt_dma_controller *ctrl, struct rt_device *slave, void *fw_data)
 
rt_err_t(* release_chan )(struct rt_dma_chan *chan)
 
rt_err_t(* start )(struct rt_dma_chan *chan)
 
rt_err_t(* pause )(struct rt_dma_chan *chan)
 
rt_err_t(* stop )(struct rt_dma_chan *chan)
 
rt_err_t(* config )(struct rt_dma_chan *chan, struct rt_dma_slave_config *conf)
 
rt_err_t(* prep_memcpy )(struct rt_dma_chan *chan, rt_ubase_t dma_addr_src, rt_ubase_t dma_addr_dst, rt_size_t len)
 
rt_err_t(* prep_cyclic )(struct rt_dma_chan *chan, rt_ubase_t dma_buf_addr, rt_size_t buf_len, rt_size_t period_len, enum rt_dma_transfer_direction dir)
 
rt_err_t(* prep_single )(struct rt_dma_chan *chan, rt_ubase_t dma_buf_addr, rt_size_t buf_len, enum rt_dma_transfer_direction dir)
 

Detailed Description

DMA controller operations vtable.

Each DMA controller driver provides implementations of these operations. start, stop, and config are mandatory; the rest are optional.

Field Documentation

◆ request_chan

struct rt_dma_chan*(* rt_dma_controller_ops::request_chan) (struct rt_dma_controller *ctrl, struct rt_device *slave, void *fw_data)

Request a DMA channel (optional)

Parameters
[in]ctrlDMA controller
[in]slaveDevice requesting the channel
[in]fw_dataDevice tree cell args (NULL for mem-to-mem)
Returns
Channel pointer, RT_NULL, or error pointer

◆ release_chan

rt_err_t(* rt_dma_controller_ops::release_chan) (struct rt_dma_chan *chan)

Release a DMA channel (optional)

Parameters
[in]chanChannel to release
Returns
RT_EOK on success

◆ start

rt_err_t(* rt_dma_controller_ops::start) (struct rt_dma_chan *chan)

Start a prepared transfer (mandatory)

Parameters
[in]chanChannel with a successfully prepared transfer
Returns
RT_EOK on success

◆ pause

rt_err_t(* rt_dma_controller_ops::pause) (struct rt_dma_chan *chan)

Pause a running transfer (optional)

If not implemented, the framework falls back to stop().

Parameters
[in]chanChannel to pause
Returns
RT_EOK on success

◆ stop

rt_err_t(* rt_dma_controller_ops::stop) (struct rt_dma_chan *chan)

Stop a running transfer (mandatory)

Parameters
[in]chanChannel to stop
Returns
RT_EOK on success

◆ config

rt_err_t(* rt_dma_controller_ops::config) (struct rt_dma_chan *chan, struct rt_dma_slave_config *conf)

Configure a DMA channel (mandatory)

Parameters
[in]chanChannel to configure
[in]confSlave configuration
Returns
RT_EOK on success

◆ prep_memcpy

rt_err_t(* rt_dma_controller_ops::prep_memcpy) (struct rt_dma_chan *chan, rt_ubase_t dma_addr_src, rt_ubase_t dma_addr_dst, rt_size_t len)

Prepare a memory-to-memory transfer (optional)

Parameters
[in]chanDMA channel
[in]dma_addr_srcSource physical address
[in]dma_addr_dstDestination physical address
[in]lenTransfer length in bytes
Returns
RT_EOK on success

◆ prep_cyclic

rt_err_t(* rt_dma_controller_ops::prep_cyclic) (struct rt_dma_chan *chan, rt_ubase_t dma_buf_addr, rt_size_t buf_len, rt_size_t period_len, enum rt_dma_transfer_direction dir)

Prepare a cyclic (repeating) transfer (optional)

Parameters
[in]chanDMA channel
[in]dma_buf_addrBuffer physical address
[in]buf_lenTotal buffer length in bytes
[in]period_lenBytes per period (callback interval)
[in]dirTransfer direction
Returns
RT_EOK on success

◆ prep_single

rt_err_t(* rt_dma_controller_ops::prep_single) (struct rt_dma_chan *chan, rt_ubase_t dma_buf_addr, rt_size_t buf_len, enum rt_dma_transfer_direction dir)

Prepare a single (one-shot) transfer (optional)

Parameters
[in]chanDMA channel
[in]dma_buf_addrBuffer physical address
[in]buf_lenTransfer length in bytes
[in]dirTransfer direction
Returns
RT_EOK on success