172 lines
4.7 KiB
C
172 lines
4.7 KiB
C
|
||
#include "debug_print.h"
|
||
#include "lcd.h"
|
||
#include "common_def.h"
|
||
#include "pinctrl.h"
|
||
#include "gpio.h"
|
||
#include "rtc.h"
|
||
#include "timer.h"
|
||
#include "systick.h"
|
||
#include "chip_core_irq.h"
|
||
// #include "thread_init.h"
|
||
#include "cmsis_os2.h" // ::CMSIS:RTOS2
|
||
#include "cmsis_compiler.h" // Compiler agnostic definitions
|
||
#include "os_tick.h"
|
||
#include "common_def.h"
|
||
#include "lcd_config.h"
|
||
|
||
|
||
extern const lcd_cmds_sequ g_display_off_cmds;
|
||
extern const lcd_cmds_sequ g_idle_in_cmds;
|
||
extern const lcd_cmds_sequ g_idle_out_cmds;
|
||
extern const lcd_cmds_sequ g_te_on_cmds;
|
||
extern const lcd_cmds_sequ g_te_off_cmds;
|
||
extern const lcd_cmds_sequ g_brightness_cmds;
|
||
extern const lcd_cmds_sequ g_sleep_in_cmds;
|
||
extern const lcd_cmds_sequ g_sleep_out_cmds;
|
||
|
||
#define TJD_LCD_460x460_SCREEN_ID 0x1133
|
||
|
||
const combo_dev_cfg_t tjd_g_panel_460x460_60_config = {
|
||
.devno = 0,
|
||
.lane_id = {0, -1},
|
||
.out_mode = OUT_MODE_DSI_CMD,
|
||
.out_format = OUT_FORMAT_RGB_24BIT,
|
||
|
||
.sync_info = {
|
||
.hsa_pixels = 2, // hsa 10 pixels
|
||
.hbp_pixels = 10, // hbp 10 pixels
|
||
.hact_pixels = 466, // hact 454 pixels
|
||
.hfp_pixels = 10, // hfp 10 pixels
|
||
.vsa_lines = 2, // vsa 4 lines
|
||
.vbp_lines = 10, // vbp 12 lines
|
||
.vact_lines = 466, // vact 454 lines
|
||
.vfp_lines = 8, // vfp 10 lines
|
||
},
|
||
|
||
//.phy_data_rate = 480, // 480Mbps mipi使用的
|
||
//.pixel_clk = 20000, // 20000KHz dpu使用
|
||
.phy_data_rate = 400, // 480Mbps mipi使用的
|
||
.pixel_clk = 16000, // 20000KHz dpu使用
|
||
|
||
};
|
||
|
||
const lcd_cmd_sequ g_tjd_460x460_screen_init_on[] = {
|
||
//bist code
|
||
#if 0
|
||
{1, 2, {0xfe, 0x20}, 0},
|
||
{1, 2, {0xf4, 0x5a}, 0},
|
||
{1, 2, {0xf5, 0x59}, 0},
|
||
{1, 2, {0xfe, 0xd0}, 0},
|
||
{1, 2, {0x4d, 0x7f}, 0},
|
||
{1, 2, {0x4e, 0x80}, 0},
|
||
{1, 2, {0xfe, 0x40}, 0},
|
||
{1, 2, {0x54, 0xaf}, 0},
|
||
#endif
|
||
/*{1, 2, {0xfe, 0x20}, 0},
|
||
{1, 2, {0xf4, 0x5a}, 0},
|
||
{1, 2, {0xf5, 0x59}, 0},
|
||
{1, 2, {0xfe, 0x40}, 0},
|
||
{1, 2, {0x08, 0x0a}, 0},*/
|
||
|
||
|
||
|
||
{1, 2, {0xfe, 0x00}, 0},
|
||
//{1, 2, {0xc4, 0x80}, 0},
|
||
//rgb24位数据
|
||
{1, 2, {0x3a, 0x77}, 0},
|
||
//te信号,低电平表示忙,高电平通知MCU可以送显
|
||
{1, 2, {0x35, 0x00}, 0},
|
||
//
|
||
{1, 2, {0x53, 0x20}, 0},
|
||
//亮度调节
|
||
{1, 2, {0x51, 0xff}, 0},
|
||
//高亮模式,默认如此,不用管
|
||
{1, 2, {0x63, 0xff}, 0},
|
||
//设置列地址
|
||
{1, 5, {0x2a, 0x00,0x06,0x01,0xd7}, 0},
|
||
//设置行地址
|
||
{1, 5, {0x2b, 0x00,0x00,0x01,0xd1}, 0},
|
||
{1, 3, {0x44, 0x01, 0xc5}, 0},
|
||
//退出睡眠
|
||
#if defined (TJD_LCD_1_43)
|
||
{1, 1, {0x11}, 120},
|
||
#else
|
||
{1, 1, {0x11}, 60},
|
||
#endif
|
||
|
||
//开启显示
|
||
{1, 1, {0x29}, 0},
|
||
};
|
||
|
||
const lcd_cmds_sequ tjd_g_460x460_screen_init_on_cmds = {
|
||
.cmd = g_tjd_460x460_screen_init_on,
|
||
.cmd_cnt = array_size(g_tjd_460x460_screen_init_on),
|
||
};
|
||
|
||
const lcd_cmd_sequ g_tjd_460x460_screen_init_off[] = {
|
||
{1, 2, {0xfe, 0x00}, 0}, /* select default cmd page */
|
||
{1, 1, {0x28}, 10}, /* display off */
|
||
{1, 1, {0x10}, 100}, /* sleep in */
|
||
{1, 2, {0x4F, 0x01}, 100}, /* idle */
|
||
};
|
||
|
||
const lcd_cmds_sequ tjd_g_460x460_screen_init_off_cmds = {
|
||
.cmd = g_tjd_460x460_screen_init_off,
|
||
.cmd_cnt = array_size(g_tjd_460x460_screen_init_off),
|
||
};
|
||
|
||
const lcd_drv_cfg g_tjd_lcd_driver_ops[] = {
|
||
{
|
||
.bus_type = BUS_DISPLAY_MIPI,
|
||
.bus_cfg = &tjd_g_panel_460x460_60_config,
|
||
.x_start = 6,
|
||
.y_start = 0,
|
||
.fps = 60,
|
||
.lcd_id = TJD_LCD_460x460_SCREEN_ID,
|
||
.display_on_cmds = &tjd_g_460x460_screen_init_on_cmds,
|
||
|
||
.display_off_cmds = &tjd_g_460x460_screen_init_off_cmds,
|
||
.enter_idle_cmds = &g_idle_in_cmds,
|
||
.exit_idle_cmds = &g_idle_out_cmds,
|
||
.te_on_cmds = &g_te_on_cmds,
|
||
.te_off_cmds = &g_te_off_cmds,
|
||
.set_brightnes_cmds = &g_brightness_cmds,
|
||
.sleep_in_cmds = &g_sleep_in_cmds,
|
||
.sleep_out_cmds = &g_sleep_out_cmds,
|
||
.lcd_id_info.reg_addr = 0x04,
|
||
.lcd_id_info.read_len = 3,
|
||
|
||
}
|
||
};
|
||
|
||
lcd_drv_cfg *tjd_lcd_get_driver_ops(void)
|
||
{
|
||
return g_tjd_lcd_driver_ops;
|
||
}
|
||
|
||
uint32_t tjd_lcd_get_ops_num(void)
|
||
{
|
||
return array_size(g_tjd_lcd_driver_ops);
|
||
}
|
||
|
||
combo_dev_cfg_t *tjd_lcd_get_bus_escape_config(void)
|
||
{
|
||
return g_tjd_lcd_driver_ops[0].bus_cfg;
|
||
}
|
||
|
||
lcd_drv_cfg *tjd_lcd_get_driver_config(uint32_t id)
|
||
{
|
||
uint32_t i;
|
||
if (id == 0) {
|
||
return NULL;
|
||
}
|
||
for (i = 0; i < array_size(g_tjd_lcd_driver_ops); i++) {
|
||
if (g_tjd_lcd_driver_ops[i].lcd_id == id) {
|
||
return &(g_tjd_lcd_driver_ops[i]);
|
||
}
|
||
}
|
||
return NULL;
|
||
}
|
||
|