Last Updated on : 2025-07-28 07:45:27download
To add an SPI-based replacement screen to T5, SPI driver adaptation is required. This topic uses the GC9A01 SPI driver as an example to illustrate the driver implementation process.
For driver initialization, you can obtain documents from the screen manufacturer.
Path: vendor/T5/t5_os/components/bk_peripheral/src/lcd/spi
lcd_spi_gc9a01.c
file in this directory.When the length is 0xFF
, it indicates a delay, and the data indicates the delay in milliseconds.
#include <common/bk_include.h>
#include <driver/lcd_types.h>
static const lcd_qspi_init_cmd_t gc9a01_init_cmds[] =
{
// Initialization command 0x11, no data
{0x11, {0x00}, 0},
// Initialization command 0x66, 10 pieces of data
{0x66, {0x3C, 0x00, 0xCD, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00}, 10},
// Initialization command 0x29, no data
{0x29, {0x00}, 0}, // Display on
// Length 0xFF indicates delay, data 0x78 means 120 ms. {0x00, {0x78}, 0xFF}, // Sleep
... // Continue initialization commands in this format
}
// Clock configuration (modify as needed)
static const lcd_spi_t lcd_spi_gc9a01_config =
{
.clk = LCD_QSPI_48M
.init_cmd = gc9a01_init_cmds,.device_init_cmd_len = sizeof(gc9a01_init_cmds) / sizeof
(lcd_qspi_init_cmd_t),
};
const lcd_device_t lcd_device_gc9a01 =
{
.id = LCD_DEVICE_GC9A01,
.name ="gc9a01", // Driver name for upper layer lookup
.type = LCD_TYPE_SPI,.ppi = PIXEL_240 << 16 | PIXEL_240, // Screen resolution (you can use direct numbers)
.spi = &lcd_spi_gc9a01_config,
.init = NULL,
.lcd_off = NULL,
};
In .id = LCD_DEVICE_GC9A01
, LCD_DEVICE_GC9A01
is a custom lcd_device_id_t
enumeration member.
Path: vendor/T5/t5_os/bk_idk/include/driver/lcd_types.h
In .ppi = PIXEL_240 << 16 | PIXEL_240
, PIXEL_240
is a custom macro, or you can write a number directly.
Path: vendor/T5/t5_os/bk_idk/include/driver/media_types.h
Add the driver file to config.cmake
.
Path: vendor/T5/t5_os/components/bk_peripheral/include/lcd_panel_devices.h
Path: vendor/T5/t5_os/components/bk_peripheral/src/lcd/lcd_panel_devices.c
Path: vendor/T5/t5_os/components/display_service/src/lcd_spi_display_service.c
SPIO pins:
#define SPIO_LL_CSN_PIN GPIO_15
#define SPIO_LL_SCK_PIN GPIO_14
#define SPIO_LL_MOSI_PIN GPIO_16
#define SPIO_LL_MISO_PIN GPIO_17
Select SPI & QSPI:
#define LCD_SPI_REFRESH_WITH_QSPI 0 //Change spi to 0 and qspi to 1
Control other pins:
#define LCD_SPI_RESET_PIN GPIO_28
#define LCD_SPI_BACKLIGHT_PIN GPIO_26
#define LCD_SPI_RS_PIN GPIO_9
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback