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 2022/08/29 21:58:19 UTC

[GitHub] [incubator-nuttx] acassis opened a new pull request, #6955: esp32c3/boards: Add support APA102/APDS0060 for Shift Game

acassis opened a new pull request, #6955:
URL: https://github.com/apache/incubator-nuttx/pull/6955

   ## Summary
   Add support APA102/APDS0060 for Shift Game
   ## Impact
   Users will be able to use the Shift game on esp32c3-devkit-rust-1 board
   ## Testing
   esp32c3-devkit-rust-1 board
   


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6955: esp32c3/boards: Add support APA102/APDS0060 for Shift Game

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


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #6955: esp32c3/boards: Add support APA102/APDS0060 for Shift Game

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on code in PR #6955:
URL: https://github.com/apache/incubator-nuttx/pull/6955#discussion_r958599597


##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apa102.c:
##########
@@ -0,0 +1,109 @@
+/****************************************************************************
+ * boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apa102.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 <stdio.h>
+#include <stdbool.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+#include <nuttx/spi/spi.h>
+#include <nuttx/lcd/lcd.h>
+#include <nuttx/lcd/apa102.h>
+
+#include "esp32c3_gpio.h"
+#include "esp32c3_spi.h"
+#include "esp32c3-devkit-rust-1.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define LCD_SPI_PORTNO        2   /* On SPI2 */
+
+#ifndef CONFIG_LCD_CONTRAST
+#  define CONFIG_LCD_CONTRAST 60
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+struct spi_dev_s *g_spidev;
+struct lcd_dev_s *g_lcddev;

Review Comment:
   Either that, or these shouldn't be placed under "Private Data"



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #6955: esp32c3/boards: Add support APA102/APDS0060 for Shift Game

Posted by GitBox <gi...@apache.org>.
acassis commented on code in PR #6955:
URL: https://github.com/apache/incubator-nuttx/pull/6955#discussion_r958834870


##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/Makefile:
##########
@@ -41,6 +41,18 @@ ifeq ($(CONFIG_BOARDCTL_IOCTL),y)
 CSRCS += esp32c3_ioctl.c
 endif
 
+ifeq ($(CONFIG_ESP32C3_SPI),y)
+CSRCS += esp32c3_board_spi.c
+endif
+
+ifeq ($(CONFIG_SENSORS_APDS9960),y)
+  CSRCS += esp32c3_apds9960.c

Review Comment:
   Done, thank you!



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6955: esp32c3/boards: Add support APA102/APDS0060 for Shift Game

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6955:
URL: https://github.com/apache/incubator-nuttx/pull/6955#discussion_r958120808


##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/Makefile:
##########
@@ -41,6 +41,18 @@ ifeq ($(CONFIG_BOARDCTL_IOCTL),y)
 CSRCS += esp32c3_ioctl.c
 endif
 
+ifeq ($(CONFIG_ESP32C3_SPI),y)
+CSRCS += esp32c3_board_spi.c
+endif
+
+ifeq ($(CONFIG_SENSORS_APDS9960),y)
+  CSRCS += esp32c3_apds9960.c

Review Comment:
   Some places have 2 spaces and other not. Please make it consistent



