patacongo commented on a change in pull request #1778:
URL: https://github.com/apache/incubator-nuttx/pull/1778#discussion_r487983115



##########
File path: boards/arm/nrf52/nrf52-feather/src/nrf52_ili9341_lcd.c
##########
@@ -0,0 +1,410 @@
+/****************************************************************************
+ * boards/arm/nrf52/nrf52-feather/src/nrf52_ili9341_lcd.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 <stdint.h>
+#include <stdbool.h>
+#include <endian.h>
+#include <debug.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/lcd/lcd.h>
+#include <nuttx/lcd/ili9341.h>
+
+#include "chip.h"
+#include "arm_arch.h"
+#include "arm_internal.h"
+#include "nrf52_gpio.h"
+#include "nrf52_spi.h"
+
+#include "nrf52-feather.h"
+#include <arch/board/board.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GRAM_ENDIAN_SWAP_BUFFER_LEN 1    /* Gram swap space */
+
+#if (GRAM_ENDIAN_SWAP_BUFFER_LEN > 127)
+#  error "GRAM_ENDIAN_SWAP_BUFFER_LEN must fit in a SPI transfer 127 words!"
+#endif
+
+/****************************************************************************
+ * Private Type Definition
+ ****************************************************************************/
+
+struct ili93414ws_lcd_s
+{
+  struct ili9341_lcd_s dev;
+  FAR struct spi_dev_s *spi;
+};
+
+/****************************************************************************
+ * Private Function Protototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct ili93414ws_lcd_s g_lcddev;
+static struct lcd_dev_s *g_lcd = NULL;
+static uint8_t swapbuf[GRAM_ENDIAN_SWAP_BUFFER_LEN * 2];
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_backlight
+ *
+ * Description:
+ *   Set the backlight level of the connected display.
+ *
+ * Input Parameters:
+ *   spi   - Reference to the public driver structure
+ *   level - backlight level
+ *
+ * Returned Value:
+ *   OK - On Success
+ *
+ ****************************************************************************/
+
+static int nrf52_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd,
+                                      int level)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_select
+ *
+ * Description:
+ *   Select the SPI, locking and re-configuring if necessary
+ *
+ * Input Parameters:
+ *   spi  - Reference to the public driver structure
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static void nrf52_ili93414ws_select(FAR struct ili9341_lcd_s *lcd)
+{
+  FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd;
+
+  SPI_LOCK(priv->spi, true);
+  SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true);
+}
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_deselect
+ *
+ * Description:
+ *   De-select the SPI
+ *
+ * Input Parameters:
+ *   spi  - Reference to the public driver structure
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static void nrf52_ili93414ws_deselect(FAR struct ili9341_lcd_s *lcd)
+{
+  FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd;
+
+  SPI_LOCK(priv->spi, false);
+  SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false);
+}
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_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 nrf52_ili93414ws_sendcmd(
+    FAR struct ili9341_lcd_s *lcd, const uint8_t cmd)
+{
+  FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd;
+
+  lcdinfo("%02x\n", cmd);
+
+  nrf52_gpio_write(ILI9341_DISPLAY_DC, false); /* Indicate CMD */
+  SPI_SEND(priv->spi, cmd);
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_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 nrf52_ili93414ws_sendparam(FAR struct ili9341_lcd_s *lcd,
+                                      const uint8_t param)
+{
+  FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd;
+
+  nrf52_gpio_write(ILI9341_DISPLAY_DC, true);  /* Indicate DATA */
+  SPI_SEND(priv->spi, param);
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: nrf52_ili93414ws_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 nrf52_ili93414ws_sendgram(FAR struct ili9341_lcd_s *lcd,

Review comment:
       > The location where the blitting is done is in graphics/nxglib/lcd. But 
that uses macros defined in graphics/nxglib/nxglib_bitblit.h.
   
   Sorry, that is bad advice.  Those macros are only used by the framebuffer 
bit-blitters (graphics/nxglib/fb).  The blitting is hardcoded for the LCD in 
the files unser graphics/nxglib/lcd.
   
   So you can't change the blitting in one place but rather in all of the 6 
files at that location.  Sorry.
   
   Hmm.. there is common logic used for the LCD blitters in 
graphics/nxglib/nxglib_copyrun.h and graphics/nxglib/nxglib_fillrun.h.  Those 
will cover most, but not all, of the blit operations in graphics/nxglib/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:
us...@infra.apache.org


Reply via email to