InPlay API
DMA device driver

HAL_DMA. More...

Data Structures

struct  dma_bd_t
 DMA block descriptor structure. More...
 

Functions

void * hal_dma_open (int id, int periph_id, uint32_t sar, uint32_t dar, int size, int sdw, int ddw, int sai, int dai, int sbz, int dbz, int sahb, int dahb, int ttype)
 Open the DMA driver. More...
 
void * hal_dma_soft_open (int id, uint32_t sar, uint32_t dar, int size, int sdw, int ddw, int sai, int dai, int sbz, int dbz, int sahb, int dahb, int ttype)
 Open a Software Control DMA driver. More...
 
void hal_dma_close (void *hdl)
 Close the DMA driver. More...
 
int hal_dma_ch_enable (void *hdl, void *arg, void(*callback)(int id, void *arg, uint32_t status))
 (Software Control) DMA channel enable More...
 
int hal_dma_ch_disable (void *hdl)
 DMA channel disable. More...
 
char hal_dma_ch_is_enabled (void *hdl)
 DMA channel is enabled. More...
 
int hal_dma_switch_buffer (void *hdl, int sa_da, uint32_t buffer_addr)
 DMA change source or destination buffer address : This function is provided to quickly switch buffer without re-program all the DMA register. More...
 
int hal_dma_src_req (void *hdl)
 DMA controlled by software to transfer data from or to peripheral. More...
 
uint32_t hal_dma_get_tran_len (void *hdl)
 Get DMA transfer length. More...
 
int hal_dma_add_mb_item (uint32_t ba, uint32_t next_ba, uint32_t dar, uint32_t sar, int dtw, int stw, int dai, int sai, int dbz, int sbz, int dms, int sms, int tt_fc, int size)
 Add DMA each block descriptor for block chaining : Call this function before start DMA block chaining. More...
 
void * hal_dma_mb_open (int id, uint32_t bd_addr, int bda_nb, int src_periph_id, int dst_periph_id)
 DMA block chaining open. More...
 
int hal_dma_mb_ch_enable (void *hdl, void *arg, void(*callback)(int id, void *arg, uint32_t status))
 DMA link list driver open. More...
 
int hal_dma_mb_ch_disable (void *hdl, uint32_t baddr)
 DMA link list driver open. More...
 
int hal_dma_pcm_en (void *buffer0, void *buffer1, uint16_t buffer_len, void *arg, void(*callback)(void *arg, int id, uint32_t status))
 DMA Audio block's PCM data to memory : This function is not responsible for setting up Audio Block's PCM output. More...
 
void * hal_dma_open (int id, int periph_id, int sai, int dai, int sahb, int dahb, int ttype, int prio)
 Open the DMA driver. More...
 

Detailed Description

HAL_DMA.

Function Documentation

◆ hal_dma_add_mb_item()

int hal_dma_add_mb_item ( uint32_t  ba,
uint32_t  next_ba,
uint32_t  dar,
uint32_t  sar,
int  dtw,
int  stw,
int  dai,
int  sai,
int  dbz,
int  sbz,
int  dms,
int  sms,
int  tt_fc,
int  size 
)

Add DMA each block descriptor for block chaining : Call this function before start DMA block chaining.

Parameters
[in]baBlock address. This should be system memory address with 4 bytes alignment
[in]next_baNext block address.
[in]darThe destination address of the DMA trandfer.
[in]sarThe source address of the DMA trandfer.
[in]dtwThe destination transfer data width,
See also
enum dma_tr_width.
Parameters
[in]stwThe source transfer data width,
See also
enum dma_tr_width.
Parameters
[in]daiThe destination address changes,
See also
enum dma_addr_chg.
Parameters
[in]saiThe source address changes,
See also
enum dma_addr_chg.
Parameters
[in]dbzThe destination burst size,
See also
enum dma_tr_msize.
Parameters
[in]sbzThe source burst size,
See also
enum dma_tr_msize.
Parameters
[in]dmsThe destination AHB master,
See also
enum dma_ahb_master.
Parameters
[in]smsThe source AHB master,
See also
enum dma_ahb_master.
Parameters
[in]tt_fc

