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 uint32_t ILI9488_EbiReadChipId (void)
00082 {
00083 uint32_t chipid = 0;
00084 uint32_t chipidBuf[5];
00085 uint8_t i;
00086 uint32_t *ptr;
00087 uint32_t shift_cnt = 2;
00088
00089 ILI9488_EbiSendCommand(ILI9488_CMD_READ_ID4, 0, 0, AccessInst, 0);
00090 ILI9488_EbiSendCommand(0, 0, chipidBuf, AccessRead, 4);
00091 ptr = &chipidBuf[1];
00092 for(i = 1; i < 4; i++) {
00093 chipid |= (*ptr &0xFF)<< (shift_cnt << 3);
00094 ptr++;
00095 shift_cnt--;
00096 }
00097 return chipid;
00098 }
00099
00100
00101
00102
00103
00104 void ILI9488_EbiSetPixelFormat(uint16_t format)
00105 {
00106 ILI9488_EbiSendCommand(ILI9488_CMD_COLMOD_PIXEL_FORMAT_SET, &format, 0, AccessWrite, 1);
00107 }
00108
00109
00110
00111
00112 uint32_t ILI9488_EbiInitialize(sXdmad * dmad)
00113 {
00114 uint32_t chipid;
00115 uint16_t param;
00116
00117 _ILI9488_EbiHW_Initialize();
00118 ILI9488_EbiInitializeWithDma(dmad);
00119
00120 ILI9488_EbiSendCommand(ILI9488_CMD_SOFTWARE_RESET, 0, 0, AccessInst, 0);
00121 Wait(200);
00122
00123 ILI9488_EbiSendCommand(ILI9488_CMD_SLEEP_OUT, 0, 0, AccessInst, 0);
00124 Wait(200);
00125
00126
00127 param = 0x48;
00128 ILI9488_EbiSendCommand(ILI9488_CMD_MEMORY_ACCESS_CONTROL,¶m, 0, AccessWrite, 1);
00129 Wait(100);
00130
00131 param = 0x04;
00132 ILI9488_EbiSendCommand(ILI9488_CMD_CABC_CONTROL_9, ¶m, 0, AccessWrite, 1);
00133
00134 if ( (chipid = ILI9488_EbiReadChipId()) != ILI9488_DEVICE_CODE ) {
00135 printf( "Read ILI9488 chip ID (0x%04x) error, skip initialization.\r\n",
00136 (unsigned int)chipid ) ;
00137 return 1 ;
00138 }
00139
00140 ILI9488_EbiSetPixelFormat(5);
00141 ILI9488_EbiSendCommand(ILI9488_CMD_NORMAL_DISP_MODE_ON, 0, 0, AccessInst, 0);
00142 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_ON, 0, 0, AccessInst, 0);
00143 return 0 ;
00144 }
00145
00146
00147
00148
00149
00150
00151 void ILI9488_EbiSetCursor(uint16_t x, uint16_t y)
00152 {
00153
00154 uint32_t cnt = 0;
00155
00156 uint16_t buf[4];
00157 cnt = sizeof(buf)/sizeof(uint16_t);
00158
00159 buf[0] = get_8b_to_16b(x);
00160 buf[1] = get_0b_to_8b(x);
00161 x+=1;
00162 buf[2] = get_8b_to_16b(x);
00163 buf[3] = get_0b_to_8b(x);
00164 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00165 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00166
00167
00168
00169 buf[0] = get_8b_to_16b(y);
00170 buf[1] = get_0b_to_8b(y);
00171 y+=1;
00172 buf[2] = get_8b_to_16b(y);
00173 buf[3] = get_0b_to_8b(y);
00174 ILI9488_EbiSendCommand(ILI9488_CMD_PAGE_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00175 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185 void ILI9488_EbiSetWindow(
00186 uint16_t dwX, uint16_t dwY, uint16_t dwWidth, uint16_t dwHeight )
00187 {
00188 uint16_t ColStart, ColEnd, RowStart, RowEnd;
00189
00190 uint32_t cnt = 0;
00191
00192 uint16_t buf[4];
00193 cnt = sizeof(buf)/sizeof(uint16_t);
00194
00195 ColStart = dwX ;
00196 ColEnd = dwWidth + dwX;
00197
00198 RowStart = dwY ;
00199 RowEnd = dwHeight + dwY;
00200
00201 buf[0] = get_8b_to_16b(ColStart);
00202 buf[1] = get_0b_to_8b(ColStart);
00203 buf[2] = get_8b_to_16b(ColEnd);
00204 buf[3] = get_0b_to_8b(ColEnd);
00205 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00206 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00207
00208
00209 buf[0] = get_8b_to_16b(RowStart);
00210 buf[1] = get_0b_to_8b(RowStart);
00211 buf[2] = get_8b_to_16b(RowEnd);
00212 buf[3] = get_0b_to_8b(RowEnd);
00213 ILI9488_EbiSendCommand(ILI9488_CMD_PAGE_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00214 ILI9488_EbiSendCommand(ILI9488_CMD_NOP, 0, 0, AccessInst, 0);
00215 }
00216
00217
00218
00219
00220 void ILI9488_EbiSetFullWindow(void)
00221 {
00222 uint16_t c_start,c_end,r_start,r_end;
00223 uint32_t cnt = 0;
00224
00225 uint16_t buf[4];
00226 cnt = sizeof(buf)/sizeof(uint16_t);
00227
00228 c_start = 0 ;
00229 c_end = ILI9488_LCD_WIDTH- 1;
00230
00231 r_start = 0 ;
00232 r_end = ILI9488_LCD_HEIGHT - 1;
00233
00234
00235 buf[0] = get_8b_to_16b(c_start);
00236 buf[1] = get_0b_to_8b(c_start);
00237 buf[2] = get_8b_to_16b(c_end);
00238 buf[3] = get_0b_to_8b(c_end);
00239 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00240 ILI9488_EbiSendCommand(ILI9488_CMD_NOP ,0, 0, AccessInst, 0);
00241
00242
00243 buf[0] = get_8b_to_16b(r_start);
00244 buf[1] = get_0b_to_8b(r_start);
00245 buf[2] = get_8b_to_16b(r_end);
00246 buf[3] = get_0b_to_8b(r_end);
00247 ILI9488_EbiSendCommand(ILI9488_CMD_COLUMN_ADDRESS_SET, (uint16_t*)buf, 0, AccessWrite, cnt);
00248 ILI9488_EbiSendCommand(ILI9488_CMD_NOP ,0, 0, AccessInst, 0);
00249 }
00250
00251
00252
00253
00254
00255 void ILI9488_EbiOn( void )
00256 {
00257 ILI9488_EbiSendCommand(ILI9488_CMD_PIXEL_OFF, 0, 0, AccessInst, 0);
00258 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_ON, 0, 0, AccessInst, 0);
00259 ILI9488_EbiSendCommand(ILI9488_CMD_NORMAL_DISP_MODE_ON, 0, 0, AccessInst, 0);
00260 }
00261
00262
00263
00264
00265 void ILI9488_EbiOff( void )
00266 {
00267 ILI9488_EbiSendCommand(ILI9488_CMD_DISPLAY_OFF, 0, 0, AccessInst, 0);
00268 }
00269
00270
00271
00272
00273
00274
00275 void ILI9488_EbiSetDisplayLandscape( uint8_t dwRGB, uint8_t LandscapeMode )
00276 {
00277 uint16_t value;
00278 if(LandscapeMode) {
00279 if(dwRGB) {
00280 value = 0xE8;
00281 } else {
00282 value = 0xE0;
00283 }
00284 } else {
00285 if(dwRGB) {
00286 value = 0x48;
00287 } else {
00288 value = 0x40;
00289 }
00290 }
00291 ILI9488_EbiSendCommand(ILI9488_CMD_MEMORY_ACCESS_CONTROL, &value, 0, AccessWrite, sizeof(value));
00292 }
00293
00294 #endif