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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0fae71f239 stm32h7/linum-stm32h753bi: fixed leds example
0fae71f239 is described below

commit 0fae71f239587d77491dfd1a278adb0e54478c2b
Author: Jorge Guzman <[email protected]>
AuthorDate: Tue Apr 2 20:34:10 2024 -0300

    stm32h7/linum-stm32h753bi: fixed leds example
    
    Signed-off-by: Jorge Guzman <[email protected]>
---
 .../arm/stm32h7/boards/linum-stm32h753bi/index.rst | 12 ++++++++++-
 .../linum-stm32h753bi/configs/leds/defconfig       |  2 ++
 .../linum-stm32h753bi/src/linum-stm32h753bi.h      | 13 ------------
 .../stm32h7/linum-stm32h753bi/src/stm32_userleds.c | 24 +++++++++++-----------
 4 files changed, 25 insertions(+), 26 deletions(-)

diff --git 
a/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst 
b/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst
index 0fa66201dd..6513090f46 100644
--- a/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst
+++ b/Documentation/platforms/arm/stm32h7/boards/linum-stm32h753bi/index.rst
@@ -478,8 +478,18 @@ This example use the timer 4 with channel 2 to generate a 
PWM output signal on b
 leds
 ------
 
-Example to blink 3 leds, the example use the gpios(PB0, PB1 and PC13) located 
on the expancion IO board::
+Example to blink the RBG led of board, using this example the board led status 
support stop to work::
 
+    # turn on led red
+    printf \x00000001 > /dev/userleds
+
+    # turn on led green
+    printf \x00000002 > /dev/userleds
+
+    # turn on led blue
+    printf \x00000004 > /dev/userleds
+
+    # Run blink leds sample
     nsh> leds
     leds_main: Starting the led_daemon
     leds_main: led_daemon started
diff --git a/boards/arm/stm32h7/linum-stm32h753bi/configs/leds/defconfig 
b/boards/arm/stm32h7/linum-stm32h753bi/configs/leds/defconfig
index 9d63ecd082..51cbb61955 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/configs/leds/defconfig
+++ b/boards/arm/stm32h7/linum-stm32h753bi/configs/leds/defconfig
@@ -5,8 +5,10 @@
 # You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
 # modifications.
 #
+# CONFIG_ARCH_LEDS is not set
 # CONFIG_NSH_DISABLE_IFCONFIG is not set
 # CONFIG_NSH_DISABLE_PS is not set
+# CONFIG_NSH_QUOTE is not set
 # CONFIG_STANDARD_SERIAL is not set
 # CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
 CONFIG_ARCH="arm"
diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h 
b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
index 2d9d3201af..a3e84e130f 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
+++ b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
@@ -49,19 +49,6 @@
 #define GPIO_LED_GREEN   GPIO_LD2
 #define GPIO_LED_BLUE    GPIO_LD3
 
-/* LED of shield */
-
-#define GPIO_LED1       (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
-                        GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN0)
-#define GPIO_LED2       (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
-                        GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN1)
-#define GPIO_LED3       (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
-                        GPIO_OUTPUT_SET | GPIO_PORTC | GPIO_PIN13)
-
-#define LED1_BIT    (1 << 0)
-#define LED2_BIT    (1 << 1)
-#define LED3_BIT    (1 << 2)
-#define LED_NUM     3
 /* Check if we can support the RTC driver */
 
 #define HAVE_RTC_DRIVER 1
diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_userleds.c 
b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_userleds.c
index b71af50b31..3120ff9357 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_userleds.c
+++ b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_userleds.c
@@ -37,7 +37,7 @@
 #include "stm32.h"
 #include "linum-stm32h753bi.h"
 
-#ifdef CONFIG_USERLED
+#ifndef CONFIG_ARCH_LEDS
 
 /****************************************************************************
  * Private Data
@@ -47,9 +47,9 @@
 
 static uint32_t g_ledcfg[BOARD_NLEDS] =
 {
-  GPIO_LED1,
-  GPIO_LED2,
-  GPIO_LED3
+  GPIO_LED_RED,
+  GPIO_LED_GREEN,
+  GPIO_LED_BLUE
 };
 
 /****************************************************************************
@@ -165,10 +165,10 @@ uint32_t board_userled_initialize(void)
 {
   /* Configure LED1-4 GPIOs for output */
 
-  stm32_configgpio(GPIO_LED1);
-  stm32_configgpio(GPIO_LED2);
-  stm32_configgpio(GPIO_LED3);
-  return LED_NUM;
+  stm32_configgpio(GPIO_LED_RED);
+  stm32_configgpio(GPIO_LED_GREEN);
+  stm32_configgpio(GPIO_LED_BLUE);
+  return BOARD_NLEDS;
 }
 
 /****************************************************************************
@@ -177,7 +177,7 @@ uint32_t board_userled_initialize(void)
 
 void board_userled(int led, bool ledon)
 {
-  if ((unsigned)led < LED_NUM)
+  if ((unsigned)led < BOARD_NLEDS)
     {
       stm32_gpiowrite(g_ledcfg[led], ledon);
     }
@@ -189,9 +189,9 @@ void board_userled(int led, bool ledon)
 
 void board_userled_all(uint32_t ledset)
 {
-  stm32_gpiowrite(GPIO_LED1, (ledset & LED1_BIT) == 0);
-  stm32_gpiowrite(GPIO_LED2, (ledset & LED2_BIT) == 0);
-  stm32_gpiowrite(GPIO_LED3, (ledset & LED3_BIT) == 0);
+  stm32_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED1_BIT) == 0);
+  stm32_gpiowrite(GPIO_LED_GREEN, (ledset & BOARD_LED2_BIT) == 0);
+  stm32_gpiowrite(GPIO_LED_BLUE, (ledset & BOARD_LED3_BIT) == 0);
 }
 
 /****************************************************************************

Reply via email to