From b0ec24bc9eb8552c335d4d62250b13e5015157e4 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Fri, 14 Jul 2023 00:59:22 +0200 Subject: [PATCH] drivers/st7735: add MCU 8080 8-/16-bit parallel mode support --- drivers/include/st77xx.h | 14 +++++++-- drivers/st77xx/include/st77xx_params.h | 40 +++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/drivers/include/st77xx.h b/drivers/include/st77xx.h index f88b711a0a73..eb755ed55376 100644 --- a/drivers/include/st77xx.h +++ b/drivers/include/st77xx.h @@ -22,8 +22,18 @@ * @ref lcd_params_t::cntrl or as macro @ref ST77XX_PARAM_CNTRL if the * default parameter set @ref ST77XX_PARAMS is used. * - * The driver uses the SPI serial interface to communicate with the display - * controller. + * The driver communicates with the device either via an + * + * - SPI serial interface (if module `lcd_spi` enabled) or an + * - MCU 8080 8-/16-bit parallel interface (if module `lcd_parallel` or + * module `lcd_parallel_16` is enabled). + * + * Usually the device driver is used either for a single display with SPI serial + * interface or for a display with parallel MCU 8080 8-/16-bit parallel + * interface. However, the device driver can also be used simultaneously for + * multiple displays with different interfaces if several of the `lcd_spi`, + * `lcd_parallel` and `lcd_parallel_16bit` modules are enabled at the same time. + * In this case, please refer to the notes in @ref lcd_params_t. * * The device requires colors to be send in big endian RGB-565 format. The * @ref CONFIG_LCD_LE_MODE compile time option can switch this, but only use this diff --git a/drivers/st77xx/include/st77xx_params.h b/drivers/st77xx/include/st77xx_params.h index e3b2ab7b309a..37508059cf4a 100644 --- a/drivers/st77xx/include/st77xx_params.h +++ b/drivers/st77xx/include/st77xx_params.h @@ -137,14 +137,46 @@ extern "C" { #define ST77XX_PARAM_OFFSET_Y 0 /**< Vertival offset */ #endif +#if MODULE_LCD_SPI || DOXYGEN +/** Default interface params if SPI serial interface is enabled */ +#define ST77XX_PARAM_IF_SPI .spi = ST77XX_PARAM_SPI, \ + .spi_clk = ST77XX_PARAM_SPI_CLK, \ + .spi_mode = ST77XX_PARAM_SPI_MODE, +#else +#define ST77XX_PARAM_IF_SPI +#endif + +#if MODULE_LCD_PARALLEL || DOXYGEN +/** Default interface params if MCU 8080 8-bit parallel interface is enabled */ +#define ST77XX_PARAM_IF_PAR .d0_pin = ST77XX_PARAM_D0, \ + .d1_pin = ST77XX_PARAM_D1, \ + .d2_pin = ST77XX_PARAM_D2, \ + .d3_pin = ST77XX_PARAM_D3, \ + .d4_pin = ST77XX_PARAM_D4, \ + .d5_pin = ST77XX_PARAM_D5, \ + .d6_pin = ST77XX_PARAM_D6, \ + .d7_pin = ST77XX_PARAM_D7, \ + .wrx_pin = ST77XX_PARAM_WRX, \ + .rdx_pin = ST77XX_PARAM_RDX, +#else +#define ST77XX_PARAM_IF_PAR +#endif + /** * @brief Default params + * + * @note The default parameter set defined here can only be used if a single + * ST77xx display and only one interface mode is used. If multiple + * ST77xx displays are used or if multiple interface modes are enabled + * by the modules `lcd_spi`, lcd_parallel and `lcd_parallel_16bit`, a user + * defined parameter set @ref ST77XX_PARAMS has to be defined. In the + * latter case @ref lcd_params_t::spi must then be set to @ref SPI_UNDEF + * for displays with MCU 8080 8-/16-bit parallel interfaces. */ #ifndef ST77XX_PARAMS #define ST77XX_PARAMS { .cntrl = ST77XX_PARAM_CNTRL, \ - .spi = ST77XX_PARAM_SPI, \ - .spi_clk = ST77XX_PARAM_SPI_CLK, \ - .spi_mode = ST77XX_PARAM_SPI_MODE, \ + ST77XX_PARAM_IF_SPI \ + ST77XX_PARAM_IF_PAR \ .cs_pin = ST77XX_PARAM_CS, \ .dcx_pin = ST77XX_PARAM_DCX, \ .rst_pin = ST77XX_PARAM_RST, \ @@ -156,7 +188,7 @@ extern "C" { .offset_x = ST77XX_PARAM_OFFSET_X, \ .offset_y = ST77XX_PARAM_OFFSET_Y, \ } -#endif +#endif /* ST77XX_PARAMS */ /** @} */ /**