aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h')
-rw-r--r--lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h593
1 files changed, 593 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h b/lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h
new file mode 100644
index 000000000..007c4fd67
--- /dev/null
+++ b/lib/chibios-contrib/os/various/devices_lib/lcd/ili9341.h
@@ -0,0 +1,593 @@
1/*
2 Copyright (C) 2013-2015 Andrea Zoppi
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file ili9341.h
19 * @brief ILI9341 TFT LCD diaplay controller driver.
20 */
21
22#ifndef _ILI9341_H_
23#define _ILI9341_H_
24
25/**
26 * @addtogroup ili9341
27 * @{
28 */
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @name ILI9341 regulative commands
36 * @{
37 */
38#define ILI9341_CMD_NOP (0x00) /**< No operation.*/
39#define ILI9341_CMD_RESET (0x01) /**< Software reset.*/
40#define ILI9341_GET_ID_INFO (0x04) /**< Get ID information.*/
41#define ILI9341_GET_STATUS (0x09) /**< Get status.*/
42#define ILI9341_GET_PWR_MODE (0x0A) /**< Get power mode.*/
43#define ILI9341_GET_MADCTL (0x0B) /**< Get MADCTL.*/
44#define ILI9341_GET_PIX_FMT (0x0C) /**< Get pixel format.*/
45#define ILI9341_GET_IMG_FMT (0x0D) /**< Get image format.*/
46#define ILI9341_GET_SIG_MODE (0x0E) /**< Get signal mode.*/
47#define ILI9341_GET_SELF_DIAG (0x0F) /**< Get self-diagnostics.*/
48#define ILI9341_CMD_SLEEP_ON (0x10) /**< Enter sleep mode.*/
49#define ILI9341_CMD_SLEEP_OFF (0x11) /**< Exist sleep mode.*/
50#define ILI9341_CMD_PARTIAL_ON (0x12) /**< Enter partial mode.*/
51#define ILI9341_CMD_PARTIAL_OFF (0x13) /**< Exit partial mode.*/
52#define ILI9341_CMD_INVERT_ON (0x20) /**< Enter inverted mode.*/
53#define ILI9341_CMD_INVERT_OFF (0x21) /**< Exit inverted mode.*/
54#define ILI9341_SET_GAMMA (0x26) /**< Set gamma params.*/
55#define ILI9341_CMD_DISPLAY_OFF (0x28) /**< Disable display.*/
56#define ILI9341_CMD_DISPLAY_ON (0x29) /**< Enable display.*/
57#define ILI9341_SET_COL_ADDR (0x2A) /**< Set column address.*/
58#define ILI9341_SET_PAGE_ADDR (0x2B) /**< Set page address.*/
59#define ILI9341_SET_MEM (0x2C) /**< Set memory.*/
60#define ILI9341_SET_COLOR (0x2D) /**< Set color.*/
61#define ILI9341_GET_MEM (0x2E) /**< Get memory.*/
62#define ILI9341_SET_PARTIAL_AREA (0x30) /**< Set partial area.*/
63#define ILI9341_SET_VSCROLL (0x33) /**< Set vertical scroll def.*/
64#define ILI9341_CMD_TEARING_ON (0x34) /**< Tearing line enabled.*/
65#define ILI9341_CMD_TEARING_OFF (0x35) /**< Tearing line disabled.*/
66#define ILI9341_SET_MEM_ACS_CTL (0x36) /**< Set mem access ctl.*/
67#define ILI9341_SET_VSCROLL_ADDR (0x37) /**< Set vscroll start addr.*/
68#define ILI9341_CMD_IDLE_OFF (0x38) /**< Exit idle mode.*/
69#define ILI9341_CMD_IDLE_ON (0x39) /**< Enter idle mode.*/
70#define ILI9341_SET_PIX_FMT (0x3A) /**< Set pixel format.*/
71#define ILI9341_SET_MEM_CONT (0x3C) /**< Set memory continue.*/
72#define ILI9341_GET_MEM_CONT (0x3E) /**< Get memory continue.*/
73#define ILI9341_SET_TEAR_SCANLINE (0x44) /**< Set tearing scanline.*/
74#define ILI9341_GET_TEAR_SCANLINE (0x45) /**< Get tearing scanline.*/
75#define ILI9341_SET_BRIGHTNESS (0x51) /**< Set brightness.*/
76#define ILI9341_GET_BRIGHTNESS (0x52) /**< Get brightness.*/
77#define ILI9341_SET_DISPLAY_CTL (0x53) /**< Set display ctl.*/
78#define ILI9341_GET_DISPLAY_CTL (0x54) /**< Get display ctl.*/
79#define ILI9341_SET_CABC (0x55) /**< Set CABC.*/
80#define ILI9341_GET_CABC (0x56) /**< Get CABC.*/
81#define ILI9341_SET_CABC_MIN (0x5E) /**< Set CABC min.*/
82#define ILI9341_GET_CABC_MIN (0x5F) /**< Set CABC max.*/
83#define ILI9341_GET_ID1 (0xDA) /**< Get ID1.*/
84#define ILI9341_GET_ID2 (0xDB) /**< Get ID2.*/
85#define ILI9341_GET_ID3 (0xDC) /**< Get ID3.*/
86/** @} */
87
88/**
89 * @name ILI9341 extended commands
90 * @{
91 */
92#define ILI9341_SET_RGB_IF_SIG_CTL (0xB0) /**< RGB IF signal ctl.*/
93#define ILI9341_SET_FRAME_CTL_NORMAL (0xB1) /**< Set frame ctl (normal).*/
94#define ILI9341_SET_FRAME_CTL_IDLE (0xB2) /**< Set frame ctl (idle).*/
95#define ILI9341_SET_FRAME_CTL_PARTIAL (0xB3) /**< Set frame ctl (partial).*/
96#define ILI9341_SET_INVERSION_CTL (0xB4) /**< Set inversion ctl.*/
97#define ILI9341_SET_BLANKING_PORCH_CTL (0xB5) /**< Set blanking porch ctl.*/
98#define ILI9341_SET_FUNCTION_CTL (0xB6) /**< Set function ctl.*/
99#define ILI9341_SET_ENTRY_MODE (0xB7) /**< Set entry mode.*/
100#define ILI9341_SET_LIGHT_CTL_1 (0xB8) /**< Set backlight ctl 1.*/
101#define ILI9341_SET_LIGHT_CTL_2 (0xB9) /**< Set backlight ctl 2.*/
102#define ILI9341_SET_LIGHT_CTL_3 (0xBA) /**< Set backlight ctl 3.*/
103#define ILI9341_SET_LIGHT_CTL_4 (0xBB) /**< Set backlight ctl 4.*/
104#define ILI9341_SET_LIGHT_CTL_5 (0xBC) /**< Set backlight ctl 5.*/
105#define ILI9341_SET_LIGHT_CTL_7 (0xBE) /**< Set backlight ctl 7.*/
106#define ILI9341_SET_LIGHT_CTL_8 (0xBF) /**< Set backlight ctl 8.*/
107#define ILI9341_SET_POWER_CTL_1 (0xC0) /**< Set power ctl 1.*/
108#define ILI9341_SET_POWER_CTL_2 (0xC1) /**< Set power ctl 2.*/
109#define ILI9341_SET_VCOM_CTL_1 (0xC5) /**< Set VCOM ctl 1.*/
110#define ILI9341_SET_VCOM_CTL_2 (0xC6) /**< Set VCOM ctl 2.*/
111#define ILI9341_SET_NVMEM (0xD0) /**< Set NVMEM data.*/
112#define ILI9341_GET_NVMEM_KEY (0xD1) /**< Get NVMEM protect key.*/
113#define ILI9341_GET_NVMEM_STATUS (0xD2) /**< Get NVMEM status.*/
114#define ILI9341_GET_ID4 (0xD3) /**< Get ID4.*/
115#define ILI9341_SET_PGAMMA (0xE0) /**< Set positive gamma.*/
116#define ILI9341_SET_NGAMMA (0xE1) /**< Set negative gamma.*/
117#define ILI9341_SET_DGAMMA_CTL_1 (0xE2) /**< Set digital gamma ctl 1.*/
118#define ILI9341_SET_DGAMMA_CTL_2 (0xE3) /**< Set digital gamma ctl 2.*/
119#define ILI9341_SET_IF_CTL (0xF6) /**< Set interface control.*/
120/** @} */
121
122/**
123 * @name ILI9341 interface modes
124 * @{
125 */
126#define ILI9341_IM_3LSI_1 (0x5) /**< 3-line serial, mode 1.*/
127#define ILI9341_IM_3LSI_2 (0xD) /**< 3-line serial, mode 2.*/
128#define ILI9341_IM_4LSI_1 (0x6) /**< 4-line serial, mode 1.*/
129#define ILI9341_IM_4LSI_2 (0xE) /**< 4-line serial, mode 2.*/
130/** @} */
131
132/*===========================================================================*/
133/* Driver pre-compile time settings. */
134/*===========================================================================*/
135
136/**
137 * @name ILI9341 configuration options
138 * @{
139 */
140
141/**
142 * @brief Enables the @p ili9341AcquireBus() and @p ili9341ReleaseBus() APIs.
143 * @note Disabling this option saves both code and data space.
144 */
145#if !defined(ILI9341_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
146#define ILI9341_USE_MUTUAL_EXCLUSION TRUE
147#endif
148
149/**
150 * @brief ILI9341 Interface Mode.
151 */
152#if !defined(ILI9341_IM) || defined(__DOXYGEN__)
153#define ILI9341_IM (ILI9341_IM_4LSI_1)
154#endif
155
156/**
157 * @brief Enables checks for ILI9341 functions.
158 * @note Disabling this option saves both code and data space.
159 * @note Disabling checks by ChibiOS will automatically disable ILI9341
160 * checks.
161 */
162#if !defined(ILI9341_USE_CHECKS) || defined(__DOXYGEN__)
163#define ILI9341_USE_CHECKS TRUE
164#endif
165
166/** @} */
167
168/*===========================================================================*/
169/* Derived constants and error checks. */
170/*===========================================================================*/
171
172#if ((TRUE == ILI9341_USE_MUTUAL_EXCLUSION) && \
173 (TRUE != CH_CFG_USE_MUTEXES) && \
174 (TRUE != CH_CFG_USE_SEMAPHORES))
175#error "ILI9341_USE_MUTUAL_EXCLUSION requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES"
176#endif
177
178/* TODO: Add the remaining modes.*/
179#if (ILI9341_IM != ILI9341_IM_4LSI_1)
180#error "Only ILI9341_IM_4LSI_1 interface mode is supported currently"
181#endif
182
183/*===========================================================================*/
184/* Driver data structures and types. */
185/*===========================================================================*/
186
187/* Complex types forwarding.*/
188typedef struct ILI9341Config ILI9341Config;
189typedef enum ili9341state_t ili9341state_t;
190typedef struct ILI9341Driver ILI9341Driver;
191
192/**
193 * @brief ILI9341 driver configuration.
194 */
195typedef struct ILI9341Config {
196 SPIDriver *spi; /**< SPI driver used by ILI9341.*/
197#if (ILI9341_IM == ILI9341_IM_4LSI_1)
198 ioportid_t dcx_port; /**< <tt>D/!C</tt> signal port.*/
199 uint16_t dcx_pad; /**< <tt>D/!C</tt> signal pad.*/
200#endif /* ILI9341_IM == * */ /* TODO: Add all modes.*/
201} ILI9341Config;
202
203/**
204 * @brief ILI9341 driver state.
205 */
206typedef enum ili9341state_t {
207 ILI9341_UNINIT = (0), /**< Not initialized.*/
208 ILI9341_STOP = (1), /**< Stopped.*/
209 ILI9341_READY = (2), /**< Ready.*/
210 ILI9341_ACTIVE = (3), /**< Exchanging data.*/
211} ili9341state_t;
212
213/**
214 * @brief ILI9341 driver.
215 */
216typedef struct ILI9341Driver {
217 ili9341state_t state; /**< Driver state.*/
218 const ILI9341Config *config; /**< Driver configuration.*/
219
220 /* Multithreading stuff.*/
221#if (TRUE == ILI9341_USE_MUTUAL_EXCLUSION)
222#if (TRUE == CH_CFG_USE_MUTEXES)
223 mutex_t lock; /**< Multithreading lock.*/
224#elif (TRUE == CH_CFG_USE_SEMAPHORES)
225 semaphore_t lock; /**< Multithreading lock.*/
226#endif
227#endif /* (TRUE == ILI9341_USE_MUTUAL_EXCLUSION) */
228
229 /* Temporary variables.*/
230 uint8_t value; /**< Non-stacked value, for SPI with CCM.*/
231} ILI9341Driver;
232
233/**
234 * @name ILI9341 command params (little endian)
235 * @{
236 */
237#pragma pack(push, 1)
238
239typedef union {
240 struct ILI9341ParamBits_GET_ID_INFO {
241 uint8_t reserved_;
242 uint8_t ID1;
243 uint8_t ID2;
244 uint8_t ID3;
245 } bits;
246 uint8_t bytes[4];
247} ILI9341Params_GET_ID_INFO;
248
249typedef union {
250 struct ILI9341ParamBits_GET_STATUS {
251 unsigned _reserved_1 : 5; /* D[ 4: 0] */
252 unsigned tearing_mode : 1; /* D[ 5] */
253 unsigned gamma_curve : 3; /* D[ 8: 6] */
254 unsigned tearing : 1; /* D[ 9] */
255 unsigned display : 1; /* D[10] */
256 unsigned all_on : 1; /* D[11] */
257 unsigned all_off : 1; /* D[12] */
258 unsigned invert : 1; /* D[13] */
259 unsigned _reserved_2 : 1; /* D[14] */
260 unsigned vscroll : 1; /* D[15] */
261 unsigned normal : 1; /* D[16] */
262 unsigned sleep : 1; /* D[17] */
263 unsigned partial : 1; /* D[18] */
264 unsigned idle : 1; /* D[19] */
265 unsigned pixel_format : 3; /* D[22:20] */
266 unsigned _reserved_3 : 2; /* D[24:23] */
267 unsigned hrefr_rtl_nltr : 1; /* D[25] */
268 unsigned bgr_nrgb : 1; /* D[26] */
269 unsigned vrefr_btt_nttb : 1; /* D[27] */
270 unsigned transpose : 1; /* D[28] */
271 unsigned coladr_rtl_nltr : 1; /* D[29] */
272 unsigned rowadr_btt_nttb : 1; /* D[30] */
273 unsigned booster : 1; /* D[31] */
274 } bits;
275 uint8_t bytes[4];
276} ILI9341Params_GET_STATUS;
277
278typedef union {
279 struct ILI9341ParamBits_GET_PWR_MODE {
280 unsigned _reserved_1 : 2; /* D[1:0] */
281 unsigned display : 1; /* D[2] */
282 unsigned normal : 1; /* D[3] */
283 unsigned sleep : 1; /* D[4] */
284 unsigned partial : 1; /* D[5] */
285 unsigned idle : 1; /* D[6] */
286 unsigned booster : 1; /* D[7] */
287 } bits;
288 uint8_t bytes[1];
289} ILI9341Params_GET_PWR_MODE;
290
291typedef union {
292 struct ILI9341ParamBits_GET_MADCTL {
293 unsigned _reserved_1 : 2; /* D[1:0] */
294 unsigned refr_rtl_nltr : 1; /* D[2] */
295 unsigned bgr_nrgb : 1; /* D[3] */
296 unsigned refr_btt_nttb : 1; /* D[4] */
297 unsigned invert : 1; /* D[5] */
298 unsigned rtl_nltr : 1; /* D[6] */
299 unsigned btt_nttb : 1; /* D[7] */
300 } bits;
301 uint8_t bytes[1];
302} ILI9341Params_GET_MADCTL;
303
304typedef union {
305 struct ILI9341ParamBits_GET_PIX_FMT {
306 unsigned DBI : 3; /* D[2:0] */
307 unsigned _reserved_1 : 1; /* D[3] */
308 unsigned DPI : 3; /* D[6:4] */
309 unsigned RIM : 1; /* D[7] */
310 } bits;
311 uint8_t bytes[1];
312} ILI9341Params_GET_PIX_FMT;
313
314typedef union {
315 struct ILI9341ParamBits_GET_IMG_FMT {
316 unsigned gamma_curve : 3; /* D[2:0] */
317 unsigned _reserved_1 : 5; /* D[7:3] */
318 } bits;
319 uint8_t bytes[1];
320} ILI9341Params_GET_IMG_FMT;
321
322typedef union {
323 struct ILI9341ParamBits_GET_SIG_MODE {
324 unsigned _reserved_1 : 2; /* D[1:0] */
325 unsigned data_enable : 1; /* D[2] */
326 unsigned pixel_clock : 1; /* D[3] */
327 unsigned vsync : 1; /* D[4] */
328 unsigned hsync : 1; /* D[5] */
329 unsigned tearing_mode : 1; /* D[6] */
330 unsigned tearing : 1; /* D[7] */
331 } bits;
332 uint8_t bytes[1];
333} ILI9341Params_GET_SIG_MODE;
334
335typedef union {
336 struct ILI9341ParamBits_GET_SELF_DIAG {
337 unsigned _reserved_1 : 6; /* D[5:0] */
338 unsigned func_err : 1; /* D[6] */
339 unsigned reg_err : 1; /* D[7] */
340 } bits;
341 uint8_t bytes[1];
342} ILI9341Params_GET_SELF_DIAG;
343
344typedef union {
345 struct ILI9341ParamBits_SET_GAMMA {
346 uint8_t gamma_curve; /* D[7:0] */
347 } bits;
348 uint8_t bytes[1];
349} ILI9341Params_SET_GAMMA;
350
351typedef union {
352 struct ILI9341ParamBits_SET_COL_ADDR {
353 uint8_t SC_15_8; /* D[ 7: 0] */
354 uint8_t SC_7_0; /* D[15: 8] */
355 uint8_t EC_15_8; /* D[23:16] */
356 uint8_t EC_7_0; /* D[31:24] */
357 } bits;
358 uint8_t bytes[4];
359} ILI9341Params_SET_COL_ADDR;
360
361typedef union {
362 struct ILI9341ParamBits_SET_PAGE_ADDR {
363 uint8_t SP_15_8; /* D[ 7: 0] */
364 uint8_t SP_7_0; /* D[15: 8] */
365 uint8_t EP_15_8; /* D[23:16] */
366 uint8_t EP_7_0; /* D[31:24] */
367 } bits;
368 uint8_t bytes[4];
369} ILI9341Params_SET_PAGE_ADDR;
370
371typedef union {
372 struct ILI9341ParamBits_SET_PARTIAL_AREA {
373 uint8_t SR_15_8; /* D[ 7: 0] */
374 uint8_t SR_7_0; /* D[15: 8] */
375 uint8_t ER_15_8; /* D[23:16] */
376 uint8_t ER_7_0; /* D[31:24] */
377 } bits;
378 uint8_t bytes[4];
379} ILI9341Params_SET_PARTIAL_AREA;
380
381typedef union {
382 struct ILI9341ParamBits_SET_VSCROLL {
383 uint8_t TFA_15_8; /* D[ 7: 0] */
384 uint8_t TFA_7_0; /* D[15: 8] */
385 uint8_t VSA_15_8; /* D[23:16] */
386 uint8_t VSA_7_0; /* D[31:24] */
387 uint8_t BFA_15_8; /* D[39:32] */
388 uint8_t BFA_7_0; /* D[47:40] */
389 } bits;
390 uint8_t bytes[6];
391} ILI9341Params_SET_VSCROLL;
392
393typedef union {
394 struct ILI9341ParamBits_CMD_TEARING_ON {
395 unsigned M : 1; /* D[0] */
396 unsigned _reserved_1 : 7; /* D[7:1] */
397 } bits;
398 uint8_t bytes[1];
399} ILI9341Params_CMD_TEARING_ON;
400
401typedef union {
402 struct ILI9341ParamBits_SET_MEM_ACS_CTL {
403 unsigned _reserved_1 : 2; /* D[1:0] */
404 unsigned MH : 1; /* D[2] */
405 unsigned BGR : 1; /* D[3] */
406 unsigned ML : 1; /* D[4] */
407 unsigned MV : 1; /* D[5] */
408 unsigned MX : 1; /* D[6] */
409 unsigned MY : 1; /* D[7] */
410 } bits;
411 uint8_t bytes[1];
412} ILI9341Params_SET_MEM_ACS_CTL;
413
414typedef union {
415 struct ILI9341ParamBits_SET_VSCROLL_ADDR {
416 uint8_t VSP_15_8; /* D[ 7: 0] */
417 uint8_t VSP_7_0; /* D[15: 8] */
418 } bits;
419 uint8_t bytes[2];
420} ILI9341Params_SET_VSCROLL_ADDR;
421
422typedef union {
423 struct ILI9341ParamBits_SET_PIX_FMT {
424 unsigned DBI : 3; /* D[2:0] */
425 unsigned _reserved_1 : 1; /* D[3] */
426 unsigned DPI : 3; /* D[4:6] */
427 unsigned _reserved_2 : 1; /* D[7] */
428 } bits;
429 uint8_t bytes[1];
430} ILI9341Params_SET_PIX_FMT;
431
432typedef union {
433 struct ILI9341ParamBits_SET_TEAR_SCANLINE {
434 uint8_t STS_8; /* D[ 7: 0] */
435 uint8_t STS_7_0; /* D[15: 8] */
436 } bits;
437 uint8_t bytes[4];
438} ILI9341Params_SET_TEAR_SCANLINE;
439
440typedef union {
441 struct ILI9341ParamBits_GET_TEAR_SCANLINE {
442 uint8_t GTS_9_8; /* D[ 7: 0] */
443 uint8_t GTS_7_0; /* D[15: 8] */
444 } bits;
445 uint8_t bytes[2];
446} ILI9341Params_GET_TEAR_SCANLINE;
447
448typedef union {
449 struct ILI9341ParamBits_SET_BRIGHTNESS {
450 uint8_t DBV; /* D[7:0] */
451 } bits;
452 uint8_t bytes[1];
453} ILI9341Params_SET_BRIGHTNESS;
454
455typedef union {
456 struct ILI9341ParamBits_GET_BRIGHTNESS {
457 uint8_t DBV; /* D[7:0] */
458 } bits;
459 uint8_t bytes[1];
460} ILI9341Params_GET_BRIGHTNESS;
461
462typedef union {
463 struct ILI9341ParamBits_SET_DISPLAY_CTL {
464 unsigned _reserved_1 : 2; /* D[1:0] */
465 unsigned BL : 1; /* D[2] */
466 unsigned DD : 1; /* D[3] */
467 unsigned _reserved_2 : 1; /* D[4] */
468 unsigned BCTRL : 1; /* D[5] */
469 unsigned _reserved_3 : 1; /* D[7:6] */
470 } bits;
471 uint8_t bytes[1];
472} ILI9341Params_SET_DISPLAY_CTL;
473
474typedef union {
475 struct ILI9341ParamBits_GET_DISPLAY_CTL {
476 unsigned _reserved_1 : 2; /* D[1:0] */
477 unsigned BL : 1; /* D[2] */
478 unsigned DD : 1; /* D[3] */
479 unsigned _reserved_2 : 1; /* D[4] */
480 unsigned BCTRL : 1; /* D[5] */
481 unsigned _reserved_3 : 1; /* D[7:6] */
482 } bits;
483 uint8_t bytes[1];
484} ILI9341Params_GET_DISPLAY_CTL;
485
486typedef union {
487 struct ILI9341ParamBits_SET_CABC {
488 unsigned C : 2; /* D[1:0] */
489 unsigned _reserved_1 : 6; /* D[7:2] */
490 } bits;
491 uint8_t bytes[1];
492} ILI9341Params_SET_CABC;
493
494typedef union {
495 struct ILI9341ParamBits_GET_CABC {
496 unsigned C : 2; /* D[1:0] */
497 unsigned _reserved_1 : 6; /* D[7:2] */
498 } bits;
499 uint8_t bytes[1];
500} ILI9341Params_GET_CABC;
501
502typedef union {
503 struct ILI9341ParamBits_SET_CABC_MIN {
504 uint8_t CMB; /* D[7:0] */
505 } bits;
506 uint8_t bytes[1];
507} ILI9341Params_SET_CABC_MIN;
508
509typedef union {
510 struct ILI9341ParamBits_GET_CABC_MIN {
511 uint8_t CMB; /* D[7:0] */
512 } bits;
513 uint8_t bytes[1];
514} ILI9341Params_GET_CABC_MIN;
515
516#if 0 /* TODO: Extended command structs.*/
517
518typedef union {
519 struct ILI9341ParamBits {
520 unsigned : 1; /* D[] */
521 unsigned : 1; /* D[] */
522 unsigned : 1; /* D[] */
523 unsigned : 1; /* D[] */
524 unsigned : 1; /* D[] */
525 unsigned : 1; /* D[] */
526 unsigned : 1; /* D[] */
527 unsigned : 1; /* D[] */
528 } bits;
529 uint8_t bytes[1];
530} ILI9341Params_;
531
532typedef union {
533 struct ILI9341ParamBits {
534 unsigned : 1; /* D[] */
535 unsigned : 1; /* D[] */
536 unsigned : 1; /* D[] */
537 unsigned : 1; /* D[] */
538 unsigned : 1; /* D[] */
539 unsigned : 1; /* D[] */
540 unsigned : 1; /* D[] */
541 unsigned : 1; /* D[] */
542 } bits;
543 uint8_t bytes[1];
544} ILI9341Params_;
545
546#endif /*0*/
547
548#pragma pack(pop)
549
550/** @} */
551
552/*===========================================================================*/
553/* Driver macros. */
554/*===========================================================================*/
555
556/*===========================================================================*/
557/* External declarations. */
558/*===========================================================================*/
559
560extern ILI9341Driver ILI9341D1;
561
562#ifdef __cplusplus
563extern "C" {
564#endif
565
566 void ili9341ObjectInit(ILI9341Driver *driverp);
567 void ili9341Start(ILI9341Driver *driverp, const ILI9341Config *configp);
568 void ili9341Stop(ILI9341Driver *driverp);
569#if (ILI9341_USE_MUTUAL_EXCLUSION == TRUE)
570 void ili9341AcquireBusS(ILI9341Driver *driverp);
571 void ili9341AcquireBus(ILI9341Driver *driverp);
572 void ili9341ReleaseBusS(ILI9341Driver *driverp);
573 void ili9341ReleaseBus(ILI9341Driver *driverp);
574#endif /* (ILI9341_USE_MUTUAL_EXCLUSION == TRUE) */
575 void ili9341SelectI(ILI9341Driver *driverp);
576 void ili9341Select(ILI9341Driver *driverp);
577 void ili9341UnselectI(ILI9341Driver *driverp);
578 void ili9341Unselect(ILI9341Driver *driverp);
579 void ili9341WriteCommand(ILI9341Driver *driverp, uint8_t cmd);
580 void ili9341WriteByte(ILI9341Driver *driverp, uint8_t value);
581 uint8_t ili9341ReadByte(ILI9341Driver *driverp);
582 void ili9341WriteChunk(ILI9341Driver *driverp, const uint8_t chunk[],
583 size_t length);
584 void ili9341ReadChunk(ILI9341Driver *driverp, uint8_t chunk[],
585 size_t length);
586
587#ifdef __cplusplus
588}
589#endif
590
591/** @} */
592
593#endif /* _ILI9341_H_ */