You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/11/28 14:57:41 UTC

[GitHub] [incubator-nuttx] yjdwbj opened a new pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

yjdwbj opened a new pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433


   
   
   ## Summary
     Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit bus interface I, This Shield pins is match the NUCLEO-L152RE's Arduino connectors.
   ## Impact
   
   ## Testing
   
   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433#issuecomment-735249183


   Please run this command to fix the error reported by https://github.com/apache/incubator-nuttx/pull/2433/checks?check_run_id=1467516736:
   ./tools/refresh.sh --silent nucleo-l152re/lcd
   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433#discussion_r532050314



##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
##########
@@ -0,0 +1,733 @@
+/****************************************************************************
+ * boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
+ *
+ * Driver for the ILI9341 Single Chip LCD driver connected
+ * via 8080-I 8-bit Series Parallel Interface
+ *
+ *   Copyright (C) 2020 Gregory Nutt. All rights reserved.

Review comment:
       Need change to Apache copyright

##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_spisd.c
##########
@@ -0,0 +1,158 @@
+/****************************************************************************
+ * boards/arm/stm32/stm32-l152re/src/stm32_spisd.c
+ *
+ *   Copyright 2019 Sony Home Entertainment & Sound Products Inc.
+ *   Author: Masayuki Ishikawa <Ma...@jp.sony.com>
+ *
+ * Based on omnibusf4/src/stm32_mmcsd.c
+ *   Copyright (C) 2019 Bill Gatliff. All rights reserved.
+ *   Copyright (C) 2017 Greg Nutt. All rights reserved.
+ *   Author: Bill Gatliff <bg...@billgatliff.com>
+ *   Author: Alan Carvalho de Assis <ac...@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <debug.h>
+#include <nuttx/config.h>
+#include <nuttx/mmcsd.h>
+#include <nuttx/spi/spi.h>
+#include <pthread.h>
+#include <sched.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "arm_arch.h"
+#include "chip.h"
+#include "stm32_spi.h"
+#include "stm32_gpio.h"
+
+#include <arch/board/board.h>
+#include "nucleo-l152re.h"
+
+#if defined(CONFIG_STM32_SPI1)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_DISABLE_MOUNTPOINT
+#error "SD driver requires CONFIG_DISABLE_MOUNTPOINT to be disabled"
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name:
+ *   stm32_spi1register
+ *
+ * Description:
+ *   Registers media change callback
+ ****************************************************************************/
+
+int stm32_spi1register(struct spi_dev_s *dev, spi_mediachange_t callback,
+                       void *arg)
+{
+  /* TODO: media change callback */
+
+  return OK;
+}
+
+void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
+                                                  bool selected)
+{
+  spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" :
+                                                     "de-assert");
+#if defined(CONFIG_MMCSD_SPI)
+  stm32_gpiowrite(GPIO_SPI1_CS, !selected);
+#endif
+}
+
+uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
+{
+  uint8_t ret = 0;
+#if defined(CONFIG_MMCSD_SPI)
+  if (devid == SPIDEV_MMCSD(0))
+    {
+      ret |= SPI_STATUS_PRESENT;
+    }
+#endif
+
+  return ret;
+}
+
+int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid,
+                      bool cmd)
+{
+  return -ENODEV;
+}
+
+/****************************************************************************
+ * Name: stm32_spisd_initialize
+ *
+ * Description:
+ *   Initialize SPI-based SD card and card detect thread.
+ ****************************************************************************/
+
+int stm32_spisd_initialize(int port, int minor)
+{
+  struct spi_dev_s *spi;
+  int rv;
+  stm32_configgpio(GPIO_SPI1_SCK);
+  stm32_configgpio(GPIO_SPI1_CS);   /* Assign CS */
+  stm32_gpiowrite(GPIO_SPI1_CS, 1); /* Ensure the CS is inactive */
+
+  mcinfo("INFO: Initializing mmcsd port %d minor %d \n",
+         port, minor);
+
+  spi = stm32_spibus_initialize(port);
+  if (spi == NULL)
+    {
+      mcerr("ERROR: Failed to initialize SPI port %d\n", port);
+      return -ENODEV;
+    }
+
+  rv = mmcsd_spislotinitialize(minor, minor, spi);
+  if (rv < 0)
+    {
+      mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n",
+            port, minor);
+      return rv;
+    }
+
+  spiinfo("INFO: mmcsd card has been initialized successfully\n");
+  return OK;
+}
+
+#endif /* CONFIG_STM32_SPI1 */

