Display APIs

[English]

LCD Display Interface

The BK LCD Display Driver supports following interfaces:

  • i8080 LCD interface
    1. 项目中使用的屏幕Driving IC 为ST7796S.

    2. 8080 接口的数据传输为8位

    3. 接口支持的数据为RGB565

  • RGB interface
    1. 项目中支持的屏幕有Driving IC ST7282,HX8282, GC9503V.

    2. 接口支持的数据包括RGB565,YUYV,UYVY,YYUV,UVYY,VUYY

LCD API Categories

LCD 8080 Config

880 lcd Overview

Figure 1. 8080 lcd config flow

LCD RGB Config

rgb lcd Overview

Figure 2. rgb lcd config flow

LCD parcical display

rgb lcd Overview

Figure 3. rgb lcd config flow

局部显示参数配置

rgb lcd Overview

Figure 4. rgb lcd config flow

API Reference

Header File

Functions

bk_err_t bk_lcd_driver_init(lcd_clk_t clk)

LCD API.

This API select LCD module clk source

  • config video power

  • open lcd sys interrupt/clk enable

BK_OK: succeed

  • others: other errors.

返回

bk_err_t bk_lcd_8080_init(uint16_t x_pixel, uint16_t y_pixel, pixel_format_t input_data_format)

This API init the 8080 lcd interface.

  • Set lcd display mode is 8080 interface

  • init 8080 lcd gpio

  • enable 8080 display -enable 8080 end of frame interrupt

  • if you want enable start of frame interrupt, please use API bk_lcd_8080_int_enable

参数

x_pixel – user can set by any value, can be lcd size x or picture size x

  • y_pixel user can set by any value, can be lcd size y or picture size y

  • input_data_format, lcd module input data format, can be rgb565, yuyv, uvyy or other pixel_format_t member

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_8080_deinit(void)

8080 lcd interface reg deinit

- This API reset all lcd reg include power 
- close 8080 lcd enable and display
- reset x pixel and y pixel zero
- unregister lcd isr

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_pixel_config(uint16_t x_pixel, uint16_t y_pixel)

This API config lcd display x size and y size.

参数

x_pixel – user can set by any value, can be lcd size x or picture size x

  • y_pixel user can set by any value, can be lcd size y or picture size y

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_8080_int_enable(bool is_sof_en, bool is_eof_en)

This API config 8080 lcd interrupt.

Attention

8080 end of frame int is open in API bk_lcd_8080_init

参数

is_sof_en – enable start of frame interrupt

  • is_eof_en enable end of frame interrupt

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_8080_start_transfer(bool start)

This API start mcu 8080 lcd transfer data to display.

参数

start_transfer

  • 1:data start transfer to lcd display on;

  • 0:stop transfer

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_rgb_deinit(void)

rgb lcd interface reg deinit

      - This API reset all lcd reg include power 
      - close rgb lcd enable and display
      - reset x pixel and y pixel zero
      - unregister lcd isr

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_rgb_display_en(bool en)

enable rgb lcd enable

参数

bool – en

  • 1: enable rgb display

  • 0: disable rgb display

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_rgb_int_enable(bool is_sof_en, bool is_eof_en)

This API config rgb lcd interrupt.

Attention

rgb end of frame int is open in API bk_lcd_rgb_init

参数

is_sof_en – enable start of frame interrupt

  • is_eof_en enable end of frame interrupt

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_isr_register(lcd_isr_t lcd_isr)

This API register lcd isr, user should check int status in isr function, and clear status.

参数

isr, : – isr function

返回

  • BK_OK: succeed

  • others: other errors.

uint32_t bk_lcd_int_status_get(void)

This API used to get lcd int status.

8080 Usage example: if (bk_lcd_int_status_get()&I8080_OUTPUT_EOF == 1), present 8080 eof int triggerd if (bk_lcd_int_status_get()&RGB_OUTPUT_EOF == 1), present rgb eof int triggerd

返回

  • status value.

bk_err_t bk_lcd_int_status_clear(lcd_int_type_t int_type)

This API used to clr lcd int status.

参数

int_type – value.

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_rgb_init(lcd_device_id_t id, uint16_t x_pixel, uint16_t y_pixel, pixel_format_t input_data_format)

This API init the rgb lcd interface.

  • Set lcd display mode is rgb interface

  • init rgb lcd gpio

  • enable rgb display

  • enable rgb end of frame interrupt

参数

lcd_device_id_t, : – lcd type select from lcd_device_id_t

  • x_pixel

  • y_pixel

  • input_data_format: input_data_format select rgb565 data, yuyv, yyuv or other yuv * mode from struct pixel_format_t

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_8080_send_cmd(uint8_t param_count, uint32_t command, uint32_t *param)

This API used send 8080 lcd init cmd.

Usage example:

#define COMMAND_1 0xf uint32_t param_command1[2] = {0xc3, 0x29}; bk_lcd_8080_send_cmd(2, COMMAND_1, param_command1);

参数

param_count, : – cmd parameter number

  • command: command

  • param: the cmd parameter

返回

  • BK_OK: succeed

  • others: other errors.

uint32_t bk_lcd_get_display_base_addr(void)

This API used get lcd display base addr.

返回

lcd display addr

bk_err_t bk_lcd_set_partical_display(bool en, uint16_t partial_clum_l, uint16_t partial_clum_r, uint16_t partial_line_l, uint16_t partial_line_r)

This API used for display partical area.

8080 Usage example:

#define PARTICAL_XS 101 #define PARTICAL_XE 220 #define PARTICAL_YS 101 #define PARTICAL_YE 380 bk_lcd_set_partical_display(EDGE_PARTICAL_XS, EDGE_PARTICAL_XE, EDGE_PARTICAL_YS, EDGE_PARTICAL_YE); bk_lcd_8080_send_cmd(2, COMMAND_1, param_command1);

参数

partial_clum_l, :

  • partial_clum_r:

  • partial_line_l:

  • partial_line_r:

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_8080_ram_write(uint32_t cmd)

This API used for 8080 mcu lcd 0x2c/0x3c. ram write cmd send.

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_init(const lcd_config_t *config)

This API used for init lcd.

Usage example: lcd_config_t lcd_config; lcd_config.device = get_lcd_device_by_id(LCD_DEVICE_ST7282); lcd_config.complete_callback = lcd_complete_callback; lcd_config.fmt = VUYY_DATA; lcd_config.pixel_x = 640; lcd_config.pixel_y = 480; lcd_driver_init(&lcd_config);

参数

lcd_config_t

返回

  • BK_OK: succeed

  • others: other errors.

const lcd_device_t *get_lcd_device_by_id(lcd_device_id_t id)

this api used to get lcd device interface

参数

select – lcd_device_id_t member

返回

lcd device infermation, include: .id = LCD_DEVICE_HX8282, .name = “hx8282”, .type = LCD_TYPE_RGB565, .ppi = PPI_1024X600, .rgb = &lcd_rgb .init = NULL,

const lcd_device_t **get_lcd_devices_list(void)

get lcd device list

返回

  • devices list

uint32_t get_lcd_devices_num(void)

get lcd device number

返回

  • devices number

bk_err_t lcd_driver_backlight_init(uint8_t pwm_id, uint8_t percent)

this api used to init lcd backlight

参数

pwm_id – gpio7—>PWM_ID_1 gpio8—>PWM_ID_2

  • percent: from 0~100

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_backlight_deinit(uint8_t pwm_id)

this api used to deinit lcd backlight

参数

pwm_id – gpio7—>PWM_ID_1 gpio8—>PWM_ID_2

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_set_backlight(uint8_t percent)

this api used to set lcd backlight

参数

percent – rang from 0~100

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_display_enable(void)

this api used to enable lcd display

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_display_continue(void)

this api used to clear eof int and diaplay continue

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_set_display_base_addr(uint32_t disp_base_addr)

this api used to set lcd display addr

参数

disp_base_addr – sram or psram

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_deinit(void)

this api used to close lcd

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_fill_color(lcd_device_id_t id, lcd_disp_framebuf_t *lcd_disp, uint32_t color)

lcd fill color

参数

lcd_disp

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_fill_data(lcd_device_id_t id, lcd_disp_framebuf_t *lcd_disp)

lcd fill data, adapt large amount of data transfer

参数

lcd_disp

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_lcd_draw_point(lcd_device_id_t id, uint16_t x, uint16_t y, uint16_t pixel)

this api used to draw point or adapt small amount of data

参数

disp_base_addr – sram or psram

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_display_frame(frame_buffer_t *frame)

push lcd display frame

参数

lcd – frame include addr, format, width, hight etc.

返回

  • BK_OK: succeed

  • others: other errors.

const lcd_device_t *get_lcd_device_by_ppi(media_ppi_t ppi)

