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

Go to the source code of this file.

Data Structures

struct  bflb_dbi_config_s
 DBI configuration structure. More...
 

Macros

#define DBI_WRITE_PIXEL_CNT_MAX   0x00FFFFFF
 
#define DBI_MODE_TYPE_B   0 /* mipi-dbi typeB 8-wire-data mode */
 
#define DBI_MODE_TYPE_C_4_WIRE   1 /* mipi-dbi typeC 4-wire mode */
 
#define DBI_MODE_TYPE_C_3_WIRE   2 /* mipi-dbi typeC 3-wire mode */
 
#define DBI_PIXEL_INPUT_FORMAT_NBGR_8888   0 /* 32-bit/pixel, memory byte: [0]->pixel[0][R], [1]->pixel[0][G], [2]->pixel[0][B], [3]->invalid, [4]->pixel[1][R], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_NRGB_8888   1 /* 32-bit/pixel, memory byte: [0]->pixel[0][B], [1]->pixel[0][G], [2]->pixel[0][R], [3]->invalid, [4]->pixel[1][B], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_BGRN_8888   2 /* 32-bit/pixel, memory byte: [0]->invalid, [1]->pixel[0][R], [2]->pixel[0][G], [3]->pixel[0][B], [4]->invalid, [5]->pixel[1][R], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_RGBN_8888   3 /* 32-bit/pixel, memory byte: [0]->invalid, [1]->pixel[0][B], [2]->pixel[0][G], [3]->pixel[0][R], [4]->invalid, [5]->pixel[1][B], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_RGB_888   4 /* 24-bit/pixel, memory byte: [0]->pixel[0][R], [1]->pixel[0][G], [2]->pixel[0][B], [3]->pixel[1][R], [4]->pixel[1][G], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_BGR_888   5 /* 24-bit/pixel, memory byte: [0]->pixel[0][B], [1]->pixel[0][G], [2]->pixel[0][R], [3]->pixel[1][B], [4]->pixel[1][G], ... */
 
#define DBI_PIXEL_INPUT_FORMAT_BGR_565   6 /* 16-bit/pixel, */
 
#define DBI_PIXEL_INPUT_FORMAT_RGB_565   7 /* 16-bit/pixel, */
 
#define DBI_PIXEL_OUTPUT_FORMAT_RGB_565   0 /* 16-bit/pixel */
 
#define DBI_PIXEL_OUTPUT_FORMAT_RGB_888   1 /* 24-bit/pixel, Compatible with RGB666 format */
 
#define DBI_CLOCK_MODE_0   0 /* CPOL=0 CHPHA=0 */
 
#define DBI_CLOCK_MODE_1   1 /* CPOL=0 CHPHA=1 */
 
#define DBI_CLOCK_MODE_2   2 /* CPOL=1 CHPHA=0 */
 
#define DBI_CLOCK_MODE_3   3 /* CPOL=1 CHPHA=1 */
 
#define DBI_QSPI_WIRE_NUM_1   0 /* 1-wire mode */
 
#define DBI_QSPI_WIRE_NUM_4   1 /* 4-wire mode */
 
#define DBI_INTSTS_TC   (1 << 0)
 
#define SPI_INTSTS_TX_FIFO   (1 << 1)
 
#define SPI_INTSTS_FIFO_ERR   (1 << 2)
 
#define DBI_INTCLR_TC   (1 << 0)
 
#define DBI_CMD_CLEAR_TX_FIFO   (0x01)
 
#define DBI_CMD_GET_TX_FIFO_CNT   (0x02)
 
#define DBI_CMD_MASK_CMD_PHASE   (0x03)
 
#define DBI_CMD_CS_CONTINUE   (0x04)
 
#define DBI_CMD_SET_DUMMY_CNT   (0x05)
 
#define DBI_CMD_GET_SIZE_OF_PIXEL_CNT   (0x06)
 
#define DBI_CMD_INPUT_PIXEL_FORMAT   (0x07)
 
#define DBI_CMD_OUTPUT_PIXEL_FORMAT   (0x08)
 

Functions

void bflb_dbi_init (struct bflb_device_s *dev, const struct bflb_dbi_config_s *config)
 Initialize dbi. More...
 
void bflb_dbi_deinit (struct bflb_device_s *dev)
 Deinitialize dbi. More...
 
int bflb_dbi_send_cmd_data (struct bflb_device_s *dev, uint8_t cmd, uint8_t data_len, uint8_t *data_buff)
 Send cmd with pixel data, send cmd -> send address(only QSPI mode) -> send parameter_data. More...
 
int bflb_dbi_send_cmd_read_data (struct bflb_device_s *dev, uint8_t cmd, uint8_t data_len, uint8_t *data_buff)
 To read the data after sending the command, send cmd -> send address(only QSPI mode) -> read parameter_data. More...
 
int bflb_dbi_send_cmd_pixel (struct bflb_device_s *dev, uint8_t cmd, uint32_t pixel_cnt, void *pixel_buff)
 Send cmd with pixel data, send cmd -> send address(only QSPI mode) -> send pixel_data,. More...
 
