aboutsummaryrefslogtreecommitdiff
path: root/include/tft.h
blob: 22303a1a39333146620acbc2ce3943d5ad018beb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef TFT_H
#define TFT_H

#include <hardware.h>
#include <stdint.h>

#define TFT_WIDTH 480
#define TFT_HEIGHT 320

enum tft_command {
    NOP        = 0x00,
    SWRESET    = 0x01,
    RDDID      = 0x04,
    RDNUMPE    = 0x05,
    RDRED      = 0x06,
    RDGREEN    = 0x07,
    RDBLUE     = 0x08,
    RDDPM      = 0x0A,
    RDDMADCTL  = 0x0B,
    RDDCOLMOD  = 0x0C,
    RDDIM      = 0x0D,
    RDDSM      = 0x0E,
    RDDSDR     = 0x0F,
    SPLIN      = 0x10,
    SLPOUT     = 0x11,
    PTLON      = 0x12,
    NORON      = 0x13,
    INVOFF     = 0x20,
    INVON      = 0x21,
    ALLPOFF    = 0x22,
    ALLPON     = 0x23,
    GAMSET     = 0x26,
    DISPOFF    = 0x28,
    DISPON     = 0x29,
    CASET      = 0x2A,
    PASET      = 0x2B,
    RAMWR      = 0x2C,
    RAMRD      = 0x2E,
    PLTAR      = 0x30,
    VSCRDEF    = 0x33,
    TEOFF      = 0x34,
    TEON       = 0x35,
    MADCTL     = 0x36,
    VSCRSADD   = 0x37,
    IDMOFF     = 0x38,
    IDMON      = 0x39,
    COLMOD     = 0x3A,
    CONRAMWR   = 0x3C,
    CONRAMRD   = 0x3E,
    TESL       = 0x44,
    GETSL      = 0x45,
    WRDISBV    = 0x51,
    RDDISBV    = 0x52,
    WRCTRLD    = 0x53,
    RDCTRLD    = 0x54,
    WRCABC     = 0x55,
    RDCABC     = 0x56,
    WRCABCMB   = 0x5E,
    RDCABCMB   = 0x5F,
    RDABVCSDR  = 0x68,
    RDBWLK     = 0x70,
    RDBKX      = 0x71,
    RDBKY      = 0x72,
    RDWX       = 0x73,
    RDWY       = 0x74,
    RDRGLB     = 0x75,
    RDRX       = 0x76,
    RDRY       = 0x77,
    RDGX       = 0x78,
    RDGY       = 0x79,
    RDBALB     = 0x7A,
    RDBX       = 0x7B,
    RDBY       = 0x7C,
    RDAX       = 0x7D,
    RDAY       = 0x7E,

    RDID1      = 0xDA,
    RDID2      = 0xDB,
    RDID3      = 0xDC,
    SETOSC     = 0xB0,
    SETPOWER   = 0xB1,
    SETDISCTRL = 0xB2,
    SETRGB     = 0xB3,
    SETCYC     = 0xB4,
    SETBGP     = 0xB5,
    SETCOM     = 0xB6,
    SETOTP     = 0xB7,
    SETEXTC    = 0xB9,
    SETSTBA    = 0xC0,
    SETDGC     = 0xC1,
    SETID      = 0xC3,
    SETDDB     = 0xC4,
    SETCABC    = 0xC9,
    SETPANEL   = 0xCC,
    SETGAMMA   = 0xE0,
    SETIMAGE   = 0xE9,
    SETMESSI   = 0xEA,
    SETCOLOR   = 0xEB
};

enum pixel_format {
    BIT12 = 0x03,
    BIT16 = 0x05,
    BIT18 = 0x06,
    BIT24 = 0x07
};

static inline void
tft_ram_wr(void)
{
	tft_ctrl = RAMWR;
}

static inline void
tft_pixel(uint8_t r, uint8_t g, uint8_t b)
{
	tft_data = r;
	tft_data = g;
	tft_data = b;
}

void
tft_set_area(unsigned int x, unsigned int y, unsigned int w, unsigned int h);

void
tft_init(void);

void
clear_screen(void);


#endif // TFT_H