1
0
Fork 0
forked from nuttx/nuttx-update

stm32h7/linum-stm32h753bi: fixed leds example

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2024-04-02 20:34:10 -03:00 committed by Alan Carvalho de Assis
parent 252e0f8a97
commit 0fae71f239
4 changed files with 25 additions and 26 deletions

View file

@ -478,8 +478,18 @@ This example use the timer 4 with channel 2 to generate a PWM output signal on b
leds 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 nsh> leds
leds_main: Starting the led_daemon leds_main: Starting the led_daemon
leds_main: led_daemon started leds_main: led_daemon started

View file

@ -5,8 +5,10 @@
# You can then do "make savedefconfig" to generate a new defconfig file that includes your # You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications. # modifications.
# #
# CONFIG_ARCH_LEDS is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set # CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_QUOTE is not set
# CONFIG_STANDARD_SERIAL is not set # CONFIG_STANDARD_SERIAL is not set
# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set # CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
CONFIG_ARCH="arm" CONFIG_ARCH="arm"

View file

@ -49,19 +49,6 @@
#define GPIO_LED_GREEN GPIO_LD2 #define GPIO_LED_GREEN GPIO_LD2
#define GPIO_LED_BLUE GPIO_LD3 #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 */ /* Check if we can support the RTC driver */
#define HAVE_RTC_DRIVER 1 #define HAVE_RTC_DRIVER 1

View file

@ -37,7 +37,7 @@
#include "stm32.h" #include "stm32.h"
#include "linum-stm32h753bi.h" #include "linum-stm32h753bi.h"
#ifdef CONFIG_USERLED #ifndef CONFIG_ARCH_LEDS
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -47,9 +47,9 @@
static uint32_t g_ledcfg[BOARD_NLEDS] = static uint32_t g_ledcfg[BOARD_NLEDS] =
{ {
GPIO_LED1, GPIO_LED_RED,
GPIO_LED2, GPIO_LED_GREEN,
GPIO_LED3 GPIO_LED_BLUE
}; };
/**************************************************************************** /****************************************************************************
@ -165,10 +165,10 @@ uint32_t board_userled_initialize(void)
{ {
/* Configure LED1-4 GPIOs for output */ /* Configure LED1-4 GPIOs for output */
stm32_configgpio(GPIO_LED1); stm32_configgpio(GPIO_LED_RED);
stm32_configgpio(GPIO_LED2); stm32_configgpio(GPIO_LED_GREEN);
stm32_configgpio(GPIO_LED3); stm32_configgpio(GPIO_LED_BLUE);
return LED_NUM; return BOARD_NLEDS;
} }
/**************************************************************************** /****************************************************************************
@ -177,7 +177,7 @@ uint32_t board_userled_initialize(void)
void board_userled(int led, bool ledon) void board_userled(int led, bool ledon)
{ {
if ((unsigned)led < LED_NUM) if ((unsigned)led < BOARD_NLEDS)
{ {
stm32_gpiowrite(g_ledcfg[led], ledon); stm32_gpiowrite(g_ledcfg[led], ledon);
} }
@ -189,9 +189,9 @@ void board_userled(int led, bool ledon)
void board_userled_all(uint32_t ledset) void board_userled_all(uint32_t ledset)
{ {
stm32_gpiowrite(GPIO_LED1, (ledset & LED1_BIT) == 0); stm32_gpiowrite(GPIO_LED_RED, (ledset & BOARD_LED1_BIT) == 0);
stm32_gpiowrite(GPIO_LED2, (ledset & LED2_BIT) == 0); stm32_gpiowrite(GPIO_LED_GREEN, (ledset & BOARD_LED2_BIT) == 0);
stm32_gpiowrite(GPIO_LED3, (ledset & LED3_BIT) == 0); stm32_gpiowrite(GPIO_LED_BLUE, (ledset & BOARD_LED3_BIT) == 0);
} }
/**************************************************************************** /****************************************************************************