This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new fd9ef2f  fix: Correct issues with userled support on the Nucleo F4x1RE.
fd9ef2f is described below

commit fd9ef2f6a22aefdc1a3f26c9c99007b0645c21ff
Author: Ryan Abel <[email protected]>
AuthorDate: Fri Oct 29 21:37:49 2021 -0500

    fix: Correct issues with userled support on the Nucleo F4x1RE.
    
    Remove space following left parenthesis.
    
    Add space after comment.
    
    Update stm32_bringup.c
---
 boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c | 26 ++++++++++++++++++++++
 .../arm/stm32/nucleo-f4x1re/src/stm32_userleds.c   | 22 +++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c 
b/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c
index 33d3090..a2aabd8 100644
--- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c
@@ -37,6 +37,10 @@
 
 #include <arch/board/board.h>
 
+#ifdef CONFIG_USERLED
+#  include <nuttx/leds/userled.h>
+#endif
+
 #include "nucleo-f4x1re.h"
 
 #include <nuttx/board.h>
@@ -45,6 +49,17 @@
 #include "board_qencoder.h"
 #endif
 
+#undef HAVE_LEDS
+#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
+#  define HAVE_LEDS 1
+#endif
+
+#ifdef CONFIG_EXAMPLES_LEDS_DEVPATH
+#  define LED_DRIVER_PATH CONFIG_EXAMPLES_LEDS_DEVPATH
+#else
+#  define LED_DRIVER_PATH "/dev/userleds"
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -67,6 +82,17 @@ int stm32_bringup(void)
 {
   int ret = OK;
 
+#ifdef HAVE_LEDS
+  /* Register the LED driver */
+
+  ret = userled_lower_initialize(LED_DRIVER_PATH);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+      return ret;
+    }
+#endif
+
   /* Configure SPI-based devices */
 
 #ifdef CONFIG_STM32_SPI1
diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c 
b/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c
index 89caf86..92d0b5b 100644
--- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c
+++ b/boards/arm/stm32/nucleo-f4x1re/src/stm32_userleds.c
@@ -164,7 +164,7 @@ uint32_t board_userled_initialize(void)
 
 void board_userled(int led, bool ledon)
 {
-  if (led == 1)
+  if (BOARD_LD2_BIT == (1 << led))
     {
       stm32_gpiowrite(GPIO_LD2, ledon);
     }
@@ -176,9 +176,29 @@ void board_userled(int led, bool ledon)
 
 void board_userled_all(uint32_t ledset)
 {
+  /* An output of '1' illuminates the LED */
+
   stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LD2_BIT) != 0);
 }
 
+#ifdef CONFIG_USERLED_LOWER_READSTATE
+/****************************************************************************
+ * Name: board_userled_getall
+ ****************************************************************************/
+
+void board_userled_getall(uint32_t *ledset)
+{
+  /* Clear the LED bits */
+
+  *ledset = 0;
+
+  /* Get LED state. An output of '1' illuminates the LED. */
+
+  *ledset |= ((stm32_gpioread(GPIO_LD2) & 1) << BOARD_LD2);
+}
+
+#endif /* CONFIG_USERLED_LOWER_READSTATE */
+
 /****************************************************************************
  * Name: stm32_led_pminitialize
  ****************************************************************************/

Reply via email to