st7735s: tft_fill and tft_setpixel basic functionality
[cortex-from-scratch] / include / drivers / st7735s.h
1 #ifndef __ST7735S_H
2 #define __ST7735S_H
3
4 enum CMDLIST {
5         TFT_NOP = 0x00,
6         TFT_SWRESET = 0x01,
7         /* READ COMMANDS: returns one or multiple bytes,
8          * use these for debugging to check if certain
9          * registers are set correctly */
10         TFT_RDDID = 0x04,
11         TFT_RDDST = 0x09,
12         TFT_RDDPM = 0x0A,
13         TFT_RDDMADCTL = 0x0B,
14         TFT_RDDCOLMOD = 0x0C,
15         TFT_RDDIM = 0x0D,
16         TFT_RDDSM = 0x0E,
17         TFT_RDDSDR = 0x0F,
18         TFT_RDID1 = 0xDA,
19         TFT_RDID2 = 0xDB,
20         TFT_RDID3 = 0xDC,
21         TFT_RAMRD = 0x2E,
22         /* DISPLAY MODE COMMANDS */
23         TFT_SLPIN = 0x10,       
24         TFT_SLPOUT = 0x11,
25         TFT_PTLON = 0x12,
26         TFT_NORON = 0x13,
27         TFT_INVOFF = 0x20,
28         TFT_INVON = 0x21,
29         TFT_GAMSET = 0x26,
30         TFT_DISPOFF = 0x28,
31         TFT_DISPON = 0x29,
32         TFT_IDMOFF = 0x38,
33         TFT_IDMON = 0x39,
34         TFT_TEOFF = 0x34,
35         TFT_TEON = 0x35,
36         /* BASIC SETTINGS COMMANDS */
37         TFT_CASET = 0x2A,
38         TFT_RASET = 0x2B,
39         TFT_RAMWR = 0x2C,
40         TFT_RGBSET = 0x2D,
41         TFT_PTLAR = 0x30,
42         TFT_SCRLAR = 0x33,
43         TFT_MADCTL = 0x36,
44         TFT_VSCSAD = 0x37,
45         TFT_COLMOD = 0x3A,
46         /* PANEL FUNCTIONS COMMANDS */
47         TFT_FRMCTR1 = 0xB1,
48         TFT_FRMCTR2 = 0xB2, 
49         TFT_FRMCTR3 = 0xB3,
50         TFT_INVCTR = 0xB4,
51         TFT_PWCTR1 = 0xC0,
52         TFT_PWCTR2 = 0xC1,
53         TFT_PWCTR3 = 0xC2,
54         TFT_PWCTR4 = 0xC3,
55         TFT_PWCTR5 = 0xC4,
56         TFT_VMCTR1 = 0xC5,
57         TFT_VMOFCTR = 0xC7,
58         TFT_WRID2 = 0xD1,
59         TFT_WRID3 = 0xD2,
60         TFT_NVCTR = 0xD9,
61         TFT_NVCTR2 = 0xDE,
62         TFT_NVCTR3 = 0xDF,
63         /* GAMMA SETTINGS */
64         TFT_GMCTRP1 = 0xE0,
65         TFT_GMCTRN1 = 0xE1
66                 
67 };
68
69 void tft_init();
70 int tft_fill(uint8_t beginx, uint8_t beginy, uint8_t endx, uint8_t endy, uint16_t color);
71 int tft_setpixel(uint8_t x, uint8_t y, uint16_t color);
72 int tft_command(uint8_t cmd, int argsc, ...);
73
74 #endif