get lcd device struct by ppi

参数

lcd – ppi

返回

  • return true is lcd_device_t member

  • or not find device, return NULL.

const lcd_device_t *get_lcd_device_by_name(char *name)

get lcd device struct by device name

参数

lcd – name

返回

  • return true is lcd_device_t member

  • or not find device, return NULL.

frame_buffer_t *lcd_driver_decoder_frame(frame_buffer_t *frame)

push jpeg frame to decode

参数

jpeg – frame, include addr, format, width, hight,size etc.

返回

  • BK_OK: succeed

  • others: other errors.

frame_buffer_t *lcd_driver_resize_frame(frame_buffer_t *frame, media_ppi_t ppi)

for resize yuv image, like decode image is 640X480, you can resize other ppi

参数
  • yuv – image, include addr, format, width, hight,size etc.

  • the – output ppi, like 320X480.

返回

  • BK_OK: succeed

  • others: other errors.

frame_buffer_t *lcd_driver_rotate_frame(frame_buffer_t *frame)

push decode complete frame to rotate

参数

jpeg – decode frame, include addr, format, width, hight,size etc.

返回

  • BK_OK: succeed

  • others: other errors.

frame_buffer_t *lcd_driver_rodegree_frame(frame_buffer_t *frame, media_rotate_t rotate)
frame_buffer_t *lcd_driver_rotate_frame_ppi(frame_buffer_t *frame, media_ppi_t ppi)

for rotate local area, like decode image is 640X480, can only rotate centre 320X480 area

参数
  • jpeg – decode frame, include addr, format, width, hight,size etc.

  • the – local area ppi, like 320X480.

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_blend(lcd_blend_t *lcd_blend)

this api for lcd blend foreground logo

参数

lcd_blend_t – config blend background/foreground addr, data format, addr offset and orther params

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_driver_font_blend(lcd_font_config_t *lcd_font)

this api for lcd blend font

参数

lcd_font – config blend background addr, addr offset and orther params

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_ldo_power_enable(uint8_t enable)

this api for lcd power

参数

enable – enable/disable lcd power: 1/0

返回

  • BK_OK: succeed

  • others: other errors.

bk_err_t lcd_backlight_control_enable(uint8_t enable)

this api for lcd backlight control

1. this function must enable lcd power, for api lcd_ldo_power_enable

参数

enable – enable/disable lcd backlight: 1/0

返回

  • BK_OK: succeed

  • others: other errors.

API Typedefs

Header File

Structures

struct lcd_rect_t
struct lcd_disp_framebuf_t
struct lcd_rgb_t

rgb interface config param

Public Members

lcd_clk_t clk

config lcd clk

rgb_out_clk_edge_t data_out_clk_edge

rgb data output in clk edge, should refer lcd device spec

uint16_t hsync_back_porch

rang 0~0xFF (0~255), should refer lcd device spec

uint16_t hsync_front_porch

rang 0~0x3F (0~127), should refer lcd device spec

uint16_t vsync_back_porch

rang 0~0x1F (0~31), should refer lcd device spec

uint16_t vsync_front_porch

rang 0~0x7F (0~127), should refer lcd device spec

uint8_t hsync_pulse_width

rang 0~0x3F (0~63), should refer lcd device spec

uint8_t vsync_pulse_width

rang 0~0x3F (0~63), should refer lcd device spec

struct lcd_mcu_t

mcu interface config param

Public Members

lcd_clk_t clk

config lcd clk

void (*set_display_area)(uint16 xs, uint16 xe, uint16 ys, uint16 ye)

if lcd size is smaller then image, and set api bk_lcd_pixel_config is image x y, should set partical display

struct lcd_device_t

Public Members

lcd_device_id_t id

lcd device type, user can add if you want to add another lcd device

char *name

lcd device name

lcd_type_t type

lcd device hw interface

media_ppi_t ppi

lcd device x y size

const lcd_rgb_t *rgb

RGB interface lcd device config

const lcd_mcu_t *mcu

MCU interface lcd device config

void (*backlight_open)(void)

lcd device initial function

void (*backlight_set)(uint8_t)

lcd device initial function

void (*init)(void)

lcd device initial function

void (*backlight_close)(void)

lcd device initial function

bk_err_t (*lcd_off)(void)

lcd off

struct lcd_config_t

Public Members

uint8_t *yuv_addr

blend yuv_data addr

uint8_t *rgb565_addr

