BK_UART
BK_UART API Status
API |
|---|
BK_UART API Reference
Header File
Functions
-
uint32_t bk_uart_open(uint32_t dev_index)
beken uart open interface.
提供uart open的接口,使用之前需要先open,参数是设备index,从0开始
- 参数:
dev_index – [in] device index, from 0(the first device), < UART_DEVICE_NUM
- 返回值:
0 – fail
other – success
- 返回:
handle
-
int32_t bk_uart_close(uint32_t handle)
beken uart close.
使用UART结束后需要close,调用前需要先 bk_uart_stop()
- 参数:
handle – [in] return value of bk_uart_open()
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_uart_config(uint32_t handle, bk_uart_cfg_t *pt_cfg)
uart config interface.
在 bk_uart_start() 之前需要先进行相关参数的配置
- 参数:
handle – [in] return value of bk_uart_open()
pt_cfg – [in] pointer to the config struct
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_uart_start(uint32_t handle)
beken uart start.
start uart function after config uart parameter
- 参数:
handle – [in] return value of bk_uart_open()
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_uart_stop(uint32_t handle)
beken uart stop.
stop uart function, 和 bk_uart_start() 的动作相反
- 参数:
handle – [in] return value of bk_uart_open()
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_uart_write(uint32_t handle, uint8_t *pu1_buf, uint16_t buf_len, pfunc_bk_uart_cb_t pfn_cb)
beken uart write interface.
使用UART来发送一些数据出去,如果pfn_cb==NULL,则该函数在把数据通过uart送出去后才会返回 如果pfn_cb!=NULL,该函数会立即返回,等数据发送出去后通过 pfn_cb进行通知
- 参数:
handle – [in] return value of bk_uart_open()
pu1_buf – [in] pointer to the send buffer
buf_len – [in] send buffer length in bytes
pfn_cb – [in] callback function for async send. it can be NULL if you do not want async send
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_uart_read(uint32_t handle, uint8_t *pu1_buf, uint16_t buf_len, pfunc_bk_uart_cb_t pfn_cb)
beken uart read interface.
使用UART收一些数据回来,如果pfn_cb==NULL,则该函数从uart收完数据后才会返回 如果pfn_cb!=NULL,该函数会立即返回,等后面数据收完后通过 pfn_cb进行通知
- 参数:
handle – [in] return value of bk_uart_open()
pu1_buf – [in] pointer to the receive buffer
buf_len – [in] receive buffer length in bytes
pfn_cb – [in] callback function for async recevie. it can be NULL if you do not want async recevie
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
uint32_t bk_uart_get_drv_handle(uint32_t handle)
get drv uart handle
使用BK uart的handle找到驱动的handle
- 参数:
handle – [in] return value of bk_uart_open()
- 返回:
drv uart handle
Structures
-
struct _bk_uart_cfg_t
Type Definitions
-
typedef void (*pfunc_bk_uart_cb_t)(uint32_t handle, uint8_t *pu1_buf, uint16_t buf_len)
-
typedef struct _bk_uart_cfg_t bk_uart_cfg_t