Nikita Ivanykov
/
LAB_DISPLAY
7
ILI9341_Init.h@0:02841331478b, 2017-10-26 (annotated)
- Committer:
- codebreaker7
- Date:
- Thu Oct 26 19:20:47 2017 +0000
- Revision:
- 0:02841331478b
- Child:
- 2:82f5f57eac91
Start revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
codebreaker7 | 0:02841331478b | 1 | |
codebreaker7 | 0:02841331478b | 2 | // This is the command sequence that initialises the ILI9341 driver |
codebreaker7 | 0:02841331478b | 3 | // |
codebreaker7 | 0:02841331478b | 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions |
codebreaker7 | 0:02841331478b | 5 | // |
codebreaker7 | 0:02841331478b | 6 | // See ST7735_Setup.h file for an alternative format |
codebreaker7 | 0:02841331478b | 7 | |
codebreaker7 | 0:02841331478b | 8 | { |
codebreaker7 | 0:02841331478b | 9 | writecommand(0xEF); |
codebreaker7 | 0:02841331478b | 10 | writedata(0x03); |
codebreaker7 | 0:02841331478b | 11 | writedata(0x80); |
codebreaker7 | 0:02841331478b | 12 | writedata(0x02); |
codebreaker7 | 0:02841331478b | 13 | |
codebreaker7 | 0:02841331478b | 14 | writecommand(0xCF); |
codebreaker7 | 0:02841331478b | 15 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 16 | writedata(0XC1); |
codebreaker7 | 0:02841331478b | 17 | writedata(0X30); |
codebreaker7 | 0:02841331478b | 18 | |
codebreaker7 | 0:02841331478b | 19 | writecommand(0xED); |
codebreaker7 | 0:02841331478b | 20 | writedata(0x64); |
codebreaker7 | 0:02841331478b | 21 | writedata(0x03); |
codebreaker7 | 0:02841331478b | 22 | writedata(0X12); |
codebreaker7 | 0:02841331478b | 23 | writedata(0X81); |
codebreaker7 | 0:02841331478b | 24 | |
codebreaker7 | 0:02841331478b | 25 | writecommand(0xE8); |
codebreaker7 | 0:02841331478b | 26 | writedata(0x85); |
codebreaker7 | 0:02841331478b | 27 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 28 | writedata(0x78); |
codebreaker7 | 0:02841331478b | 29 | |
codebreaker7 | 0:02841331478b | 30 | writecommand(0xCB); |
codebreaker7 | 0:02841331478b | 31 | writedata(0x39); |
codebreaker7 | 0:02841331478b | 32 | writedata(0x2C); |
codebreaker7 | 0:02841331478b | 33 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 34 | writedata(0x34); |
codebreaker7 | 0:02841331478b | 35 | writedata(0x02); |
codebreaker7 | 0:02841331478b | 36 | |
codebreaker7 | 0:02841331478b | 37 | writecommand(0xF7); |
codebreaker7 | 0:02841331478b | 38 | writedata(0x20); |
codebreaker7 | 0:02841331478b | 39 | |
codebreaker7 | 0:02841331478b | 40 | writecommand(0xEA); |
codebreaker7 | 0:02841331478b | 41 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 42 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 43 | |
codebreaker7 | 0:02841331478b | 44 | writecommand(ILI9341_PWCTR1); //Power control |
codebreaker7 | 0:02841331478b | 45 | writedata(0x23); //VRH[5:0] |
codebreaker7 | 0:02841331478b | 46 | |
codebreaker7 | 0:02841331478b | 47 | writecommand(ILI9341_PWCTR2); //Power control |
codebreaker7 | 0:02841331478b | 48 | writedata(0x10); //SAP[2:0];BT[3:0] |
codebreaker7 | 0:02841331478b | 49 | |
codebreaker7 | 0:02841331478b | 50 | writecommand(ILI9341_VMCTR1); //VCM control |
codebreaker7 | 0:02841331478b | 51 | writedata(0x3e); |
codebreaker7 | 0:02841331478b | 52 | writedata(0x28); |
codebreaker7 | 0:02841331478b | 53 | |
codebreaker7 | 0:02841331478b | 54 | writecommand(ILI9341_VMCTR2); //VCM control2 |
codebreaker7 | 0:02841331478b | 55 | writedata(0x86); //-- |
codebreaker7 | 0:02841331478b | 56 | |
codebreaker7 | 0:02841331478b | 57 | writecommand(ILI9341_MADCTL); // Memory Access Control |
codebreaker7 | 0:02841331478b | 58 | writedata(0x48); |
codebreaker7 | 0:02841331478b | 59 | |
codebreaker7 | 0:02841331478b | 60 | writecommand(ILI9341_PIXFMT); |
codebreaker7 | 0:02841331478b | 61 | writedata(0x55); |
codebreaker7 | 0:02841331478b | 62 | |
codebreaker7 | 0:02841331478b | 63 | writecommand(ILI9341_FRMCTR1); |
codebreaker7 | 0:02841331478b | 64 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 65 | writedata(0x13); // 0x18 79Hz, 0x1B default 70Hz, 0x13 100Hz |
codebreaker7 | 0:02841331478b | 66 | |
codebreaker7 | 0:02841331478b | 67 | writecommand(ILI9341_DFUNCTR); // Display Function Control |
codebreaker7 | 0:02841331478b | 68 | writedata(0x08); |
codebreaker7 | 0:02841331478b | 69 | writedata(0x82); |
codebreaker7 | 0:02841331478b | 70 | writedata(0x27); |
codebreaker7 | 0:02841331478b | 71 | |
codebreaker7 | 0:02841331478b | 72 | writecommand(0xF2); // 3Gamma Function Disable |
codebreaker7 | 0:02841331478b | 73 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 74 | |
codebreaker7 | 0:02841331478b | 75 | writecommand(ILI9341_GAMMASET); //Gamma curve selected |
codebreaker7 | 0:02841331478b | 76 | writedata(0x01); |
codebreaker7 | 0:02841331478b | 77 | |
codebreaker7 | 0:02841331478b | 78 | writecommand(ILI9341_GMCTRP1); //Set Gamma |
codebreaker7 | 0:02841331478b | 79 | writedata(0x0F); |
codebreaker7 | 0:02841331478b | 80 | writedata(0x31); |
codebreaker7 | 0:02841331478b | 81 | writedata(0x2B); |
codebreaker7 | 0:02841331478b | 82 | writedata(0x0C); |
codebreaker7 | 0:02841331478b | 83 | writedata(0x0E); |
codebreaker7 | 0:02841331478b | 84 | writedata(0x08); |
codebreaker7 | 0:02841331478b | 85 | writedata(0x4E); |
codebreaker7 | 0:02841331478b | 86 | writedata(0xF1); |
codebreaker7 | 0:02841331478b | 87 | writedata(0x37); |
codebreaker7 | 0:02841331478b | 88 | writedata(0x07); |
codebreaker7 | 0:02841331478b | 89 | writedata(0x10); |
codebreaker7 | 0:02841331478b | 90 | writedata(0x03); |
codebreaker7 | 0:02841331478b | 91 | writedata(0x0E); |
codebreaker7 | 0:02841331478b | 92 | writedata(0x09); |
codebreaker7 | 0:02841331478b | 93 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 94 | |
codebreaker7 | 0:02841331478b | 95 | writecommand(ILI9341_GMCTRN1); //Set Gamma |
codebreaker7 | 0:02841331478b | 96 | writedata(0x00); |
codebreaker7 | 0:02841331478b | 97 | writedata(0x0E); |
codebreaker7 | 0:02841331478b | 98 | writedata(0x14); |
codebreaker7 | 0:02841331478b | 99 | writedata(0x03); |
codebreaker7 | 0:02841331478b | 100 | writedata(0x11); |
codebreaker7 | 0:02841331478b | 101 | writedata(0x07); |
codebreaker7 | 0:02841331478b | 102 | writedata(0x31); |
codebreaker7 | 0:02841331478b | 103 | writedata(0xC1); |
codebreaker7 | 0:02841331478b | 104 | writedata(0x48); |
codebreaker7 | 0:02841331478b | 105 | writedata(0x08); |
codebreaker7 | 0:02841331478b | 106 | writedata(0x0F); |
codebreaker7 | 0:02841331478b | 107 | writedata(0x0C); |
codebreaker7 | 0:02841331478b | 108 | writedata(0x31); |
codebreaker7 | 0:02841331478b | 109 | writedata(0x36); |
codebreaker7 | 0:02841331478b | 110 | writedata(0x0F); |
codebreaker7 | 0:02841331478b | 111 | |
codebreaker7 | 0:02841331478b | 112 | writecommand(ILI9341_SLPOUT); //Exit Sleep |
codebreaker7 | 0:02841331478b | 113 | |
codebreaker7 | 0:02841331478b | 114 | //spi_end(); |
codebreaker7 | 0:02841331478b | 115 | wait_ms(120); |
codebreaker7 | 0:02841331478b | 116 | //spi_begin(); |
codebreaker7 | 0:02841331478b | 117 | |
codebreaker7 | 0:02841331478b | 118 | writecommand(ILI9341_DISPON); //Display on |
codebreaker7 | 0:02841331478b | 119 | } |