blend rgb_data addr

const lcd_device_t *device

lcd device config

pixel_format_t fmt

display module input data format

void (*complete_callback)(void)

lcd display a frame complete callbace

struct yuv_data_t
struct lcd_blend_t

lcd blend config

Public Members

void *pfg_addr

lcd blend background addr

void *pbg_addr

lcd blend foregound addr

uint16_t bg_width

background img width

uint16_t bg_height

background img height

uint32_t fg_offline

foregound addr offset

uint32_t bg_offline

background addr offset

uint32 xsize

lcd blend logo width

uint32 ysize

lcd blend logo height

uint8_t fg_alpha_value

foregound logo alpha value,depend on alpha_mode

uint8_t bg_alpha_value

background logo alpha value,depend on alpha_mode

data_format_t fg_data_format

foregound data format

pixel_format_t bg_data_format

background data format

uint8_t flag

background data format

struct font_str_t

Public Members

const char *str

background data format

font_colot_t font_color

1: white; 0:black

const gui_font_digit_struct *font_digit_type

lcd blend logo width

int x_pos

based on param xsize, to config really draw pos, value 0 is draw in start xsize

int y_pos

based on param ysize, to config really draw pos, value 0 is draw in start xsize

struct lcd_font_config_t

Public Members

void *pbg_addr

lcd draw font foregound addr

uint32_t bg_offline

background addr offset

uint16_t bg_width

background img width

uint16_t bg_height

background img height

pixel_format_t bg_data_format

background data format

uint32 xsize

lcd draw font logo width

uint32 ysize

lcd draw font logo height

Macros

USE_LCD_REGISTER_CALLBACKS
USE_DMA2D_BLEND_ISR_CALLBACKS

Type Definitions

typedef void (*lcd_isr_t)(void)

Enumerations

enum lcd_device_id_t

Values:

enumerator LCD_DEVICE_UNKNOW
enumerator LCD_DEVICE_ST7282

480X270 RGB

enumerator LCD_DEVICE_HX8282

1024X600 RGB

enumerator LCD_DEVICE_GC9503V

480X800 RGB

enumerator LCD_DEVICE_ST7796S

320X480 MCU

enumerator LCD_DEVICE_NT35512

480X800 MCU

enumerator LCD_DEVICE_NT35510

480X854 RGB

enumerator LCD_DEVICE_NT35510_MCU

480X800 MCU

enumerator LCD_DEVICE_H050IWV

800X480 RGB

enumerator LCD_DEVICE_MD0430R

800X480 RGB

enumerator LCD_DEVICE_MD0700R

1024X600 RGB

enumerator LCD_DEVIDE_ST7710S

480X800 RGB

enumerator LCD_DEVICE_ST7701S

480X480 RGB

enumerator LCD_DEVICE_ST7701S_LY

480X480 RGB

enumerator LCD_DEVICE_SN5ST7701S

480X480 RGB

enum lcd_type_t

Values:

enumerator LCD_TYPE_RGB565

lcd devicd output data hardware interface is RGB565 format

enumerator LCD_TYPE_MCU8080

lcd devicd output data hardware interface is MCU 8BIT format

enum lcd_int_type_t

Values:

enumerator RGB_OUTPUT_EOF

reg end of frame int,

enumerator RGB_OUTPUT_SOF

reg display output start of frame

enumerator I8080_OUTPUT_SOF

8080 display output start of frame

enumerator I8080_OUTPUT_EOF

8080 display output end of frame

enum lcd_clk_t

rgb lcd clk select, infulence pfs, user should select according to lcd device spec

Values:

enumerator LCD_320M

diaplay module clk config 320MHz

enumerator LCD_160M
enumerator LCD_120M
enumerator LCD_80M
enumerator LCD_60M
enumerator LCD_54M
enumerator LCD_40M
enumerator LCD_32M
enumerator LCD_30M
enumerator LCD_26M
enumerator LCD_20M
enumerator LCD_12M
enumerator LCD_10M
enumerator LCD_8M
enum rgb_out_clk_edge_t

rgb data output in clk rising or falling

Values:

enumerator POSEDGE_OUTPUT

output in clk falling

enumerator NEGEDGE_OUTPUT

output in clk rising

enum data_format_t

Values:

enumerator ARGB8888

ARGB8888 DMA2D color mode

enumerator RGB888

RGB888 DMA2D color mode

enumerator RGB565

RGB565 DMA2D color mode

enumerator YUYV