Metal Detector
 
Loading...
Searching...
No Matches
ili9341.h
Go to the documentation of this file.
1
14#ifndef INC_ILI9341_H_
15#define INC_ILI9341_H_
16
17#include "main.h"
18
19/*********************
20 * DEFINES
21 *********************/
22
23
24#define ILI9341_HOR_RES 240
25#define ILI9341_VER_RES 320
27#define MY_DISP_HOR_RES ILI9341_HOR_RES
28#define MY_DISP_VER_RES ILI9341_VER_RES
29
30#define ILI9341_BGR 1
31#define ILI9341_RGB 0
33#define ILI9341_GAMMA 1
36/* Level 1 Commands -------------- [section] Description */
37
38#define ILI9341_NOP 0x00
40#define ILI9341_SWRESET 0x01
42#define ILI9341_RDDIDIF 0x04
44#define ILI9341_RDDST 0x09
46#define ILI9341_RDDPM 0x0A
48#define ILI9341_RDDMADCTL 0x0B
50#define ILI9341_RDDCOLMOD 0x0C
52#define ILI9341_RDDIM 0x0D
54#define ILI9341_RDDSM 0x0E
56#define ILI9341_RDDSDR 0x0F
58#define ILI9341_SLPIN 0x10
60#define ILI9341_SLPOUT 0x11
62#define ILI9341_PTLON 0x12
64#define ILI9341_NORON 0x13
66#define ILI9341_DINVOFF 0x20
68#define ILI9341_DINVON 0x21
70#define ILI9341_GAMSET 0x26
72#define ILI9341_DISPOFF 0x28
74#define ILI9341_DISPON 0x29
76#define ILI9341_CASET 0x2A
78#define ILI9341_PASET 0x2B
80#define ILI9341_RAMWR 0x2C
82#define ILI9341_RGBSET 0x2D
84#define ILI9341_RAMRD 0x2E
86#define ILI9341_PTLAR 0x30
88#define ILI9341_VSCRDEF 0x33
90#define ILI9341_TEOFF 0x34
92#define ILI9341_TEON 0x35
94#define ILI9341_MADCTL 0x36
96#define MADCTL_MY 0x80
98#define MADCTL_MX 0x40
100#define MADCTL_MV 0x20
102#define MADCTL_ML 0x10
104#define MADCTL_MH 0x04
106#define MADCTL_RGB 0x00
108#define MADCTL_BGR 0x08
110#define ILI9341_VSCRSADD 0x37
112#define ILI9341_IDMOFF 0x38
114#define ILI9341_IDMON 0x39
116#define ILI9341_PIXSET 0x3A
118#define ILI9341_WRMEMCONT 0x3C
120#define ILI9341_RDMEMCONT 0x3E
122#define ILI9341_SETSCANTE 0x44
124#define ILI9341_GETSCAN 0x45
126#define ILI9341_WRDISBV 0x51
128#define ILI9341_RDDISBV 0x52
130#define ILI9341_WRCTRLD 0x53
132#define ILI9341_RDCTRLD 0x54
134#define ILI9341_WRCABC 0x55
136#define ILI9341_RDCABC 0x56
138#define ILI9341_WRCABCMIN 0x5E
140#define ILI9341_RDCABCMIN 0x5F
142#define ILI9341_RDID1 0xDA
144#define ILI9341_RDID2 0xDB
146#define ILI9341_RDID3 0xDC
149/* Level 2 Commands -------------- [section] Description */
150
151#define ILI9341_IFMODE 0xB0 /* [8.3.1 ] Interface Mode Control */
152#define ILI9341_FRMCTR1 0xB1 /* [8.3.2 ] Frame Rate Control (In Normal Mode/Full Colors) */
153#define ILI9341_FRMCTR2 0xB2 /* [8.3.3 ] Frame Rate Control (In Idle Mode/8 colors) */
154#define ILI9341_FRMCTR3 0xB3 /* [8.3.4 ] Frame Rate control (In Partial Mode/Full Colors) */
155#define ILI9341_INVTR 0xB4 /* [8.3.5 ] Display Inversion Control */
156#define ILI9341_PRCTR 0xB5 /* [8.3.6 ] Blanking Porch Control */
157#define ILI9341_DISCTRL 0xB6 /* [8.3.7 ] Display Function Control */
158#define ILI9341_ETMOD 0xB7 /* [8.3.8 ] Entry Mode Set */
159#define ILI9341_BLCTRL1 0xB8 /* [8.3.9 ] Backlight Control 1 - Grayscale Histogram UI mode */
160#define ILI9341_BLCTRL2 0xB9 /* [8.3.10] Backlight Control 2 - Grayscale Histogram still picture mode */
161#define ILI9341_BLCTRL3 0xBA /* [8.3.11] Backlight Control 3 - Grayscale Thresholds UI mode */
162#define ILI9341_BLCTRL4 0xBB /* [8.3.12] Backlight Control 4 - Grayscale Thresholds still picture mode */
163#define ILI9341_BLCTRL5 0xBC /* [8.3.13] Backlight Control 5 - Brightness Transition time */
164#define ILI9341_BLCTRL7 0xBE /* [8.3.14] Backlight Control 7 - PWM Frequency */
165#define ILI9341_BLCTRL8 0xBF /* [8.3.15] Backlight Control 8 - ON/OFF + PWM Polarity*/
166#define ILI9341_PWCTRL1 0xC0 /* [8.3.16] Power Control 1 - GVDD */
167#define ILI9341_PWCTRL2 0xC1 /* [8.3.17] Power Control 2 - step-up factor for operating voltage */
168#define ILI9341_VMCTRL1 0xC5 /* [8.3.18] VCOM Control 1 - Set VCOMH and VCOML */
169#define ILI9341_VMCTRL2 0xC7 /* [8.3.19] VCOM Control 2 - VCOM offset voltage */
170#define ILI9341_NVMWR 0xD0 /* [8.3.20] NV Memory Write */
171#define ILI9341_NVMPKEY 0xD1 /* [8.3.21] NV Memory Protection Key */
172#define ILI9341_RDNVM 0xD2 /* [8.3.22] NV Memory Status Read */
173#define ILI9341_RDID4 0xD3 /* [8.3.23] Read ID4 - IC Device Code */
174#define ILI9341_PGAMCTRL 0xE0 /* [8.3.24] Positive Gamma Control */
175#define ILI9341_NGAMCTRL 0xE1 /* [8.3.25] Negative Gamma Correction */
176#define ILI9341_DGAMCTRL1 0xE2 /* [8.3.26] Digital Gamma Control 1 */
177#define ILI9341_DGAMCTRL2 0xE3 /* [8.3.27] Digital Gamma Control 2 */
178#define ILI9341_IFCTL 0xF6 /* [8.3.28] 16bits Data Format Selection */
179
180/* Extended Commands --------------- [section] Description*/
181
182#define ILI9341_PWCTRLA 0xCB /* [8.4.1] Power control A */
183#define ILI9341_PWCTRLB 0xCF /* [8.4.2] Power control B */
184#define ILI9341_TIMECTRLA_INT 0xE8 /* [8.4.3] Internal Clock Driver timing control A */
185#define ILI9341_TIMECTRLA_EXT 0xE9 /* [8.4.4] External Clock Driver timing control A */
186#define ILI9341_TIMECTRLB 0xEA /* [8.4.5] Driver timing control B (gate driver timing control) */
187#define ILI9341_PWSEQCTRL 0xED /* [8.4.6] Power on sequence control */
188#define ILI9341_GAM3CTRL 0xF2 /* [8.4.7] Enable 3 gamma control */
189#define ILI9341_PUMPRATIO 0xF7 /* [8.4.8] Pump ratio control */
190
198#define ILI9341_DELAY( __DELAY__ ) HAL_Delay(__DELAY__)
199
200
201typedef struct
202{
205 uint8_t *buff;
207
211void ILI9341_Init(void);
212
218void ILI9341_WriteCommand(uint8_t cmd);
219
226void ILI9341_WriteData(uint8_t *data_buff, uint32_t data_len);
227
234void ILI9341_Rotate(uint16_t degrees, uint8_t bgr);
235
244void ILI9341_SetWindow(uint16_t x_axis_start, uint16_t x_axis_end, uint16_t y_axis_start, uint16_t y_axis_end);
245
252void ILI9341_FillWindow(uint8_t *buff, uint32_t buff_len);
253
260void ILI9341_FillWindowDMA(uint8_t *buff, uint32_t buff_len);
261
265void ILI9341_SPICmpltHandler(void);
266
271
272#endif
void ILI9341_WriteData(uint8_t *data_buff, uint32_t data_len)
Writes data to the ILI9341 LCD.
Definition ili9341.c:245
void ILI9341_WriteCommand(uint8_t cmd)
Writes a command to the ILI9341 LCD.
Definition ili9341.c:217
void ILI9341_Rotate(uint16_t degrees, uint8_t bgr)
Rotates the ILI9341 LCD display.
Definition ili9341.c:417
void ILI9341_SetWindow(uint16_t x_axis_start, uint16_t x_axis_end, uint16_t y_axis_start, uint16_t y_axis_end)
Sets the window area for the ILI9341 LCD.
Definition ili9341.c:269
void ILI9341_FillWindowDMA(uint8_t *buff, uint32_t buff_len)
Fills the window area of the ILI9341 LCD using DMA.
Definition ili9341.c:301
void ILI9341_SPICmpltHandler(void)
Handles SPI DMA transfer completion.
Definition ili9341.c:367
void ILI9341_Init(void)
Initializes the ILI9341 LCD.
Definition ili9341.c:33
void ILI9341_FillWindow(uint8_t *buff, uint32_t buff_len)
Fills the window area of the ILI9341 LCD.
Definition ili9341.c:341
void ILI9341_FillWindowCmpltCallBack(void)
Weak callback function for window fill completion.
Definition display.c:149
Definition ili9341.h:202
uint32_t buff_remain_len
Definition ili9341.h:203
uint32_t buff_current_pos
Definition ili9341.h:204
uint8_t * buff
Definition ili9341.h:205