|
SemiDrive SSDK Appication Program Interface PTG3.0
|
#include <part.h>#include "common.h"#include "../source/dma/sdrv_dma_regdef.h"#include "compiler.h"#include "regs_base.h"#include "sdrv_common.h"Go to the source code of this file.
Data Structures | |
| struct | sdrv_dma_mux_param_t |
| struct | sdrv_dma_linklist_descriptor_t |
| struct | sdrv_dma |
| struct | sdrv_dma_channel_config_t |
| struct | sdrv_dma_channel_t |
| #define SDRV_DMA_LIMIT_TIMES 5 |
| #define SDRV_DMA_LP0_LPSIZE_MAX (0x00FFFFFF) |
| #define SDRV_DMA_LP1_LP_COUNT_MAX (0X00000FFF) |
| #define SDRV_DMA_LP1_LPSIZE_MAX (0X00000FFF) |
| #define SDRV_DMA_LP2_LPSIZE | ( | n | ) | ((__builtin_ffs(n) - 1) & 0xf) |
| #define SDRV_DMA_LP2_LPSIZE_MAX (0x000FFFFF) |
| #define SDRV_DMA_LP2_TT | ( | n | ) | ((((n)-1) << 4) & 0xfffff0) |
| #define SDRV_DMA_MAD_CRC_REGISTERS (7) |
| typedef void(* sdrv_dma_irq_handler) (uint32_t status, uint32_t param, void *context) |
DMA channel interrupt callback type.
| typedef struct sdrv_dma sdrv_dma_t |
DMA controller structure.
| anonymous enum |
| enum sdrv_dma_addr_inc_e |
The buffer mode used by different application scenarios.
MAD (Memory access description) - one transaction configuration include source address, target address,transfer mode,transfer length,link address,etc..
Buffer mode is related to transfer mode and loop mode (For details see sdrv_dma_loop_mode_e), when Single Mode selected,buffer mode should be set to SINGLE_BUFFER or 2D_BUFFER. when Continuous Mode selected,buffer mode should be set to DOUBLE_BUFFER or CIRCULAR_BUFFER.
| enum sdrv_dma_burst_len_e |
DMA channel burst length for each transaction.
This is actually the burst length, i.e. AXI AWLEN and ARLEN,for DMA burst transactions. for peripheral transactions,you should set burst length according to peripheral FIFO LEVEL.
| enum sdrv_dma_bus_width_e |
DMA channel data width for each transaction.
This is actually the burst size, i.e., AXI AWSIZE and ARSIZE, for DMA transactions. For memory to memory transactions, use 8 bytes width to get better throughput. However for peripheral transactions, you should set bus width according to hardware register data width.
DMA Channel ID.
DMA channel current status.
DMA channel control state machine status.
DMA Data CRC.
DMA channel interrupt types.
| enum sdrv_dma_loop_mode_e |
DMA channel transfer data mode in one handshake.
LOOP_MODE_0: when one handshake request, DMA transfers the entire length data then terminated according to MAD. LOOP_MODE_1: DMA transfers the specified length (burst length x bus_width) data through one handshake request. LOOP_MODE_2: DMA transfers the specified length (power of 2) data through one handshake request.
| Enumerator | |
|---|---|
| SDRV_DMA_LOOP_MODE_0 | entire length data transaction |
| SDRV_DMA_LOOP_MODE_1 | burst length data transaction |
| SDRV_DMA_LOOP_MODE_2 | power of 2 length data transaction |
| SDRV_DMA_LOOP_MODE_UNDEFINED | |
| enum sdrv_dma_port_sel_e |
The master port used by DMA source and target ports.
The DMA controller as a bus master, has both AXI64 port (for memory access) and AHB32 master port (for device register access). You can configure DMA channels to use different ports for different source and target addresses.
| enum sdrv_dma_status_e |
DMA channel transfer status.
Hardware control after MAD completed just for LOOP_MODE_1.
When one transaction is completed according to MAD, DMA will trigger different control.
DMA channel transfer triggered by which mode.
Select appropriate trigger mode according to transfer type and transfer mode. Hardware trigger actually for peripheral transactions, Software trigger actually for memory transactions,Gtimer trigger actually use DMA internal timer for period transactions, Internal event trigger actually for linklist transactions.
| enum sdrv_dma_xfer_mode_e |
| enum sdrv_dma_xfer_type_e |
DMA channel transfer types.
| status_t sdrv_dma_clear_channel_xfer_bytes | ( | sdrv_dma_channel_t * | channel | ) |
Clear DMA channel transfered bytes counter.
This function clear transfered bytes counter.
| [in] | channel | DMA channel. |
| status_t sdrv_dma_clear_channel_xfer_status | ( | sdrv_dma_channel_t * | channel, |
| uint32_t | status | ||
| ) |
Clear DMA channel status.
This function clear channel current status.
| [in] | channel | DMA channel. |
| [in] | status | Channel status bitmask. |
| status_t sdrv_dma_create_instance | ( | sdrv_dma_t * | dma_instance, |
| paddr_t | base | ||
| ) |
Create DMA controller instance.
This function create instance by dma controller base address.
| [in] | dma_instance | Pointer to DMA instance structure. |
| [in] | base | DMA controller base address. |
| status_t sdrv_dma_deinit_channel | ( | sdrv_dma_channel_t * | channel | ) |
De-initialize the DMA channel.
This function reset channel registers to default value.
| [in] | channel | The DMA channel to de-initialize. |
|
inlinestatic |
get dma channel controller base address.
This function get dma channel base address by dma controller base address and channel id.
| [in] | dma_base | dma controller base address. |
| [in] | channel | dma channel id. |
| channel | controller base address. |
| uint32_t sdrv_dma_get_channel_xfer_bytes | ( | sdrv_dma_channel_t * | channel | ) |
Get number of transfered bytes for the channel.
This function get transfered length in bytes.
| [in] | channel | DMA channel. |
| uint32_t sdrv_dma_get_channel_xfer_status | ( | sdrv_dma_channel_t * | channel | ) |
Get DMA channel status.
This function get channel current status.
| [in] | channel | DMA channel. |
| status_t sdrv_dma_init_channel | ( | sdrv_dma_channel_t * | channel, |
| const sdrv_dma_channel_config_t * | config | ||
| ) |
Initialize DMA channel.
This function set configuration to channel.
| [in] | channel | The channel to initialize. |
| [in] | config | DMA channel configuration. |
| status_t sdrv_dma_init_channel_config | ( | sdrv_dma_channel_config_t * | config, |
| sdrv_dma_t * | instance | ||
| ) |
Initialize default configuration for DMA channel.
This function get channel default configuration.
| [in] | config | DMA channel configuration to initialize. |
| [in] | dma_instance | DMA controller instance. |
| void sdrv_dma_init_dmac | ( | paddr_t | base | ) |
Initialize the DMA controller.
This function initialize dma controller with reset status and fifo.
| [in] | base | DMA controller base address. |
| status_t sdrv_dma_init_linklist_entry | ( | sdrv_dma_linklist_descriptor_t * | desc, |
| const sdrv_dma_channel_config_t * | config | ||
| ) |
Initialize DMA link list descriptor.
This function initializes a DMA link list descriptor, using specified channel configuration.
| [in] | desc | Link list descriptor. |
| [in] | config | DMA channel config. |
|
inlinestatic |
reset dma interrupt type.
This function reset dma controller interrupt status.
| [in] | dma_base | dma controller base address. |
|
inlinestatic |
reset dma fifo.
This function reset dma controller fifo.
| [in] | dma_base | dma controller base address. |
| void sdrv_dma_set_channel_buffer_size | ( | sdrv_dma_channel_t * | channel, |
| sdrv_dma_loop_mode_e | loop_mode, | ||
| uint32_t | total_size, | ||
| uint32_t | loop_size | ||
| ) |
set dma channel single transmit buffer size
This is an unsafe interface. The parameters filled in need to be calculated by yourself, and there is no verification inside the function.
| channel | dma channel ptr |
| loop_mode | loop mode |
| total_size | total bytes |
| loop_size | every handshake transmic bytes(The loop mode 0 does not take effect) |
| status_t sdrv_dma_set_channel_destination_address | ( | sdrv_dma_channel_t * | channel, |
| paddr_t | addr | ||
| ) |
Set DMA channel target address.
This function set target address to channel.
| [in] | channel | DMA channel. |
| [in] | addr | target address. |
|
inlinestatic |
set dma channel interrupt type.
This function set dma channel interrupt type.
| [in] | dma_base | dma controller base address. |
| [in] | channel | dma channel id. |
| [in] | int_type | interrupt type. |
|
inlinestatic |
set dma channel mux id.
This function set mux id for periphal transactions.
| [in] | dma_base | dma controller base address. |
| [in] | channel | dma channel id. |
| [in] | mux_id | dma channel mux id. |
|
inlinestatic |
set dma channel read outstanding.
This function set read outstanding for memory transactions to get better performance.
| [in] | dma_base | dma controller base address. |
| [in] | channel | dma channel id. |
| [in] | value | read outstanding value. |
| status_t sdrv_dma_set_channel_source_address | ( | sdrv_dma_channel_t * | channel, |
| paddr_t | addr | ||
| ) |
Set DMA channel source address.
This function set source address to channel.
| [in] | channel | DMA channel. |
| [in] | addr | source address. |
|
inlinestatic |
set dma channel status.
| [in] | channel_base | dma channel controller base address. |
| [in] | status | dma channel status. |
|
inlinestatic |
set dma channel software handshake.
This function set software handshake for memory transactions.
| [in] | channel_base | dma channel controller base address. |
|
inlinestatic |
set dma channel write outstanding.
This function set write outstanding for memory transactions to get better performance.
| [in] | dma_base | dma controller base address. |
| [in] | channel | dma channel id. |
| [in] | value | write outstanding value. |
| status_t sdrv_dma_set_channel_xfer_bytes | ( | sdrv_dma_channel_t * | channel, |
| uint32_t | xfer_bytes | ||
| ) |
Set transfer length in bytes for the channel.
This function set transfer length in one transaction.
| [in] | channel | DMA channel. |
| [in] | xfer_bytes | transfer bytes. |
| status_t sdrv_dma_start_channel_xfer | ( | sdrv_dma_channel_t * | channel | ) |
Start DMA transaction.
This function start transfer.
| [in] | channel | The DMA channel to start. |
| status_t sdrv_dma_stop_channel_xfer | ( | sdrv_dma_channel_t * | channel | ) |
Stop DMA transaction.
This function stop transfer.
| [in] | channel | The DMA channel to stop. |