Loading...
Searching...
No Matches
lcd.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Koen Zandberg
3 * 2021 Francisco Molina
4 * 2023 Gunar Schorcht
5 *
6 * This file is subject to the terms and conditions of the GNU Lesser
7 * General Public License v2.1. See the file LICENSE in the top level
8 * directory for more details.
9 */
10
47#ifndef LCD_H
48#define LCD_H
49
50#include "board.h"
51#include "mutex.h"
52#include "periph/spi.h"
53#include "periph/gpio.h"
54
55#ifdef MODULE_DISP_DEV
56#include "disp_dev.h"
57#endif
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
69#ifdef DOXYGEN
70#define CONFIG_LCD_LE_MODE
71#endif
72
77#define LCD_MADCTL_MY 0x80
78#define LCD_MADCTL_MX 0x40
79#define LCD_MADCTL_MV 0x20
80#define LCD_MADCTL_ML 0x10
81#define LCD_MADCTL_BGR 0x08
82#define LCD_MADCTL_MH 0x04
85#if MODULE_LCD_PARALLEL || DOXYGEN
98#endif
99
113typedef struct {
114#if MODULE_LCD_SPI || DOXYGEN
115 /* Interface parameters used for serial interface */
116 spi_t spi;
119#endif
120#if MODULE_LCD_PARALLEL || DOXYGEN
122 /* Interface parameters used for MCU 8080 8-bit parallel interface */
123 gpio_t wrx_pin;
124 gpio_t rdx_pin;
125 gpio_t d0_pin;
126 gpio_t d1_pin;
127 gpio_t d2_pin;
128 gpio_t d3_pin;
129 gpio_t d4_pin;
130 gpio_t d5_pin;
131 gpio_t d6_pin;
132 gpio_t d7_pin;
133#if MODULE_LCD_PARALLEL_16BIT || DOXYGEN
134 /* Interface parameters used for MCU 8080 16-bit parallel interface */
135 gpio_t d8_pin;
136 gpio_t d9_pin;
137 gpio_t d10_pin;
138 gpio_t d11_pin;
139 gpio_t d12_pin;
140 gpio_t d13_pin;
141 gpio_t d14_pin;
142 gpio_t d15_pin;
143#endif /* MODULE_LCD_PARALLEL_16BIT */
144#endif /* MODULE_LCD_PARALLEL */
145 /* Common interface parameters */
146 gpio_t cs_pin;
147 gpio_t dcx_pin;
148 gpio_t rst_pin;
149 bool rgb;
151 bool inverted;
152 uint16_t lines;
155 uint16_t rgb_channels;
156 uint8_t rotation;
157 uint8_t offset_x;
158 uint8_t offset_y;
159#if MODULE_LCD_MULTI_CNTRL || DOXYGEN
160 uint8_t cntrl;
163#endif
165
172
176typedef struct {
177#if MODULE_DISP_DEV || DOXYGEN
179#endif
182#if MODULE_LCD_PARALLEL || DOXYGEN
185#endif
186#if MODULE_LCD_PARALLEL_16BIT || DOXYGEN
188#endif
189} lcd_t;
190
205 int (*init)(lcd_t *dev, const lcd_params_t *params);
206
222 void (*set_area)(lcd_t *dev, uint16_t x1, uint16_t x2, uint16_t y1,
223 uint16_t y2);
224};
225
243
250
262void lcd_ll_write_cmd(lcd_t *dev, uint8_t cmd, const uint8_t *data,
263 size_t len);
264
281void lcd_ll_read_cmd(lcd_t *dev, uint8_t cmd, uint8_t *data, size_t len);
282
293void lcd_ll_set_area(lcd_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2);
310int lcd_init(lcd_t *dev, const lcd_params_t *params);
311
326void lcd_fill(lcd_t *dev, uint16_t x1, uint16_t x2,
327 uint16_t y1, uint16_t y2, uint16_t color);
328
345void lcd_pixmap(lcd_t *dev, uint16_t x1, uint16_t x2, uint16_t y1,
346 uint16_t y2, const uint16_t *color);
347
356void lcd_write_cmd(lcd_t *dev, uint8_t cmd, const uint8_t *data,
357 size_t len);
358
373void lcd_read_cmd(lcd_t *dev, uint8_t cmd, uint8_t *data, size_t len);
374
381
390#if MODULE_LCD_PARALLEL || DOXYGEN
419typedef struct {
425 void (*init)(lcd_t *dev);
426
433 void (*set_data_dir)(lcd_t *dev, bool output);
434
442 void (*cmd_start)(lcd_t *dev, uint8_t cmd, bool cont);
443
451 void (*write_byte)(lcd_t *dev, bool cont, uint8_t out);
452
461 uint8_t (*read_byte)(lcd_t *dev, bool cont);
462
463#if MODULE_LCD_PARALLEL_16BIT || DOXYGEN
471 void (*write_word)(lcd_t *dev, bool cont, uint16_t out);
472
481 uint16_t (*read_word)(lcd_t *dev, bool cont);
482#endif
484
489
491#endif
492
493#ifdef __cplusplus
494}
495#endif
496#endif /* LCD_H */
spi_clk_t
Definition periph_cpu.h:352
Low-level GPIO peripheral driver interface definitions.
void lcd_ll_release(lcd_t *dev)
Low-level function to release the device.
void lcd_invert_off(lcd_t *dev)
Disable color inversion.
void lcd_fill(lcd_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.
const lcd_ll_par_driver_t lcd_ll_par_driver
Low-level parallel interface driver instance.
void lcd_ll_set_area(lcd_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2)
Set the LCD work area.
void lcd_read_cmd(lcd_t *dev, uint8_t cmd, uint8_t *data, size_t len)
Raw read command.
lcd_if_mode_t
Display interface modi.
Definition lcd.h:93
void lcd_ll_acquire(lcd_t *dev)
Low-level function to acquire the device.
void lcd_ll_write_cmd(lcd_t *dev, uint8_t cmd, const uint8_t *data, size_t len)
Low-level function to write a command.
void lcd_invert_on(lcd_t *dev)
Invert the display colors.
void lcd_pixmap(lcd_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.
int lcd_init(lcd_t *dev, const lcd_params_t *params)
Setup an LCD display device.
void lcd_write_cmd(lcd_t *dev, uint8_t cmd, const uint8_t *data, size_t len)
Raw write command.
void lcd_ll_read_cmd(lcd_t *dev, uint8_t cmd, uint8_t *data, size_t len)
Low-level function for read command.
@ LCD_IF_PARALLEL_16BIT
MCU 8080 16-bit parallel interface mode.
Definition lcd.h:96
@ LCD_IF_SPI
SPI serial interface mode.
Definition lcd.h:94
@ LCD_IF_PARALLEL_8BIT
MCU 8080 8-bit parallel interface mode.
Definition lcd.h:95
spi_mode_t
Support SPI modes.
Definition periph_cpu.h:43
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Generic type for a display device.
Definition disp_dev.h:107
LCD driver interface.
Definition lcd.h:196
void(* set_area)(lcd_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2)
Set the LCD work area.
Definition lcd.h:222
int(* init)(lcd_t *dev, const lcd_params_t *params)
Initialize LCD controller.
Definition lcd.h:205
Low-level MCU 8080 8-/16-bit parallel interface driver.
Definition lcd.h:419
Device initialization parameters.
Definition lcd.h:113
spi_clk_t spi_clk
SPI clock speed to use.
Definition lcd.h:117
gpio_t d15_pin
pin connected to the D15 line
Definition lcd.h:142
gpio_t d14_pin
pin connected to the D14 line
Definition lcd.h:141
gpio_t d9_pin
pin connected to the D9 line
Definition lcd.h:136
gpio_t rst_pin
pin connected to the RESET line
Definition lcd.h:148
bool rgb
True when display is connected in RGB mode False when display is connected in BGR mode.
Definition lcd.h:149
gpio_t dcx_pin
pin connected to the DC line
Definition lcd.h:147
uint8_t offset_y
LCD offset to apply on y axis.
Definition lcd.h:158
lcd_if_mode_t mode
LCD driver interface mode.
Definition lcd.h:121
uint16_t rgb_channels
Display rgb channels.
Definition lcd.h:155
uint8_t offset_x
LCD offset to apply on x axis.
Definition lcd.h:157
uint8_t cntrl
controller variant used, if the controller- specific driver supports multiple controller variants
Definition lcd.h:160
gpio_t d12_pin
pin connected to the D12 line
Definition lcd.h:139
gpio_t d11_pin
pin connected to the D11 line
Definition lcd.h:138
uint8_t rotation
Display rotation mode.
Definition lcd.h:156
gpio_t d13_pin
pin connected to the D13 line
Definition lcd.h:140
gpio_t wrx_pin
pin connected to the WRITE ENABLE line
Definition lcd.h:123
spi_mode_t spi_mode
SPI mode.
Definition lcd.h:118
gpio_t d10_pin
pin connected to the D10 line
Definition lcd.h:137
gpio_t rdx_pin
pin connected to the READ ENABLE line
Definition lcd.h:124
uint16_t lines
Number of lines, from 16 to the number of lines supported by the driver IC in 8 line steps.
Definition lcd.h:152
gpio_t d4_pin
pin connected to the D4 line
Definition lcd.h:129
spi_t spi
SPI device that the display is connected to.
Definition lcd.h:116
gpio_t d5_pin
pin connected to the D5 line
Definition lcd.h:130
gpio_t d2_pin
pin connected to the D2 line
Definition lcd.h:127
gpio_t d3_pin
pin connected to the D3 line
Definition lcd.h:128
bool inverted
Display works in inverted color mode.
Definition lcd.h:151
gpio_t d0_pin
pin connected to the D0 line
Definition lcd.h:125
gpio_t d6_pin
pin connected to the D6 line
Definition lcd.h:131
gpio_t d8_pin
pin connected to the D8 line
Definition lcd.h:135
gpio_t cs_pin
pin connected to the CHIP SELECT line
Definition lcd.h:146
gpio_t d7_pin
pin connected to the D7 line
Definition lcd.h:132
gpio_t d1_pin
pin connected to the D1 line
Definition lcd.h:126
Device descriptor for a lcd.
Definition lcd.h:176
const lcd_params_t * params
Device initialization parameters.
Definition lcd.h:181
disp_dev_t * dev
Pointer to the generic display device.
Definition lcd.h:178
mutex_t lock
Mutex used to lock the device in MCU 8080 parallel interface mode.
Definition lcd.h:183
const lcd_driver_t * driver
LCD driver.
Definition lcd.h:180
bool word_access
indicates that a word access is active
Definition lcd.h:187
Mutex structure.
Definition mutex.h:146