##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apds9960.c:
##########
@@ -0,0 +1,183 @@
+/****************************************************************************
+ * boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apds9960.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 <errno.h>
+#include <debug.h>
+#include <stdio.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/sensors/apds9960.h>
+#include <arch/board/board.h>
+
+#include "esp32c3.h"
+#include "esp32c3_i2c.h"
+#include "esp32c3_gpio.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Use IO1 as APDS9960 INT */
+
+#define GPIO_APDS9960_INT    1
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+struct esp32c3_apds9960config_s
+{
+  /* Configuration structure as seen by the APDS-9960 driver */
+
+  struct apds9960_config_s config;
+
+  /* Additional private definitions only known to this driver */
+
+  void *arg;  /* Argument to pass to the interrupt handler */
+  xcpt_t isr; /* ISR Handler */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int  apds9960_irq_attach(struct apds9960_config_s *state,
+                                xcpt_t isr, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* A reference to a structure of this type must be passed to the APDS-9960
+ * driver.  This structure provides information about the configuration
+ * of the APDS-9960 and provides some board-specific hooks.
+ *
+ * Memory for this structure is provided by the caller.  It is not copied
+ * by the driver and is presumed to persist while the driver is active. The
+ * memory must be writable because, under certain circumstances, the driver
+ * may modify frequency or X plate resistance values.
+ */
+
+static struct esp32c3_apds9960config_s g_apds9960config =
+{
+  .config =
+    {
+      .irq_attach  = apds9960_irq_attach,
+    },
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* Attach the APDS-9960 interrupt handler to the GPIO interrupt */
+
+static int apds9960_irq_attach(struct apds9960_config_s *state,
+                               xcpt_t isr, void *arg)
+{
+  irqstate_t flags;
+  int ret;
+  int irq = ESP32C3_PIN2IRQ(GPIO_APDS9960_INT);
+
+  sninfo("apds9960_irq_attach\n");
+
+  flags = enter_critical_section();
+
+  /* Configure the pins that will be used as interrupt input */
+
+  esp32c3_configgpio(GPIO_APDS9960_INT, INPUT_FUNCTION_1 | PULLUP);
+
+  /* Make sure the interrupt is disabled */
+
+  esp32c3_gpioirqdisable(irq);
+
+  ret = irq_attach(irq, isr, arg);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: apds9960_irq_attach() failed: %d\n", ret);
+      return ret;
+    }
+
+  /* Setup interrupt for Falling Edge */
+
+  esp32c3_gpioirqenable(irq, FALLING);
+
+  leave_critical_section(flags);
+
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: apds9960_initialize
+ *
+ * Description:
+ *   Initialize and register the APDS9960 gesture sensor.
+ *
+ * Input Parameters:
+ *   devno - The device number, used to build the device path as /dev/gestN
+ *   busno - The I2C bus number
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int apds9960_initialize(int devno, int busno)
+{
+  struct i2c_master_s *i2c;
+  char devpath[12];
+  int ret;
+
+  sninfo("Initializing APDS9960!\n");
+
+  /* Initialize I2C */
+
+  i2c = esp32c3_i2cbus_initialize(busno);
+  if (i2c == NULL)
+    {
+      return -ENODEV;
+    }
+
+  /* Save this i2c in the config */
+
+  g_apds9960config.config.i2c_dev  = i2c;
+  g_apds9960config.config.i2c_addr = APDS9960_I2C_ADDR;
+
+  /* Then register the gesture sensor */
+
+  snprintf(devpath, 12, "/dev/gest%d", devno);

Review Comment:
   ```suggestion
     snprintf(devpath, sizeof(devpath), "/dev/gest%d", devno);
   ```
   



##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apa102.c:
##########
@@ -0,0 +1,109 @@
+/****************************************************************************
+ * boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3_apa102.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 <stdio.h>
+#include <stdbool.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+#include <nuttx/spi/spi.h>
+#include <nuttx/lcd/lcd.h>
+#include <nuttx/lcd/apa102.h>
+
+#include "esp32c3_gpio.h"
+#include "esp32c3_spi.h"
+#include "esp32c3-devkit-rust-1.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define LCD_SPI_PORTNO        2   /* On SPI2 */
+
+#ifndef CONFIG_LCD_CONTRAST
+#  define CONFIG_LCD_CONTRAST 60
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+struct spi_dev_s *g_spidev;
+struct lcd_dev_s *g_lcddev;

Review Comment:
   Do we need `static` here?



##########
boards/risc-v/esp32c3/esp32c3-devkit-rust-1/src/esp32c3-devkit-rust-1.h:
##########
@@ -27,6 +27,10 @@
 
 #include <nuttx/compiler.h>
 
+#ifdef CONFIG_VIDEO_FB
+#include <nuttx/video/fb.h>

Review Comment:
   ```suggestion
   #  include <nuttx/video/fb.h>
   ```
   



-- 
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-unsubscribe@nuttx.apache.org

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