BK_I2C
BK_I2C API Status
API |
|---|
BK_I2C API Reference
Header File
Functions
-
uint32_t bk_i2c_open(uint32_t dev_index)
beken I2C open.
使用之前需要先open,参数是设备index,从0开始
- 参数:
dev_index – [in] device index, from 0(the first device), < I2C_DEVICE_NUM
- 返回值:
0 – fail
other – success
- 返回:
handle
-
int32_t bk_i2c_close(uint32_t handle)
beken I2C close.
使用I2C结束后需要close,和 bk_i2c_open() 是配对的
- 参数:
handle – [in] return value of bk_i2c_open()
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_i2c_master_tx_rx(uint32_t handle, bk_i2c_blk_t *pt_blk)
beken master I2C send and receive.
使用I2C来发送一些数据出去,然后收一些数据回来(可选)。该函数是一个异步函数
- 参数:
handle – [in] return value of bk_i2c_open()
pt_blk – [in] 指向待发送的结构体。pt_blk->pu1_buf 在 pt_blk->pfn_cb 调用之前不能被free重用 发送的结果会通过 pt_blk->pfn_cb 来通知
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_i2c_slave_rx_tx(uint32_t handle, bk_i2c_blk_t *pt_blk)
beken slave I2C receive and response.
使用I2C来接收一些数据,然后回复一些数据(可选)。该函数是一个异步函数
- 参数:
handle – [in] return value of bk_i2c_open()
pt_blk – [in] 指向待发送的结构体。pt_blk->pu1_buf 在 pt_blk->pfn_cb 调用之前不能被free重用 发送的结果会通过 pt_blk->pfn_cb 来通知
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
Structures
-
struct _bk_i2c_blk_t
Type Definitions
-
typedef void (*pfunc_bk_i2c_cb_t)(uint32_t handle, int32_t err_code, void *pv_arg)
-
typedef struct _bk_i2c_blk_t bk_i2c_blk_t