Review comment:
       add a new line

##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
##########
@@ -0,0 +1,733 @@
+/****************************************************************************
+ * boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
+ *
+ * Driver for the ILI9341 Single Chip LCD driver connected
+ * via 8080-I 8-bit Series Parallel Interface
+ *
+ *   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+ *   Author: Chunyang Liu <yj...@gmail.com>
+ *
+ * References: ILI9341_DS_V1.10.pdf (Rev: 1.10), "a-Si TFT LCD Single Chip
+ *             Driver 240RGBx320 Resolution and 262K color", ILI TECHNOLOGY
+ *             CORP., http://www.ilitek.com.
+ *             ILI TECHNOLOGY CORP., http://www.ilitek.com.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+
+#include "nucleo-l152re.h"
+#include <nuttx/lcd/lcd.h>
+#include <nuttx/lcd/ili9341.h>
+#include <nuttx/video/rgbcolors.h>
+
+#include "stm32_gpio.h"
+
+#include <arch/board/board.h>
+
+#ifdef CONFIG_LCD_ILI9341
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Protototypes
+ ****************************************************************************/
+
+/* DE Mode RCM = 2, Sync Mode RCM = 3
+ * Interface Mode Control
+ *
+ * EPL:         0 High enable for RGB interface
+ * DPL:         1 data fetched at the falling time
+ * HSPL:        0 Low level sync clock
+ * VSPL:        0 Low level sync clock
+ * RCM:         2 (DE Mode)
+ * ByPass_Mode: 1 (Memory)
+ */
+
+#define STM32_ILI9341_IFMODE_PARAM ((!ILI9341_INTERFACE_CONTROL_EPL) |  \
+                                    ILI9341_INTERFACE_CONTROL_DPL |     \
+                                    (!ILI9341_INTERFACE_CONTROL_HSPL) | \
+                                    (!ILI9341_INTERFACE_CONTROL_VSPL) | \
+                                    ILI9341_INTERFACE_CONTROL_RCM(2) |  \
+                                    ILI9341_INTERFACE_CONTROL_BPASS)
+
+/* Interface control (IFCTL)
+ *
+ * Parameter 1: 0x0001
+ * MY_EOR:  0
+ * MX_EOR:  0
+ * MV_EOR:  0
+ * BGR_EOR: 0
+ * WEMODE:  1   Reset column and page if data transfer exceeds
+ */
+
+#define STM32_ILI9341_IFCTL_PARAM1 (ILI9341_INTERFACE_CONTROL_WEMODE |  \
+                                    !ILI9341_INTERFACE_CONTROL_BGREOR | \
+                                    !ILI9341_INTERFACE_CONTROL_MVEOR |  \
+                                    !ILI9341_INTERFACE_CONTROL_MXEOR |  \
+                                    !ILI9341_INTERFACE_CONTROL_MYEOR)
+
+/* Parameter 2: 0x0000
+ *
+ * EPF:     0   65k color format for RGB interface
+ * MDT:     0   Display data transfer mode
+ *
+ */
+#define STM32_ILI9341_IFCTL_PARAM2 (ILI9341_INTERFACE_CONTROL_MDT(0) | \
+                                    ILI9341_INTERFACE_CONTROL_EPF(0))
+
+/* Parameter 3: 0x0000/0x0020
+ *
+ * ENDIAN:  0   Big endian
+ * DM:      1   RGB Interface Mode
+ * RM:      1   RGB interface
+ * RIM:     0   18-bit 1 transfer/pixel RGB interface mode
+ *
+ */
+#define STM32_ILI9341_IFCTL_PARAM3 ((!ILI9341_INTERFACE_CONTROL_RIM) | \
+                                    ILI9341_INTERFACE_CONTROL_RM |     \
+                                    ILI9341_INTERFACE_CONTROL_DM(1) |  \
+                                    (!ILI9341_INTERFACE_CONTROL_ENDIAN))
+
+/* LCD CONTROL */
+
+#define LCD_CS_CLR (stm32_gpiowrite(GPIO_LCD_CS, 0))
+#define LCD_CS_SET (stm32_gpiowrite(GPIO_LCD_CS, 1))
+
+#define LCD_WR_CLR (stm32_gpiowrite(GPIO_LCD_WR, 0))
+#define LCD_WR_SET (stm32_gpiowrite(GPIO_LCD_WR, 1))
+
+#define LCD_RD_CLR (stm32_gpiowrite(GPIO_LCD_RD, 0))
+#define LCD_RD_SET (stm32_gpiowrite(GPIO_LCD_RD, 1))
+
+#define LCD_RS_DATA (stm32_gpiowrite(GPIO_LCD_RS, 1)) /* write data */
+#define LCD_RS_CMD (stm32_gpiowrite(GPIO_LCD_RS, 0))  /* write cmd */
+
+#define BIT_SHIFT (0)
+#define BIT0 (0 << BIT_SHIFT)
+#define BIT1 (1 << BIT_SHIFT)
+#define BIT2 (2 << BIT_SHIFT)
+#define BIT3 (3 << BIT_SHIFT)
+#define BIT4 (4 << BIT_SHIFT)
+#define BIT5 (5 << BIT_SHIFT)
+#define BIT6 (6 << BIT_SHIFT)
+#define BIT7 (7 << BIT_SHIFT)
+
+#define GET_BIT(data, bit) (((data) & (1 << (bit))) >> (bit))
+#define WRITE_BIT(b, pin) ((b) == 1 ? GPIO_BSRR_SET(pin) : GPIO_BSRR_RESET(pin))
+
+static const uint32_t g_lcdpin[] =
+    {
+      GPIO_LCD_D0, GPIO_LCD_D1, GPIO_LCD_D2, GPIO_LCD_D3, /* D0-D3 */
+      GPIO_LCD_D4, GPIO_LCD_D5, GPIO_LCD_D6, GPIO_LCD_D7, /* D4-D7 */
+      GPIO_LCD_RD, GPIO_LCD_WR, GPIO_LCD_RS, GPIO_LCD_RST,
+      GPIO_LCD_CS
+    };
+
+#define LCD_NPINS (sizeof(g_lcdpin) / sizeof(uint32_t))
+
+/* Command and data transmission control */
+
+static int stm32_ili93418b_recvblock(FAR struct ili9341_lcd_s *lcd,
+                                     uint16_t *wd, uint16_t nwords);
+static void stm32_ili93418b_deselect(FAR struct ili9341_lcd_s *lcd);
+static void stm32_ili93418b_select(FAR struct ili9341_lcd_s *lcd);
+static int stm32_ili93418b_sendcmd(FAR struct ili9341_lcd_s *lcd,
+                                     const uint8_t cmd);
+static int stm32_ili93418b_sendparam(FAR struct ili9341_lcd_s *lcd,
+                                     const uint8_t param);
+static int stm32_ili93418b_recvparam(FAR struct ili9341_lcd_s *lcd,
+                                     uint8_t *param);
+static int stm32_ili93418b_backlight(FAR struct ili9341_lcd_s *lcd,
+                                     int level);
+static int stm32_ili93418b_sendgram(FAR struct ili9341_lcd_s *lcd,
+                                    const uint16_t *wd, uint32_t nwords);
+static int stm32_ili93418b_recvgram(FAR struct ili9341_lcd_s *lcd,
+                                    uint16_t *wd, uint32_t nwords);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* This is the standard, NuttX LCD driver object */
+
+static struct ili9341_lcd_s g_ili9341_lcddev =
+{
+  /* Initialize structure */
+
+  .select    = stm32_ili93418b_select,
+  .deselect  = stm32_ili93418b_deselect,
+  .sendcmd   = stm32_ili93418b_sendcmd,
+  .sendparam = stm32_ili93418b_sendparam,
+  .recvparam = stm32_ili93418b_recvparam,
+  .sendgram  = stm32_ili93418b_sendgram,
+  .recvgram  = stm32_ili93418b_recvgram,
+  .backlight = stm32_ili93418b_backlight,
+};
+
+/****************************************************************************
+ * Name: write_byte
+ *
+ * Description:
+ *   Send a byte to the lcd driver.
+ *
+ * Input Parameters:
+ *   data - a byte
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static inline void write_byte(uint8_t data)
+{
+  LCD_RD_SET;
+
+  /**
+   * This is simple to understand
+   *
+   * stm32_gpiowrite(GPIO_LCD_D0, GET_BIT(data, BIT0));
+   * stm32_gpiowrite(GPIO_LCD_D1, GET_BIT(data, BIT1));
+   * stm32_gpiowrite(GPIO_LCD_D2, GET_BIT(data, BIT2));
+   * stm32_gpiowrite(GPIO_LCD_D3, GET_BIT(data, BIT3));
+   * stm32_gpiowrite(GPIO_LCD_D4, GET_BIT(data, BIT4));
+   * stm32_gpiowrite(GPIO_LCD_D5, GET_BIT(data, BIT5));
+   * stm32_gpiowrite(GPIO_LCD_D6, GET_BIT(data, BIT6));
+   * stm32_gpiowrite(GPIO_LCD_D7, GET_BIT(data, BIT7));
+   *
+   **/
+
+  putreg32(WRITE_BIT(GET_BIT(data, BIT0), GPIO_PIN9) |
+               WRITE_BIT(GET_BIT(data, BIT2), GPIO_PIN10) |
+               WRITE_BIT(GET_BIT(data, BIT7), GPIO_PIN8),
+               STM32_GPIOA_BSRR);
+  putreg32(WRITE_BIT(GET_BIT(data, BIT3), GPIO_PIN3) |
+               WRITE_BIT(GET_BIT(data, BIT4), GPIO_PIN5) |
+               WRITE_BIT(GET_BIT(data, BIT5), GPIO_PIN4) |
+               WRITE_BIT(GET_BIT(data, BIT6), GPIO_PIN10),
+               STM32_GPIOB_BSRR);
+  putreg32(WRITE_BIT(GET_BIT(data, BIT1), GPIO_PIN7), STM32_GPIOC_BSRR);
+
+  LCD_WR_CLR;
+  LCD_WR_SET;
+}
+
+/** references https://controllerstech.com/interface-tft-display-with-stm32/
+ * #define READ() (((getreg32(STM32_GPIOA_IDR) & (1 << GPIO_PIN9)) >> 9) |  \
+ *                 ((getreg32(STM32_GPIOC_IDR) & (1 << GPIO_PIN7)) >> 6) |  \
+ *                 ((getreg32(STM32_GPIOA_IDR) & (1 << GPIO_PIN10)) >> 8) | \
+ *                 ((getreg32(STM32_GPIOB_IDR) & (1 << GPIO_PIN3)) >> 0) |  \
+ *                 ((getreg32(STM32_GPIOB_IDR) & (1 << GPIO_PIN5)) >> 1) |  \
+ *                 ((getreg32(STM32_GPIOB_IDR) & (1 << GPIO_PIN4)) << 1) |  \
+ *                 ((getreg32(STM32_GPIOB_IDR) & (1 << GPIO_PIN10)) >> 4) | \
+ *                 ((getreg32(STM32_GPIOA_IDR) & (1 << GPIO_PIN8)) >> 1))
+ **/
+
+/****************************************************************************
+ * Name: read_byte
+ *
+ * Description:
+ *   Read a byte from IOs
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   On success - The received byte from the LCD Single Chip Driver.
+ *   On error   - 0 (If timeout during receiving)
+ *
+ ****************************************************************************/
+
+static inline uint8_t read_byte(void)
+{
+  uint32_t a_idr;
+  uint32_t b_idr;
+  uint8_t data = 0;
+  LCD_RD_CLR;
+  up_udelay(1);
+  a_idr = getreg32(STM32_GPIOA_IDR);
+  b_idr = getreg32(STM32_GPIOB_IDR);
+
+  data |= (stm32_gpioread(GPIO_LCD_D1) << 1);
+  data |= (GET_BIT(a_idr, GPIO_PIN9) << BIT0 |
+           GET_BIT(a_idr, GPIO_PIN10) << BIT2 |
+           GET_BIT(a_idr, GPIO_PIN8) << BIT7);
+  data |= (GET_BIT(b_idr, BIT3) << BIT3 |
+           GET_BIT(b_idr, GPIO_PIN5) << BIT4 |
+           GET_BIT(b_idr, GPIO_PIN4) << BIT5 |
+           GET_BIT(b_idr, GPIO_PIN10) << BIT6);
+
+  /* data = READ(); */
+
+  LCD_RD_SET;
+  return data;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93414ws_recvblock
+ *
+ * Description:
+ *   Receive a number of words from to the lcd driver.
+ *   Note: The first received word is the dummy word and discarded!
+ *
+ * Input Parameters:
+ *   lcd    - Reference to the private device structure
+ *   wd    -  Reference to where the words receive
+ *   nwords - number of words to receive
+ *
+ * Returned Value:
+ *  OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_recvblock(FAR struct ili9341_lcd_s *lcd,
+                                     uint16_t *wd, uint16_t nwords)
+{
+  /** ili9341 uses a 18-bit pixel format packed in a 24-bit stream per pixel.
+   *  The following format is transmitted: RRRRRR00 GGGGGG00 BBBBBB00
+   *  Convert it to:                       RRRRRGGG GGGBBBBB
+   */
+
+  /**  8-bit parallel mode is enabled for pixel data operations.
+   *  Each pixel must be received by three read operations.
+   */
+
+  uint16_t *dest = (uint16_t *)wd;
+  LCD_RS_DATA;
+  while (nwords--)
+    {
+      uint8_t r;
+      uint8_t g;
+      uint8_t b;
+
+      /* read dummy */
+
+      r = read_byte();
+
+      /* read red */
+
+      r = read_byte();
+      r = r >> 3;
+
+      /* read green  */
+
+      g = read_byte();
+      g = g >> 2;
+
+      /* read blue */
+
+      b = read_byte();
+      b = b >> 3;
+      *dest++ = ((r << 11) | (g << 5) | b);
+    }
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_select
+ *
+ * Description:
+ *   Select the LCD
+ *
+ * Input Parameters:
+ *   lcd  - Reference to the public driver structure
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static void stm32_ili93418b_select(FAR struct ili9341_lcd_s *lcd)
+{
+  LCD_CS_CLR;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_deselect
+ *
+ * Description:
+ *   De-select the LCD
+ *
+ * Input Parameters:
+ *   lcd  - Reference to the public driver structure
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static void stm32_ili93418b_deselect(FAR struct ili9341_lcd_s *lcd)
+{
+  LCD_CS_SET;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_sendparam
+ *
+ * Description:
+ *   Send a parameter to the lcd driver.
+ *
+ * Input Parameters:
+ *   lcd    - Reference to the ili9341_lcd_s driver structure
+ *   param  - parameter to send
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_sendparam(FAR struct ili9341_lcd_s *lcd,
+                                     const uint8_t param)
+{
+  lcdinfo("param=%04x\n", param);
+  LCD_RS_DATA;
+  write_byte(param);
+  return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_sendgram
+ *
+ * Description:
+ *   Send a number of pixel words to the lcd driver gram.
+ *
+ * Input Parameters:
+ *   lcd    - Reference to the ili9341_lcd_s driver structure
+ *   wd     - Reference to the words to send
+ *   nwords - number of words to send
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_sendgram(FAR struct ili9341_lcd_s *lcd,
+                                    const uint16_t *wd, uint32_t nwords)
+{
+  lcdinfo("wd=%p , wd=0x%x, nwords=%d\n", wd, *wd, nwords);
+
+  /* 8-bit parallel mode is enabled for pixel data operations.
+   * Each pixel must be transmitted by two write operations.
+   */
+
+  const uint16_t *src = wd;
+  uint16_t word;
+  LCD_RS_DATA;
+  while (nwords-- > 0)
+    {
+      word = *src++;
+      write_byte((word & 0xff));
+      write_byte((word >> 8));
+    }
+
+  return OK;
+};
+
+/****************************************************************************
+ * Name: stm32_ili93418b_recvparam
+ *
+ * Description:
+ *   Receive a parameter from the lcd driver.
+ *
+ * Input Parameters:
+ *   lcd    - Reference to the ili9341_lcd_s driver structure
+ *   param  - Reference to where parameter receive
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_recvparam(FAR struct ili9341_lcd_s *lcd,
+                                     uint8_t *param)
+{
+  LCD_RS_DATA;
+  *param = read_byte();
+  lcdinfo("param=%04x\n", param);
+  return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_recvgram
+ *
+ * Description:
+ *   Receive pixel words from the lcd driver gram.
+ *
+ * Input Parameters:
+ *   lcd    - Reference to the public driver structure
+ *   wd     - Reference to where the pixel words receive
+ *   nwords - number of pixel words to receive
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_recvgram(FAR struct ili9341_lcd_s *lcd,
+                                    uint16_t *wd, uint32_t nwords)
+{
+  lcdinfo("wd=%p, nwords=%d\n", wd, nwords);
+  return stm32_ili93418b_recvblock(lcd, wd, nwords);
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_sndcmd
+ *
+ * Description:
+ *   Send a command to the lcd driver.
+ *
+ * Input Parameters:
+ *   lcd  - Reference to the ili9341_lcd_s driver structure
+ *   cmd  - command to send
+ *
+ * Returned Value:
+ *   On success - OK
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_sendcmd(
+    FAR struct ili9341_lcd_s *lcd, const uint8_t cmd)
+{
+  lcdinfo("cmd=%04x\n", cmd);
+  LCD_RS_CMD;
+  write_byte(cmd);
+  return OK;
+}
+
+/****************************************************************************
+ * Name: stm32_ili93418b_backlight
+ *
+ * Description:
+ *   Set the backlight level of the connected display.
+ *
+ * Input Parameters:
+ *   lcd   - Reference to the public driver structure
+ *   level - backligth level
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int stm32_ili93418b_backlight(FAR struct ili9341_lcd_s *lcd,
+                                     int level)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name:  sam_gpio_initialize
+ *
+ * Description:
+ *   Configure LCD GPIO pins
+ *
+ ****************************************************************************/
+
+static inline void stm32_gpio_initialize(void)
+{
+  int i;
+
+  /* Configure all LCD pins pins (backlight is initially off) */
+
+  for (i = 0; i < LCD_NPINS; i++)
+    {
+      stm32_configgpio(g_lcdpin[i]);
+    }
+}
+
+/****************************************************************************
+ * Name:  stm32_ili93414ws_initialize
+ *
+ * Description:
+ *   Initialize the device structure to control the LCD Single chip driver.
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ *   On success, this function returns a reference to the LCD control object
+ *   for the specified ILI9341 LCD Single chip driver connected as 8-bit
+ *   series parallel. NULL is returned on any failure.
+ *
+ ****************************************************************************/
+
+struct lcd_dev_s *g_lcddev;
+FAR struct lcd_dev_s *stm32_ili93418b_initialize(void)
+{
+  FAR struct ili9341_lcd_s *lcd = &g_ili9341_lcddev;
+
+  lcdinfo("initialize ili9341 8bit parallel subdriver\n");
+
+  /* Configure gpios */
+
+  stm32_gpio_initialize();
+  up_mdelay(50);
+
+  /* reset LCD   */
+
+  stm32_gpiowrite(GPIO_LCD_RST, 0);
+  up_mdelay(100);
+  stm32_gpiowrite(GPIO_LCD_RST, 1);
+  up_mdelay(50);
+
+  /* initialize LCD */
+
+  g_lcddev = ili9341_initialize(lcd, 0);
+
+  /* Select LCD device */
+
+  lcdinfo("Initialize ili9341 lcd driver\n");
+  lcd->select(lcd);
+
+#ifdef CONFIG_DEBUG_LCD_INFO
+  /* Read display identification */
+
+  uint8_t param;
+
+  lcd->sendcmd(lcd, ILI9341_READ_ID1);
+  lcd->recvparam(lcd, &param);
+  lcdinfo("ili9341 LCD driver: LCD modules manufacturer ID: %d\n", param);
+
+  lcd->sendcmd(lcd, ILI9341_READ_ID2);
+  lcd->recvparam(lcd, &param);
+  lcdinfo("ili9341 LCD driver: LCD modules driver version ID: %d\n", param);
+
+  lcd->sendcmd(lcd, ILI9341_READ_ID3);
+  lcd->recvparam(lcd, &param);
+  lcdinfo("ili9341 LCD driver: LCD modules driver ID: %d\n", param);
+#endif
+
+  /* Reset the lcd display to the default state */
+
+  lcdinfo("ili9341 LCD driver: Software Reset\n");
+  lcd->sendcmd(lcd, ILI9341_SOFTWARE_RESET);
+  up_mdelay(5);
+
+  /* RGB Interface signal control */
+
+  lcdinfo("ili9341 LCD driver: Set RGB Interface signal control: %02x\n",
+          STM32_ILI9341_IFMODE_PARAM);
+  lcd->sendcmd(lcd, ILI9341_RGB_SIGNAL_CONTROL);
+  lcd->sendparam(lcd, STM32_ILI9341_IFMODE_PARAM);
+
+  /* Interface control */
+
+  lcdinfo("ili9341 LCD driver: Set Interface control: %d:%d:%d\n",
+          STM32_ILI9341_IFCTL_PARAM1,
+          STM32_ILI9341_IFCTL_PARAM2,
+          STM32_ILI9341_IFCTL_PARAM3);
+
+  lcd->sendcmd(lcd, ILI9341_INTERFACE_CONTROL);
+  lcd->sendparam(lcd, STM32_ILI9341_IFCTL_PARAM1);
+  lcd->sendparam(lcd, STM32_ILI9341_IFCTL_PARAM2);
+  lcd->sendparam(lcd, STM32_ILI9341_IFCTL_PARAM3);
+
+  lcdinfo("ili9341 set Frame control\n");
+  lcd->sendcmd(lcd, ILI9341_FRAME_RATE_CONTROL_NORMAL);
+  lcd->sendparam(lcd, 0x00);
+  lcd->sendparam(lcd, 0x13); /* 0x18 79Hz, 0x1B default 70Hz, 0x13 100Hz */
+
+  /* Sleep out set to the end */
+
+  lcdinfo("ili9341 LCD driver: Sleep Out\n");
+  lcd->sendcmd(lcd, ILI9341_SLEEP_OUT);
+  up_mdelay(5);
+
+  /* Display on */
+
+  lcdinfo("ili9341 LCD driver: Display On\n");
+  lcd->sendcmd(lcd, ILI9341_DISPLAY_ON);
+
+  /* Deselect LCD device */
+
+  lcd->deselect(lcd);
+  return g_lcddev;
+}
+
+/****************************************************************************
+ * Name:  board_lcd_initialize
+ *
+ * Description:
+ *   Initialize the LCD video hardware.  The initial state of the LCD is
+ *   fully initialized, display memory cleared, and the LCD ready to use,
+ *   but with the power setting at 0 (full off).
+ *
+ ****************************************************************************/
+
+int board_lcd_initialize(void)
+{
+  g_lcddev = stm32_ili93418b_initialize();
+  if (g_lcddev == NULL)
+    {
+      lcdinfo("Initialize ili9341 lcd driver NULL\n");
+      return ENODEV;
+    }
+
+  ili9341_clear(g_lcddev, 0);
+  return OK;
+}
+
+/****************************************************************************
+ * Name:  board_lcd_getdev
+ *
+ * Description:
+ *   Return a a reference to the LCD object for the specified LCD.
+ *   This allows support
+ *   for multiple LCD devices.
+ *
+ ****************************************************************************/
+
+FAR struct lcd_dev_s *board_lcd_getdev(int lcddev)
+{
+  if (lcddev == 0)
+    {
+      return g_lcddev;
+    }
+
+  return NULL;
+}
+
+#endif /* CONFIG_LCD_ILI9341 */

Review comment:
       add a new line

##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_spisd.c
##########
@@ -0,0 +1,158 @@
+/****************************************************************************
+ * boards/arm/stm32/stm32-l152re/src/stm32_spisd.c
+ *
+ *   Copyright 2019 Sony Home Entertainment & Sound Products Inc.

Review comment:
       change to apache copyright




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433#issuecomment-735347714


   @yjdwbj could you squach three patch into one like this?
   ```
   git rebase --interactive HEAD~3
   change pick to squach in editor
   git push -f origin stm32l152re-ili9341
   ```


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2433: Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit…

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2433:
URL: https://github.com/apache/incubator-nuttx/pull/2433#discussion_r532157428



##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
##########
@@ -0,0 +1,720 @@
+/****************************************************************************
+ * boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
+ *
+ * Driver for the ILI9341 Single Chip LCD driver connected
+ * via 8080-I 8-bit Series Parallel Interface
+ *
+ *   Author: Chunyang Liu <yj...@gmail.com>

Review comment:
       Please remove the author from header file, here is some dissussion:
   https://github.com/apache/incubator-nuttx/pull/2375

##########
File path: boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
##########
@@ -0,0 +1,720 @@
+/****************************************************************************
+ * boards/arm/stm32/nucleo-l152re/src/stm32_ili93418b.c
+ *
+ * Driver for the ILI9341 Single Chip LCD driver connected
+ * via 8080-I 8-bit Series Parallel Interface
+ *
+ *   Author: Chunyang Liu <yj...@gmail.com>
+ *
+ * References: ILI9341_DS_V1.10.pdf (Rev: 1.10), "a-Si TFT LCD Single Chip
+ *             Driver 240RGBx320 Resolution and 262K color", ILI TECHNOLOGY
+ *             CORP., http://www.ilitek.com.
+ *             ILI TECHNOLOGY CORP., http://www.ilitek.com.

Review comment:
       it's better to move the reference section out of copyright header, so the tool can identify the copyright more easier.




----------------------------------------------------------------
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.

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