00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "board.h"
00041 #include <string.h>
00042 #include <stdio.h>
00043
00044 #ifdef BOARD_LCD_ILI9488
00045
00046
00047
00048
00049
00050
00051 static const Pin lcd_ebi_reset_pin = LCD_EBI_PIN_RESET;
00052 static const Pin lcd_ebi_pwm_pin = BOARD_EBI_LCD_PIN_BACKLIGHT;
00053
00054 static const Pin lcd_ebi_pins[] = BOARD_EBI_LCD_PINS;
00055
00056 static const Pin lcd_ebi_cds_pin = BOARD_EBI_LCD_PIN_CDS;
00057
00058
00059
00060
00061
00062
00063
00064 static void _ILI9488_EbiHW_Initialize(void)
00065 {
00066
00067 PIO_Configure(&lcd_ebi_reset_pin, 1);
00068 PIO_Configure(&lcd_ebi_cds_pin, 1);
00069 PIO_Configure(lcd_ebi_pins, PIO_LISTSIZE(lcd_ebi_pins));
00070 PIO_Configure(&lcd_ebi_pwm_pin, 1);
00071 PIO_Set(&lcd_ebi_pwm_pin);
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081 COMPILER_ALIGNED(32) static uint32_t chipidBuf[5];
00082 uint32_t ILI9488_EbiReadChipId (void)
00083 {
00084 uint32_t chipid = 0;
00085
00086 uint8_t i;
00087 uint32_t *ptr;
00088 uint32_t shift_cnt = 2;
00089
00090 ILI9488_EbiSendCommand(ILI9488_CMD_READ_ID4, 0, 0, AccessInst, 0);
00091 ILI9488_EbiSendCommand(0, 0, chipidBuf, AccessRead, 4);
00092 ptr = &chipidBuf[1];
00093
00094 for (i = 1; i < 4; i++) {
00095 chipid |= (*ptr & 0xFF) << (shift_cnt << 3);
00096 ptr++;
00097 shift_cnt--;
00098 }
00099
00100 return chipid;
00101 }
00102
00103
00104
00105
00106
00107 void ILI9488_EbiSetPixelFormat(uint16_t format)
00108 {
00109 ILI9488_EbiSendCommand(ILI9488_CMD_COLMOD_PIXEL_FORMAT_SET, &format, 0,
00110 AccessWrite, 1);
00111 }
00112
00113
00114
00115
00116 uint32_t ILI9488_EbiInitialize(sXdmad *dmad)
00117 {
00118 uint32_t chipid;
00119 uint16_t param;
00120
00121 _ILI9488_EbiHW_Initialize();
00122 ILI9488_EbiInitializeWithDma(dmad);
00123
00124 ILI9488_EbiSendCommand(ILI9488_CMD_SOFTWARE_RESET, 0, 0, AccessInst, 0);
00125 Wait(200);
00126
00127 ILI9488_EbiSendCommand(ILI9488_CMD_SLEEP_OUT, 0, 0, AccessInst, 0);
00128 Wait(200);
00129
00130
00131 param = 0x48;
00132 ILI9488_EbiSendCommand(ILI9488_CMD_MEMORY_ACCESS_CONTROL, ¶m, 0,
00133 AccessWrite, 1);
00134 Wait(100);
00135
00136 param = 0x04;
00137 ILI9488_EbiSendCommand(ILI9488_CMD_CABC_CONTROL_9, ¶m, 0, AccessWrite, 1);
00138
00139 if ((chipid = ILI9488_EbiReadChipId()) != ILI9488_DEVICE_CODE) {
00140 printf("Read ILI9488 chip ID (0x%04x) error, skip initialization.\r\n",
00141 (unsigned int)chipid);
00142 return 1;
00143 }
00144
00145 ILI9488_EbiSetPixelFormat(5);
00146 ILI9488_EbiSendCommand(ILI9488_CMD_NORMAL_DISP_MODE_ON, 0, 0, AccessInst, 0);
00147 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_ON, 0, 0, AccessInst, 0);
00148 return 0;
00149 }
00150
00151
00152
00153
00154
00155
00156 void ILI9488_EbiSetCursor(uint16_t x, uint16_t y)
00157 {
00158
00159 uint32_t cnt = 0;
00160
00161 uint16_t buf[4];
00162 cnt = sizeof(buf) / sizeof(uint16_t);
00163
00164 buf[0] = get_8b_to_16b(x);
00165 buf[1] = get_0b_to_8b(x);
00166 x += 1;
00167 buf[2] = get_8b_to_16b(x);
00168 buf[3] = get_0b_to_8b(x);
00169 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t *)buf, 0,
00170 AccessWrite, cnt);
00171 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00172
00173
00174
00175 buf[0] = get_8b_to_16b(y);
00176 buf[1] = get_0b_to_8b(y);
00177 y += 1;
00178 buf[2] = get_8b_to_16b(y);
00179 buf[3] = get_0b_to_8b(y);
00180 ILI9488_EbiSendCommand(ILI9488_CMD_PAGE_ADDRESS_SET, (uint16_t *)buf, 0,
00181 AccessWrite, cnt);
00182 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192 COMPILER_ALIGNED(32) static uint16_t buf[4];
00193 void ILI9488_EbiSetWindow(
00194 uint16_t dwX, uint16_t dwY, uint16_t dwWidth, uint16_t dwHeight)
00195 {
00196 uint16_t ColStart, ColEnd, RowStart, RowEnd;
00197
00198 uint32_t cnt = 0;
00199
00200
00201 cnt = sizeof(buf) / sizeof(uint16_t);
00202
00203 ColStart = dwX;
00204 ColEnd = dwWidth + dwX;
00205
00206 RowStart = dwY;
00207 RowEnd = dwHeight + dwY;
00208
00209 buf[0] = get_8b_to_16b(ColStart);
00210 buf[1] = get_0b_to_8b(ColStart);
00211 buf[2] = get_8b_to_16b(ColEnd);
00212 buf[3] = get_0b_to_8b(ColEnd);
00213 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t *)buf, 0,
00214 AccessWrite, cnt);
00215 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00216
00217
00218 buf[0] = get_8b_to_16b(RowStart);
00219 buf[1] = get_0b_to_8b(RowStart);
00220 buf[2] = get_8b_to_16b(RowEnd);
00221 buf[3] = get_0b_to_8b(RowEnd);
00222 ILI9488_EbiSendCommand(ILI9488_CMD_PAGE_ADDRESS_SET, (uint16_t *)buf, 0,
00223 AccessWrite, cnt);
00224 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00225 }
00226
00227
00228
00229
00230 void ILI9488_EbiSetFullWindow(void)
00231 {
00232 uint16_t c_start, c_end, r_start, r_end;
00233 uint32_t cnt = 0;
00234
00235 cnt = sizeof(buf) / sizeof(uint16_t);
00236
00237 c_start = 0;
00238 c_end = ILI9488_LCD_WIDTH - 1;
00239
00240 r_start = 0;
00241 r_end = ILI9488_LCD_HEIGHT - 1;
00242
00243
00244 buf[0] = get_8b_to_16b(c_start);
00245 buf[1] = get_0b_to_8b(c_start);
00246 buf[2] = get_8b_to_16b(c_end);
00247 buf[3] = get_0b_to_8b(c_end);
00248 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t *)buf, 0,
00249 AccessWrite, cnt);
00250 ILI9488_EbiSendCommand(ILI9488_CMD_NOP , 0, 0, AccessInst, 0);
00251
00252
00253 buf[0] = get_8b_to_16b(r_start);
00254 buf[1] = get_0b_to_8b(r_start);
00255 buf[2] = get_8b_to_16b(r_end);
00256 buf[3] = get_0b_to_8b(r_end);
00257 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t *)buf, 0,
00258 AccessWrite, cnt);
00259 ILI9488_EbiSendCommand(ILI9488_CMD_NOP , 0, 0, AccessInst, 0);
00260 }
00261
00262
00263
00264
00265
00266 void ILI9488_EbiOn(void)
00267 {
00268 ILI9488_EbiSendCommand(ILI9488_CMD_PIXEL_OFF, 0, 0, AccessInst, 0);
00269 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_ON, 0, 0, AccessInst, 0);
00270 ILI9488_EbiSendCommand(ILI9488_CMD_NORMAL_DISP_MODE_ON, 0, 0, AccessInst, 0);
00271 }
00272
00273
00274
00275
00276 void ILI9488_EbiOff(void)
00277 {
00278 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_OFF, 0, 0, AccessInst, 0);
00279 }
00280
00281
00282
00283
00284
00285
00286 void ILI9488_EbiSetDisplayLandscape(uint8_t dwRGB, uint8_t LandscapeMode)
00287 {
00288 uint16_t value;
00289
00290 if (LandscapeMode) {
00291 if (dwRGB)
00292 value = 0xE8;
00293 else
00294 value = 0xE0;
00295 } else {
00296 if (dwRGB)
00297 value = 0x48;
00298 else
00299 value = 0x40;
00300 }
00301
00302 ILI9488_EbiSendCommand(ILI9488_CMD_MEMORY_ACCESS_CONTROL, &value, 0,
00303 AccessWrite, sizeof(value));
00304 }
00305
00306 #endif