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

drivers/st7735: split off separate driver modules for st7789 and st7796 #19828

Closed
Closed
5 changes: 0 additions & 5 deletions boards/esp32s2-lilygo-ttgo-t8/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ ifneq (,$(filter disp_dev,$(USEMODULE)))
USEMODULE += st7789
endif

ifneq (,$(filter st7735,$(USEMODULE)))
# use st7789 pseudomodule if st7735 is enabled to indicate that we use a ST7789
USEMODULE += st7789
endif

include $(RIOTBOARD)/common/esp32s2/Makefile.dep
2 changes: 1 addition & 1 deletion boards/esp32s2-lilygo-ttgo-t8/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

void board_init(void)
{
if (IS_USED(MODULE_ST7735)) {
if (IS_USED(MODULE_ST7789)) {
gpio_init(BACKLIGHT_PIN, GPIO_OUT);
}
}
28 changes: 14 additions & 14 deletions boards/esp32s2-lilygo-ttgo-t8/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@
* OLED display uses SPI_DEV(0) on this board.
* @{
*/
#if defined(MODULE_ST7735)
#define ST7735_PARAM_SPI SPI_DEV(0) /**< SPI device */
#define ST7735_PARAM_SPI_CLK SPI_CLK_10MHZ /**< SPI clock frequency */
#define ST7735_PARAM_SPI_MODE SPI_MODE_0 /**< SPI mode */
#define ST7735_PARAM_CS GPIO34 /**< Chip Select pin */
#define ST7735_PARAM_DCX GPIO37 /**< DCX pin */
#define ST7735_PARAM_RST GPIO38 /**< Reset pin */
#define ST7735_PARAM_RGB 1 /**< RGB mode enable */
#define ST7735_PARAM_INVERTED 1 /**< Inverted mode enable */
#define ST7735_PARAM_NUM_LINES 240U /**< Number of lines */
#define ST7735_PARAM_RGB_CHANNELS 135U /**< Number of columns */
#define ST7735_PARAM_ROTATION LCD_MADCTL_MY /**< Rotation */
#define ST7735_PARAM_OFFSET_X 40 /**< X offset */
#define ST7735_PARAM_OFFSET_Y 52 /**< Y offset */
#if defined(MODULE_ST7789)
#define ST7789_PARAM_SPI SPI_DEV(0) /**< SPI device */
#define ST7789_PARAM_SPI_CLK SPI_CLK_10MHZ /**< SPI clock frequency */
#define ST7789_PARAM_SPI_MODE SPI_MODE_0 /**< SPI mode */
#define ST7789_PARAM_CS GPIO34 /**< Chip Select pin */
#define ST7789_PARAM_DCX GPIO37 /**< DCX pin */
#define ST7789_PARAM_RST GPIO38 /**< Reset pin */
#define ST7789_PARAM_RGB 1 /**< RGB mode enable */
#define ST7789_PARAM_INVERTED 1 /**< Inverted mode enable */
#define ST7789_PARAM_NUM_LINES 240U /**< Number of lines */
#define ST7789_PARAM_RGB_CHANNELS 135U /**< Number of columns */
#define ST7789_PARAM_ROTATION ST7789_ROTATION_HORZ /**< Rotation */
#define ST7789_PARAM_OFFSET_X 40 /**< X offset */
#define ST7789_PARAM_OFFSET_Y 52 /**< Y offset */
#endif
/** @} */

Expand Down
4 changes: 0 additions & 4 deletions boards/esp32s3-usb-otg/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ endif
ifneq (,$(filter disp_dev,$(USEMODULE)))
USEMODULE += st7789
endif

ifneq (,$(filter st7735,$(USEMODULE)))
USEMODULE += st7789
endif
2 changes: 1 addition & 1 deletion boards/esp32s3-usb-otg/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

void board_init(void)
{
#if MODULE_ST7735
#if MODULE_ST7789
gpio_init(LCD_BACKLIGHT, GPIO_OUT);
#endif
}
20 changes: 10 additions & 10 deletions boards/esp32s3-usb-otg/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,21 @@
* This configuration cannot be changed.
* @{
*/
#if MODULE_ST7735
#if MODULE_ST7789
#define LCD_DC GPIO4 /**< LCD DC signal */
#define LCD_CS GPIO5 /**< LCD EN signal */
#define LCD_RST GPIO8 /**< LCD RST signal */
#define LCD_BACKLIGHT GPIO9 /**< LCD BL signal */

#define ST7735_PARAM_SPI SPI_DEV(0)
#define ST7735_PARAM_CS LCD_CS
#define ST7735_PARAM_DCX LCD_DC
#define ST7735_PARAM_RST LCD_RST
#define ST7735_PARAM_NUM_LINES 240
#define ST7735_PARAM_RGB_CHANNELS 240
#define ST7735_PARAM_ROTATION LCD_MADCTL_MV | LCD_MADCTL_MX | LCD_MADCTL_MY
#define ST7735_PARAM_INVERTED 1
#define ST7735_PARAM_RGB 1
#define ST7789_PARAM_SPI SPI_DEV(0)
#define ST7789_PARAM_CS LCD_CS
#define ST7789_PARAM_DCX LCD_DC
#define ST7789_PARAM_RST LCD_RST
#define ST7789_PARAM_NUM_LINES 240
#define ST7789_PARAM_RGB_CHANNELS 240
#define ST7789_PARAM_ROTATION ST7789_ROTATION_VERT
#define ST7789_PARAM_INVERTED 1
#define ST7789_PARAM_RGB 1

#define BACKLIGHT_ON gpio_set(LCD_BACKLIGHT)
#define BACKLIGHT_OFF gpio_clear(LCD_BACKLIGHT)
Expand Down
45 changes: 45 additions & 0 deletions boards/sipeed-longan-nano-tft/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2023 Inria
#
# 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.
#

config BOARD
default "sipeed-longan-nano-tft" if BOARD_SIPEED_LONGAN_NANO_TFT

config BOARD_SIPEED_LONGAN_NANO_TFT
bool
default y
select CPU_MODEL_GD32VF103CBT6
select BOARD_HAS_HXTAL
select BOARD_HAS_LXTAL
select HAS_HIGHLEVEL_STDIO
select HAS_PERIPH_ADC
select HAS_PERIPH_DAC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
select HAS_RIOTBOOT
select HAS_TINYUSB_DEVICE
select HAVE_SAUL_GPIO
select HAVE_ST7735
select MODULE_SIPEED_LONGAN_NANO_TFT

select HAVE_MTD_SDCARD_DEFAULT
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG

config FORCE_USB_STDIO
default y

config MODULE_SIPEED_LONGAN_NANO_TFT
bool "Sipeed Longan Nano with TFT"
default y
help
Indicates that the board is a Sipeed Longan Nano board with TFT display.

source "$(RIOTBOARD)/common/gd32v/Kconfig"
2 changes: 2 additions & 0 deletions boards/sipeed-longan-nano-tft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DIRS = $(RIOTBOARD)/sipeed-longan-nano
include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions boards/sipeed-longan-nano-tft/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USEMODULE += sipeed_longan_nano_tft

include $(RIOTBOARD)/sipeed-longan-nano/Makefile.dep
1 change: 1 addition & 0 deletions boards/sipeed-longan-nano-tft/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBOARD)/sipeed-longan-nano/Makefile.features
2 changes: 2 additions & 0 deletions boards/sipeed-longan-nano-tft/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INCLUDES += -I$(RIOTBOARD)/sipeed-longan-nano/include
include $(RIOTBOARD)/sipeed-longan-nano/Makefile.include
21 changes: 21 additions & 0 deletions boards/sipeed-longan-nano-tft/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
@defgroup boards_sipeed_longan_nano_tft Sipeed Longan Nano TFT board
@ingroup boards
@brief Support for the Sipeed Longan Nano TFT board
@author Gunar Schorcht <[email protected]>

The [Sipeed Longan Nano TFT](https://longan.sipeed.com/en) board is a version
of the \ref sipeed_longan_nano "Sipeed Longan Nano" development board
that is equipped with a TFT display with the following on-board components:

- GD32VF103CBT6 RISC-V MCU @108MHz
- USB Type C
- TF card slot
- 3 user LEDs
- 0.96" TFT display 160 x 80 pixel

@image html "https://media-cdn.seeedstudio.com/media/catalog/product/cache/7f7f32ef807b8c2c2215b49801c56084/1/1/114992425_1.jpg" "Sipeed Longan Nano" width=600

Detailed information about board configuration and flashing can be found in the
\ref sipeed_longan_nano "Sipeed Longan Nano" documentation.
*/
11 changes: 0 additions & 11 deletions boards/sipeed-longan-nano/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,4 @@ config BOARD_SIPEED_LONGAN_NANO
config FORCE_USB_STDIO
default y

menu "Sipeed Longan Nano Board Configuration"

config SIPEED_LONGAN_NANO_WITH_TFT
bool "Board with TFT display"
default y if MODULE_DISP_DEV
select HAVE_ST7735
help
Indicates that a Sipeed Longan Nano board with TFT display is used.

endmenu

source "$(RIOTBOARD)/common/gd32v/Kconfig"
4 changes: 1 addition & 3 deletions boards/sipeed-longan-nano/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
PORT_LINUX ?= /dev/ttyACM0
PROGRAMMER ?= dfu-util

ifneq (,$(filter st7735,$(USEMODULE)))
CFLAGS += '-DCONFIG_SIPEED_LONGAN_NANO_WITH_TFT=1'
endif
PSEUDOMODULES += sipeed_longan_nano_tft

include $(RIOTBOARD)/common/gd32v/Makefile.include
23 changes: 15 additions & 8 deletions boards/sipeed-longan-nano/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
@brief Support for the Sipeed Longan Nano board
@author Gunar Schorcht <[email protected]>

\section sipeed_longan_nano Sipeed Longan Nano

## Overview

The [Sipeed Longan Nano](https://longan.sipeed.com/en) is a
development board for the GigaDevice GD32VF103CBT6 MCU with the following
on-board components:
The [Sipeed Longan Nano](https://longan.sipeed.com/en) is a development board
for the GigaDevice GD32VF103CBT6 MCU with the following on-board components:

- GD32VF103CBT6 RISC-V MCU @108MHz
- USB Type C
Expand Down Expand Up @@ -98,10 +99,10 @@ by pins.

\n
@note To use the TFT display of a Sipeed Longan Nano board, if available, the
macro `CONFIG_SIPEED_LONGAN_NANO_WITH_TFT=1` has to be defined, for
example using the `CFLAGS` variable in the make command:
module `sipeed_longan_nano_tft` has to be enabled, for
example using the `USEMODULE` variable in the make command:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BOARD=sipeed-longan-nano CFLAGS='-DCONFIG_SIPEED_LONGAN_NANO_WITH_TFT=1' make ...
BOARD=sipeed-longan-nano USEMODULE=sipeed_longan_nano_tft make ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

| Pin | Board Function | RIOT Function 1 | RIOT Function 2 | RIOT Function 3 |
Expand Down Expand Up @@ -188,10 +189,16 @@ PROGRAMMER=openocd OPENOCD_DEBUG_ADAPTER=jlink BOARD=sipeed-longan-nano make -C
## Using the TFT Display

To use the TFT display of a Sipeed Longan Nano board, if available, the
macro `CONFIG_SIPEED_LONGAN_NANO_WITH_TFT=1` has to be defined, for
`sipeed_longan_nano_tft` module has to be enabled, for
example using the `CFLAGS` variable in the make command:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BOARD=sipeed-longan-nano CFLAGS='-DCONFIG_SIPEED_LONGAN_NANO_WITH_TFT=1' make -C tests/drivers/st7735 flash
BOARD=sipeed-longan-nano USEMODULE=sipeed_longan_nano_tft make -C tests/drivers/st7735 flash
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Alternatively, the `sipeed-longan-nano-tft` board definition can be used,
which simply enables the `sipeed_longan_nano_tft` module:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BOARD=sipeed-longan-nano-tft make -C tests/drivers/st7735 flash
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

## Accessing STDIO
Expand Down
2 changes: 1 addition & 1 deletion boards/sipeed-longan-nano/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extern "C" {
#define SDCARD_SPI_PARAM_MOSI GPIO_PIN(PORT_B, 15)
#endif

#if defined(MODULE_ST7735) && defined(CONFIG_SIPEED_LONGAN_NANO_WITH_TFT)
#if defined(MODULE_ST7735) && defined(MODULE_SIPEED_LONGAN_NANO_TFT)
#define ST7735_PARAM_SPI SPI_DEV(1) /**< SPI device */
#define ST7735_PARAM_SPI_CLK SPI_CLK_5MHZ /**< SPI clock frequency */
#define ST7735_PARAM_SPI_MODE SPI_MODE_0 /**< SPI mode */
Expand Down
16 changes: 8 additions & 8 deletions boards/sipeed-longan-nano/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define CONFIG_CLOCK_HXTAL MHZ(8) /**< HXTAL frequency */
#endif

#if CONFIG_SIPEED_LONGAN_NANO_WITH_TFT
#if MODULE_SIPEED_LONGAN_NANO_TFT
#define SPI_DEV_1_USED /**< Enable SPI_DEV(1) if TFT is connected */
#endif

Expand Down Expand Up @@ -61,18 +61,18 @@ static const adc_conf_t adc_config[] = {
{ .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
/* ADC VREF channel */
{ .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
#if !CONFIG_SIPEED_LONGAN_NANO_WITH_TFT
#if !MODULE_SIPEED_LONGAN_NANO_TFT
/* This conflicts with TFT pins if connected. */
{ .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 8 },
{ .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 },
/* This conflicts with the SPI0 controller which is used if TFT is connected */
{ .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
{ .pin = GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 7 },
#if !defined(MODULE_PERIPH_DAC)
#if !MODULE_PERIPH_DAC
{ .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
{ .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
#endif /* !defined(MODULE_PERIPH_DAC) */
#endif /* !CONFIG_SIPEED_LONGAN_NANO_WITH_TFT */
#endif /* !MODULE_PERIPH_DAC */
#endif /* !MODULE_SIPEED_LONGAN_NANO_TFT */
};

#define ADC_NUMOF ARRAY_SIZE(adc_config)
Expand All @@ -83,10 +83,10 @@ static const adc_conf_t adc_config[] = {
* @{
*/
static const dac_conf_t dac_config[] = {
#if !CONFIG_SIPEED_LONGAN_NANO_WITH_TFT
#if !MODULE_SIPEED_LONGAN_NANO_TFT
{ .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
{ .pin = GPIO_PIN(PORT_A, 5), .chan = 1 },
#endif /* !CONFIG_SIPEED_LONGAN_NANO_WITH_TFT */
#endif /* !MODULE_SIPEED_LONGAN_NANO_TFT */
};

#define DAC_NUMOF ARRAY_SIZE(dac_config)
Expand All @@ -110,7 +110,7 @@ static const pwm_conf_t pwm_config[] = {
.af = GPIO_AF_OUT_PP,
.bus = APB1,
},
#if !defined(MODULE_PERIPH_CAN)
#if !MODULE_PERIPH_CAN
{
.dev = TIMER3,
.rcu_mask = RCU_APB1EN_TIMER3EN_Msk,
Expand Down
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ rsource "hd44780/Kconfig"
rsource "ili9341/Kconfig"
rsource "lcd/Kconfig"
rsource "st7735/Kconfig"
rsource "st7789/Kconfig"
rsource "st7796/Kconfig"
rsource "touch_dev/Kconfig"
endmenu # Display Device Drivers

Expand Down
4 changes: 0 additions & 4 deletions drivers/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ ifneq (,$(filter stmpe811_%,$(USEMODULE)))
USEMODULE += stmpe811
endif

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

ifneq (,$(filter sx126%,$(USEMODULE)))
USEMODULE += sx126x
endif
Expand Down
Loading