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/06/29 07:31:55 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6540: ESP32-S2: Improvements to the GPIO driver

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


##########
arch/xtensa/src/esp32s2/esp32s2_gpio.c:
##########
@@ -61,27 +57,55 @@ static int g_gpio_cpuint;
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: is_valid_gpio
+ *
+ * Description:
+ *   Check if the requested pin is a valid GPIO pin.
+ *
+ * Input Parameters:
+ *   pin  - Pin to be checked for validity.
+ *
+ * Returned Value:
+ *   True if the requested pin is a valid GPIO pin, false otherwise.
+ *
+ ****************************************************************************/
+
+static inline bool is_valid_gpio(uint32_t pin)
+{
+  /* ESP32-S2 has 43 GPIO pins numbered from 0 to 21 and 26 to 46 */
+
+  return pin <= 21 || (pin >= 26 && pin < ESP32S2_NPINS);
+}
+
 /****************************************************************************
  * Name: gpio_dispatch
  *
  * Description:
  *   Second level dispatch for GPIO interrupt handling.
  *
+ * Input Parameters:
+ *   irq           - GPIO IRQ number.
+ *   status        - Value from the GPIO interrupt status clear register.
+ *   regs          - Saved CPU context.
+ *
+ * Returned Value:
+ *   None.
+ *
  ****************************************************************************/
 
 #ifdef CONFIG_ESP32S2_GPIO_IRQ
 static void gpio_dispatch(int irq, uint32_t status, uint32_t *regs)
 {
   uint32_t mask;
-  int i;
 
   /* Check each bit in the status register */
 
-  for (i = 0; i < 32 && status != 0; i++)
+  for (int i = 0; i < 32 && status != 0; i++)

Review Comment:
   does C99 allow this? I think yes, but I'm not sure



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