145 lines
4.1 KiB
C
145 lines
4.1 KiB
C
#include "include.h"
|
|
#include "tft.h"
|
|
|
|
#define CommEnd() tft_write_end()
|
|
#define WriteData(v) tft_write_data(v)
|
|
#define WriteComm(v) tft_write_cmd(v)
|
|
|
|
#define GUI_TFT_SCREEN_ID 0x0
|
|
|
|
#define GUI_SCREEN_OFS_X 0
|
|
#define GUI_SCREEN_OFS_Y 0
|
|
|
|
static void tft_gui_set_window(u16 x0, u16 y0, u16 x1, u16 y1)
|
|
{
|
|
x0 += GUI_SCREEN_OFS_X;
|
|
x1 += GUI_SCREEN_OFS_X;
|
|
y0 += GUI_SCREEN_OFS_Y;
|
|
y1 += GUI_SCREEN_OFS_Y;
|
|
|
|
WriteComm(0x2A); // TFT_CASET
|
|
WriteData(BYTE1(x0));
|
|
WriteData(BYTE0(x0));
|
|
WriteData(BYTE1(x1));
|
|
WriteData(BYTE0(x1));
|
|
|
|
WriteComm(0x2B); // TFT_PASET
|
|
WriteData(BYTE1(y0));
|
|
WriteData(BYTE0(y0));
|
|
WriteData(BYTE1(y1));
|
|
WriteData(BYTE0(y1));
|
|
|
|
tft_write_end();
|
|
}
|
|
|
|
static void tft_read_id(uint8_t *buf)
|
|
{
|
|
tft_read_id_cmd(0x04);
|
|
|
|
/* dummy clock cycle */
|
|
tft_dummy_clock();
|
|
|
|
buf[0] = tft_spi_getbyte();
|
|
buf[1] = tft_spi_getbyte();
|
|
buf[2] = tft_spi_getbyte();
|
|
tft_write_end();
|
|
}
|
|
|
|
static void tft_128_xsj3023hsd_init(void)
|
|
{
|
|
printf("tft_xsh3023hsd_init\n");
|
|
tft_hw_reset();
|
|
WriteComm(0xff);
|
|
WriteData(0xa5); //switch system register to write
|
|
WriteComm(0x3E);
|
|
WriteData(0x08);
|
|
WriteComm(0x3A);
|
|
WriteData(0x05);
|
|
WriteComm(0x82);
|
|
WriteData(0x00);
|
|
WriteComm(0x98);
|
|
WriteData(0x00);
|
|
WriteComm(0x63);
|
|
WriteData(0x0f);
|
|
WriteComm(0x64);
|
|
WriteData(0x0f);
|
|
WriteComm(0xB4);
|
|
WriteData(0x33);
|
|
WriteComm(0xB5);
|
|
WriteData(0x30);
|
|
WriteComm(0x83);
|
|
WriteData(0x03);
|
|
WriteComm(0x86);//frc
|
|
WriteData(0x07);
|
|
WriteComm(0x87);
|
|
WriteData(0x12);
|
|
WriteComm(0x88);//VCOMH
|
|
WriteData(0x26);
|
|
WriteComm(0x89);//
|
|
WriteData(0x2f);//2F
|
|
WriteComm(0x93); //60:1line 63:frame
|
|
WriteData(0x63);
|
|
WriteComm(0x96);
|
|
WriteData(0x81);
|
|
WriteComm(0xC3);
|
|
WriteData(0x11);
|
|
WriteComm(0xE6);
|
|
WriteData(0x00);
|
|
WriteComm(0x99);
|
|
WriteData(0x01);
|
|
WriteComm(0x44);
|
|
WriteData(0x00);
|
|
|
|
////////////////////////gamma_set//////////////////////////////////////
|
|
WriteComm(0x70);WriteData(0x12);//VRP 0
|
|
WriteComm(0x71);WriteData(0x18);//VRP 1
|
|
WriteComm(0x72);WriteData(0x0a);//VRP 2
|
|
WriteComm(0x73);WriteData(0x11);//VRP 3
|
|
WriteComm(0x74);WriteData(0x17);//VRP 6
|
|
WriteComm(0x75);WriteData(0x1c);//VRP 8
|
|
WriteComm(0x76);WriteData(0x3d);//VRP 10
|
|
WriteComm(0x77);WriteData(0x0a);//VRP 14
|
|
WriteComm(0x78);WriteData(0x08);//VRP 17
|
|
WriteComm(0x79);WriteData(0x3c);//VRP 21
|
|
WriteComm(0x7a);WriteData(0x09);//VRP 23
|
|
WriteComm(0x7b);WriteData(0x0e);//VRP 25
|
|
WriteComm(0x7c);WriteData(0x15);//VRP 28
|
|
WriteComm(0x7d);WriteData(0x0d);//VRP 29
|
|
WriteComm(0x7e);WriteData(0x06);//VRP 30
|
|
WriteComm(0x7f);WriteData(0x0c);//VRP 31
|
|
|
|
WriteComm(0xa0);WriteData(0x0b);//VRN 0
|
|
WriteComm(0xa1);WriteData(0x30);//VRN 1
|
|
WriteComm(0xa2);WriteData(0x08);//VRN 2
|
|
WriteComm(0xa3);WriteData(0x0c);//VRN 3
|
|
WriteComm(0xa4);WriteData(0x08);//VRN 6
|
|
WriteComm(0xa5);WriteData(0x22);//VRN 8
|
|
WriteComm(0xa6);WriteData(0x3b);//VRN 10
|
|
WriteComm(0xa7);WriteData(0x04);//VRN 14
|
|
WriteComm(0xa8);WriteData(0x09);//VRN 17
|
|
WriteComm(0xa9);WriteData(0x36);//VRN 21
|
|
WriteComm(0xaa);WriteData(0x0d);//VRN 23
|
|
WriteComm(0xab);WriteData(0x13);//VRN 25
|
|
WriteComm(0xac);WriteData(0x0d);//VRN 28
|
|
WriteComm(0xad);WriteData(0x05);//VRN 29
|
|
WriteComm(0xae);WriteData(0x31);//VRN 30
|
|
WriteComm(0xaf);WriteData(0x0a);//VRN 31
|
|
//////////////////////////////////////////////////////////////////
|
|
WriteComm(0x35);
|
|
WriteData(0x00);
|
|
WriteComm(0xff);
|
|
WriteData(0x00);
|
|
WriteComm(0x11);
|
|
delay_ms(120);
|
|
WriteComm(0x36);
|
|
WriteData(0x08);
|
|
WriteComm(0x29);
|
|
delay_ms(10);
|
|
}
|
|
|
|
tft_driver_t tft_driver_128_xsj3023hsd = {
|
|
.id = GUI_TFT_SCREEN_ID,
|
|
.init = tft_128_xsj3023hsd_init,
|
|
.read_id = tft_read_id,
|
|
.set_window = tft_gui_set_window,
|
|
}; |