Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Dependents: afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more
Fork of UniGraphic by
UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.
Inits/ILI932x.cpp@30:87855d03d91a, 2015-11-29 (annotated)
- Committer:
- Geremia
- Date:
- Sun Nov 29 19:58:47 2015 +0000
- Revision:
- 30:87855d03d91a
- Parent:
- 21:ae0a4eedfc90
Add ILI9320 init to ILI932x
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 20:14daa48ffd4c | 1 | /* mbed UniGraphic library - Device specific class |
Geremia | 20:14daa48ffd4c | 2 | * Copyright (c) 2015 Giuliano Dianda |
Geremia | 20:14daa48ffd4c | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Geremia | 20:14daa48ffd4c | 4 | */ |
Geremia | 20:14daa48ffd4c | 5 | |
Geremia | 20:14daa48ffd4c | 6 | #include "Protocols.h" |
Geremia | 20:14daa48ffd4c | 7 | #include "ILI932x.h" |
Geremia | 20:14daa48ffd4c | 8 | |
Geremia | 20:14daa48ffd4c | 9 | ////////////////////////////////////////////////////////////////////////////////// |
Geremia | 20:14daa48ffd4c | 10 | // display settings /////////////////////////////////////////////////////// |
Geremia | 20:14daa48ffd4c | 11 | ///////////////////////////////////////////////////////////////////////// |
Geremia | 20:14daa48ffd4c | 12 | |
Geremia | 20:14daa48ffd4c | 13 | |
Geremia | 20:14daa48ffd4c | 14 | ILI932x::ILI932x(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Geremia | 20:14daa48ffd4c | 15 | : TFT932x(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 20:14daa48ffd4c | 16 | { |
Geremia | 20:14daa48ffd4c | 17 | hw_reset(); |
Geremia | 20:14daa48ffd4c | 18 | BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false); |
Geremia | 20:14daa48ffd4c | 19 | identify(); // will collect tftID |
Geremia | 20:14daa48ffd4c | 20 | if(tftID==0x9325) init9325(); |
Geremia | 30:87855d03d91a | 21 | else if(tftID==0x9320) init9320(); |
Geremia | 20:14daa48ffd4c | 22 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Geremia | 20:14daa48ffd4c | 23 | set_orientation(0); |
Geremia | 20:14daa48ffd4c | 24 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Geremia | 20:14daa48ffd4c | 25 | cls(); |
Geremia | 20:14daa48ffd4c | 26 | locate(0,0); |
Geremia | 20:14daa48ffd4c | 27 | } |
Geremia | 21:ae0a4eedfc90 | 28 | ILI932x::ILI932x(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Geremia | 21:ae0a4eedfc90 | 29 | : TFT932x(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 21:ae0a4eedfc90 | 30 | { |
Geremia | 21:ae0a4eedfc90 | 31 | hw_reset(); |
Geremia | 21:ae0a4eedfc90 | 32 | BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false); |
Geremia | 21:ae0a4eedfc90 | 33 | identify(); // will collect tftID |
Geremia | 21:ae0a4eedfc90 | 34 | if(tftID==0x9325) init9325(); |
Geremia | 30:87855d03d91a | 35 | else if(tftID==0x9320) init9320(); |
Geremia | 21:ae0a4eedfc90 | 36 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Geremia | 21:ae0a4eedfc90 | 37 | set_orientation(0); |
Geremia | 21:ae0a4eedfc90 | 38 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Geremia | 21:ae0a4eedfc90 | 39 | cls(); |
Geremia | 21:ae0a4eedfc90 | 40 | locate(0,0); |
Geremia | 21:ae0a4eedfc90 | 41 | } |
Geremia | 20:14daa48ffd4c | 42 | ILI932x::ILI932x(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Geremia | 20:14daa48ffd4c | 43 | : TFT932x(displayproto, Hz, mosi, miso, sclk, CS, reset, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 20:14daa48ffd4c | 44 | { |
Geremia | 20:14daa48ffd4c | 45 | hw_reset(); //TFT class forwards to Protocol class |
Geremia | 20:14daa48ffd4c | 46 | BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer |
Geremia | 20:14daa48ffd4c | 47 | identify(); // will collect tftID |
Geremia | 20:14daa48ffd4c | 48 | if(tftID==0x9325) init9325(); |
Geremia | 30:87855d03d91a | 49 | else if(tftID==0x9320) init9320(); |
Geremia | 20:14daa48ffd4c | 50 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Geremia | 20:14daa48ffd4c | 51 | set_orientation(0); |
Geremia | 20:14daa48ffd4c | 52 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Geremia | 20:14daa48ffd4c | 53 | cls(); |
Geremia | 20:14daa48ffd4c | 54 | locate(0,0); |
Geremia | 20:14daa48ffd4c | 55 | } |
Geremia | 20:14daa48ffd4c | 56 | // reset and init the lcd controller |
Geremia | 20:14daa48ffd4c | 57 | |
Geremia | 20:14daa48ffd4c | 58 | void ILI932x::init9325() |
Geremia | 20:14daa48ffd4c | 59 | { |
Geremia | 20:14daa48ffd4c | 60 | /* Example for ILI9325 ----------------------------------------------------*/ |
Geremia | 20:14daa48ffd4c | 61 | |
Geremia | 30:87855d03d91a | 62 | flipped=FLIP_NONE; // FLIP_NONE, FLIP_X, FLIP_Y, FLIP_X|FLIP_Y |
Geremia | 30:87855d03d91a | 63 | |
Geremia | 20:14daa48ffd4c | 64 | reg_write(0x0001,0x0100); |
Geremia | 20:14daa48ffd4c | 65 | reg_write(0x0002,0x0700); |
Geremia | 20:14daa48ffd4c | 66 | reg_write(0x0003,0x1030); |
Geremia | 20:14daa48ffd4c | 67 | reg_write(0x0004,0x0000); |
Geremia | 20:14daa48ffd4c | 68 | reg_write(0x0008,0x0207); |
Geremia | 20:14daa48ffd4c | 69 | reg_write(0x0009,0x0000); |
Geremia | 20:14daa48ffd4c | 70 | reg_write(0x000A,0x0000); |
Geremia | 20:14daa48ffd4c | 71 | reg_write(0x000C,0x0000); |
Geremia | 20:14daa48ffd4c | 72 | reg_write(0x000D,0x0000); |
Geremia | 20:14daa48ffd4c | 73 | reg_write(0x000F,0x0000); |
Geremia | 20:14daa48ffd4c | 74 | //power on sequence VGHVGL |
Geremia | 20:14daa48ffd4c | 75 | reg_write(0x0010,0x0000); |
Geremia | 20:14daa48ffd4c | 76 | reg_write(0x0011,0x0007); |
Geremia | 20:14daa48ffd4c | 77 | reg_write(0x0012,0x0000); |
Geremia | 20:14daa48ffd4c | 78 | reg_write(0x0013,0x0000); |
Geremia | 20:14daa48ffd4c | 79 | reg_write(0x0007,0x0001); |
Geremia | 20:14daa48ffd4c | 80 | wait_ms(200); |
Geremia | 20:14daa48ffd4c | 81 | //vgh |
Geremia | 20:14daa48ffd4c | 82 | reg_write(0x0010,0x1290); |
Geremia | 20:14daa48ffd4c | 83 | reg_write(0x0011,0x0227); |
Geremia | 20:14daa48ffd4c | 84 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 85 | //vregiout |
Geremia | 20:14daa48ffd4c | 86 | reg_write(0x0012,0x001d); //0x001b |
Geremia | 20:14daa48ffd4c | 87 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 88 | //vom amplitude |
Geremia | 20:14daa48ffd4c | 89 | reg_write(0x0013,0x1500); |
Geremia | 20:14daa48ffd4c | 90 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 91 | //vom H |
Geremia | 20:14daa48ffd4c | 92 | reg_write(0x0029,0x0018); |
Geremia | 20:14daa48ffd4c | 93 | reg_write(0x002B,0x000D); |
Geremia | 20:14daa48ffd4c | 94 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 95 | //gamma |
Geremia | 20:14daa48ffd4c | 96 | reg_write(0x0030,0x0004); |
Geremia | 20:14daa48ffd4c | 97 | reg_write(0x0031,0x0307); |
Geremia | 20:14daa48ffd4c | 98 | reg_write(0x0032,0x0002);// 0006 |
Geremia | 20:14daa48ffd4c | 99 | reg_write(0x0035,0x0206); |
Geremia | 20:14daa48ffd4c | 100 | reg_write(0x0036,0x0408); |
Geremia | 20:14daa48ffd4c | 101 | reg_write(0x0037,0x0507); |
Geremia | 20:14daa48ffd4c | 102 | reg_write(0x0038,0x0204);//0200 |
Geremia | 20:14daa48ffd4c | 103 | reg_write(0x0039,0x0707); |
Geremia | 20:14daa48ffd4c | 104 | reg_write(0x003C,0x0405);// 0504 |
Geremia | 20:14daa48ffd4c | 105 | reg_write(0x003D,0x0F02); |
Geremia | 20:14daa48ffd4c | 106 | //ram |
Geremia | 20:14daa48ffd4c | 107 | reg_write(0x0050,0x0000); |
Geremia | 20:14daa48ffd4c | 108 | reg_write(0x0051,0x00EF); |
Geremia | 20:14daa48ffd4c | 109 | reg_write(0x0052,0x0000); |
Geremia | 20:14daa48ffd4c | 110 | reg_write(0x0053,0x013F); |
Geremia | 20:14daa48ffd4c | 111 | reg_write(0x0060,0xA700); |
Geremia | 20:14daa48ffd4c | 112 | reg_write(0x0061,0x0001); |
Geremia | 20:14daa48ffd4c | 113 | reg_write(0x006A,0x0000); |
Geremia | 20:14daa48ffd4c | 114 | // |
Geremia | 20:14daa48ffd4c | 115 | reg_write(0x0080,0x0000); |
Geremia | 20:14daa48ffd4c | 116 | reg_write(0x0081,0x0000); |
Geremia | 20:14daa48ffd4c | 117 | reg_write(0x0082,0x0000); |
Geremia | 20:14daa48ffd4c | 118 | reg_write(0x0083,0x0000); |
Geremia | 20:14daa48ffd4c | 119 | reg_write(0x0084,0x0000); |
Geremia | 20:14daa48ffd4c | 120 | reg_write(0x0085,0x0000); |
Geremia | 20:14daa48ffd4c | 121 | // |
Geremia | 20:14daa48ffd4c | 122 | reg_write(0x0090,0x0010); |
Geremia | 20:14daa48ffd4c | 123 | reg_write(0x0092,0x0600); |
Geremia | 20:14daa48ffd4c | 124 | reg_write(0x0093,0x0003); |
Geremia | 20:14daa48ffd4c | 125 | reg_write(0x0095,0x0110); |
Geremia | 20:14daa48ffd4c | 126 | reg_write(0x0097,0x0000); |
Geremia | 20:14daa48ffd4c | 127 | reg_write(0x0098,0x0000); |
Geremia | 20:14daa48ffd4c | 128 | |
Geremia | 20:14daa48ffd4c | 129 | reg_write(0x0007,0x0133); // display on |
Geremia | 20:14daa48ffd4c | 130 | |
Geremia | 30:87855d03d91a | 131 | } |
Geremia | 30:87855d03d91a | 132 | void ILI932x::init9320() |
Geremia | 30:87855d03d91a | 133 | { |
Geremia | 30:87855d03d91a | 134 | /* Example for ILI9320 ----------------------------------------------------*/ |
Geremia | 30:87855d03d91a | 135 | |
Geremia | 30:87855d03d91a | 136 | flipped=FLIP_X; // FLIP_NONE, FLIP_X, FLIP_Y, FLIP_X|FLIP_Y |
Geremia | 30:87855d03d91a | 137 | |
Geremia | 30:87855d03d91a | 138 | reg_write(0x0001,0x0100); |
Geremia | 30:87855d03d91a | 139 | reg_write(0x0002,0x0700); |
Geremia | 30:87855d03d91a | 140 | reg_write(0x0003,0x1030); |
Geremia | 30:87855d03d91a | 141 | reg_write(0x0004,0x0000); |
Geremia | 30:87855d03d91a | 142 | reg_write(0x0008,0x0202); |
Geremia | 30:87855d03d91a | 143 | reg_write(0x0009,0x0000); |
Geremia | 30:87855d03d91a | 144 | reg_write(0x000A,0x0000); |
Geremia | 30:87855d03d91a | 145 | reg_write(0x000C,0x0000); |
Geremia | 30:87855d03d91a | 146 | reg_write(0x000D,0x0000); |
Geremia | 30:87855d03d91a | 147 | reg_write(0x000F,0x0000); |
Geremia | 30:87855d03d91a | 148 | //power on sequence |
Geremia | 30:87855d03d91a | 149 | reg_write(0x0010,0x0000); |
Geremia | 30:87855d03d91a | 150 | reg_write(0x0011,0x0007); |
Geremia | 30:87855d03d91a | 151 | reg_write(0x0012,0x0000); |
Geremia | 30:87855d03d91a | 152 | reg_write(0x0013,0x0000); |
Geremia | 30:87855d03d91a | 153 | reg_write(0x0007,0x0001); |
Geremia | 30:87855d03d91a | 154 | wait_ms(200); |
Geremia | 30:87855d03d91a | 155 | |
Geremia | 30:87855d03d91a | 156 | reg_write(0x0010,0x10C0); |
Geremia | 30:87855d03d91a | 157 | reg_write(0x0011,0x0007); |
Geremia | 30:87855d03d91a | 158 | wait_ms(50); |
Geremia | 30:87855d03d91a | 159 | |
Geremia | 30:87855d03d91a | 160 | reg_write(0x0012,0x0110); |
Geremia | 30:87855d03d91a | 161 | wait_ms(50); |
Geremia | 30:87855d03d91a | 162 | |
Geremia | 30:87855d03d91a | 163 | reg_write(0x0013,0x0b00); |
Geremia | 30:87855d03d91a | 164 | wait_ms(50); |
Geremia | 30:87855d03d91a | 165 | |
Geremia | 30:87855d03d91a | 166 | reg_write(0x0029,0x0000); |
Geremia | 30:87855d03d91a | 167 | reg_write(0x002B,0x4010); // bit 14??? |
Geremia | 30:87855d03d91a | 168 | wait_ms(50); |
Geremia | 30:87855d03d91a | 169 | //gamma |
Geremia | 30:87855d03d91a | 170 | /* |
Geremia | 30:87855d03d91a | 171 | reg_write(0x0030,0x0004); |
Geremia | 30:87855d03d91a | 172 | reg_write(0x0031,0x0307); |
Geremia | 30:87855d03d91a | 173 | reg_write(0x0032,0x0002);// 0006 |
Geremia | 30:87855d03d91a | 174 | reg_write(0x0035,0x0206); |
Geremia | 30:87855d03d91a | 175 | reg_write(0x0036,0x0408); |
Geremia | 30:87855d03d91a | 176 | reg_write(0x0037,0x0507); |
Geremia | 30:87855d03d91a | 177 | reg_write(0x0038,0x0204);//0200 |
Geremia | 30:87855d03d91a | 178 | reg_write(0x0039,0x0707); |
Geremia | 30:87855d03d91a | 179 | reg_write(0x003C,0x0405);// 0504 |
Geremia | 30:87855d03d91a | 180 | reg_write(0x003D,0x0F02); |
Geremia | 30:87855d03d91a | 181 | */ |
Geremia | 30:87855d03d91a | 182 | //ram |
Geremia | 30:87855d03d91a | 183 | reg_write(0x0050,0x0000); |
Geremia | 30:87855d03d91a | 184 | reg_write(0x0051,0x00EF); |
Geremia | 30:87855d03d91a | 185 | reg_write(0x0052,0x0000); |
Geremia | 30:87855d03d91a | 186 | reg_write(0x0053,0x013F); |
Geremia | 30:87855d03d91a | 187 | reg_write(0x0060,0x2700); |
Geremia | 30:87855d03d91a | 188 | reg_write(0x0061,0x0001); |
Geremia | 30:87855d03d91a | 189 | reg_write(0x006A,0x0000); |
Geremia | 30:87855d03d91a | 190 | // |
Geremia | 30:87855d03d91a | 191 | reg_write(0x0080,0x0000); |
Geremia | 30:87855d03d91a | 192 | reg_write(0x0081,0x0000); |
Geremia | 30:87855d03d91a | 193 | reg_write(0x0082,0x0000); |
Geremia | 30:87855d03d91a | 194 | reg_write(0x0083,0x0000); |
Geremia | 30:87855d03d91a | 195 | reg_write(0x0084,0x0000); |
Geremia | 30:87855d03d91a | 196 | reg_write(0x0085,0x0000); |
Geremia | 30:87855d03d91a | 197 | // |
Geremia | 30:87855d03d91a | 198 | reg_write(0x0090,0x0000); |
Geremia | 30:87855d03d91a | 199 | reg_write(0x0092,0x0000); |
Geremia | 30:87855d03d91a | 200 | reg_write(0x0093,0x0001); |
Geremia | 30:87855d03d91a | 201 | reg_write(0x0095,0x0110); |
Geremia | 30:87855d03d91a | 202 | reg_write(0x0097,0x0000); |
Geremia | 30:87855d03d91a | 203 | reg_write(0x0098,0x0000); |
Geremia | 30:87855d03d91a | 204 | |
Geremia | 30:87855d03d91a | 205 | reg_write(0x0007,0x0133); // display on |
Geremia | 30:87855d03d91a | 206 | |
Geremia | 20:14daa48ffd4c | 207 | } |