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 e16d1218ae arm/stm32f401rc-rs485: Add support to WS2812 addressable LED e16d1218ae is described below commit e16d1218ae1f7505c54a1aba11177e558ad5b94e Author: Rodrigo Sim <rcsi...@gmail.com> AuthorDate: Sat Oct 12 10:45:54 2024 -0300 arm/stm32f401rc-rs485: Add support to WS2812 addressable LED Signed-off-by: Rodrigo Sim <rcsi...@gmail.com> --- .../arm/stm32f4/boards/stm32f401rc-rs485/index.rst | 23 +++++++- .../stm32f401rc-rs485/configs/ws2812/defconfig | 68 ++++++++++++++++++++++ .../stm32/stm32f401rc-rs485/src/stm32_bringup.c | 14 +++++ .../stm32f401rc-rs485/src/stm32f401rc-rs485.h | 4 ++ 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst b/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst index 95c1087812..196af0e3a3 100644 --- a/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst @@ -748,6 +748,27 @@ NSH commands:: WRITING: 0000: 1b5b471b5b30304c1b5b4548656c6c6f 204e75747458 .[G.[00L.[EHello NuttX Test complete - nsh> + nsh> + +ws2812 +------ + +This configuration sets up the NuttShell (NSH) interface over USB Serial (refer to the usbserial +configuration for details). It also enables the driver for an addressable LED WS2812 and the SPI1. +The MOSI pin from SPI must be connected to DIN on WS2812 module and the number of LEDs can be +configured using CONFIG_WS2812_LED_COUNT. + + +======= ==== + WS2812 PINS +======= ==== +DIN PA7 +======= ==== + +NSH commands:: + + NuttShell (NSH) NuttX-12.7.0-RC0 + nsh> ws2812 + diff --git a/boards/arm/stm32/stm32f401rc-rs485/configs/ws2812/defconfig b/boards/arm/stm32/stm32f401rc-rs485/configs/ws2812/defconfig new file mode 100644 index 0000000000..d0ad24b472 --- /dev/null +++ b/boards/arm/stm32/stm32f401rc-rs485/configs/ws2812/defconfig @@ -0,0 +1,68 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="stm32f401rc-rs485" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_STM32F401RC_RS485=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32F401RC=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_USBDEVCTRL=y +CONFIG_BOARD_LOOPSPERMSEC=8499 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_EXAMPLES_BUTTONS=y +CONFIG_EXAMPLES_BUTTONS_NAME0="SW3" +CONFIG_EXAMPLES_BUTTONS_NAME1="SW4" +CONFIG_EXAMPLES_BUTTONS_NAME2="SW5" +CONFIG_EXAMPLES_BUTTONS_NAMES=y +CONFIG_EXAMPLES_BUTTONS_QTD=3 +CONFIG_EXAMPLES_WS2812=y +CONFIG_EXAMPLES_WS2812_DEFAULT_DEV="/dev/leddrv0" +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_INPUT_BUTTONS=y +CONFIG_INPUT_BUTTONS_LOWER=y +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=98304 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=5 +CONFIG_START_MONTH=5 +CONFIG_START_YEAR=2014 +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_OTGFS=y +CONFIG_STM32_PWR=y +CONFIG_STM32_SPI1=y +CONFIG_STM32_USART6=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USBDEV=y +CONFIG_WS2812=y +CONFIG_WS2812_FREQUENCY=9000000 +CONFIG_WS2812_LED_COUNT=10 diff --git a/boards/arm/stm32/stm32f401rc-rs485/src/stm32_bringup.c b/boards/arm/stm32/stm32f401rc-rs485/src/stm32_bringup.c index fb03c70efa..96c904e3ad 100644 --- a/boards/arm/stm32/stm32f401rc-rs485/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32f401rc-rs485/src/stm32_bringup.c @@ -83,6 +83,10 @@ #include "stm32_lcd_backpack.h" #endif +#ifdef CONFIG_WS2812 +#include "stm32_ws2812.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -328,5 +332,15 @@ int stm32_bringup(void) } #endif +#if defined(CONFIG_WS2812) && defined(CONFIG_WS2812_LED_COUNT) + /* Configure and initialize the WS2812 LEDs. */ + + ret = board_ws2812_initialize(0, WS2812_SPI, CONFIG_WS2812_LED_COUNT); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_ws2812_initialize() failed: %d\n", ret); + } +#endif + return ret; } diff --git a/boards/arm/stm32/stm32f401rc-rs485/src/stm32f401rc-rs485.h b/boards/arm/stm32/stm32f401rc-rs485/src/stm32f401rc-rs485.h index d123bb0374..8e55a96154 100644 --- a/boards/arm/stm32/stm32f401rc-rs485/src/stm32f401rc-rs485.h +++ b/boards/arm/stm32/stm32f401rc-rs485/src/stm32f401rc-rs485.h @@ -124,6 +124,10 @@ GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5) #endif +/* WS2812 LEDs SPI */ + +#define WS2812_SPI 1 + /* PWM * * The STM32F401RC-RS485 has no real on-board PWM devices, but the board can