Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_spi.h File Reference
#include "bflb_core.h"
Include dependency graph for bflb_spi.h:

Go to the source code of this file.

Data Structures

struct  bflb_spi_config_s
 SPI configuration structure. More...
 

Macros

#define SPI_ROLE_MASTER   0
 
#define SPI_ROLE_SLAVE   1
 
#define SPI_MODE0   0 /* CPOL=0 CHPHA=0 */
 
#define SPI_MODE1   1 /* CPOL=0 CHPHA=1 */
 
#define SPI_MODE2   2 /* CPOL=1 CHPHA=0 */
 
#define SPI_MODE3   3 /* CPOL=1 CHPHA=1 */
 
#define SPI_DATA_WIDTH_8BIT   1
 
#define SPI_DATA_WIDTH_16BIT   2
 
#define SPI_DATA_WIDTH_24BIT   3
 
#define SPI_DATA_WIDTH_32BIT   4
 
#define SPI_BIT_LSB   1
 
#define SPI_BIT_MSB   0
 
#define SPI_BYTE_LSB   0
 
#define SPI_BYTE_MSB   1
 
#define SPI_INTSTS_TC   (1 << 0)
 
#define SPI_INTSTS_TX_FIFO   (1 << 1)
 
#define SPI_INTSTS_RX_FIFO   (1 << 2)
 
#define SPI_INTSTS_SLAVE_TIMEOUT   (1 << 3)
 
#define SPI_INTSTS_SLAVE_TX_UNDERRUN   (1 << 4)
 
#define SPI_INTSTS_FIFO_ERR   (1 << 5)
 
#define SPI_INTCLR_TC   (1 << 16)
 
#define SPI_INTCLR_SLAVE_TIMEOUT   (1 << 19)
 
#define SPI_INTCLR_SLAVE_TX_UNDERRUN   (1 << 20)
 
#define SPI_CMD_SET_DATA_WIDTH   (0x01)
 
#define SPI_CMD_GET_DATA_WIDTH   (0x02)
 
#define SPI_CMD_CLEAR_TX_FIFO   (0x03)
 
#define SPI_CMD_CLEAR_RX_FIFO   (0x04)
 
#define SPI_CMD_SET_CS_INTERVAL   (0x05)
 
#define SPI_CMD_RX_IGNORE   (0x06)
 
#define SPI_CMD_SET_MODE   (0x07)
 
#define SPI_CMD_GET_MODE   (0x08)
 
#define SPI_CMD_SET_FREQ   (0x09)
 
#define SPI_CMD_GET_FREQ   (0x0A)
 
#define SPI_CMD_SET_BIT_ORDER   (0x0B)
 
#define SPI_CMD_GET_BIT_ORDER   (0x0C)
 
#define SPI_CMD_SET_BYTE_ORDER   (0x0E)
 
#define SPI_CMD_GET_BYTE_ORDER   (0x0F)
 

Functions

void bflb_spi_init (struct bflb_device_s *dev, const struct bflb_spi_config_s *config)
 Initialize spi. More...
 
void bflb_spi_deinit (struct bflb_device_s *dev)
 Deinitialize spi. More...
 
void bflb_spi_link_txdma (struct bflb_device_s *dev, bool enable)
 Enable spi tx dma. More...
 
void bflb_spi_link_rxdma (struct bflb_device_s *dev, bool enable)
 Enable spi rx dma. More...
 
uint32_t bflb_spi_poll_send (struct bflb_device_s *dev, uint32_t data)
 Send and receive one data on spi. More...
 
int bflb_spi_poll_exchange (struct bflb_device_s *dev, const void *txbuffer, void *rxbuffer, size_t nbytes)
 Send and receive a block of data on spi. More...
 
bool bflb_spi_isbusy (struct bflb_device_s *dev)
 Check if spi is busy. More...
 
void bflb_spi_txint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable spi rx fifo threhold interrupt. More...
 
void bflb_spi_rxint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable spi rx fifo threhold interrupt. More...
 
void bflb_spi_tcint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable spi transfer done interrupt. More...
 
void bflb_spi_errint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable spi error interrupt. More...
 
uint32_t bflb_spi_get_intstatus (struct bflb_device_s *dev)
 Get spi interrupt status. More...
 
void bflb_spi_int_clear (struct bflb_device_s *dev, uint32_t int_clear)
 Clear spi interrupt status. More...
 
int bflb_spi_feature_control (struct bflb_device_s *dev, int cmd, size_t arg)
 Control spi feature. More...