You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2022/06/28 12:34:23 UTC

[incubator-nuttx] branch master updated: Esp32 lilygo t5v2 fixed Data/Command line support.

This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7df798991c Esp32 lilygo t5v2 fixed Data/Command line support.
7df798991c is described below

commit 7df798991ccefcd87bf648c6091092616353974c
Author: Adam Kaliszan <ak...@altimetrik.com>
AuthorDate: Fri Jun 24 13:45:01 2022 +0200

    Esp32 lilygo t5v2 fixed Data/Command line support.
---
 boards/xtensa/esp32/common/Kconfig                 |  29 -----
 boards/xtensa/esp32/common/src/esp32_board_spi.c   |   5 +-
 boards/xtensa/esp32/common/src/esp32_ssd1680.c     | 144 +++++++++++----------
 boards/xtensa/esp32/ttgo_eink5_v2/include/board.h  |   8 ++
 boards/xtensa/esp32/ttgo_eink5_v2/src/Make.defs    |   4 -
 .../esp32/ttgo_eink5_v2/src/esp32_lcd_ssd1680.c    |  65 ----------
 .../xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h |   2 -
 drivers/lcd/Kconfig                                |   4 +-
 8 files changed, 90 insertions(+), 171 deletions(-)

diff --git a/boards/xtensa/esp32/common/Kconfig b/boards/xtensa/esp32/common/Kconfig
index 9d02025661..afc26b70b6 100644
--- a/boards/xtensa/esp32/common/Kconfig
+++ b/boards/xtensa/esp32/common/Kconfig
@@ -60,35 +60,6 @@ choice ESP32_SPIFLASH_FS
 
 endchoice
 
-if LCD_SSD1680
-config SSD1680_GPIO_PIN_RST
-	int "Pin that handles the reset line (output)"
-	default "12" if ARCH_BOARD_TTGO_T5V2_ESP32
-
-config SSD1680_GPIO_PIN_BUSY
-	int "Pin that handles the busy line (input)"
-	default "4" if ARCH_BOARD_TTGO_T5V2_ESP32
-
-config SSD1680_GPIO_PIN_PWR
-	int "Pin that handles the pwr on/off line (output)"
-	default "-1" if ARCH_BOARD_TTGO_T5V2_ESP32
-
-config SSD1680_GPIO_PIN_CS
-	int "Pin that select the chip on SPI bus"
-	default "5" if ARCH_BOARD_TTGO_T5V2_ESP32
-
-config SSD1680_GPIO_PIN_DTA_CMD
-	int "Pin that switch between command and data on 4-wire SPI bus"
-	default "19" if ARCH_BOARD_TTGO_T5V2_ESP32
-
-config SSD1680_SPI_BUS
-	int "Spi Bus Number"
-	range 2 3
-	default "3"
-	depends on ESP32_SPI
-
-endif #LCD_SSD1680
-
 config ESP32_LCD_OVERCLOCK
 	bool "Run LCD at higher clock speed than allowed"
 	default n
diff --git a/boards/xtensa/esp32/common/src/esp32_board_spi.c b/boards/xtensa/esp32/common/src/esp32_board_spi.c
index 5412b8edef..5a02dd6622 100644
--- a/boards/xtensa/esp32/common/src/esp32_board_spi.c
+++ b/boards/xtensa/esp32/common/src/esp32_board_spi.c
@@ -52,7 +52,7 @@ static inline uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid)
     }
 #endif
 