◆ hal_dma_ch_disable()

int hal_dma_ch_disable ( void *  hdl)

DMA channel disable.

Parameters
[in]hdlThe handle from the previous "open" function.
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.

◆ hal_dma_ch_enable()

int hal_dma_ch_enable ( void *  hdl,
void *  arg,
void(*)(int id, void *arg, uint32_t status)  callback 
)

(Software Control) DMA channel enable

Parameters
[in]hdlThe handle from the previous "open" function.
[in]*argThe pointer to the caller's argument.
[in]*callbackThe call back function for DMA complete.
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.

◆ hal_dma_ch_is_enabled()

char hal_dma_ch_is_enabled ( void *  hdl)

DMA channel is enabled.

Parameters
hdlThe handle from the previous "open" function.
Returns
char 1: is enabled. 0: not enabled. other: error.

◆ hal_dma_close()

void hal_dma_close ( void *  hdl)

Close the DMA driver.

Parameters
[in]hdlThe handle from the previous "open" function.
Returns
This function has no return value.

◆ hal_dma_get_tran_len()

uint32_t hal_dma_get_tran_len ( void *  hdl)

Get DMA transfer length.

Parameters
[in]hdlThe handle from the previous "open" function.
Returns
the length of DMA transfer bytes

◆ hal_dma_mb_ch_disable()

int hal_dma_mb_ch_disable ( void *  hdl,
uint32_t  baddr 
)

DMA link list driver open.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]baddrBlock address to stop.
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.

◆ hal_dma_mb_ch_enable()

int hal_dma_mb_ch_enable ( void *  hdl,
void *  arg,
void(*)(int id, void *arg, uint32_t status)  callback 
)

DMA link list driver open.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]argArguement pass to call back.
[in]callbackCall back after each block finish
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.

◆ hal_dma_mb_open()

void * hal_dma_mb_open ( int  id,
uint32_t  bd_addr,
int  bda_nb,
int  src_periph_id,
int  dst_periph_id 
)

DMA block chaining open.

Parameters
[in]idThe DMAI ID,
See also
enum dma_id.
Parameters
[in]bd_addrFIrst block descriptor base address.
[in]bda_nbNumber of block descriptor
[in]src_periph_idThe peripheral ID,
See also
enum dma0_periph_id and
dma1_periph_id.
Parameters
[in]dst_periph_idThe peripheral ID,
See also
enum dma0_periph_id and
dma1_periph_id.
Returns
the length of DMA transfer bytes

◆ hal_dma_open() [1/2]

void* hal_dma_open ( int  id,
int  periph_id,
int  sai,
int  dai,
int  sahb,
int  dahb,
int  ttype,
int  prio 
)

Open the DMA driver.

Parameters
[in]idThe DMAI ID,
See also
enum dma_id.
Parameters
[in]periph_idThe peripheral ID,
See also
enum dma0_periph_id and
dma1_periph_id.
Parameters
[in]sarThe source address of the DMA trandfer.
[in]darThe destination address of the DMA trandfer.
[in]sizeThe total transfer size.
[in]sdwThe source data width,
See also
enum dma_tr_width.
Parameters
[in]ddwThe destination data width,
See also
enum dma_tr_width.
Parameters
[in]saiThe source address changes,
See also
enum dma_addr_chg.
Parameters
[in]daiThe destination address changes,
See also
enum dma_addr_chg.
Parameters
[in]sbzThe source burst size,
See also
enum dma_tr_msize.
Parameters
[in]dbzThe destination burst size,
See also
enum dma_tr_msize.
Parameters
[in]sahbThe source AHB master,
See also
enum dma_ahb_master.
Parameters
[in]dahbThe destination AHB master,
See also
enum dma_ahb_master.
Parameters
[in]ttypeThe DMA transfer type,
See also
enum dma_ttype.
Returns
Handle to the DMA driver, NULL means open failed.

◆ hal_dma_open() [2/2]

void* hal_dma_open ( int  id,
int  periph_id,
uint32_t  sar,
uint32_t  dar,
int  size,
int  sdw,
int  ddw,
int  sai,
int  dai,
int  sbz,
int  dbz,
int  sahb,
int  dahb,
int  ttype 
)

