ili9341.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Koen Zandberg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
33 #ifndef ILI9341_H
34 #define ILI9341_H
35 
36 #include "periph/spi.h"
37 #include "periph/gpio.h"
38 
39 #ifdef MODULE_DISP_DEV
40 #include "disp_dev.h"
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
57 #ifndef ILI9341_GVDD
58 #define ILI9341_GVDD 4800
59 #endif
60 
66 #ifndef ILI9341_VCOMH
67 #define ILI9341_VCOMH 4250
68 #endif
69 
75 #ifndef ILI9341_VCOML
76 #define ILI9341_VCOML -2000
77 #endif
78 
85 #ifndef ILI9341_LE_MODE
86 #define ILI9341_LE_MODE (0)
87 #endif
88 
93 typedef struct {
97  gpio_t cs_pin;
98  gpio_t dcx_pin;
99  gpio_t rst_pin;
100  bool rgb;
102  bool inverted;
103  uint16_t lines;
105 
109 typedef struct {
110 #ifdef MODULE_DISP_DEV
111  disp_dev_t *dev;
112 #endif
114 } ili9341_t;
115 
116 
123 int ili9341_init(ili9341_t *dev, const ili9341_params_t *params);
124 
139 void ili9341_fill(const ili9341_t *dev, uint16_t x1, uint16_t x2,
140  uint16_t y1, uint16_t y2, uint16_t color);
141 
158 void ili9341_pixmap(const ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1,
159  uint16_t y2, const uint16_t *color);
160 
169 void ili9341_write_cmd(const ili9341_t *dev, uint8_t cmd, const uint8_t *data,
170  size_t len);
171 
182 void ili9341_read_cmd(const ili9341_t *dev, uint8_t cmd, uint8_t *data, size_t len);
183 
189 void ili9341_invert_on(const ili9341_t *dev);
190 
196 void ili9341_invert_off(const ili9341_t *dev);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 #endif /* ILI9341_H */
202 
ili9341_params_t::lines
uint16_t lines
Number of lines, from 16 to 320 in 8 line steps.
Definition: ili9341.h:103
ili9341_write_cmd
void ili9341_write_cmd(const ili9341_t *dev, uint8_t cmd, const uint8_t *data, size_t len)
Raw write command.
ili9341_t::params
const ili9341_params_t * params
Device initialization parameters.
Definition: ili9341.h:113
ili9341_params_t::spi
spi_t spi
SPI device that the display is connected to.
Definition: ili9341.h:94
ili9341_t
Device descriptor for a ili9341.
Definition: ili9341.h:109
ili9341_params_t::spi_clk
spi_clk_t spi_clk
SPI clock speed to use.
Definition: ili9341.h:95
ili9341_params_t::inverted
bool inverted
Display works in inverted color mode.
Definition: ili9341.h:102
spi.h
Low-level SPI peripheral driver interface definition.
disp_dev
Generic type for a display device.
Definition: disp_dev.h:100
ili9341_params_t::dcx_pin
gpio_t dcx_pin
pin connected to the DC line
Definition: ili9341.h:98
spi_mode_t
spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
Definition: spi.h:157
ili9341_pixmap
void ili9341_pixmap(const ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, const uint16_t *color)
Fill a rectangular area with an array of pixels.
ili9341_params_t
Device initialization parameters.
Definition: ili9341.h:93
ili9341_params_t::rgb
bool rgb
True when display is connected in RGB mode False when display is connected in BGR mode.
Definition: ili9341.h:100
spi_clk_t
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
ili9341_invert_on
void ili9341_invert_on(const ili9341_t *dev)
Invert the display colors.
ili9341_invert_off
void ili9341_invert_off(const ili9341_t *dev)
Disable color inversion.
ili9341_params_t::rst_pin
gpio_t rst_pin
pin connected to the reset line
Definition: ili9341.h:99
ili9341_fill
void ili9341_fill(const ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, uint16_t color)
Fill a rectangular area with a single pixel color.
gpio.h
Low-level GPIO peripheral driver interface definitions.
ili9341_init
int ili9341_init(ili9341_t *dev, const ili9341_params_t *params)
Setup an ili9341 display device.
ili9341_params_t::cs_pin
gpio_t cs_pin
pin connected to the CHIP SELECT line
Definition: ili9341.h:97
ili9341_params_t::spi_mode
spi_mode_t spi_mode
SPI mode.
Definition: ili9341.h:96
ili9341_read_cmd
void ili9341_read_cmd(const ili9341_t *dev, uint8_t cmd, uint8_t *data, size_t len)
Raw read command.
spi_t
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:118