-#ifdef CONFIG_LCD_ILI9341
+#if defined(CONFIG_LCD_ILI9341) || defined(CONFIG_LCD_SSD1680)
   if (devid == SPIDEV_DISPLAY(0))
     {
        status |= SPI_STATUS_PRESENT;
@@ -71,7 +71,7 @@ static inline uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid)
 static inline int spi_cmddata(struct spi_dev_s *dev, uint32_t devid,
                               bool cmd)
 {
-#ifdef CONFIG_LCD_ILI9341
+#if defined(CONFIG_LCD_ILI9341) || defined(CONFIG_LCD_SSD1680)
   if (devid == SPIDEV_DISPLAY(0))
     {
       /*  This is the Data/Command control pad which determines whether the
@@ -79,7 +79,6 @@ static inline int spi_cmddata(struct spi_dev_s *dev, uint32_t devid,
        */
 
       esp32_gpiowrite(DISPLAY_DC, !cmd);
-
       return OK;
     }
 #endif
diff --git a/boards/xtensa/esp32/common/src/esp32_ssd1680.c b/boards/xtensa/esp32/common/src/esp32_ssd1680.c
index 1391ea8881..8b518db653 100644
--- a/boards/xtensa/esp32/common/src/esp32_ssd1680.c
+++ b/boards/xtensa/esp32/common/src/esp32_ssd1680.c
@@ -35,36 +35,27 @@
 #  include <nuttx/video/fb.h>
 #endif
 
+#include <arch/board/board.h>
+
 #include "esp32_gpio.h"
 #include "esp32_spi.h"
 
 #ifdef CONFIG_LCD_SSD1680
 
 /****************************************************************************
- * Private Functions
+ * Private Functions Prototypes
  ****************************************************************************/
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR>=0)
-static bool ssd1680_set_vcc(bool state)
-{
-  esp32_gpiowrite(CONFIG_SSD1680_GPIO_PIN_PWR, state);
-  return true;
-}
+#ifdef DISPLAY_VCC
+static bool ssd1680_set_vcc(bool state);
 #endif
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_RST) && (CONFIG_SSD1680_GPIO_PIN_RST>=0)
-static bool ssd1680_set_rst(bool state)
-{
-  esp32_gpiowrite(CONFIG_SSD1680_GPIO_PIN_RST, state);
-  return true;
-}
+#ifdef DISPLAY_RST
+static bool ssd1680_set_rst(bool state);
 #endif
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY>=0)
-static bool ssd1680_check_busy(void)
-{
-  return esp32_gpioread(CONFIG_SSD1680_GPIO_PIN_BUSY);
-}
+#ifdef DISPLAY_BUSY
+static bool ssd1680_check_busy(void);
 #endif
 
 /****************************************************************************
@@ -72,79 +63,107 @@ static bool ssd1680_check_busy(void)
  ****************************************************************************/
 
 static struct lcd_dev_s    *g_lcddev;
-struct ssd1680_priv_s g_ssd1680_priv =
+
+static struct ssd1680_priv_s g_ssd1680_priv =
 {
-#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
+#ifdef DISPLAY_VCC
   .set_vcc = ssd1680_set_vcc,
-#else
-  .set_vcc = NULL,
 #endif
-#if defined(CONFIG_SSD1680_GPIO_PIN_RST)  && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
+#ifdef DISPLAY_RST
   .set_rst = ssd1680_set_rst,
-#else
-  .set_rst = NULL,
 #endif
-#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY >= 0)
+#ifdef DISPLAY_BUSY
   .check_busy = ssd1680_check_busy,
-#else
-  .check_busy = NULL,
 #endif
 };
 
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef DISPLAY_VCC
+static bool ssd1680_set_vcc(bool state)
+{
+  esp32_gpiowrite(DISPLAY_VCC, state);
+  return true;
+}
+#endif
+
+#ifdef DISPLAY_RST
+static bool ssd1680_set_rst(bool state)
+{
+  esp32_gpiowrite(DISPLAY_RST, state);
+  return true;
+}
+#endif
+
+#ifdef DISPLAY_BUSY
+static bool ssd1680_check_busy(void)
+{
+  return esp32_gpioread(DISPLAY_BUSY);
+}
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: board_lcd_getdev
+ ****************************************************************************/
+
+struct lcd_dev_s *board_lcd_getdev(int devno)
+{
+  return g_lcddev;
+}
+
 /****************************************************************************
  * Name: board_lcd_initialize
  ****************************************************************************/
 
 int board_lcd_initialize(void)
 {
+  int ret = ERROR;
+
   struct spi_dev_s *spi;
 
   /* Initialize additional I/O for e-ink display */
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_DTA_CMD) && \
-  (CONFIG_SSD1680_GPIO_PIN_DTA_CMD >= 0)
-  esp32_configgpio(CONFIG_SSD1680_GPIO_PIN_DTA_CMD, OUTPUT);
-#endif
+  esp32_configgpio(DISPLAY_DC, OUTPUT);
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
-  esp32_configgpio(CONFIG_SSD1680_GPIO_PIN_PWR, OUTPUT);
-  lcdinfo("Using pin %d as PWR control\n", CONFIG_SSD1680_GPIO_PIN_PWR);
+#ifdef DISPLAY_VCC
+  esp32_configgpio(DISPLAY_VCC, OUTPUT);
+  lcdinfo("Using pin %d as VCC control\n", DISPLAY_VCC);
 #else