Open the DMA driver.

Parameters
[in]idThe DMAI ID,
See also
enum dma_id.
Parameters
[in]periph_idThe peripheral ID,
See also
enum dma0_periph_id and
dma1_periph_id.
Parameters
[in]sarThe source address of the DMA trandfer.
[in]darThe destination address of the DMA trandfer.
[in]sizeThe total transfer size.
[in]sdwThe source data width,
See also
enum dma_tr_width.
Parameters
[in]ddwThe destination data width,
See also
enum dma_tr_width.
Parameters
[in]saiThe source address changes,
See also
enum dma_addr_chg.
Parameters
[in]daiThe destination address changes,
See also
enum dma_addr_chg.
Parameters
[in]sbzThe source burst size,
See also
enum dma_tr_msize.
Parameters
[in]dbzThe destination burst size,
See also
enum dma_tr_msize.
Parameters
[in]sahbThe source AHB master,
See also
enum dma_ahb_master.
Parameters
[in]dahbThe destination AHB master,
See also
enum dma_ahb_master.
Parameters
[in]ttypeThe DMA transfer type,
See also
enum dma_ttype.
Returns
Handle to the DMA driver, NULL means open failed.

◆ hal_dma_pcm_en()

int hal_dma_pcm_en ( void *  buffer0,
void *  buffer1,
uint16_t  buffer_len,
void *  arg,
void(*)(void *arg, int id, uint32_t status)  callback 
)

DMA Audio block's PCM data to memory : This function is not responsible for setting up Audio Block's PCM output.

Parameters
[in]buffer0Ping buffer
[in]buffer1Pong buffer
[in]buffer_lenPing/Pong buffer size in 4 bytes unit
[in]argPointer to the user's argument to pass to DMA ping/pong transfer done call back function
[in]callbackPointer to the user's call back function for the DMA ping/pong transfer done.
Returns
DMA_PCM_ERR_OK if successful, otherwise DMA failed
See also
enum dma_pcm_error_code.

◆ hal_dma_soft_open()

void * hal_dma_soft_open ( int  id,
uint32_t  sar,
uint32_t  dar,
int  size,
int  sdw,
int  ddw,
int  sai,
int  dai,
int  sbz,
int  dbz,
int  sahb,
int  dahb,
int  ttype 
)

Open a Software Control DMA driver.

Parameters
[in]idThe DMAI ID,
See also
enum dma_id.
Parameters
[in]sarThe source address of the DMA trandfer.
[in]darThe destination address of the DMA trandfer.
[in]sizeThe total transfer size.
[in]sdwThe source data width,
See also
enum dma_tr_width.
Parameters
[in]ddwThe destination data width,
See also
enum dma_tr_width.
Parameters
[in]saiThe source address changes,
See also
enum dma_addr_chg.
Parameters
[in]daiThe destination address changes,
See also
enum dma_addr_chg.
Parameters
[in]sbzThe source burst size,
See also
enum dma_tr_msize.
Parameters
[in]dbzThe destination burst size,
See also
enum dma_tr_msize.
Parameters
[in]sahbThe source AHB master,
See also
enum dma_ahb_master.
Parameters
[in]dahbThe destination AHB master,
See also
enum dma_ahb_master.
Parameters
[in]ttypeThe DMA transfer type,
See also
enum dma_ttype.
Returns
Handle to the DMA driver, NULL means open failed.

◆ hal_dma_src_req()

int hal_dma_src_req ( void *  hdl)

DMA controlled by software to transfer data from or to peripheral.

Parameters
[in]hdlThe handle from the previous "open" function.
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.

◆ hal_dma_switch_buffer()

int hal_dma_switch_buffer ( void *  hdl,
int  sa_da,
uint32_t  buffer_addr 
)

DMA change source or destination buffer address : This function is provided to quickly switch buffer without re-program all the DMA register.

Parameters
[in]hdlThe handle from the previous "open" function.
[in]sa_daFlag to indicate which buffer address to change, 1: Source address, 0: Destination address
[in]buffer_addrNew buffer address.
Returns
DMA_ERR_OK if successful, otherwise DMA failed.
See also
enum dma_error_code.