Nuvoton
/
NuMaker-mbed-emWin-example
NuMaker emWin HMI
emWin/Config/TARGET_NUMAKER_PFM_M487/LCDConf2.c@7:1bf2238df581, 8 months ago (annotated)
- Committer:
- csyang2
- Date:
- Wed Feb 28 00:31:45 2024 +0800
- Revision:
- 7:1bf2238df581
Update lcd for M487
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
csyang2 |
7:1bf2238df581 | 1 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 2 | * SEGGER Software GmbH * |
csyang2 |
7:1bf2238df581 | 3 | * Solutions for real time microcontroller applications * |
csyang2 |
7:1bf2238df581 | 4 | ********************************************************************** |
csyang2 |
7:1bf2238df581 | 5 | * * |
csyang2 |
7:1bf2238df581 | 6 | * (c) 1996 - 2018 SEGGER Microcontroller GmbH * |
csyang2 |
7:1bf2238df581 | 7 | * * |
csyang2 |
7:1bf2238df581 | 8 | * Internet: www.segger.com Support: support@segger.com * |
csyang2 |
7:1bf2238df581 | 9 | * * |
csyang2 |
7:1bf2238df581 | 10 | ********************************************************************** |
csyang2 |
7:1bf2238df581 | 11 | |
csyang2 |
7:1bf2238df581 | 12 | ** emWin V5.48 - Graphical user interface for embedded applications ** |
csyang2 |
7:1bf2238df581 | 13 | All Intellectual Property rights in the Software belongs to SEGGER. |
csyang2 |
7:1bf2238df581 | 14 | emWin is protected by international copyright laws. Knowledge of the |
csyang2 |
7:1bf2238df581 | 15 | source code may not be used to write a similar product. This file may |
csyang2 |
7:1bf2238df581 | 16 | only be used in accordance with the following terms: |
csyang2 |
7:1bf2238df581 | 17 | |
csyang2 |
7:1bf2238df581 | 18 | The software has been licensed by SEGGER Software GmbH to Nuvoton Technology Corporationat the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan |
csyang2 |
7:1bf2238df581 | 19 | for the purposes of creating libraries for its |
csyang2 |
7:1bf2238df581 | 20 | Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation |
csyang2 |
7:1bf2238df581 | 21 | under the terms and conditions of an End User |
csyang2 |
7:1bf2238df581 | 22 | License Agreement supplied with the libraries. |
csyang2 |
7:1bf2238df581 | 23 | Full source code is available at: www.segger.com |
csyang2 |
7:1bf2238df581 | 24 | |
csyang2 |
7:1bf2238df581 | 25 | We appreciate your understanding and fairness. |
csyang2 |
7:1bf2238df581 | 26 | ---------------------------------------------------------------------- |
csyang2 |
7:1bf2238df581 | 27 | Licensing information |
csyang2 |
7:1bf2238df581 | 28 | Licensor: SEGGER Software GmbH |
csyang2 |
7:1bf2238df581 | 29 | Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan |
csyang2 |
7:1bf2238df581 | 30 | Licensed SEGGER software: emWin |
csyang2 |
7:1bf2238df581 | 31 | License number: GUI-00735 |
csyang2 |
7:1bf2238df581 | 32 | License model: emWin License Agreement, signed February 27, 2018 |
csyang2 |
7:1bf2238df581 | 33 | Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation |
csyang2 |
7:1bf2238df581 | 34 | ---------------------------------------------------------------------- |
csyang2 |
7:1bf2238df581 | 35 | Support and Update Agreement (SUA) |
csyang2 |
7:1bf2238df581 | 36 | SUA period: 2018-03-26 - 2019-03-27 |
csyang2 |
7:1bf2238df581 | 37 | Contact to extend SUA: sales@segger.com |
csyang2 |
7:1bf2238df581 | 38 | ---------------------------------------------------------------------- |
csyang2 |
7:1bf2238df581 | 39 | File : LCDConf.c |
csyang2 |
7:1bf2238df581 | 40 | Purpose : Display controller configuration (single layer) |
csyang2 |
7:1bf2238df581 | 41 | ---------------------------END-OF-HEADER------------------------------ |
csyang2 |
7:1bf2238df581 | 42 | */ |
csyang2 |
7:1bf2238df581 | 43 | #include <stddef.h> |
csyang2 |
7:1bf2238df581 | 44 | #include <stdio.h> |
csyang2 |
7:1bf2238df581 | 45 | |
csyang2 |
7:1bf2238df581 | 46 | #include "GUI.h" |
csyang2 |
7:1bf2238df581 | 47 | #include "GUIDRV_FlexColor.h" |
csyang2 |
7:1bf2238df581 | 48 | |
csyang2 |
7:1bf2238df581 | 49 | #include "NuMicro.h" |
csyang2 |
7:1bf2238df581 | 50 | |
csyang2 |
7:1bf2238df581 | 51 | #include "TouchPanel.h" |
csyang2 |
7:1bf2238df581 | 52 | |
csyang2 |
7:1bf2238df581 | 53 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 54 | * |
csyang2 |
7:1bf2238df581 | 55 | * Layer configuration |
csyang2 |
7:1bf2238df581 | 56 | * |
csyang2 |
7:1bf2238df581 | 57 | ********************************************************************** |
csyang2 |
7:1bf2238df581 | 58 | */ |
csyang2 |
7:1bf2238df581 | 59 | // |
csyang2 |
7:1bf2238df581 | 60 | // Physical display size |
csyang2 |
7:1bf2238df581 | 61 | // |
csyang2 |
7:1bf2238df581 | 62 | #define XSIZE_PHYS 240 |
csyang2 |
7:1bf2238df581 | 63 | #define YSIZE_PHYS 320 |
csyang2 |
7:1bf2238df581 | 64 | |
csyang2 |
7:1bf2238df581 | 65 | // |
csyang2 |
7:1bf2238df581 | 66 | // Color conversion |
csyang2 |
7:1bf2238df581 | 67 | // |
csyang2 |
7:1bf2238df581 | 68 | #define COLOR_CONVERSION GUICC_565 |
csyang2 |
7:1bf2238df581 | 69 | |
csyang2 |
7:1bf2238df581 | 70 | // |
csyang2 |
7:1bf2238df581 | 71 | // Display driver |
csyang2 |
7:1bf2238df581 | 72 | // |
csyang2 |
7:1bf2238df581 | 73 | #define DISPLAY_DRIVER GUIDRV_FLEXCOLOR |
csyang2 |
7:1bf2238df581 | 74 | |
csyang2 |
7:1bf2238df581 | 75 | // |
csyang2 |
7:1bf2238df581 | 76 | // Orientation |
csyang2 |
7:1bf2238df581 | 77 | // |
csyang2 |
7:1bf2238df581 | 78 | #define DISPLAY_ORIENTATION (0) |
csyang2 |
7:1bf2238df581 | 79 | |
csyang2 |
7:1bf2238df581 | 80 | // |
csyang2 |
7:1bf2238df581 | 81 | // Hardware related |
csyang2 |
7:1bf2238df581 | 82 | // |
csyang2 |
7:1bf2238df581 | 83 | /* LCD Module "RS" */ |
csyang2 |
7:1bf2238df581 | 84 | #define PH_CTRL_RS 1 |
csyang2 |
7:1bf2238df581 | 85 | #if PH_CTRL_RS |
csyang2 |
7:1bf2238df581 | 86 | #define SET_RS PH3 = 1; |
csyang2 |
7:1bf2238df581 | 87 | #define CLR_RS PH3 = 0; |
csyang2 |
7:1bf2238df581 | 88 | #endif |
csyang2 |
7:1bf2238df581 | 89 | |
csyang2 |
7:1bf2238df581 | 90 | /* LCD Module "RESET" */ |
csyang2 |
7:1bf2238df581 | 91 | #define SET_RST PB6 = 1; |
csyang2 |
7:1bf2238df581 | 92 | #define CLR_RST PB6 = 0; |
csyang2 |
7:1bf2238df581 | 93 | |
csyang2 |
7:1bf2238df581 | 94 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 95 | * |
csyang2 |
7:1bf2238df581 | 96 | * Configuration checking |
csyang2 |
7:1bf2238df581 | 97 | * |
csyang2 |
7:1bf2238df581 | 98 | ********************************************************************** |
csyang2 |
7:1bf2238df581 | 99 | */ |
csyang2 |
7:1bf2238df581 | 100 | #ifndef VXSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 101 | #define VXSIZE_PHYS XSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 102 | #endif |
csyang2 |
7:1bf2238df581 | 103 | #ifndef VYSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 104 | #define VYSIZE_PHYS YSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 105 | #endif |
csyang2 |
7:1bf2238df581 | 106 | #ifndef XSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 107 | #error Physical X size of display is not defined! |
csyang2 |
7:1bf2238df581 | 108 | #endif |
csyang2 |
7:1bf2238df581 | 109 | #ifndef YSIZE_PHYS |
csyang2 |
7:1bf2238df581 | 110 | #error Physical Y size of display is not defined! |
csyang2 |
7:1bf2238df581 | 111 | #endif |
csyang2 |
7:1bf2238df581 | 112 | #ifndef COLOR_CONVERSION |
csyang2 |
7:1bf2238df581 | 113 | #error Color conversion not defined! |
csyang2 |
7:1bf2238df581 | 114 | #endif |
csyang2 |
7:1bf2238df581 | 115 | #ifndef DISPLAY_DRIVER |
csyang2 |
7:1bf2238df581 | 116 | #error No display driver defined! |
csyang2 |
7:1bf2238df581 | 117 | #endif |
csyang2 |
7:1bf2238df581 | 118 | #ifndef DISPLAY_ORIENTATION |
csyang2 |
7:1bf2238df581 | 119 | #define DISPLAY_ORIENTATION 0 |
csyang2 |
7:1bf2238df581 | 120 | #endif |
csyang2 |
7:1bf2238df581 | 121 | |
csyang2 |
7:1bf2238df581 | 122 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 123 | * |
csyang2 |
7:1bf2238df581 | 124 | * Static code |
csyang2 |
7:1bf2238df581 | 125 | * |
csyang2 |
7:1bf2238df581 | 126 | **********************************************************************/ |
csyang2 |
7:1bf2238df581 | 127 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 128 | // Write control registers of LCD module |
csyang2 |
7:1bf2238df581 | 129 | // |
csyang2 |
7:1bf2238df581 | 130 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 131 | #if PH_CTRL_RS |
csyang2 |
7:1bf2238df581 | 132 | void LCD_WR_REG(uint16_t cmd) |
csyang2 |
7:1bf2238df581 | 133 | { |
csyang2 |
7:1bf2238df581 | 134 | CLR_RS |
csyang2 |
7:1bf2238df581 | 135 | EBI0_WRITE_DATA16(0x00000000, cmd); |
csyang2 |
7:1bf2238df581 | 136 | SET_RS |
csyang2 |
7:1bf2238df581 | 137 | |
csyang2 |
7:1bf2238df581 | 138 | } |
csyang2 |
7:1bf2238df581 | 139 | |
csyang2 |
7:1bf2238df581 | 140 | #else |
csyang2 |
7:1bf2238df581 | 141 | void LCD_WR_REG(uint16_t cmd) |
csyang2 |
7:1bf2238df581 | 142 | { |
csyang2 |
7:1bf2238df581 | 143 | EBI0_WRITE_DATA16(0x00000000, cmd); |
csyang2 |
7:1bf2238df581 | 144 | } |
csyang2 |
7:1bf2238df581 | 145 | |
csyang2 |
7:1bf2238df581 | 146 | #endif |
csyang2 |
7:1bf2238df581 | 147 | |
csyang2 |
7:1bf2238df581 | 148 | |
csyang2 |
7:1bf2238df581 | 149 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 150 | // Write data to SRAM of LCD module |
csyang2 |
7:1bf2238df581 | 151 | // |
csyang2 |
7:1bf2238df581 | 152 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 153 | void LCD_WR_DATA(uint16_t dat) |
csyang2 |
7:1bf2238df581 | 154 | { |
csyang2 |
7:1bf2238df581 | 155 | EBI0_WRITE_DATA16(0x00030000, dat); |
csyang2 |
7:1bf2238df581 | 156 | |
csyang2 |
7:1bf2238df581 | 157 | } |
csyang2 |
7:1bf2238df581 | 158 | |
csyang2 |
7:1bf2238df581 | 159 | |
csyang2 |
7:1bf2238df581 | 160 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 161 | // Read data from SRAM of LCD module |
csyang2 |
7:1bf2238df581 | 162 | // |
csyang2 |
7:1bf2238df581 | 163 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 164 | uint16_t LCD_RD_DATA(void) |
csyang2 |
7:1bf2238df581 | 165 | { |
csyang2 |
7:1bf2238df581 | 166 | return EBI0_READ_DATA16(0x00030000); |
csyang2 |
7:1bf2238df581 | 167 | |
csyang2 |
7:1bf2238df581 | 168 | } |
csyang2 |
7:1bf2238df581 | 169 | |
csyang2 |
7:1bf2238df581 | 170 | /******************************************************************** |
csyang2 |
7:1bf2238df581 | 171 | * |
csyang2 |
7:1bf2238df581 | 172 | * LcdWriteDataMultiple |
csyang2 |
7:1bf2238df581 | 173 | * |
csyang2 |
7:1bf2238df581 | 174 | * Function description: |
csyang2 |
7:1bf2238df581 | 175 | * Writes multiple values to a display register. |
csyang2 |
7:1bf2238df581 | 176 | */ |
csyang2 |
7:1bf2238df581 | 177 | static void LcdWriteDataMultiple(uint16_t * pData, int NumItems) |
csyang2 |
7:1bf2238df581 | 178 | { |
csyang2 |
7:1bf2238df581 | 179 | while (NumItems--) { |
csyang2 |
7:1bf2238df581 | 180 | EBI0_WRITE_DATA16(0x00030000,*pData++); |
csyang2 |
7:1bf2238df581 | 181 | } |
csyang2 |
7:1bf2238df581 | 182 | } |
csyang2 |
7:1bf2238df581 | 183 | |
csyang2 |
7:1bf2238df581 | 184 | /******************************************************************** |
csyang2 |
7:1bf2238df581 | 185 | * |
csyang2 |
7:1bf2238df581 | 186 | * LcdReadDataMultiple |
csyang2 |
7:1bf2238df581 | 187 | * |
csyang2 |
7:1bf2238df581 | 188 | * Function description: |
csyang2 |
7:1bf2238df581 | 189 | * Reads multiple values from a display register. |
csyang2 |
7:1bf2238df581 | 190 | */ |
csyang2 |
7:1bf2238df581 | 191 | static void LcdReadDataMultiple(uint16_t * pData, int NumItems) |
csyang2 |
7:1bf2238df581 | 192 | { |
csyang2 |
7:1bf2238df581 | 193 | while (NumItems--) { |
csyang2 |
7:1bf2238df581 | 194 | *pData++ = EBI0_READ_DATA16(0x00030000); |
csyang2 |
7:1bf2238df581 | 195 | } |
csyang2 |
7:1bf2238df581 | 196 | } |
csyang2 |
7:1bf2238df581 | 197 | |
csyang2 |
7:1bf2238df581 | 198 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 199 | // Set cursor positon on the LCD screen |
csyang2 |
7:1bf2238df581 | 200 | // |
csyang2 |
7:1bf2238df581 | 201 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 202 | #if 0 |
csyang2 |
7:1bf2238df581 | 203 | void LCD_SetCursor(uint16_t x_s, uint16_t y_s) |
csyang2 |
7:1bf2238df581 | 204 | { |
csyang2 |
7:1bf2238df581 | 205 | uint16_t x_e = x_s+1; |
csyang2 |
7:1bf2238df581 | 206 | uint16_t y_e = y_s+1; |
csyang2 |
7:1bf2238df581 | 207 | |
csyang2 |
7:1bf2238df581 | 208 | /* X range */ |
csyang2 |
7:1bf2238df581 | 209 | LCD_WR_REG(0x2A); |
csyang2 |
7:1bf2238df581 | 210 | LCD_WR_DATA(x_s>>8); |
csyang2 |
7:1bf2238df581 | 211 | LCD_WR_DATA(x_s); |
csyang2 |
7:1bf2238df581 | 212 | LCD_WR_DATA(x_e>>8); |
csyang2 |
7:1bf2238df581 | 213 | LCD_WR_DATA(x_e); |
csyang2 |
7:1bf2238df581 | 214 | |
csyang2 |
7:1bf2238df581 | 215 | /* Y range */ |
csyang2 |
7:1bf2238df581 | 216 | LCD_WR_REG(0x2B); |
csyang2 |
7:1bf2238df581 | 217 | LCD_WR_DATA(y_s>>8); |
csyang2 |
7:1bf2238df581 | 218 | LCD_WR_DATA(y_s); |
csyang2 |
7:1bf2238df581 | 219 | LCD_WR_DATA(y_e>>8); |
csyang2 |
7:1bf2238df581 | 220 | LCD_WR_DATA(y_e); |
csyang2 |
7:1bf2238df581 | 221 | |
csyang2 |
7:1bf2238df581 | 222 | /* Memory write */ |
csyang2 |
7:1bf2238df581 | 223 | LCD_WR_REG(0x2C); |
csyang2 |
7:1bf2238df581 | 224 | |
csyang2 |
7:1bf2238df581 | 225 | } |
csyang2 |
7:1bf2238df581 | 226 | #endif |
csyang2 |
7:1bf2238df581 | 227 | |
csyang2 |
7:1bf2238df581 | 228 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 229 | // Initial LIL9341 LCD driver chip |
csyang2 |
7:1bf2238df581 | 230 | // |
csyang2 |
7:1bf2238df581 | 231 | /*-----------------------------------------------*/ |
csyang2 |
7:1bf2238df581 | 232 | void ILI9341_Initial(void) |
csyang2 |
7:1bf2238df581 | 233 | { |
csyang2 |
7:1bf2238df581 | 234 | uint16_t Reg = 0; |
csyang2 |
7:1bf2238df581 | 235 | |
csyang2 |
7:1bf2238df581 | 236 | /* Hardware reset */ |
csyang2 |
7:1bf2238df581 | 237 | SET_RST; |
csyang2 |
7:1bf2238df581 | 238 | GUI_X_Delay(5); // Delay 5ms |
csyang2 |
7:1bf2238df581 | 239 | |
csyang2 |
7:1bf2238df581 | 240 | CLR_RST; |
csyang2 |
7:1bf2238df581 | 241 | GUI_X_Delay(20); // Delay 20ms |
csyang2 |
7:1bf2238df581 | 242 | |
csyang2 |
7:1bf2238df581 | 243 | SET_RST; |
csyang2 |
7:1bf2238df581 | 244 | GUI_X_Delay(40); // Delay 40ms |
csyang2 |
7:1bf2238df581 | 245 | |
csyang2 |
7:1bf2238df581 | 246 | /* Initial control registers */ |
csyang2 |
7:1bf2238df581 | 247 | LCD_WR_REG(0xCB); |
csyang2 |
7:1bf2238df581 | 248 | LCD_WR_DATA(0x39); |
csyang2 |
7:1bf2238df581 | 249 | LCD_WR_DATA(0x2C); |
csyang2 |
7:1bf2238df581 | 250 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 251 | LCD_WR_DATA(0x34); |
csyang2 |
7:1bf2238df581 | 252 | LCD_WR_DATA(0x02); |
csyang2 |
7:1bf2238df581 | 253 | |
csyang2 |
7:1bf2238df581 | 254 | LCD_WR_REG(0xCF); |
csyang2 |
7:1bf2238df581 | 255 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 256 | LCD_WR_DATA(0xC1); |
csyang2 |
7:1bf2238df581 | 257 | LCD_WR_DATA(0x30); |
csyang2 |
7:1bf2238df581 | 258 | |
csyang2 |
7:1bf2238df581 | 259 | LCD_WR_REG(0xE8); |
csyang2 |
7:1bf2238df581 | 260 | LCD_WR_DATA(0x85); |
csyang2 |
7:1bf2238df581 | 261 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 262 | LCD_WR_DATA(0x78); |
csyang2 |
7:1bf2238df581 | 263 | |
csyang2 |
7:1bf2238df581 | 264 | LCD_WR_REG(0xEA); |
csyang2 |
7:1bf2238df581 | 265 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 266 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 267 | |
csyang2 |
7:1bf2238df581 | 268 | LCD_WR_REG(0xED); |
csyang2 |
7:1bf2238df581 | 269 | LCD_WR_DATA(0x64); |
csyang2 |
7:1bf2238df581 | 270 | LCD_WR_DATA(0x03); |
csyang2 |
7:1bf2238df581 | 271 | LCD_WR_DATA(0x12); |
csyang2 |
7:1bf2238df581 | 272 | LCD_WR_DATA(0x81); |
csyang2 |
7:1bf2238df581 | 273 | |
csyang2 |
7:1bf2238df581 | 274 | LCD_WR_REG(0xF7); |
csyang2 |
7:1bf2238df581 | 275 | LCD_WR_DATA(0x20); |
csyang2 |
7:1bf2238df581 | 276 | |
csyang2 |
7:1bf2238df581 | 277 | LCD_WR_REG(0xC0); |
csyang2 |
7:1bf2238df581 | 278 | LCD_WR_DATA(0x23); |
csyang2 |
7:1bf2238df581 | 279 | |
csyang2 |
7:1bf2238df581 | 280 | LCD_WR_REG(0xC1); |
csyang2 |
7:1bf2238df581 | 281 | LCD_WR_DATA(0x10); |
csyang2 |
7:1bf2238df581 | 282 | |
csyang2 |
7:1bf2238df581 | 283 | LCD_WR_REG(0xC5); |
csyang2 |
7:1bf2238df581 | 284 | LCD_WR_DATA(0x3e); |
csyang2 |
7:1bf2238df581 | 285 | LCD_WR_DATA(0x28); |
csyang2 |
7:1bf2238df581 | 286 | |
csyang2 |
7:1bf2238df581 | 287 | LCD_WR_REG(0xC7); |
csyang2 |
7:1bf2238df581 | 288 | LCD_WR_DATA(0x86); |
csyang2 |
7:1bf2238df581 | 289 | |
csyang2 |
7:1bf2238df581 | 290 | LCD_WR_REG(0x36); |
csyang2 |
7:1bf2238df581 | 291 | LCD_WR_DATA(0x48); |
csyang2 |
7:1bf2238df581 | 292 | |
csyang2 |
7:1bf2238df581 | 293 | LCD_WR_REG(0x3A); |
csyang2 |
7:1bf2238df581 | 294 | LCD_WR_DATA(0x55); |
csyang2 |
7:1bf2238df581 | 295 | |
csyang2 |
7:1bf2238df581 | 296 | LCD_WR_REG(0xB1); |
csyang2 |
7:1bf2238df581 | 297 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 298 | LCD_WR_DATA(0x18); |
csyang2 |
7:1bf2238df581 | 299 | |
csyang2 |
7:1bf2238df581 | 300 | LCD_WR_REG(0xB6); |
csyang2 |
7:1bf2238df581 | 301 | LCD_WR_DATA(0x08); |
csyang2 |
7:1bf2238df581 | 302 | LCD_WR_DATA(0x82); |
csyang2 |
7:1bf2238df581 | 303 | LCD_WR_DATA(0x27); |
csyang2 |
7:1bf2238df581 | 304 | |
csyang2 |
7:1bf2238df581 | 305 | LCD_WR_REG(0xF2); |
csyang2 |
7:1bf2238df581 | 306 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 307 | |
csyang2 |
7:1bf2238df581 | 308 | LCD_WR_REG(0x26); |
csyang2 |
7:1bf2238df581 | 309 | LCD_WR_DATA(0x01); |
csyang2 |
7:1bf2238df581 | 310 | |
csyang2 |
7:1bf2238df581 | 311 | LCD_WR_REG(0xE0); |
csyang2 |
7:1bf2238df581 | 312 | LCD_WR_DATA(0x0F); |
csyang2 |
7:1bf2238df581 | 313 | LCD_WR_DATA(0x31); |
csyang2 |
7:1bf2238df581 | 314 | LCD_WR_DATA(0x2B); |
csyang2 |
7:1bf2238df581 | 315 | LCD_WR_DATA(0x0C); |
csyang2 |
7:1bf2238df581 | 316 | LCD_WR_DATA(0x0E); |
csyang2 |
7:1bf2238df581 | 317 | LCD_WR_DATA(0x08); |
csyang2 |
7:1bf2238df581 | 318 | LCD_WR_DATA(0x4E); |
csyang2 |
7:1bf2238df581 | 319 | LCD_WR_DATA(0xF1); |
csyang2 |
7:1bf2238df581 | 320 | LCD_WR_DATA(0x37); |
csyang2 |
7:1bf2238df581 | 321 | LCD_WR_DATA(0x07); |
csyang2 |
7:1bf2238df581 | 322 | LCD_WR_DATA(0x10); |
csyang2 |
7:1bf2238df581 | 323 | LCD_WR_DATA(0x03); |
csyang2 |
7:1bf2238df581 | 324 | LCD_WR_DATA(0x0E); |
csyang2 |
7:1bf2238df581 | 325 | LCD_WR_DATA(0x09); |
csyang2 |
7:1bf2238df581 | 326 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 327 | |
csyang2 |
7:1bf2238df581 | 328 | LCD_WR_REG(0xE1); |
csyang2 |
7:1bf2238df581 | 329 | LCD_WR_DATA(0x00); |
csyang2 |
7:1bf2238df581 | 330 | LCD_WR_DATA(0x0E); |
csyang2 |
7:1bf2238df581 | 331 | LCD_WR_DATA(0x14); |
csyang2 |
7:1bf2238df581 | 332 | LCD_WR_DATA(0x03); |
csyang2 |
7:1bf2238df581 | 333 | LCD_WR_DATA(0x11); |
csyang2 |
7:1bf2238df581 | 334 | LCD_WR_DATA(0x07); |
csyang2 |
7:1bf2238df581 | 335 | LCD_WR_DATA(0x31); |
csyang2 |
7:1bf2238df581 | 336 | LCD_WR_DATA(0xC1); |
csyang2 |
7:1bf2238df581 | 337 | LCD_WR_DATA(0x48); |
csyang2 |
7:1bf2238df581 | 338 | LCD_WR_DATA(0x08); |
csyang2 |
7:1bf2238df581 | 339 | LCD_WR_DATA(0x0F); |
csyang2 |
7:1bf2238df581 | 340 | LCD_WR_DATA(0x0C); |
csyang2 |
7:1bf2238df581 | 341 | LCD_WR_DATA(0x31); |
csyang2 |
7:1bf2238df581 | 342 | LCD_WR_DATA(0x36); |
csyang2 |
7:1bf2238df581 | 343 | LCD_WR_DATA(0x0F); |
csyang2 |
7:1bf2238df581 | 344 | |
csyang2 |
7:1bf2238df581 | 345 | LCD_WR_REG(0x11); |
csyang2 |
7:1bf2238df581 | 346 | GUI_X_Delay(200); // Delay 200ms |
csyang2 |
7:1bf2238df581 | 347 | |
csyang2 |
7:1bf2238df581 | 348 | LCD_WR_REG(0x29); //Display on |
csyang2 |
7:1bf2238df581 | 349 | |
csyang2 |
7:1bf2238df581 | 350 | LCD_WR_REG(0x0A); |
csyang2 |
7:1bf2238df581 | 351 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 352 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 353 | printf("0Ah = %02x.\n", Reg); |
csyang2 |
7:1bf2238df581 | 354 | |
csyang2 |
7:1bf2238df581 | 355 | LCD_WR_REG(0x0B); |
csyang2 |
7:1bf2238df581 | 356 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 357 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 358 | printf("0Bh = %02x.\n", Reg); |
csyang2 |
7:1bf2238df581 | 359 | |
csyang2 |
7:1bf2238df581 | 360 | LCD_WR_REG(0x0C); |
csyang2 |
7:1bf2238df581 | 361 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 362 | Reg = LCD_RD_DATA(); |
csyang2 |
7:1bf2238df581 | 363 | printf("0Ch = %02x.\n", Reg); |
csyang2 |
7:1bf2238df581 | 364 | |
csyang2 |
7:1bf2238df581 | 365 | printf("Initial ILI9341 LCD Module done.\n\n"); |
csyang2 |
7:1bf2238df581 | 366 | |
csyang2 |
7:1bf2238df581 | 367 | } |
csyang2 |
7:1bf2238df581 | 368 | |
csyang2 |
7:1bf2238df581 | 369 | //void I2C2_Init(void) |
csyang2 |
7:1bf2238df581 | 370 | //{ |
csyang2 |
7:1bf2238df581 | 371 | /* Open I2C2 and set clock to 100k */ |
csyang2 |
7:1bf2238df581 | 372 | //I2C_Open(I2C2, 100000); |
csyang2 |
7:1bf2238df581 | 373 | //} |
csyang2 |
7:1bf2238df581 | 374 | |
csyang2 |
7:1bf2238df581 | 375 | //void EINT7_IRQHandler(void) |
csyang2 |
7:1bf2238df581 | 376 | //{ |
csyang2 |
7:1bf2238df581 | 377 | // /* To check if PB.9 external interrupt occurred */ |
csyang2 |
7:1bf2238df581 | 378 | // if(GPIO_GET_INT_FLAG(PB, BIT9)) { |
csyang2 |
7:1bf2238df581 | 379 | // GPIO_CLR_INT_FLAG(PB, BIT9); |
csyang2 |
7:1bf2238df581 | 380 | // printf("PB.9 EINT7 occurred.\n"); |
csyang2 |
7:1bf2238df581 | 381 | // } |
csyang2 |
7:1bf2238df581 | 382 | |
csyang2 |
7:1bf2238df581 | 383 | //} |
csyang2 |
7:1bf2238df581 | 384 | |
csyang2 |
7:1bf2238df581 | 385 | |
csyang2 |
7:1bf2238df581 | 386 | void EBI_FuncPinInit(void) |
csyang2 |
7:1bf2238df581 | 387 | { |
csyang2 |
7:1bf2238df581 | 388 | /*=== EBI (LCD module) mult-function pins ===*/ |
csyang2 |
7:1bf2238df581 | 389 | /* EBI AD0~5 pins on PG.9~14 */ |
csyang2 |
7:1bf2238df581 | 390 | SYS->GPG_MFPH &= ~(SYS_GPG_MFPH_PG9MFP_Msk | SYS_GPG_MFPH_PG10MFP_Msk | |
csyang2 |
7:1bf2238df581 | 391 | SYS_GPG_MFPH_PG11MFP_Msk | SYS_GPG_MFPH_PG12MFP_Msk | |
csyang2 |
7:1bf2238df581 | 392 | SYS_GPG_MFPH_PG13MFP_Msk | SYS_GPG_MFPH_PG14MFP_Msk); |
csyang2 |
7:1bf2238df581 | 393 | SYS->GPG_MFPH |= (SYS_GPG_MFPH_PG9MFP_EBI_AD0 | SYS_GPG_MFPH_PG10MFP_EBI_AD1 | |
csyang2 |
7:1bf2238df581 | 394 | SYS_GPG_MFPH_PG11MFP_EBI_AD2 | SYS_GPG_MFPH_PG12MFP_EBI_AD3 | |
csyang2 |
7:1bf2238df581 | 395 | SYS_GPG_MFPH_PG13MFP_EBI_AD4 | SYS_GPG_MFPH_PG14MFP_EBI_AD5); |
csyang2 |
7:1bf2238df581 | 396 | |
csyang2 |
7:1bf2238df581 | 397 | /* EBI AD6, AD7 pins on PD.8, PD.9 */ |
csyang2 |
7:1bf2238df581 | 398 | SYS->GPD_MFPH &= ~(SYS_GPD_MFPH_PD8MFP_Msk | SYS_GPD_MFPH_PD9MFP_Msk); |
csyang2 |
7:1bf2238df581 | 399 | SYS->GPD_MFPH |= (SYS_GPD_MFPH_PD8MFP_EBI_AD6 | SYS_GPD_MFPH_PD9MFP_EBI_AD7); |
csyang2 |
7:1bf2238df581 | 400 | |
csyang2 |
7:1bf2238df581 | 401 | /* EBI AD8, AD9 pins on PE.14, PE.15 */ |
csyang2 |
7:1bf2238df581 | 402 | SYS->GPE_MFPH &= ~(SYS_GPE_MFPH_PE14MFP_Msk | SYS_GPE_MFPH_PE15MFP_Msk); |
csyang2 |
7:1bf2238df581 | 403 | SYS->GPE_MFPH |= (SYS_GPE_MFPH_PE14MFP_EBI_AD8 | SYS_GPE_MFPH_PE15MFP_EBI_AD9); |
csyang2 |
7:1bf2238df581 | 404 | |
csyang2 |
7:1bf2238df581 | 405 | /* EBI AD10, AD11 pins on PE.1, PE.0 */ |
csyang2 |
7:1bf2238df581 | 406 | SYS->GPE_MFPL &= ~(SYS_GPE_MFPL_PE1MFP_Msk | SYS_GPE_MFPL_PE0MFP_Msk); |
csyang2 |
7:1bf2238df581 | 407 | SYS->GPE_MFPL |= (SYS_GPE_MFPL_PE1MFP_EBI_AD10 | SYS_GPE_MFPL_PE0MFP_EBI_AD11); |
csyang2 |
7:1bf2238df581 | 408 | |
csyang2 |
7:1bf2238df581 | 409 | /* EBI AD12~15 pins on PH.8~11 */ |
csyang2 |
7:1bf2238df581 | 410 | SYS->GPH_MFPH &= ~(SYS_GPH_MFPH_PH8MFP_Msk | SYS_GPH_MFPH_PH9MFP_Msk | |
csyang2 |
7:1bf2238df581 | 411 | SYS_GPH_MFPH_PH10MFP_Msk | SYS_GPH_MFPH_PH11MFP_Msk); |
csyang2 |
7:1bf2238df581 | 412 | SYS->GPH_MFPH |= (SYS_GPH_MFPH_PH8MFP_EBI_AD12 | SYS_GPH_MFPH_PH9MFP_EBI_AD13 | |
csyang2 |
7:1bf2238df581 | 413 | SYS_GPH_MFPH_PH10MFP_EBI_AD14 | SYS_GPH_MFPH_PH11MFP_EBI_AD15); |
csyang2 |
7:1bf2238df581 | 414 | |
csyang2 |
7:1bf2238df581 | 415 | /* Configure PH.3 as Output mode for LCD_RS (use GPIO PH.3 to control LCD_RS) */ |
csyang2 |
7:1bf2238df581 | 416 | GPIO_SetMode(PH, BIT3, GPIO_MODE_OUTPUT); |
csyang2 |
7:1bf2238df581 | 417 | PH3 = 1; |
csyang2 |
7:1bf2238df581 | 418 | |
csyang2 |
7:1bf2238df581 | 419 | /* EBI RD and WR pins on PE.4 and PE.5 */ |
csyang2 |
7:1bf2238df581 | 420 | SYS->GPE_MFPL &= ~(SYS_GPE_MFPL_PE4MFP_Msk | SYS_GPE_MFPL_PE5MFP_Msk); |
csyang2 |
7:1bf2238df581 | 421 | SYS->GPE_MFPL |= (SYS_GPE_MFPL_PE4MFP_EBI_nWR | SYS_GPE_MFPL_PE5MFP_EBI_nRD); |
csyang2 |
7:1bf2238df581 | 422 | |
csyang2 |
7:1bf2238df581 | 423 | /* EBI CS0 pin on PD.14 */ |
csyang2 |
7:1bf2238df581 | 424 | SYS->GPD_MFPH &= ~SYS_GPD_MFPH_PD14MFP_Msk; |
csyang2 |
7:1bf2238df581 | 425 | SYS->GPD_MFPH |= SYS_GPD_MFPH_PD14MFP_EBI_nCS0; |
csyang2 |
7:1bf2238df581 | 426 | |
csyang2 |
7:1bf2238df581 | 427 | /* Configure PB.6 and PB.7 as Output mode for LCD_RST and LCD_Backlight */ |
csyang2 |
7:1bf2238df581 | 428 | GPIO_SetMode(PB, BIT6, GPIO_MODE_OUTPUT); |
csyang2 |
7:1bf2238df581 | 429 | GPIO_SetMode(PB, BIT7, GPIO_MODE_OUTPUT); |
csyang2 |
7:1bf2238df581 | 430 | PB6 = 1; |
csyang2 |
7:1bf2238df581 | 431 | PB7 = 0; |
csyang2 |
7:1bf2238df581 | 432 | |
csyang2 |
7:1bf2238df581 | 433 | //GPIO_SetMode(PH, BIT5, GPIO_MODE_INPUT); |
csyang2 |
7:1bf2238df581 | 434 | //GPIO_SetMode(PH, BIT6, GPIO_MODE_INPUT); |
csyang2 |
7:1bf2238df581 | 435 | //GPIO_SetMode(PH, BIT7, GPIO_MODE_INPUT); |
csyang2 |
7:1bf2238df581 | 436 | |
csyang2 |
7:1bf2238df581 | 437 | } |
csyang2 |
7:1bf2238df581 | 438 | |
csyang2 |
7:1bf2238df581 | 439 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 440 | * |
csyang2 |
7:1bf2238df581 | 441 | * _InitController |
csyang2 |
7:1bf2238df581 | 442 | * |
csyang2 |
7:1bf2238df581 | 443 | * Purpose: |
csyang2 |
7:1bf2238df581 | 444 | * Initializes the display controller |
csyang2 |
7:1bf2238df581 | 445 | */ |
csyang2 |
7:1bf2238df581 | 446 | static void _InitController(void) |
csyang2 |
7:1bf2238df581 | 447 | { |
csyang2 |
7:1bf2238df581 | 448 | static uint8_t s_InitOnce = 0; |
csyang2 |
7:1bf2238df581 | 449 | |
csyang2 |
7:1bf2238df581 | 450 | if (s_InitOnce == 0) |
csyang2 |
7:1bf2238df581 | 451 | s_InitOnce = 1; |
csyang2 |
7:1bf2238df581 | 452 | else |
csyang2 |
7:1bf2238df581 | 453 | return; |
csyang2 |
7:1bf2238df581 | 454 | |
csyang2 |
7:1bf2238df581 | 455 | CLK_EnableModuleClock(EBI_MODULE); |
csyang2 |
7:1bf2238df581 | 456 | |
csyang2 |
7:1bf2238df581 | 457 | /* Configure DC/RESET/LED pins */ |
csyang2 |
7:1bf2238df581 | 458 | EBI_FuncPinInit(); |
csyang2 |
7:1bf2238df581 | 459 | |
csyang2 |
7:1bf2238df581 | 460 | /* Initialize EBI bank0 to access external LCD Module */ |
csyang2 |
7:1bf2238df581 | 461 | EBI_Open(EBI_BANK0, EBI_BUSWIDTH_16BIT, EBI_TIMING_NORMAL, 0, EBI_CS_ACTIVE_LOW); |
csyang2 |
7:1bf2238df581 | 462 | EBI->CTL0 |= EBI_CTL0_CACCESS_Msk; |
csyang2 |
7:1bf2238df581 | 463 | EBI->TCTL0 |= (EBI_TCTL0_WAHDOFF_Msk | EBI_TCTL0_RAHDOFF_Msk); |
csyang2 |
7:1bf2238df581 | 464 | printf("\n[EBI CTL0:0x%08X, TCLT0:0x%08X]\n\n", EBI->CTL0, EBI->TCTL0); |
csyang2 |
7:1bf2238df581 | 465 | |
csyang2 |
7:1bf2238df581 | 466 | /* Init LCD Module */ |
csyang2 |
7:1bf2238df581 | 467 | ILI9341_Initial(); |
csyang2 |
7:1bf2238df581 | 468 | |
csyang2 |
7:1bf2238df581 | 469 | /* PB.7 BL_CTRL pin */ |
csyang2 |
7:1bf2238df581 | 470 | PB7 = 1; |
csyang2 |
7:1bf2238df581 | 471 | |
csyang2 |
7:1bf2238df581 | 472 | /* Init I2C2 to TP of LCD module */ |
csyang2 |
7:1bf2238df581 | 473 | //I2C2_Init(); |
csyang2 |
7:1bf2238df581 | 474 | |
csyang2 |
7:1bf2238df581 | 475 | // /* Configure PB.9 as Quasi-bidirection mode and enable interrupt by falling edge trigger */ |
csyang2 |
7:1bf2238df581 | 476 | // GPIO_SetMode(PB, BIT9, GPIO_MODE_QUASI); |
csyang2 |
7:1bf2238df581 | 477 | // GPIO_EnableInt(PB, 9, GPIO_INT_FALLING); |
csyang2 |
7:1bf2238df581 | 478 | // NVIC_EnableIRQ(EINT7_IRQn); |
csyang2 |
7:1bf2238df581 | 479 | } |
csyang2 |
7:1bf2238df581 | 480 | |
csyang2 |
7:1bf2238df581 | 481 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 482 | * |
csyang2 |
7:1bf2238df581 | 483 | * Public code |
csyang2 |
7:1bf2238df581 | 484 | * |
csyang2 |
7:1bf2238df581 | 485 | ********************************************************************** |
csyang2 |
7:1bf2238df581 | 486 | */ |
csyang2 |
7:1bf2238df581 | 487 | #if GUI_SUPPORT_TOUCH |
csyang2 |
7:1bf2238df581 | 488 | extern int ts_phy2log(int *sumx, int *sumy); |
csyang2 |
7:1bf2238df581 | 489 | |
csyang2 |
7:1bf2238df581 | 490 | void GUI_TOUCH_X_ActivateX(void) { |
csyang2 |
7:1bf2238df581 | 491 | } |
csyang2 |
7:1bf2238df581 | 492 | |
csyang2 |
7:1bf2238df581 | 493 | void GUI_TOUCH_X_ActivateY(void) { |
csyang2 |
7:1bf2238df581 | 494 | } |
csyang2 |
7:1bf2238df581 | 495 | |
csyang2 |
7:1bf2238df581 | 496 | |
csyang2 |
7:1bf2238df581 | 497 | |
csyang2 |
7:1bf2238df581 | 498 | int GUI_TOUCH_X_MeasureX(void) { |
csyang2 |
7:1bf2238df581 | 499 | int sumx; |
csyang2 |
7:1bf2238df581 | 500 | int sumy; |
csyang2 |
7:1bf2238df581 | 501 | if (Read_TouchPanel(&sumx, &sumy)) |
csyang2 |
7:1bf2238df581 | 502 | { |
csyang2 |
7:1bf2238df581 | 503 | // sysprintf("X = %d\n", sumx); |
csyang2 |
7:1bf2238df581 | 504 | ts_phy2log(&sumx, &sumy); |
csyang2 |
7:1bf2238df581 | 505 | return sumx; |
csyang2 |
7:1bf2238df581 | 506 | } |
csyang2 |
7:1bf2238df581 | 507 | return -1; |
csyang2 |
7:1bf2238df581 | 508 | } |
csyang2 |
7:1bf2238df581 | 509 | |
csyang2 |
7:1bf2238df581 | 510 | int GUI_TOUCH_X_MeasureY(void) { |
csyang2 |
7:1bf2238df581 | 511 | int sumx; |
csyang2 |
7:1bf2238df581 | 512 | int sumy; |
csyang2 |
7:1bf2238df581 | 513 | if ( Read_TouchPanel(&sumx, &sumy) ) |
csyang2 |
7:1bf2238df581 | 514 | { |
csyang2 |
7:1bf2238df581 | 515 | // sysprintf("Y = %d\n", sumy); |
csyang2 |
7:1bf2238df581 | 516 | ts_phy2log(&sumx, &sumy); |
csyang2 |
7:1bf2238df581 | 517 | return sumy; |
csyang2 |
7:1bf2238df581 | 518 | } |
csyang2 |
7:1bf2238df581 | 519 | return -1; |
csyang2 |
7:1bf2238df581 | 520 | } |
csyang2 |
7:1bf2238df581 | 521 | #endif |
csyang2 |
7:1bf2238df581 | 522 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 523 | * |
csyang2 |
7:1bf2238df581 | 524 | * LCD_X_Config |
csyang2 |
7:1bf2238df581 | 525 | * |
csyang2 |
7:1bf2238df581 | 526 | * Purpose: |
csyang2 |
7:1bf2238df581 | 527 | * Called during the initialization process in order to set up the |
csyang2 |
7:1bf2238df581 | 528 | * display driver configuration. |
csyang2 |
7:1bf2238df581 | 529 | * |
csyang2 |
7:1bf2238df581 | 530 | */ |
csyang2 |
7:1bf2238df581 | 531 | void LCD_X_Config(void) |
csyang2 |
7:1bf2238df581 | 532 | { |
csyang2 |
7:1bf2238df581 | 533 | GUI_DEVICE * pDevice; |
csyang2 |
7:1bf2238df581 | 534 | CONFIG_FLEXCOLOR Config = {0}; |
csyang2 |
7:1bf2238df581 | 535 | GUI_PORT_API PortAPI = {0}; |
csyang2 |
7:1bf2238df581 | 536 | // |
csyang2 |
7:1bf2238df581 | 537 | // Set display driver and color conversion |
csyang2 |
7:1bf2238df581 | 538 | // |
csyang2 |
7:1bf2238df581 | 539 | pDevice = GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0); |
csyang2 |
7:1bf2238df581 | 540 | |
csyang2 |
7:1bf2238df581 | 541 | // |
csyang2 |
7:1bf2238df581 | 542 | // Display driver configuration |
csyang2 |
7:1bf2238df581 | 543 | // |
csyang2 |
7:1bf2238df581 | 544 | LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS); |
csyang2 |
7:1bf2238df581 | 545 | LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS); |
csyang2 |
7:1bf2238df581 | 546 | // |
csyang2 |
7:1bf2238df581 | 547 | // Orientation |
csyang2 |
7:1bf2238df581 | 548 | // |
csyang2 |
7:1bf2238df581 | 549 | Config.Orientation = GUI_MIRROR_X | GUI_MIRROR_Y | GUI_SWAP_XY; |
csyang2 |
7:1bf2238df581 | 550 | GUIDRV_FlexColor_Config(pDevice, &Config); |
csyang2 |
7:1bf2238df581 | 551 | // |
csyang2 |
7:1bf2238df581 | 552 | // Set controller and operation mode |
csyang2 |
7:1bf2238df581 | 553 | // |
csyang2 |
7:1bf2238df581 | 554 | PortAPI.pfWrite16_A0 = LCD_WR_REG; |
csyang2 |
7:1bf2238df581 | 555 | PortAPI.pfWrite16_A1 = LCD_WR_DATA; |
csyang2 |
7:1bf2238df581 | 556 | PortAPI.pfWriteM16_A0 = LcdWriteDataMultiple; |
csyang2 |
7:1bf2238df581 | 557 | PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple; |
csyang2 |
7:1bf2238df581 | 558 | PortAPI.pfRead16_A0 = LCD_RD_DATA; |
csyang2 |
7:1bf2238df581 | 559 | PortAPI.pfRead16_A1 = LCD_RD_DATA; |
csyang2 |
7:1bf2238df581 | 560 | PortAPI.pfReadM16_A0 = LcdReadDataMultiple; |
csyang2 |
7:1bf2238df581 | 561 | PortAPI.pfReadM16_A1 = LcdReadDataMultiple; |
csyang2 |
7:1bf2238df581 | 562 | GUIDRV_FlexColor_SetReadFunc66709_B16(pDevice, GUIDRV_FLEXCOLOR_READ_FUNC_III); |
csyang2 |
7:1bf2238df581 | 563 | GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16); |
csyang2 |
7:1bf2238df581 | 564 | |
csyang2 |
7:1bf2238df581 | 565 | #if GUI_SUPPORT_TOUCH |
csyang2 |
7:1bf2238df581 | 566 | // LCD calibration |
csyang2 |
7:1bf2238df581 | 567 | // |
csyang2 |
7:1bf2238df581 | 568 | // Calibrate touch screen |
csyang2 |
7:1bf2238df581 | 569 | // |
csyang2 |
7:1bf2238df581 | 570 | GUI_TOUCH_Calibrate(GUI_COORD_X, 0, (__DEMO_TS_WIDTH__ - 1), 0, (__DEMO_TS_WIDTH__ - 1)); |
csyang2 |
7:1bf2238df581 | 571 | GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, (__DEMO_TS_HEIGHT__- 1), 0, (__DEMO_TS_HEIGHT__- 1)); |
csyang2 |
7:1bf2238df581 | 572 | #endif |
csyang2 |
7:1bf2238df581 | 573 | } |
csyang2 |
7:1bf2238df581 | 574 | /********************************************************************* |
csyang2 |
7:1bf2238df581 | 575 | * |
csyang2 |
7:1bf2238df581 | 576 | * LCD_X_DisplayDriver |
csyang2 |
7:1bf2238df581 | 577 | * |
csyang2 |
7:1bf2238df581 | 578 | * Purpose: |
csyang2 |
7:1bf2238df581 | 579 | * This function is called by the display driver for several purposes. |
csyang2 |
7:1bf2238df581 | 580 | * To support the according task the routine needs to be adapted to |
csyang2 |
7:1bf2238df581 | 581 | * the display controller. Please note that the commands marked with |
csyang2 |
7:1bf2238df581 | 582 | * 'optional' are not cogently required and should only be adapted if |
csyang2 |
7:1bf2238df581 | 583 | * the display controller supports these features. |
csyang2 |
7:1bf2238df581 | 584 | * |
csyang2 |
7:1bf2238df581 | 585 | * Parameter: |
csyang2 |
7:1bf2238df581 | 586 | * LayerIndex - Index of layer to be configured |
csyang2 |
7:1bf2238df581 | 587 | * Cmd - Please refer to the details in the switch statement below |
csyang2 |
7:1bf2238df581 | 588 | * pData - Pointer to a LCD_X_DATA structure |
csyang2 |
7:1bf2238df581 | 589 | */ |
csyang2 |
7:1bf2238df581 | 590 | int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) |
csyang2 |
7:1bf2238df581 | 591 | { |
csyang2 |
7:1bf2238df581 | 592 | int r; |
csyang2 |
7:1bf2238df581 | 593 | |
csyang2 |
7:1bf2238df581 | 594 | GUI_USE_PARA(LayerIndex); |
csyang2 |
7:1bf2238df581 | 595 | GUI_USE_PARA(pData); |
csyang2 |
7:1bf2238df581 | 596 | switch (Cmd) { |
csyang2 |
7:1bf2238df581 | 597 | // |
csyang2 |
7:1bf2238df581 | 598 | // Required |
csyang2 |
7:1bf2238df581 | 599 | // |
csyang2 |
7:1bf2238df581 | 600 | case LCD_X_INITCONTROLLER: { |
csyang2 |
7:1bf2238df581 | 601 | // |
csyang2 |
7:1bf2238df581 | 602 | // Called during the initialization process in order to set up the |
csyang2 |
7:1bf2238df581 | 603 | // display controller and put it into operation. If the display |
csyang2 |
7:1bf2238df581 | 604 | // controller is not initialized by any external routine this needs |
csyang2 |
7:1bf2238df581 | 605 | // to be adapted by the customer... |
csyang2 |
7:1bf2238df581 | 606 | // |
csyang2 |
7:1bf2238df581 | 607 | _InitController(); |
csyang2 |
7:1bf2238df581 | 608 | //printf("\n************ _InitController \n\n"); |
csyang2 |
7:1bf2238df581 | 609 | return 0; |
csyang2 |
7:1bf2238df581 | 610 | } |
csyang2 |
7:1bf2238df581 | 611 | default: |
csyang2 |
7:1bf2238df581 | 612 | r = -1; |
csyang2 |
7:1bf2238df581 | 613 | } |
csyang2 |
7:1bf2238df581 | 614 | return r; |
csyang2 |
7:1bf2238df581 | 615 | } |
csyang2 |
7:1bf2238df581 | 616 | /*************************** End of file ****************************/ |