image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
EVE_ILI9488_FT9XX.c
Go to the documentation of this file.
1
32#include "EVE_Platform.h"
33#if (defined(FT9XX_PLATFORM)) \
34 && (defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT))
35#define ILI9488_SEL 1
36
44int16_t ILI9488_SPI_WriteCmd(uint8_t cmd, uint8_t data)
45{
46 uint8_t i;
47 /* bit banging mechanism */
48 ILI9488_DCX_LOW;
49
50 ILI9488_CS_LOW;
51 usleep(1);
52 spi_open(SPIM, ILI9488_SEL);
53 spi_writen(SPIM, &cmd, 1);
54 ILI9488_DCX_HIGH;
55 spi_writen(SPIM, &data, 1);
56 ILI9488_CS_HIGH;
57 ILI9488_DCX_LOW;
58 spi_close(SPIM, ILI9488_SEL);
59
60 return 0;
61}
62
71int16_t ILI9488_SPI_WriteCmdN(uint8_t cmd, uint8_t bytecount, const uint8_t *pbuff)
72{
73 uint8_t i, j, transbit;
74 /* bit banging mechanism */
75 ILI9488_DCX_LOW;
76
77 ILI9488_CS_LOW;
78 usleep(1);
79 spi_open(SPIM, ILI9488_SEL);
80 spi_writen(SPIM, &cmd, 1);
81 ILI9488_DCX_HIGH;
82 spi_writen(SPIM, pbuff, bytecount);
83 spi_close(SPIM, ILI9488_SEL);
84 ILI9488_CS_HIGH;
85 ILI9488_DCX_LOW;
86
87 return 0;
88}
89
96uint8_t ILI9488_SPI_Read(uint8_t cmd)
97{
98 uint8_t i, readbyte = 0;
99 /* bit banging mechanism */
100 ILI9488_DCX_LOW;
101 ILI9488_CS_LOW;
102 usleep(1);
103 spi_open(SPIM, ILI9488_SEL);
104 spi_writen(SPIM, &cmd, 1);
105 ILI9488_DCX_HIGH;
106 spi_readn(SPIM, &readbyte, 1);
107 spi_close(SPIM, ILI9488_SEL);
108 ILI9488_CS_HIGH;
109 ILI9488_DCX_LOW;
110
111 return readbyte;
112}
113
122uint8_t ILI9488_SPI_ReadN(uint8_t cmd, uint8_t numbytes, const uint8_t *pbuffer)
123{
124 uint8_t i, readbyte = 0, j;
125 /* bit banging mechanism */
126 ILI9488_DCX_LOW;
127 ILI9488_CS_LOW;
128 usleep(1);
129 spi_open(SPIM, ILI9488_SEL);
130 spi_writen(SPIM, &cmd, 1);
131 ILI9488_DCX_HIGH;
132 spi_readn(SPIM, pbuffer, numbytes);
133 spi_close(SPIM, ILI9488_SEL);
134 ILI9488_CS_HIGH;
135 ILI9488_DCX_LOW;
136
137 return readbyte;
138}
139
146uint32_t ILI9488_SPI_ReadRDDID(uint8_t cmd)
147{
148 uint8_t i;
149 uint32_t readword = 0;
150 /* bit banging mechanism */
151 ILI9488_DCX_LOW;
152 ILI9488_CS_LOW;
153 usleep(1);
154 spi_open(SPIM, ILI9488_SEL);
155 spi_writen(SPIM, &cmd, 1);
156#if 0
157 //extra clock cycle for dummy
158 ILI9488_CLK_LOW;
159 usleep(1);
160 ILI9488_CLK_HIGH;
161 usleep(1);
162#endif
163 ILI9488_DCX_HIGH;
164 //NOTE: for little-endian, this is fine
165 spi_readn(SPIM, &readword, 3);
166 spi_close(SPIM, ILI9488_SEL);
167 ILI9488_CS_HIGH;
168
169 return readword;
170}
171
178uint32_t ILI9488_SPI_ReadRDDST(uint8_t cmd)
179{
180 uint8_t i;
181 uint32_t readword = 0;
182 /* bit banging mechanism */
183 ILI9488_DCX_LOW;
184 ILI9488_CS_LOW;
185 usleep(1);
186 spi_open(SPIM, ILI9488_SEL);
187 spi_writen(SPIM, &cmd, 1);
188#if 0
189 //extra clock cycle for dummy
190 ILI9488_CLK_LOW;
191 usleep(1);
192 ILI9488_CLK_HIGH;
193 usleep(1);
194#endif
195
196 ILI9488_DCX_HIGH;
197 spi_readn(SPIM, &readword, 4);
198 spi_close(SPIM, ILI9488_SEL);
199 ILI9488_CS_HIGH;
200 ILI9488_DCX_LOW;
201 return readword;
202}
203
208void EVE_ILI9488_bootup()
209{
210#ifdef FT900_PLATFORM
211#define pad_pwd pad_gpio43
212#elif defined(FT93X_PLATFORM)
213#define pad_pwd pad_gpio15
214#endif
215 /* ILI9488 driver - configure pins for bit bang */
216 gpio_function(GPIO_SPIM_CLK, pad_spim_sck);
217 gpio_function(GPIO_SPIM_SS0, pad_spim_ss0);
218 gpio_function(GPIO_SPIM_MOSI, pad_spim_mosi);
219 gpio_function(GPIO_SPIM_MISO, pad_spim_miso);
220 gpio_function(GPIO_ILI9488_DCX, pad_ili9488_dcx);
221 gpio_function(GPIO_ILI9488_CS1, pad_ili9488_cs1);
222
223 gpio_function(GPIO_FT800_PWD, pad_pwd);
224
225 gpio_dir(GPIO_ILI9488_DCX, pad_dir_output); //gpios for ili9488 - dcx
226 gpio_dir(GPIO_ILI9488_CS1, pad_dir_output); //gpios for ili9488 - cs1#
227
228 gpio_dir(GPIO_FT800_PWD, pad_dir_output); //gpios for ili9488 - pwd#
229
230 gpio_write(GPIO_ILI9488_DCX, 1);
231 gpio_write(GPIO_SPIM_SS0, 1);
232 gpio_write(GPIO_ILI9488_CS1, 1);
233 gpio_write(GPIO_FT800_PWD, 1);
234
235 /* Enable the SPI Master device... */
236
237 sys_enable(sys_device_spi_master);
238 spi_init(SPIM, spi_dir_master, spi_mode_0, 64);
239 spi_option(SPIM, spi_option_fifo_size, 16);
240 spi_option(SPIM, spi_option_fifo, 1);
241 spi_option(SPIM, spi_option_bus_width, 1);
242
243 //display driver bring up
244 {
245
246 /* Temp buffer to construct the parameters */
247 uint8_t arraytemp[16];
248
249 ILI9488_SPI_WriteCmd(ILI9488_CMD_SOFTWARE_RESET, 0);
250 usleep(120);
251
252 //colomn address set - 0 to 319
253 arraytemp[0] = 0x00;
254 arraytemp[1] = 0x00;
255 arraytemp[2] = 0x01;
256 arraytemp[3] = 0x3f;
257 ILI9488_SPI_WriteCmdN(ILI9488_CMD_COLOMNADDR, 4, arraytemp);
258
259 //row address set - 0 to 479
260 arraytemp[0] = 0x00;
261 arraytemp[1] = 0x00;
262 arraytemp[2] = 0x01;
263 arraytemp[3] = 0xdf;
264 ILI9488_SPI_WriteCmdN(ILI9488_CMD_ROWADDR, 4, arraytemp);
265
266 //Frame rate 70HZ
267 ILI9488_SPI_WriteCmd(ILI9488_CMD_FRAME_RATE_CONTROL, 0xB0);
268
269 //adjust control 3
270 arraytemp[0] = 0xa9;
271 arraytemp[1] = 0x51;
272 arraytemp[2] = 0x2c;
273 arraytemp[3] = 0x82;
274 ILI9488_SPI_WriteCmdN(0XF7, 4, arraytemp);
275
276 ILI9488_SPI_WriteCmd(ILI9488_CMD_INTERFACE_MODE_CONTROL, 2);
277 ILI9488_SPI_WriteCmd(ILI9488_CMD_INTERFACE_PIXEL_FORMAT, ILI9488_INTERFACE_PIXEL_FORMAT_18BIT_DPI);
278 ILI9488_SPI_WriteCmd(ILI9488_CMD_IMAGEFUNCTION, 0);
279 ILI9488_SPI_WriteCmd(ILI9488_CMD_WRITE_CONTROL_DISPLAY, 0x2c);
280
281 ILI9488_SPI_WriteCmd(ILI9488_CMD_MADCTRL, 0x48); //bgr connection and colomn address order
282
283 arraytemp[0] = 0x30;
284 arraytemp[1] = 0x02;
285 arraytemp[2] = 0x3b;
286
287 ILI9488_SPI_WriteCmdN(ILI9488_CMD_DISPLAY_FUNCTION_CONTROL, 3, arraytemp);
288
289 ILI9488_SPI_WriteCmd(ILI9488_CMD_SLEEP_OUT, 0);
290 usleep(120);
291
292 ILI9488_SPI_WriteCmd(ILI9488_CMD_DISPLAYON, 0);
293 ILI9488_SPI_WriteCmd(0x2c, 0xB0);
294 }
295}
296
297#endif
298
299/* end of file */
unsigned int uint32_t
short int16_t
unsigned char uint8_t
Platform selector.
static ft_void_t ft_uint32_t * cmd
Definition FT_Gpu_Hal.h:184