BK24
SPI API Status
API |
|---|
SPI API Reference
Header File
Functions
-
int32_t bk_spi_open(uint32_t dev_index)
beken spi open interface.
提供spi open的接口,使用之前需要先open,参数是设备index,从0开始
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
- 返回值:
0 – fail
other – success
- 返回:
handle
-
int32_t bk_spi_close(uint32_t dev_index)
beken uart close.
使用SPI结束后需要close,调用前需要先 bk_uart_stop()
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_spi_get_default_config(spi_config_t *pt_cfg)
beken uart get default spi config.
可以条用此接口获取默认的spi配置参数
- 参数:
pt_cfg – [out] pointer to the config struct
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_spi_config(uint32_t dev_index, spi_config_t *pt_cfg)
uart config interface.
在 bk_uart_start() 之前需要先进行相关参数的配置
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
pt_cfg – [in] pointer to the config struct
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_spi_write(uint32_t dev_index, uint8_t *tx_buf, uint32_t tx_len, pfunc_bk_spi_cb_t pfn_cb, void *p_arg)
beken uart write interface.
使用SPI来发送数据,如果pfn_cb==NULL,则该函数在把数据通过SPI送出去后才会返回 如果pfn_cb!=NULL,该函数会立即返回,等数据发送出去后通过 pfn_cb进行通知 发送数据长度的不能大于0xFFF
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
tx_buf – [in] pointer to the send buffer
tx_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
p_arg – [in] callback parameter
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_spi_read(uint32_t dev_index, uint8_t *rx_buf, uint32_t rx_len, pfunc_bk_spi_cb_t pfn_cb, void *p_arg)
beken uart read interface.
使用SPI接收数据,如果pfn_cb==NULL,则该函数从SPI收完数据后才会返回 如果pfn_cb!=NULL,该函数会立即返回,等后面数据收完后通过 pfn_cb进行通知 接收数据长度的不能大于0xFFF
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
rx_buf – [in] pointer to the receive buffer
rx_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
p_arg – [in] callback parameter
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t bk_spi_transmit(uint32_t dev_index, uint8_t *tx_buf, uint32_t tx_len, uint8_t *rx_buf, uint32_t rx_len, pfunc_bk_spi_cb_t pfn_cb, void *p_arg)
beken uart transmit interface.
使用SPI进行发送数据同时接收,如果pfn_cb==NULL,则该函数从SPI通信完成后才会返回。 如果pfn_cb!=NULL,该函数会立即返回,等后面通信完成后通过 pfn_cb进行通知。 发送数据长度的不能大于0xFFF 接收数据长度的不能大于0xFFF 本接口请注意预留足够的rx buffer,并且填写正确的rx_len
- 参数:
dev_index – [in] device index, from 0(the first device), < SPI_DEVICE_NUM
tx_buf – [in] pointer to the send buffer
tx_len – [in] send length in bytes
rx_buf – [in] pointer to the receive buffer
rx_len – [in] receive length in bytes
pfn_cb – [in] callback function for async transmit. it can be NULL if you do not want async transmit
p_arg – [in] callback parameter
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
Type Definitions
-
typedef void (*pfunc_bk_spi_cb_t)(uint8_t dev_index, void *p_arg)