Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/stm32l496g-disco: enable ST7789 display and touch panel #19938

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/stm32l496g-disco/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ config BOARD_STM32L496G_DISCO

select HAVE_SAUL_GPIO
select HAVE_FT5X06
select HAVE_ST7789
select HAVE_LCD_PARALLEL_16BIT if MODULE_ST7789

select MODULE_PERIPH_LPUART if MODULE_PERIPH_UART
select MODULE_PERIPH_UART_HW_FC if MODULE_PERIPH_UART && !MODULE_PERIPH_SPI_STMOD && HAS_PERIPH_UART_HW_FC
Expand Down
8 changes: 8 additions & 0 deletions boards/stm32l496g-disco/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ ifneq (,$(filter periph_uart,$(USEMODULE)))
FEATURES_REQUIRED += periph_uart_hw_fc
endif
endif

ifneq (,$(filter disp_dev,$(USEMODULE)))
USEMODULE += st7789
endif

ifneq (,$(filter st7789,$(USEMODULE)))
USEMODULE += lcd_parallel_16bit
endif
32 changes: 32 additions & 0 deletions boards/stm32l496g-disco/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_stm32l496g-disco
* @{
*
* @file
* @brief Board specific initializations for the STM32L496G-DISCO board
*
* @author Gunar Schorcht <[email protected]>
*/

#include "board.h"

void board_init(void)
{
#if MODULE_ST77XX
/* initialize the pin for the HIGH active LCD_BL signal */
gpio_init(BACKLIGHT_PIN, GPIO_OUT);
#endif
#if MODULE_ST77XX || MODULE_FT5X06
/* enable VDD_LCD by the LOW active LCD_PWR_ON signal connected to PH0 */
gpio_init(LCD_DISP_PIN, GPIO_OUT);
gpio_clear(LCD_DISP_PIN);
#endif
}
94 changes: 90 additions & 4 deletions boards/stm32l496g-disco/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
* @name LCD Backlight control defines
* @{
*/
#define BACKLIGHT_PIN GPIO_PIN(PORT_I, 0) /**< Backlight pin */
#define BACKLIGHT_PIN GPIO_PIN(PORT_I, 0) /**< Backlight pin (HIGH active LD_BL) */
#define BACKLIGHT_MASK (1 << 0) /**< Backlight pin mask */

/** Set the backlight pin */
Expand All @@ -46,11 +46,97 @@ extern "C" {

/**
* @name LCD display definitions
*
* The STM32L496-DISCO board has a 240 x 240 pixel TFT color LCD display with
* ST7789 driver IC using MCU 8080 16-bit parallel interface (default with
* SB14=ON and SB15=OFF). SB14 and SB15 control the ST7789 `IM0` signal.
* With SB14=OFF and SB15=ON, the MCU 8080 8-bit parallel interface is enabled.
*
* For the `LCD_*` pins the identifiers are used as given in the [schematic]
* (https://www.st.com/resource/en/schematic_pack/mb1261-l496g-b06-schematic.pdf).
*
* The LCD display has to switched on explicitly by activating VDD_LCD using
* the LOW active `LD_PWR_ON` signal.
*
* @note The `LCD_RESET` signal is provided by the MFX GPIO2 pin. Since the MFX
* is not yet supported, the `LCD_RESET` signal cannot be used by the display
* driver. However, since the `LCD_RESET` signal is pulled up and the MFX GPIO2
* pin is configured as a floating input by default, the driver will work
* without MFX support and the `LCD_RESET` signal.
*
* @{
*/
#define LCD_DISP_PIN GPIO_PIN(PORT_H, 0) /**< LCD power pin (LOW active LD_PWR_ON) */
#define LCD_SCREEN_WIDTH 240 /**< LCD width */
#define LCD_SCREEN_HEIGHT 240 /**< LCD height */

#define LCD_D0 GPIO_PIN(PORT_D, 14) /**< LCD_D0 pin */
#define LCD_D1 GPIO_PIN(PORT_D, 15) /**< LCD_D1 pin */
#define LCD_D2 GPIO_PIN(PORT_D, 0) /**< LCD_D2 pin */
#define LCD_D3 GPIO_PIN(PORT_D, 1) /**< LCD_D3 pin */
#define LCD_D4 GPIO_PIN(PORT_E, 7) /**< LCD_D4 pin */
#define LCD_D5 GPIO_PIN(PORT_E, 8) /**< LCD_D5 pin */
#define LCD_D6 GPIO_PIN(PORT_E, 9) /**< LCD_D6 pin */
#define LCD_D7 GPIO_PIN(PORT_E, 10) /**< LCD_D7 pin */
#define LCD_D8 GPIO_PIN(PORT_E, 11) /**< LCD_D8 pin */
#define LCD_D9 GPIO_PIN(PORT_E, 12) /**< LCD_D9 pin */
#define LCD_D10 GPIO_PIN(PORT_E, 13) /**< LCD_D10 pin */
#define LCD_D11 GPIO_PIN(PORT_E, 14) /**< LCD_D11 pin */
#define LCD_D12 GPIO_PIN(PORT_E, 15) /**< LCD_D12 pin */
#define LCD_D13 GPIO_PIN(PORT_D, 8) /**< LCD_D13 pin */
#define LCD_D14 GPIO_PIN(PORT_D, 9) /**< LCD_D14 pin */
#define LCD_D15 GPIO_PIN(PORT_D, 10) /**< LCD_D15 pin */
#define LCD_TE GPIO_PIN(PORT_H, 7) /**< LCD_TE pin */
#define LCD_WE GPIO_PIN(PORT_D, 5) /**< LCD_WE pin */
#define LCD_OE GPIO_PIN(PORT_D, 4) /**< LCD_OE pin */
#define LCD_RS GPIO_PIN(PORT_D, 13) /**< LCD_RS pin */
#define LCD_NE GPIO_PIN(PORT_D, 7) /**< LCD_NE pin */
#define LCD_RST GPIO_UNDEF /**< LCD_RST pin (MFX_GPIO2) */
#define LCD_BACKLIGHT BACKLIGHT_PIN /**< LCD_BL pin */

#define ST77XX_PARAM_CNTRL ST77XX_CNTRL_ST7789 /**< ST77xx controller variant */
#define ST77XX_PARAM_SPI SPI_UNDEF /**< parallel interface is used */
#define ST77XX_PARAM_D0 LCD_D0 /**< ST77xx D0 signal */
#define ST77XX_PARAM_D1 LCD_D1 /**< ST77xx D1 signal */
#define ST77XX_PARAM_D2 LCD_D2 /**< ST77xx D2 signal */
#define ST77XX_PARAM_D3 LCD_D3 /**< ST77xx D3 signal */
#define ST77XX_PARAM_D4 LCD_D4 /**< ST77xx D4 signal */
#define ST77XX_PARAM_D5 LCD_D5 /**< ST77xx D5 signal */
#define ST77XX_PARAM_D6 LCD_D6 /**< ST77xx D6 signal */
#define ST77XX_PARAM_D7 LCD_D7 /**< ST77xx D7 signal */
#define ST77XX_PARAM_D8 LCD_D8 /**< ST77xx D8 signal */
#define ST77XX_PARAM_D9 LCD_D9 /**< ST77xx D9 signal */
#define ST77XX_PARAM_D10 LCD_D10 /**< ST77xx D10 signal */
#define ST77XX_PARAM_D11 LCD_D11 /**< ST77xx D11 signal */
#define ST77XX_PARAM_D12 LCD_D12 /**< ST77xx D12 signal */
#define ST77XX_PARAM_D13 LCD_D13 /**< ST77xx D13 signal */
#define ST77XX_PARAM_D14 LCD_D14 /**< ST77xx D14 signal */
#define ST77XX_PARAM_D15 LCD_D15 /**< ST77xx D15 signal */
#define ST77XX_PARAM_WRX LCD_WE /**< ST77xx WR signal */
#define ST77XX_PARAM_RDX LCD_OE /**< ST77xx RD signal */
#define ST77XX_PARAM_DCX LCD_RS /**< ST77xx RS signal */
#define ST77XX_PARAM_RST LCD_RST /**< ST77xx RST signal */
#define ST77XX_PARAM_CS LCD_NE /**< ST77xx CS signal */
#define ST77XX_PARAM_RGB 1 /**< ST77xx RGB mode */
#define ST77XX_PARAM_INVERTED 1 /**< ST77xx inverted colors */
#define ST77XX_PARAM_ROTATION ST77XX_ROTATION_0 /**< ST77xx rotation */
#define ST77XX_PARAM_NUM_LINES LCD_SCREEN_HEIGHT /**< ST77xx number of lines */
#define ST77XX_PARAM_RGB_CHANNELS LCD_SCREEN_WIDTH /**< ST77xx number of channels */
/** @} */

/**
* @name Touch panel configuration
*
* The board uses a FT6236 touch panel driver IC.
*
* @{
*/
#define LCD_DISP_PIN GPIO_PIN(PORT_H, 0) /**< LCD screen enable pin */
#define LCD_SCREEN_WIDTH 240 /**< LCD screen width */
#define LCD_SCREEN_HEIGHT 240 /**< LCD screen height */
#define FT5X06_PARAM_I2C_DEV I2C_DEV(1) /**< I2C device */
#define FT5X06_PARAM_INT_PIN GPIO_PIN(PORT_G, 14) /**< Interrupt pin */
#define FT5X06_PARAM_XMAX LCD_SCREEN_WIDTH /**< Max width */
#define FT5X06_PARAM_YMAX LCD_SCREEN_HEIGHT /**< Max height */
#define FT5X06_PARAM_TYPE FT5X06_TYPE_FT6X36 /**< Device type */
#define FT5X06_PARAM_XYCONV FT5X06_SWAP_XY | FT5X06_MIRROR_Y /**< Swap XY, then mirror Y */
/** @} */

/**
Expand Down
1 change: 1 addition & 0 deletions tests/drivers/st77xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include ../Makefile.drivers_common
ST7789_BOARDS = \
esp32s2-lilygo-ttgo-t8 \
esp32s3-usb-otg \
stm32l496g-disco \
#

ST7796_BOARDS = \
Expand Down