DMA
DMA API Status
API |
BK7236 |
BK7236_cp1 |
---|---|---|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
|
Y |
Y |
DMA Channel Number
Capability |
BK7236 |
BK7236_cp1 |
---|---|---|
Channel Number |
6 |
6 |
DMA API Reference
Header File
Functions
-
bk_err_t bk_dma_driver_init(void)
Init the DMA driver.
This API init the resoure common to all dma channels:
Init dma driver control memory
This API should be called before any other dma APIs.
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_driver_deinit(void)
Deinit the DMA driver.
This API free all resource related to dma and power down all dma channels.
- 返回
BK_OK: succeed
others: other errors.
-
dma_id_t bk_dma_alloc(u16 user_id)
Allocate a DMA channel.
This API should be called before any other dma channel APIs.
- Attention
: This API can only be called in task context,
and can’t be called in context that interrupt is disabled.
- 参数
user_id – DMA channel applicant
- 返回
DMA channel id.
> DMA_ID_MAX: no free DMA channel.
-
bk_err_t bk_dma_free(u16 user_id, dma_id_t id)
Free the DMA channel.
- Attention
: This API can only be called in task context,
and can’t be called in context that interrupt is disabled.
- 参数
user_id – DMA channel applicant, the same as in bk_dma_alloc.
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
uint32_t bk_dma_user(dma_id_t id)
get the user of DMA channel
- 参数
id – DMA channel
- 返回
DMA channel user_id.
u32: high u16 is the CPU_ID, low 16 bits is the applicant_id.
-
bk_err_t bk_dma_init(dma_id_t id, const dma_config_t *config)
Init the DMA channel.
- Attention
1. the higher channel priority value, the higher the priority
- 参数
id – DMA channel
config – DMA configuration
- 返回
BK_OK: succeed
BK_ERR_DMA_NOT_INIT: DMA driver not init
BK_ERR_NULL_PARAM: config is NULL
BK_ERR_DMA_ID: invalid DMA channel
BK_ERR_DMA_INVALID_ADDR: invalid DMA address
others: other errors.
-
bk_err_t bk_dma_deinit(dma_id_t id)
Deinit a DMA channel.
This API deinit the DMA channel:
Stop the DMA channel
Reset all configuration of DMA channel to default value
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_start(dma_id_t id)
Start a DMA channel.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_stop(dma_id_t id)
Stop a DMA channel.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_write(dma_id_t id, const uint8_t *data, uint32_t size)
Transfer data from memory to peripheral.
- 参数
id – DMA channel
data – DMA transfer data
size – data size
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_read(dma_id_t id, uint8_t *data, uint32_t size)
Transfer data from peripheral to memory.
- 参数
id – DMA channel
data – DMA transfer data
size – data size
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_finish_interrupt(dma_id_t id)
Enable DMA finish intterrup.
before enable interrupt, please confirm have called bk_dma_register_isr.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_finish_interrupt(dma_id_t id)
Disable DMA finish intterrup.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_half_finish_interrupt(dma_id_t id)
Enable DMA half finish intterrup.
before enable interrupt, please confirm have called bk_dma_register_isr.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_half_finish_interrupt(dma_id_t id)
Disable DMA half finish intterrup.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_register_isr(dma_id_t id, dma_isr_t half_finish_isr, dma_isr_t finish_isr)
Register the interrupt service routine for DMA channel.
This API regist dma isr callback function.
- 参数
id – DMA channel
half_finish_isr – DMA half finish callback
finish_isr – DMA finish callback
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_set_transfer_len(dma_id_t id, uint32_t tran_len)
Set DMA transfer length.
- 参数
id – DMA channel
tran_len – DMA transfer length
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_set_src_addr(dma_id_t id, uint32_t start_addr, uint32_t end_addr)
Set DMA source address.
- Attention
1. address should be zero when there is no value, e.g. bk_dma_set_src_addr(1, 0x80210C, 0)
- 参数
id – DMA channel
start_addr – DMA source start address
end_addr – DMA source end address
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_set_src_start_addr(dma_id_t id, uint32_t start_addr)
Set DMA source start address.
- 参数
id – DMA channel
start_addr – DMA source start address
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_set_dest_addr(dma_id_t id, uint32_t start_addr, uint32_t end_addr)
Set DMA dest address.
- Attention
1. address should be zero when there is no value, e.g. bk_dma_set_dest_addr(1, 0x80210C, 0)
- 参数
id – DMA channel
start_addr – DMA dest start address
end_addr – DMA dest end address
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_set_dest_start_addr(dma_id_t id, uint32_t start_addr)
Set DMA dest start address.
- 参数
id – DMA channel
start_addr – DMA dest start address
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_src_addr_increase(dma_id_t id)
Enable DMA source address increase.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_src_addr_increase(dma_id_t id)
Disable DMA source address increase.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_src_addr_loop(dma_id_t id)
Enable DMA source address loop.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_src_addr_loop(dma_id_t id)
Disable DMA source address loop.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_dest_addr_increase(dma_id_t id)
Enable DMA dest address increase.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_dest_addr_increase(dma_id_t id)
Disable DMA dest address increase.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_enable_dest_addr_loop(dma_id_t id)
Enable DMA dest address loop.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
bk_err_t bk_dma_disable_dest_addr_loop(dma_id_t id)
Disable DMA dest address loop.
- 参数
id – DMA channel
- 返回
BK_OK: succeed
others: other errors.
-
uint32_t bk_dma_get_remain_len(dma_id_t id)
Get DMA transfer remain length.
- 参数
id – DMA channel
- 返回
DMA transfer remain length
-
uint32_t bk_dma_get_enable_status(dma_id_t id)
Gets the current DMA channel working status.
- 参数
id – DMA channel
- 返回
0: Channel idle state
others: Channel busy state.
-
bk_err_t bk_dma_flush_src_buffer(dma_id_t id)
flush reserved data in dma internal buffer I.E:If source data width is not 4bytes, and data size isn’t 4bytes align, but dest data width is 4bytes, then maybe 1~3 bytes data reserved in dma internal buffer, then the left 1~3 bytes data not copy to dest address.
- 参数
id – DMA channel
attr – DMA privileged attr
- 返回
0: Channel idle state
others: Channel busy state.
DMA API Typedefs
Header File
Macros
-
BK_ERR_DMA_ID
DMA id is invalid
-
BK_ERR_DMA_NOT_INIT
DMA driver not init
-
BK_ERR_DMA_ID_NOT_INIT
DMA id not init
-
BK_ERR_DMA_ID_NOT_START
DMA id not start
-
BK_ERR_DMA_INVALID_ADDR
DMA addr is invalid
-
BK_ERR_DMA_ID_REINIT
DMA id has inited, if reinit,please de-init firstly
Type Definitions
Header File
Structures
-
struct dma_port_config_t
Public Members
-
dma_data_width_t width
DMA data width
-
dma_addr_inc_t addr_inc_en
enable/disable DMA address increase
-
dma_addr_loop_t addr_loop_en
enable/disable DMA address loop
-
uint32_t start_addr
DMA start address
-
uint32_t end_addr
DMA end address
-
dma_data_width_t width
-
struct dma_config_t
Public Members
-
dma_work_mode_t mode
DMA work mode
-
dma_chan_priority_t chan_prio
DMA channel prioprity
-
dma_port_config_t src
DMA source configuration
-
dma_port_config_t dst
DMA dest configuration
-
dma_work_mode_t mode
Macros
-
BK_ERR_DMA_HAL_INVALID_ADDR
Type Definitions
-
typedef uint8_t dma_unit_t
DMA uint id
-
typedef uint8_t dma_chan_priority_t
DMA channel priority:the value is higher then the priority is higher
Enumerations
-
enum dma_id_t
Values:
-
enumerator DMA_ID_0
DMA channel 0
-
enumerator DMA_ID_1
DMA channel 1
-
enumerator DMA_ID_2
DMA channel 2
-
enumerator DMA_ID_3
DMA channel 3
-
enumerator DMA_ID_4
DMA channel 4
-
enumerator DMA_ID_5
DMA channel 5
-
enumerator DMA_ID_6
DMA channel 6
-
enumerator DMA_ID_7
DMA channel 7
-
enumerator DMA_ID_8
DMA channel 8
-
enumerator DMA_ID_9
DMA channel 9
-
enumerator DMA_ID_10
DMA channel 10
-
enumerator DMA_ID_11
DMA channel 11
-
enumerator DMA_ID_MAX
DMA channel max
-
enumerator DMA_ID_0
-
enum dma_dev_t
Values:
-
enumerator DMA_DEV_DTCM
DMA device DTCM
-
enumerator DMA_DEV_LA
DMA device LA
-
enumerator DMA_DEV_HSSPI
DMA device HSSPI
-
enumerator DMA_DEV_AUDIO
DMA device AUDIO
-
enumerator DMA_DEV_AUDIO_RX
DMA device AUDIO
-
enumerator DMA_DEV_SDIO
DMA device SDIO
-
enumerator DMA_DEV_SDIO_RX
DMA device SDIO
-
enumerator DMA_DEV_UART1
DMA device UART1
-
enumerator DMA_DEV_UART1_RX
DMA device UART1
-
enumerator DMA_DEV_UART2
DMA device UART2
-
enumerator DMA_DEV_UART2_RX
DMA device UART 2 RX
-
enumerator DMA_DEV_UART3
DMA device UART3
-
enumerator DMA_DEV_UART3_RX
DMA device UART3
-
enumerator DMA_DEV_I2S
DMA device I2S
-
enumerator DMA_DEV_I2S_CH1
DMA device I2S
-
enumerator DMA_DEV_I2S_CH2
DMA device I2S
-
enumerator DMA_DEV_I2S_RX
DMA device I2S
-
enumerator DMA_DEV_I2S_RX_CH1
DMA device I2S
-
enumerator DMA_DEV_I2S_RX_CH2
DMA device I2S
-
enumerator DMA_DEV_I2S1
DMA device I2S
-
enumerator DMA_DEV_I2S1_RX
DMA device I2S
-
enumerator DMA_DEV_I2S2
DMA device I2S
-
enumerator DMA_DEV_I2S2_RX
DMA device I2S
-
enumerator DMA_DEV_GSPI0
DMA device GSPI1
-
enumerator DMA_DEV_GSPI0_RX
DMA device GSPI1
-
enumerator DMA_DEV_GSPI1
DMA device GSPI2
-
enumerator DMA_DEV_GSPI1_RX
DMA device GSPI2
-
enumerator DMA_DEV_GSPI2
DMA device GSPI3
-
enumerator DMA_DEV_JPEG
DMA device JPEG
-
enumerator DMA_DEV_PSRAM_VIDEO
DMA device PSRAM VIDEO
-
enumerator DMA_DEV_PSRAM_AUDIO
DMA device PSRAM AUDIO
-
enumerator DMA_DEV_USB
DMA device USB
-
enumerator DMA_DEV_LCD_CMD
DMA device LCD CMD
-
enumerator DMA_DEV_LCD_DATA
DMA device LCD DATA
-
enumerator DMA_DEV_DISP_RX
DMA device DISP RX
-
enumerator DMA_DEV_SDMADC_RX
DMA device SDMADC RX
-
enumerator DMA_DEV_AHB_MEM
DMA device AHB_MEM
-
enumerator DMA_DEV_SPI0
DMA device SPI 0
-
enumerator DMA_DEV_SPI1
DMA device SPI 1
-
enumerator DMA_DEV_H264
DMA device H264
-
enumerator DMA_DEV_MAX
-
enumerator DMA_DEV_DTCM
-
enum dma_data_width_t
Values:
-
enumerator DMA_DATA_WIDTH_8BITS
DMA data width 8bit
-
enumerator DMA_DATA_WIDTH_16BITS
DMA data width 16bit
-
enumerator DMA_DATA_WIDTH_32BITS
DMA data width 32bit
-
enumerator DMA_DATA_WIDTH_8BITS
-
enum dma_work_mode_t
Values:
-
enumerator DMA_WORK_MODE_SINGLE
DMA work mode single_mode
-
enumerator DMA_WORK_MODE_REPEAT
DMA work mode repeat_mode (forever repeat until software clear dma_en)
-
enumerator DMA_WORK_MODE_SINGLE
-
enum dma_priority_mode_t
Values:
-
enumerator DMA_PRIO_MODE_ROUND_ROBIN
DMA priority mode round-robin(all dma priority are the same)
-
enumerator DMA_PRIO_MODE_FIXED_PRIO
DMA priority mode fixed prio(depend on chan_prio)
-
enumerator DMA_PRIO_MODE_ROUND_ROBIN
-
enum dma_addr_inc_t
Values:
-
enumerator DMA_ADDR_INC_DISABLE
DMA disable addrress increase
-
enumerator DMA_ADDR_INC_ENABLE
DMA enable addrress increase
-
enumerator DMA_ADDR_INC_DISABLE
-
enum dma_addr_loop_t
Values:
-
enumerator DMA_ADDR_LOOP_DISABLE
DMA disable addrress loop
-
enumerator DMA_ADDR_LOOP_ENABLE
DMA enable addrress loop
-
enumerator DMA_ADDR_LOOP_DISABLE