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_RP2040.c
Go to the documentation of this file.
1
32#include "EVE_Platform.h"
33
34#if defined(RP2040_PLATFORM) \
35 && (defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT))
36
37#define GPIO_ILI9488_CS 9
38#define GPIO_ILI9488_DCX 8
39
40int16_t ILI9488_SPI_WriteCmd(EVE_HalContext *phost, uint8_t cmd, uint8_t data)
41{
42 gpio_put(GPIO_ILI9488_CS, 0);
43 gpio_put(GPIO_ILI9488_DCX, 0);
44
45 uint8_t hcmd[1] = { 0 };
46 hcmd[0] = cmd;
47
48 spi_write_blocking(phost->SpiPort, hcmd, 1);
49
50 uint8_t hdata[1] = { 0 };
51 hdata[0] = data;
52
53 gpio_put(GPIO_ILI9488_DCX, 1);
54
55 spi_write_blocking(phost->SpiPort, hdata, 1);
56
57 gpio_put(GPIO_ILI9488_CS, 1);
58
59 return 0;
60}
61
62int16_t ILI9488_SPI_WriteCmdN(EVE_HalContext *phost, uint8_t cmd, uint8_t bytecount, const uint8_t *pbuff)
63{
64
65 gpio_put(GPIO_ILI9488_CS, 0);
66 gpio_put(GPIO_ILI9488_DCX, 0);
67
68 uint8_t hcmd[1] = { 0 };
69 hcmd[0] = cmd;
70
71 spi_write_blocking(phost->SpiPort, hcmd, 1);
72
73 gpio_put(GPIO_ILI9488_DCX, 1);
74
75 int byteWritten = spi_write_blocking(phost->SpiPort, pbuff, bytecount);
76
77 gpio_put(GPIO_ILI9488_CS, 1);
78
79 return byteWritten;
80}
81
82void EVE_ILI9488_RP2040_bootup(EVE_HalContext *phost)
83{
84 gpio_put(phost->SpiCsPin, 1);
85
86 gpio_init(GPIO_ILI9488_DCX);
87 gpio_set_dir(GPIO_ILI9488_DCX, GPIO_OUT); //gpios for ili9488 - dcx
88 gpio_put(GPIO_ILI9488_DCX, 0);
89
90 gpio_init(GPIO_ILI9488_CS);
91 gpio_set_dir(GPIO_ILI9488_CS, GPIO_OUT); //gpios for ili9488 - cs
92 gpio_put(GPIO_ILI9488_CS, 1);
93
94 uint8_t arraytemp[16];
95
96 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_SOFTWARE_RESET, 0);
97 EVE_sleep(1);
98
99 //colomn address set - 0 to 319
100 arraytemp[0] = 0x00;
101 arraytemp[1] = 0x00;
102 arraytemp[2] = 0x01;
103 arraytemp[3] = 0x3f;
104 ILI9488_SPI_WriteCmdN(phost, ILI9488_CMD_COLOMNADDR, 4, arraytemp);
105
106 //row address set - 0 to 479
107 arraytemp[0] = 0x00;
108 arraytemp[1] = 0x00;
109 arraytemp[2] = 0x01;
110 arraytemp[3] = 0xdf;
111 ILI9488_SPI_WriteCmdN(phost, ILI9488_CMD_ROWADDR, 4, arraytemp);
112
113 //Frame rate 70HZ
114 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_FRAME_RATE_CONTROL, 0xB0);
115
116 //adjust control 3
117 arraytemp[0] = 0xa9;
118 arraytemp[1] = 0x51;
119 arraytemp[2] = 0x2c;
120 arraytemp[3] = 0x82;
121 ILI9488_SPI_WriteCmdN(phost, 0XF7, 4, arraytemp);
122
123 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_INTERFACE_MODE_CONTROL, 2);
124 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_INTERFACE_PIXEL_FORMAT, ILI9488_INTERFACE_PIXEL_FORMAT_18BIT_DPI);
125 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_IMAGEFUNCTION, 0);
126 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_WRITE_CONTROL_DISPLAY, 0x2c);
127
128 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_MADCTRL, 0x48); //bgr connection and colomn address order
129
130 arraytemp[0] = 0x30;
131 arraytemp[1] = 0x02;
132 arraytemp[2] = 0x3b;
133
134 ILI9488_SPI_WriteCmdN(phost, ILI9488_CMD_DISPLAY_FUNCTION_CONTROL, 3, arraytemp);
135
136 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_SLEEP_OUT, 0);
137 EVE_sleep(1);
138
139 ILI9488_SPI_WriteCmd(phost, ILI9488_CMD_DISPLAYON, 0);
140 ILI9488_SPI_WriteCmd(phost, 0x2c, 0xB0);
141}
142
143#endif
144
145/*end of file*/
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.
short int16_t
unsigned char uint8_t
Platform selector.
static ft_void_t ft_uint32_t * cmd
Definition FT_Gpu_Hal.h:184