Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

This section provides DMA OS-HAL APIs to use DMA channel for data transfer. More...

Overview

This section provides DMA OS-HAL APIs to use DMA channel for data transfer.

Functions

int mtk_os_hal_dma_alloc_chan (enum dma_channel chn)
 This function is used to allocate one DMA channel. More...
 
int mtk_os_hal_dma_config (enum dma_channel chn, struct dma_setting *setting)
 This function is used to config one DMA channel. More...
 
int mtk_os_hal_dma_start (enum dma_channel chn)
 This function is used to start one DMA channel. More...
 
int mtk_os_hal_dma_stop (enum dma_channel chn)
 This function is used to stop one DMA channel. More...
 
int mtk_os_hal_dma_pause (enum dma_channel chn)
 This function is used to pause one DMA channel. More...
 
int mtk_os_hal_dma_resume (enum dma_channel chn)
 This function is used to resume one DMA channel. More...
 
int mtk_os_hal_dma_get_status (enum dma_channel chn)
 This function is used to get DMA channel status. More...
 
int mtk_os_hal_dma_register_isr (enum dma_channel chn, dma_interrupt_callback callback, void *callback_data, enum dma_interrupt_type isr_type)
 This function is used to register interrupt callback. More...
 
int mtk_os_hal_dma_dump_register (enum dma_channel chn)
 This function is used to dump DMA registers for debug. More...
 
int mtk_os_hal_dma_set_param (enum dma_channel chn, enum dma_param_type param_type, u32 value)
 This function is used to set DMA parameter which is defined in the dma_param_type. More...
 
int mtk_os_hal_dma_get_param (enum dma_channel chn, enum dma_param_type param_type)
 This function is used to get DMA parameter which is defined in the dma_param_type. More...
 
int mtk_os_hal_dma_update_swptr (enum dma_channel chn, u32 length_byte)
 This function is used to update VFF DMA channel swptr. More...
 
int mtk_os_hal_dma_vff_read_data (enum dma_channel chn, u8 *buffer, u32 length)
 This function is used to read data from FIFO of VFF DMA channel. More...
 
int mtk_os_hal_dma_release_chan (enum dma_channel chn)
 This function is used to release one DMA channel. More...
 
int mtk_os_hal_dma_reset (enum dma_channel chn)
 This function is used to reset DMA channel. More...
 
int mtk_os_hal_dma_clr_dreq (enum dma_channel chn)
 This function is used to clear dreq signal of DMA channel. More...
 

Function Documentation

int mtk_os_hal_dma_alloc_chan ( enum dma_channel  chn)

This function is used to allocate one DMA channel.

Usage: Users should call it as the first step when use DMA OS-HAL APIs.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users allocate DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_config ( enum dma_channel  chn,
struct dma_setting setting 
)

This function is used to config one DMA channel.

Usage: Used to config one DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[in]setting: The DMA channel data transfer setting, please refer to dma_setting.
Returns
Return 0 if users allocate DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_start ( enum dma_channel  chn)

This function is used to start one DMA channel.

Usage: Used to start one DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users start DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_stop ( enum dma_channel  chn)

This function is used to stop one DMA channel.

Usage: Used to stop one DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users stop DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_pause ( enum dma_channel  chn)

This function is used to pause one DMA channel.

Usage: Used to pause one DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users pause DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_resume ( enum dma_channel  chn)

This function is used to resume one DMA channel.

Usage: Used to resume one DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users resume DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_get_status ( enum dma_channel  chn)

This function is used to get DMA channel status.

Usage: Used to get DMA channel status. The DMA channel status can refer to dma_status in M-HAL.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return DMA channel status if get DMA channel status successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_register_isr ( enum dma_channel  chn,
dma_interrupt_callback  callback,
void *  callback_data,
enum dma_interrupt_type  isr_type 
)

This function is used to register interrupt callback.

Usage: Used to register interrupt callback.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[in]callback: The DMA interrupt callback, please refer to dma_interrupt_callback.
[in]callback_data: The users data of callback.
[in]isr_type: The interrupt type, please refer to dma_interrupt_type.
Returns
Return 0 if users allocate DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_dump_register ( enum dma_channel  chn)

This function is used to dump DMA registers for debug.

Usage: Used to dump DMA registers for debug.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users dump DMA registers successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_set_param ( enum dma_channel  chn,
enum dma_param_type  param_type,
u32  value 
)

This function is used to set DMA parameter which is defined in the dma_param_type.

Usage: Users should call this function carefully if DMA channel is running.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[in]param_type: The parameter type whose value to be set.
[in]value: The new parameter value.
Returns
Return 0 if users set DMA channel parameter successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_get_param ( enum dma_channel  chn,
enum dma_param_type  param_type 
)

This function is used to get DMA parameter which is defined in the dma_param_type.

Usage: Users should call this function carefully if DMA channel is running.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[in]param_type: The parameter type whose value to be got.
Returns
Return the parameter value if users get DMA parameters successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_update_swptr ( enum dma_channel  chn,
u32  length_byte 
)

This function is used to update VFF DMA channel swptr.

Usage: Used to update VFF DMA channel swptr. If users read data from Virtual FIFO or write data into Virtual FIFO, users should update swptr to control read pointer or write pointer of fifo control engine. This API is only for VFF DMA.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[in]length_byte: The updated byte count. It cannot be larger than vfifo size.
Returns
Return 0 if users update VFF DMA channel swptr successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_vff_read_data ( enum dma_channel  chn,
u8 *  buffer,
u32  length 
)

This function is used to read data from FIFO of VFF DMA channel.

Usage: Used to read data from FIFO of VFF DMA channel. This api will also update swptr after reading data. This API is only for VFF DMA.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
[out]buffer: buffer for saving read data.
[in]length: byte number which users want to read. It cannot be larger than vfifo size.
Returns
Return the actual read data byte count if successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_release_chan ( enum dma_channel  chn)

This function is used to release one DMA channel.

Usage: Users should call it as the last step when use DMA OS-HAL APIs.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users release DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_reset ( enum dma_channel  chn)

This function is used to reset DMA channel.

Usage: Users can call this API to reset DMA channel.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users reset DMA channel successfully.
Return negative integer indicating error number when error occur.
int mtk_os_hal_dma_clr_dreq ( enum dma_channel  chn)

This function is used to clear dreq signal of DMA channel.

Usage: This function is specified for HALF-SIZE DMA and VFF DMA.

Parameters
[in]chn: The DMA channel number, please refer to dma_channel.
Returns
Return 0 if users clear dreq signal successfully.
Return negative integer indicating error number when error occur.