-  lcdinfo("PWR control line is disabled\n");
+  lcdinfo("VCC line is disabled\n");
 #endif
-#if defined(CONFIG_SSD1680_GPIO_PIN_RST) && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
-  esp32_configgpio(CONFIG_SSD1680_GPIO_PIN_RST, OUTPUT);
-  lcdinfo("Using pin %d as RESET\n", CONFIG_SSD1680_GPIO_PIN_RST);
-#elif
+
+#ifdef DISPLAY_RST
+  esp32_configgpio(DISPLAY_RST, OUTPUT);
+  lcdinfo("Using pin %d as RESET\n", DISPLAY_RST);
+#else
   lcdinfo("RESET line is disabled\n");
 #endif
 
-#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && \
-  (CONFIG_SSD1680_GPIO_PIN_BUSY >= 0)
-  esp32_configgpio(CONFIG_SSD1680_GPIO_PIN_BUSY, INPUT | PULLUP);
+#ifdef DISPLAY_BUSY
+  esp32_configgpio(DISPLAY_BUSY, INPUT | PULLUP);
   lcdinfo("Using pin %d for reading busy state\n",
-          CONFIG_SSD1680_GPIO_PIN_BUSY);
-#elif
+          DISPLAY_BUSY);
+#else
   lcdinfo("Read busy line is disabled\n");
 #endif
 
   /* Initialize SPI */
 
-  spi = esp32_spibus_initialize(CONFIG_SSD1680_SPI_BUS);
+  spi = esp32_spibus_initialize(DISPLAY_SPI_BUS);
   if (!spi)
     {
-      lcderr("ERROR: Failed to initialize SPI port %d\n",
-             CONFIG_SSD1680_SPI_BUS);
+      lcderr("ERROR: Failed to initialize SPI port %d\n", DISPLAY_SPI_BUS);
       return -ENODEV;
     }
   else
     {
-      lcdinfo("Using SPI bus %d. SPI is initialized\n",
-              CONFIG_SSD1680_SPI_BUS);
+      lcdinfo("Using SPI bus %d. SPI is initialized\n", DISPLAY_SPI_BUS);
     }
 
   /* Bind the SPI port to the E-PAPER display */
@@ -153,37 +172,30 @@ int board_lcd_initialize(void)
   if (!g_lcddev)
     {
       lcderr("ERROR: Failed to bind SPI port %d to E-paper display\n",
-             CONFIG_SSD1680_SPI_BUS);
+             DISPLAY_SPI_BUS);
       return -ENODEV;
     }
   else
     {
-      lcdinfo("Bound SPI port %d to E-PAPER\n", CONFIG_SSD1680_SPI_BUS);
+      lcdinfo("Bound SPI port %d to E-PAPER\n", DISPLAY_SPI_BUS);
 
-      /* And turn the OLED on.
+      /* And turn the E-PAPER display on in order to clear.
        * Must be because setpower(1) function invokes the chip configuration
        */
 
       g_lcddev->setpower(g_lcddev, CONFIG_LCD_MAXPOWER);
     }
 
