pkarashchenko commented on code in PR #6418:
URL: https://github.com/apache/incubator-nuttx/pull/6418#discussion_r900215409


##########
boards/xtensa/esp32/common/src/esp32_ssd1680.c:
##########
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_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 <nuttx/spi/spi.h>
+
+#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
+#  include <nuttx/video/fb.h>
+#endif
+
+#include "esp32_gpio.h"
+#include "esp32_spi.h"
+
+#ifdef CONFIG_LCD_SSD1680
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#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;
+}
+#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;
+}
+#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);
+}
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct lcd_dev_s    *g_lcddev;
+struct ssd1680_priv_s g_ssd1680_priv =
+{
+#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
+  .set_vcc = ssd1680_set_vcc,
+#else
+  .set_vcc = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_RST)  && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
+  .set_rst = ssd1680_set_rst,
+#else
+  .set_rst = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY >= 
0)
+  .check_busy = ssd1680_check_busy,
+#else
+  .check_busy = NULL,
+#endif
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_lcd_initialize
+ ****************************************************************************/
+
+int board_lcd_initialize(void)
+{
+  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
+
+#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);
+#else
+  lcdinfo("PWR control 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
+  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);
+  lcdinfo("Using pin %d for reading busy state\n",
+    CONFIG_SSD1680_GPIO_PIN_BUSY);
+#elif
+  lcdinfo("Read busy line is disabled\n");
+#endif
+
+  /* Initialize SPI */
+
+  spi = esp32_spibus_initialize(CONFIG_SSD1680_SPI_BUS);
+  if (!spi)
+    {
+      lcderr("ERROR: Failed to initialize SPI port %d\n",
+        CONFIG_SSD1680_SPI_BUS);
+      return -ENODEV;
+    }
+  else
+    {
+      lcdinfo("Using SPI bus %d. SPI is initialized\n",
+        CONFIG_SSD1680_SPI_BUS);

Review Comment:
   ```suggestion
         lcdinfo("Using SPI bus %d. SPI is initialized\n",
                 CONFIG_SSD1680_SPI_BUS);
   ```



##########
boards/xtensa/esp32/common/src/esp32_ssd1680.c:
##########
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_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 <nuttx/spi/spi.h>
+
+#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
+#  include <nuttx/video/fb.h>
+#endif
+
+#include "esp32_gpio.h"
+#include "esp32_spi.h"
+
+#ifdef CONFIG_LCD_SSD1680
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#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;
+}
+#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;
+}
+#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);
+}
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct lcd_dev_s    *g_lcddev;
+struct ssd1680_priv_s g_ssd1680_priv =
+{
+#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
+  .set_vcc = ssd1680_set_vcc,
+#else
+  .set_vcc = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_RST)  && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
+  .set_rst = ssd1680_set_rst,
+#else
+  .set_rst = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY >= 
0)
+  .check_busy = ssd1680_check_busy,
+#else
+  .check_busy = NULL,
+#endif
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_lcd_initialize
+ ****************************************************************************/
+
+int board_lcd_initialize(void)
+{
+  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
+
+#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);
+#else
+  lcdinfo("PWR control 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
+  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);
+  lcdinfo("Using pin %d for reading busy state\n",
+    CONFIG_SSD1680_GPIO_PIN_BUSY);
+#elif
+  lcdinfo("Read busy line is disabled\n");
+#endif
+
+  /* Initialize SPI */
+
+  spi = esp32_spibus_initialize(CONFIG_SSD1680_SPI_BUS);
+  if (!spi)
+    {
+      lcderr("ERROR: Failed to initialize SPI port %d\n",
+        CONFIG_SSD1680_SPI_BUS);

Review Comment:
   ```suggestion
         lcderr("ERROR: Failed to initialize SPI port %d\n",
                CONFIG_SSD1680_SPI_BUS);
   ```



##########
boards/xtensa/esp32/common/src/esp32_ssd1680.c:
##########
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_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 <nuttx/spi/spi.h>
+
+#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
+#  include <nuttx/video/fb.h>
+#endif
+
+#include "esp32_gpio.h"
+#include "esp32_spi.h"
+
+#ifdef CONFIG_LCD_SSD1680
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#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;
+}
+#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;
+}
+#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);
+}
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct lcd_dev_s    *g_lcddev;
+struct ssd1680_priv_s g_ssd1680_priv =
+{
+#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
+  .set_vcc = ssd1680_set_vcc,
+#else
+  .set_vcc = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_RST)  && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
+  .set_rst = ssd1680_set_rst,
+#else
+  .set_rst = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY >= 
0)
+  .check_busy = ssd1680_check_busy,
+#else
+  .check_busy = NULL,
+#endif
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_lcd_initialize
+ ****************************************************************************/
+
+int board_lcd_initialize(void)
+{
+  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
+
+#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);
+#else
+  lcdinfo("PWR control 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
+  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);
+  lcdinfo("Using pin %d for reading busy state\n",
+    CONFIG_SSD1680_GPIO_PIN_BUSY);

Review Comment:
   ```suggestion
     lcdinfo("Using pin %d for reading busy state\n",
             CONFIG_SSD1680_GPIO_PIN_BUSY);
   ```



##########
boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h:
##########
@@ -0,0 +1,152 @@
+/****************************************************************************
+ * boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_SRC_H
+#define __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_SRC_H

Review Comment:
   ```suggestion
   #ifndef __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_H
   #define __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_H
   ```



##########
boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h:
##########
@@ -0,0 +1,152 @@
+/****************************************************************************
+ * boards/xtensa/esp32/ttgo_eink5_v2/src/ttgo_eink5_v2.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_SRC_H
+#define __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_SRC_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* ESP32-DevKitC GPIOs ******************************************************/
+
+/* BOOT Button */
+
+#define BUTN1  37
+#define BUTN2  38
+#define BUTN3  39
+
+/* Sound PWM Out */
+
+#define SND 25
+
+/* E-INK SSD1680 Out */
+
+/* LED
+ *
+ * This is an externally connected LED used for testing.
+ */
+
+#define GPIO_LED1             26
+
+/* MCP2515 Interrupt pin */
+
+#define GPIO_MCP2515_IRQ      22
+
+/* TIMERS */
+
+#define TIMER0 0
+#define TIMER1 1
+#define TIMER2 2
+#define TIMER3 3
+
+/* ONESHOT */
+
+#define ONESHOT_TIMER         1
+#define ONESHOT_RESOLUTION_US 1
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y :
+ *     Called from the NSH library via board_app_initialize()
+ *
+ ****************************************************************************/
+
+int esp32_bringup(void);
+
+/****************************************************************************
+ * Name: esp32_mmcsd_initialize
+ *
+ * Description:
+ *   Initialize SPI-based SD card and card detect thread.
+ ****************************************************************************/
+
+int esp32_mmcsd_initialize(int minor);
+
+/****************************************************************************
+ * Name: esp32_gpio_init
+ ****************************************************************************/
+
+#ifdef CONFIG_DEV_GPIO
+int esp32_gpio_init(void);
+#endif
+
+/****************************************************************************
+ * Name: esp32_ledc_setup
+ *
+ * Description:
+ *   Initialize LEDC PWM and register the PWM device.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ESP32_LEDC
+int esp32_pwm_setup(void);
+#endif
+
+/****************************************************************************
+ * Name: board_spidev_initialize
+ *
+ * Description:
+ *   Initialize SPI driver and register the /dev/spi device.
+ *
+ * Input Parameters:
+ *   bus - The SPI bus number, used to build the device path as /dev/spiN
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; A negated errno value is returned
+ *   to indicate the nature of any failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_DRIVER
+int board_spidev_initialize(int bus);
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_SRC_H*/

Review Comment:
   ```suggestion
   #endif /* __BOARDS_XTENSA_ESP32_TTGO_EINK5_V2_SRC_TTGO_EINK5_V2_H */
   ```



##########
boards/xtensa/esp32/common/src/esp32_ssd1680.c:
##########
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_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 <nuttx/spi/spi.h>
+
+#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
+#  include <nuttx/video/fb.h>
+#endif
+
+#include "esp32_gpio.h"
+#include "esp32_spi.h"
+
+#ifdef CONFIG_LCD_SSD1680
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#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;
+}
+#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;
+}
+#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);
+}
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct lcd_dev_s    *g_lcddev;
+struct ssd1680_priv_s g_ssd1680_priv =
+{
+#if defined(CONFIG_SSD1680_GPIO_PIN_PWR) && (CONFIG_SSD1680_GPIO_PIN_PWR >= 0)
+  .set_vcc = ssd1680_set_vcc,
+#else
+  .set_vcc = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_RST)  && (CONFIG_SSD1680_GPIO_PIN_RST >= 0)
+  .set_rst = ssd1680_set_rst,
+#else
+  .set_rst = NULL,
+#endif
+#if defined(CONFIG_SSD1680_GPIO_PIN_BUSY) && (CONFIG_SSD1680_GPIO_PIN_BUSY >= 
0)
+  .check_busy = ssd1680_check_busy,
+#else
+  .check_busy = NULL,
+#endif
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_lcd_initialize
+ ****************************************************************************/
+
+int board_lcd_initialize(void)
+{
+  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
+
+#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);
+#else
+  lcdinfo("PWR control 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
+  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);
+  lcdinfo("Using pin %d for reading busy state\n",
+    CONFIG_SSD1680_GPIO_PIN_BUSY);
+#elif
+  lcdinfo("Read busy line is disabled\n");
+#endif
+
+  /* Initialize SPI */
+
+  spi = esp32_spibus_initialize(CONFIG_SSD1680_SPI_BUS);
+  if (!spi)
+    {
+      lcderr("ERROR: Failed to initialize SPI port %d\n",
+        CONFIG_SSD1680_SPI_BUS);
+      return -ENODEV;
+    }
+  else
+    {
+      lcdinfo("Using SPI bus %d. SPI is initialized\n",
+        CONFIG_SSD1680_SPI_BUS);
+    }
+
+  /* Bind the SPI port to the E-PAPER display */
+
+  g_lcddev = ssd1680_initialize(spi, &g_ssd1680_priv);
+  if (!g_lcddev)
+    {
+      lcderr("ERROR: Failed to bind SPI port %d to E-paper display\n",
+          CONFIG_SSD1680_SPI_BUS);

Review Comment:
   ```suggestion
         lcderr("ERROR: Failed to bind SPI port %d to E-paper display\n",
                CONFIG_SSD1680_SPI_BUS);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to