SPI
SPI API Reference
Functions
-
int bk_spi_slave_init(UINT32 rate, UINT32 mode)
Initialises spi slave driver User example:
max_hz=26 * 1000 * 1000; mode = SPI_MODE_0 | SPI_MSB | SPI_SLAVE; bk_spi_slave_init(max_hz, mode);
- 参数
rate, : – the rate of spi transfer
mode, : – spi mode
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_slave_xfer(struct spi_message *msg)
spi slave tX/rx spi data User example:
//TX msg.send_buf = buf; msg.send_len = tx_len; msg.recv_buf = NULL; msg.recv_len = 0; bk_spi_slave_xfer(&msg); //RX msg.send_buf = NULL; msg.send_len = 0; msg.recv_buf = buf; msg.recv_len = buf_len; rx_len = bk_spi_slave_xfer(&msg);
- 参数
msg, : – the config of spi driver
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_slave_deinit(void)
De-initialise spi slave driver.
- 参数
void –
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_init(UINT32 rate, UINT32 mode)
Initialises spi master driver User example:
max_hz=26 * 1000 * 1000; mode = SPI_MODE_0 | SPI_MSB | SPI_MASTER; bk_spi_slave_init(max_hz, mode);
- 参数
rate, : – the rate of spi transfer
mode, : – spi mode
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_xfer(struct spi_message *msg)
spi master tX/rx spi data User example:
//TX msg.send_buf = buf; msg.send_len = tx_len; msg.recv_buf = NULL; msg.recv_len = 0; bk_spi_master_xfer(&msg); //RX msg.send_buf = NULL; msg.send_len = 0; msg.recv_buf = buf; msg.recv_len = buf_len; rx_len = bk_spi_master_xfer(&msg);
- 参数
msg, : – the config of spi driver
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_deinit(void)
De-initialise spi master driver.
- 参数
void –
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_dma_init(UINT32 mode, UINT32 rate, struct spi_message *spi_msg)
Initialises spi dma driver User example:
max_hz=26 * 1000 * 1000; msg.send_buf = buf; msg.send_len = tx_len; msg.recv_buf = NULL; msg.recv_len = 0; mode = SPI_MODE_0 | SPI_MSB | SPI_MASTER; bk_spi_dma_init(mode, max_hz, &msg);
- 参数
rate, : – the rate of spi transfer
mode, : – spi mode
spi_msg, : – the config of spi driver
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_dma_transfer(UINT32 mode, struct spi_message *spi_msg)
start spi tX/rx spi data User example:
max_hz=26 * 1000 * 1000; msg.send_buf = buf; msg.send_len = tx_len; msg.recv_buf = NULL; msg.recv_len = 0; mode = SPI_MODE_0 | SPI_MSB | SPI_MASTER; bk_spi_dma_transfer(mode, max_hz, &msg);
- 参数
mode, : – spi mode
spi_msg, : – the config of spi driver
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_dma_tx_loop_init(UINT32 mode, UINT32 rate, struct spi_message *spi_msg)
Initialises spi dma driver with loop mode User example:
max_hz=26 * 1000 * 1000; msg.send_buf = buf; msg.send_len = tx_len; msg.recv_buf = NULL; msg.recv_len = 0; msg.repeat_cnt =100; //repeat_cnt 0 & 1, means send 1 time. mode = SPI_MODE_0 | SPI_MSB | SPI_MASTER; bk_spi_master_dma_tx_loop_init(mode, max_hz, &msg);
- 参数
rate, : – the rate of spi transfer
mode, : – spi mode
spi_msg, : – the config of spi driver
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_dma_send_loop(struct spi_message *spi_msg)
start loop spi tX/rx spi data User example:
- 参数
spi_msg, : – the data of spi transfer
- 返回
kNoErr: On success.
others: other errors.
-
int bk_spi_master_dma_tx_loop_deinit(void)
De-initialise spi dma loop mode.
- 参数
void –
- 返回
kNoErr: On success.
others: other errors.
Structures
-
struct spi_message
-
struct spi_configuration
SPI configuration structure
-
struct spi_callback_des
Macros
-
SPI_FAILURE
-
SPI_SUCCESS
-
SPI_DEV_NAME
-
SPI_CMD_MAGIC
-
BK_SPI_DEBUG
-
BK_SPI_PRT
-
BK_SPI_WPRT
-
BK_SPI_FATAL
-
USE_SPI_GPIO_14_17
-
USE_SPI_GPIO_30_33
-
USE_SPI_GPIO_NUM
-
SPI_FLASH_WP_GPIO_NUM
-
SPI_FLASH_HOLD_GPIO_NUM
-
SPI_DEF_CLK_HZ
-
TX_FINISH_FLAG
-
BK_SPI_CPOL
-
BK_SPI_CPHA
-
SPI_DEF_MODE
-
SPI_CPHA
-
SPI_CPOL
-
SPI_LSB
-
SPI_MSB
-
SPI_MASTER
-
SPI_SLAVE
-
SPI_USE_4_LINE
-
SPI_USE_3_LINE
-
SPI_LINE_MODE
-
SPI_MODE_0
-
SPI_MODE_1
-
SPI_MODE_2
-
SPI_MODE_3
-
ENABLE
-
DISABLE
-
SPI_TX_LENGTH_MAX
Type Definitions
-
typedef void (*spi_callback)(int port, void *param)
Enumerations
-
enum [anonymous]
Values:
-
enumerator CMD_SPI_UNIT_ENABLE
-
enumerator CMD_SPI_SET_MSTEN
-
enumerator CMD_SPI_SET_CKPHA
-
enumerator CMD_SPI_SET_CKPOL
-
enumerator CMD_SPI_SET_BITWIDTH
-
enumerator CMD_SPI_SET_NSSMD
-
enumerator CMD_SPI_SET_CKR
-
enumerator CMD_SPI_RXINT_EN
-
enumerator CMD_SPI_TXINT_EN
-
enumerator CMD_SPI_RXOVR_EN
-
enumerator CMD_SPI_TXOVR_EN
-
enumerator CMD_SPI_RXFIFO_CLR
-
enumerator CMD_SPI_RXINT_MODE
-
enumerator CMD_SPI_TXINT_MODE
-
enumerator CMD_SPI_INIT_MSTEN
-
enumerator CMD_SPI_GET_BUSY
-
enumerator CMD_SPI_SET_RX_CALLBACK
-
enumerator CMD_SPI_SET_TX_NEED_WRITE_CALLBACK
-
enumerator CMD_SPI_SET_TX_FINISH_CALLBACK
-
enumerator CMD_SPI_DEINIT_MSTEN
-
enumerator CMD_SPI_LSB_EN
-
enumerator CMD_SPI_TX_EN
-
enumerator CMD_SPI_RX_EN
-
enumerator CMD_SPI_TXFINISH_EN
-
enumerator CMD_SPI_RXFINISH_EN
-
enumerator CMD_SPI_TXTRANS_EN
-
enumerator CMD_SPI_RXTRANS_EN
-
enumerator CMD_SPI_CS_EN
-
enumerator CMD_SPI_SET_TX_FINISH_INT_CALLBACK
-
enumerator CMD_SPI_SET_RX_FINISH_INT_CALLBACK
-
enumerator CMD_SPI_UNIT_ENABLE