-  return OK;
+  return ret;
 }
 
-#endif
-
 /****************************************************************************
- * Name: board_ssd1680_getdev
- *
- * Description:
- *   Get the SSD1680 device driver instance
- *
- * Returned Value:
- *   Pointer to the instance
- *
+ * Name: board_lcd_uninitialize
  ****************************************************************************/
 
-struct lcd_dev_s *board_ssd1680_getdev(void)
+void board_lcd_uninitialize(void)
 {
-  return g_lcddev;
+  /* TO-FIX */
 }
+
+#endif
diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/include/board.h b/boards/xtensa/esp32/ttgo_eink5_v2/include/board.h
index a0ac29f251..d988c553e5 100644
--- a/boards/xtensa/esp32/ttgo_eink5_v2/include/board.h
+++ b/boards/xtensa/esp32/ttgo_eink5_v2/include/board.h
@@ -82,4 +82,12 @@
 #define BOARD_NGPIOIN     1 /* Amount of GPIO Input without Interruption */
 #define BOARD_NGPIOINT    1 /* Amount of GPIO Input w/ Interruption pins */
 
+/* E-INK SSD1680  */
+
+#define DISPLAY_DC      19
+#define DISPLAY_RST     12
+#define DISPLAY_BUSY    4
+#define DISPLAY_CS      5
+#define DISPLAY_SPI_BUS 3
+
 #endif /* __BOARDS_XTENSA_ESP32_TTGO_EINK_5_V2_INCLUDE_BOARD_H */
diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/src/Make.defs b/boards/xtensa/esp32/ttgo_eink5_v2/src/Make.defs
index 45c41c2e5e..76e6b0bfc8 100644
--- a/boards/xtensa/esp32/ttgo_eink5_v2/src/Make.defs
+++ b/boards/xtensa/esp32/ttgo_eink5_v2/src/Make.defs
@@ -31,10 +31,6 @@ CSRCS += esp32_reset.c
 endif
 endif
 
-ifeq ($(CONFIG_VIDEO_FB),y)
-  CSRCS += esp32_lcd_ssd1680.c
-endif
-
 ifeq ($(CONFIG_MMCSD),y)
 CSRCS += esp32_mmcsd.c
 endif
diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_lcd_ssd1680.c b/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_lcd_ssd1680.c
deleted file mode 100644
index 110a5a8020..0000000000
--- a/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_lcd_ssd1680.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
- * boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_lcd_ssd1680.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <debug.h>
-
-#include <nuttx/board.h>
-#include <nuttx/lcd/lcd.h>
-#include <nuttx/lcd/ssd1680.h>
-
-#include "esp32_ssd1680.h"
-
-#include "ttgo_eink5_v2.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: board_lcd_getdev
- ****************************************************************************/
-
-struct lcd_dev_s *board_lcd_getdev(int devno)
-{
-  return board_ssd1680_getdev();
-}
-
-/****************************************************************************
- * Name: board_lcd_uninitialize
- ****************************************************************************/
-
-void board_lcd_uninitialize(void)
-{
-  /* TO-FIX */
-}
diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h b/boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h
index 56c53d7e55..19db5d147b 100644
--- a/boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h
+++ b/boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h
@@ -45,8 +45,6 @@
 
 #define SND 25
 
-/* E-INK SSD1680 Out */
-
 /* LED
  *
  * This is an externally connected LED used for testing.
diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig
index 365e504eb6..2b6203a892 100644
--- a/drivers/lcd/Kconfig
+++ b/drivers/lcd/Kconfig
@@ -1557,8 +1557,8 @@ config SSD1680_SPIMODE
 
 config SSD1680_FREQUENCY
 	int "SSD1680 SPI Frequency"
-	default 2000000
-	range 100000 2000000
+	default 5000000
+	range 100000 20000000
 	---help---
 		Selects the SPI bus frequency used with the SSD1680 device. 
 		Max for read mode is 2.5 MHz, for write mode is 20 HHz