void bflb_dbi_link_txdma (struct bflb_device_s *dev, bool enable)
 Enable dbi tx dma. More...
 
void bflb_dbi_txint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable dbi rx fifo threhold interrupt. More...
 
void bflb_dbi_tcint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable dbi transfer completion interrupt. More...
 
void bflb_dbi_errint_mask (struct bflb_device_s *dev, bool mask)
 Enable or disable dbi error interrupt. More...
 
uint32_t bflb_dbi_get_intstatus (struct bflb_device_s *dev)
 Get dbi interrupt status. More...
 
void bflb_dbi_int_clear (struct bflb_device_s *dev, uint32_t int_clear)
 Clear dbi interrupt status. More...
 
int bflb_dbi_feature_control (struct bflb_device_s *dev, int cmd, size_t arg)
 Control dbi feature. More...
 

Function Documentation

◆ bflb_dbi_deinit()

void bflb_dbi_deinit ( struct bflb_device_s dev)

Deinitialize dbi.

Parameters
[in]devdevice handle

◆ bflb_dbi_errint_mask()

void bflb_dbi_errint_mask ( struct bflb_device_s dev,
bool  mask 
)

Enable or disable dbi error interrupt.

Parameters
[in]devdevice handle
[in]masktrue means disable, false means enable

◆ bflb_dbi_feature_control()

int bflb_dbi_feature_control ( struct bflb_device_s dev,
int  cmd,
size_t  arg 
)

Control dbi feature.

Parameters
[in]devdevice handle
[in]cmdfeature command, use dbi feature control cmd definition
[in]arguser data
Returns
A negated errno value on failure.

◆ bflb_dbi_get_intstatus()

uint32_t bflb_dbi_get_intstatus ( struct bflb_device_s dev)

Get dbi interrupt status.

Parameters
[in]devdevice handle
Returns
interrupt status, use DBI_INTSTS

◆ bflb_dbi_init()

void bflb_dbi_init ( struct bflb_device_s dev,
const struct bflb_dbi_config_s config 
)

Initialize dbi.

Parameters
[in]devdevice handle
[in]configpointer to save dbi config

◆ bflb_dbi_int_clear()

void bflb_dbi_int_clear ( struct bflb_device_s dev,
uint32_t  int_clear 
)

Clear dbi interrupt status.

Parameters
[in]devdevice handle
[in]int_clearclear value, use spi interrupt clear definition

◆ bflb_dbi_link_txdma()

void bflb_dbi_link_txdma ( struct bflb_device_s dev,
bool  enable 
)

Enable dbi tx dma.

Parameters
[in]devdevice handle
[in]enabletrue means enable, otherwise disable.

◆ bflb_dbi_send_cmd_data()

int bflb_dbi_send_cmd_data ( struct bflb_device_s dev,
uint8_t  cmd,
uint8_t  data_len,
uint8_t *  data_buff 
)

Send cmd with pixel data, send cmd -> send address(only QSPI mode) -> send parameter_data.

Parameters
[in]devdevice handle
[in]cmdcommand
[in]data_lenParameter length (byte), The maximum is DBI_WRITE_DATA_BYTE_MAX
[in]data_buffParameter buffer, Cannot be null
Returns

◆ bflb_dbi_send_cmd_pixel()

int bflb_dbi_send_cmd_pixel ( struct bflb_device_s dev,
uint8_t  cmd,
uint32_t  pixel_cnt,
void *  pixel_buff 
)

Send cmd with pixel data, send cmd -> send address(only QSPI mode) -> send pixel_data,.

Parameters
[in]devdevice handle
[in]cmdcommand
[in]pixel_cntNumber of pixels,The maximum is DBI_WRITE_PIXEL_CNT_MAX
[in]pixel_buffPixels buffer, NULL when using DMA, in which case data needs to be transferred by DMA later, and wait for the transfer to complete
Returns

◆ bflb_dbi_send_cmd_read_data()

int bflb_dbi_send_cmd_read_data ( struct bflb_device_s dev,
uint8_t  cmd,
uint8_t  data_len,
uint8_t *  data_buff 
)

To read the data after sending the command, send cmd -> send address(only QSPI mode) -> read parameter_data.

Parameters
[in]devdevice handle
[in]cmdcommand
[in]data_lenLength of data to be read (byte), The maximum is DBI_READ_DATA_BYTE_MAX
[in]data_buffBuff of data to be read, discard data if null
Returns

◆ bflb_dbi_tcint_mask()

void bflb_dbi_tcint_mask ( struct bflb_device_s dev,
bool  mask 
)

Enable or disable dbi transfer completion interrupt.

Parameters
[in]devdevice handle
[in]masktrue means disable, false means enable

◆ bflb_dbi_txint_mask()

void bflb_dbi_txint_mask ( struct bflb_device_s dev,
bool  mask 
)

Enable or disable dbi rx fifo threhold interrupt.

Parameters
[in]devdevice handle
[in]masktrue means disable, false means enable