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

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

commit 81b775e735aa4cd94bdd9ab26c6c6b61c95ce7c4
Author: Kerogit <[email protected]>
AuthorDate: Tue Oct 13 01:17:48 2026 +0200

    boards/avr/avrdx/breadxavr: added WS2812 LED example
    
    This patch adds an example configuration that enables zero latency
    interrupt functionality, software interrupt emulation and driver
    for WS2812 RGB LEDs
    
    Signed-off-by: Kerogit <[email protected]>
---
 .../platforms/avr/avrdx/boards/breadxavr/index.rst | 11 ++++
 boards/avr/avrdx/breadxavr/Kconfig                 | 11 ++++
 .../avr/avrdx/breadxavr/configs/ws2812/defconfig   | 59 ++++++++++++++++++++++
 boards/avr/avrdx/breadxavr/src/avrdx_init.c        | 37 +++++++++++++-
 4 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst 
b/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst
index 5458fd29e3d..a4e01418933 100644
--- a/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst
+++ b/Documentation/platforms/avr/avrdx/boards/breadxavr/index.rst
@@ -25,6 +25,17 @@ Basic testing configuration. When :menuselection:`Library 
Routines --> Support B
 and :menuselection:`Application Configuration --> NSH Library --> Enable 
built-in applications`
 are both set, allows adding and execution of other applications.
 
+ws2812
+------
+
+Testing configuration with NSH and also ws2812 example from NuttX apps enabled 
and configured
+to have LEDs connected to serial port ``USART2`` and console to ``USART0``.
+
+This configuration uses software interrupt emulation - see 
:doc:`../../docs/software_interrupt`.
+I/O port C pin 3 is used - it is switched to output automatically and must not 
be connected
+to any voltage driving circuitry. If needed, another pin can be chosen instead.
+
+
 Peripheral usage
 ================
 
diff --git a/boards/avr/avrdx/breadxavr/Kconfig 
b/boards/avr/avrdx/breadxavr/Kconfig
index 02f04fa121e..60c1c2b80a1 100644
--- a/boards/avr/avrdx/breadxavr/Kconfig
+++ b/boards/avr/avrdx/breadxavr/Kconfig
@@ -13,4 +13,15 @@ config BREADXAVR_BUTTONS_DRIVER
                If set, button driver registered as /dev/buttons
                for PORT A and PORT C (pins 2 and 3 for both ports.)
 
+config BREADXAVR_WS2812_DRIVER
+       bool "Register default names for WS2812 LEDs"
+       depends on AVR_AVRDX_DRIVER_WS2812
+       default n
+       ---help---
+               If set, all WS2812 lower-half drivers that use builtin
+               peripherals will have their LED device(s) enabled automatically.
+
+               For USART drivers, LED chains will be registered as 
/dev/ledUSARTx
+               with "x" replaced by the index of the peripheral.
+
 endif
diff --git a/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig 
b/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
new file mode 100644
index 00000000000..7f95ca3fd7e
--- /dev/null
+++ b/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
@@ -0,0 +1,59 @@
+#
+# 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="avr"
+CONFIG_ARCH_AVR=y
+CONFIG_ARCH_BOARD="breadxavr"
+CONFIG_ARCH_BOARD_AVRDX_BREADXAVR=y
+CONFIG_ARCH_CHIP="avrdx"
+CONFIG_ARCH_CHIP_AVR128DA28=y
+CONFIG_ARCH_CHIP_AVRDX=y
+CONFIG_AVRDX_HIGH_PRIO_INTERRUPTS=y
+CONFIG_AVRDX_SWINT_GPIO_MUX=y
+CONFIG_AVRDX_SWINT_PIN_NUM=3
+CONFIG_AVRDX_SWINT_PORT_IDX=2
+CONFIG_AVR_AVRDX_DRIVER_WS2812=y
+CONFIG_AVR_AVRDX_GPIO_ISR_MUX=y
+CONFIG_AVR_AVRDX_SWINT=y
+CONFIG_AVR_AVRDX_WS2812_NO_READS=y
+CONFIG_AVR_AVRDX_WS2812_SHORT_LANE=y
+CONFIG_AVR_AVRDX_WS2812_USART2=y
+CONFIG_AVR_LINUXGCC_TOOLCHAIN=y
+CONFIG_AVR_USART0=y
+CONFIG_BREADXAVR_WS2812_DRIVER=y
+CONFIG_BUILTIN=y
+CONFIG_DEFAULT_SMALL=y
+CONFIG_DISABLE_MOUNTPOINT=y
+CONFIG_EXAMPLES_WS2812=y
+CONFIG_EXAMPLES_WS2812_DEFAULT_DEV="/dev/ledUSART2"
+CONFIG_FILE_STREAM=y
+CONFIG_IDLETHREAD_STACKSIZE=512
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=512
+CONFIG_INTELHEX_BINARY=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NUNGET_CHARS=0
+CONFIG_PTHREAD_STACK_DEFAULT=1024
+CONFIG_RAM_SIZE=16384
+CONFIG_RAM_START=0x804000
+CONFIG_RAW_DISASSEMBLY=y
+CONFIG_SCHED_TICKLESS=y
+CONFIG_SCHED_TICKLESS_ALARM=y
+CONFIG_START_DAY=16
+CONFIG_START_MONTH=6
+CONFIG_START_YEAR=2011
+CONFIG_STDIO_BUFFER_SIZE=0
+CONFIG_SYSLOG_CONSOLE=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART0_BAUD=57600
+CONFIG_USART0_SERIAL_CONSOLE=y
+CONFIG_USEC_PER_TICK=500
+CONFIG_WS2812=y
+CONFIG_WS2812_LED_COUNT=4
+CONFIG_WS2812_NON_SPI_DRIVER=y
diff --git a/boards/avr/avrdx/breadxavr/src/avrdx_init.c 
b/boards/avr/avrdx/breadxavr/src/avrdx_init.c
index 9ca31d8a0ee..86c22e4acd0 100644
--- a/boards/avr/avrdx/breadxavr/src/avrdx_init.c
+++ b/boards/avr/avrdx/breadxavr/src/avrdx_init.c
@@ -31,7 +31,9 @@
 #ifdef CONFIG_BREADXAVR_BUTTONS_DRIVER
 #  include <nuttx/input/buttons.h>
 #endif
-
+#ifdef CONFIG_BREADXAVR_WS2812_DRIVER
+#  include "avrdx_ws2812.h"
+#endif
 #include <assert.h>
 #include <avr/io.h>
 
@@ -118,6 +120,39 @@ void board_early_initialize(void)
 
 void board_late_initialize(void)
 {
+#  if defined(CONFIG_BREADXAVR_WS2812_DRIVER)
+  int ret = OK;
+#  endif
+
+#  ifdef CONFIG_BREADXAVR_WS2812_DRIVER
+#    ifdef CONFIG_AVR_AVRDX_WS2812_USART0
+  ret = avrdx_ws2812_register("/dev/ledUSART0", CONFIG_WS2812_LED_COUNT,
+                              AVRDX_WS2812_LANE_USART0, FALSE);
+  if (ret != OK)
+    {
+      PANIC();
+    }
+
+#    endif
+#    ifdef CONFIG_AVR_AVRDX_WS2812_USART1
+  ret = avrdx_ws2812_register("/dev/ledUSART1", CONFIG_WS2812_LED_COUNT,
+                              AVRDX_WS2812_LANE_USART1, FALSE);
+  if (ret != OK)
+    {
+      PANIC();
+    }
+
+#    endif
+#    ifdef CONFIG_AVR_AVRDX_WS2812_USART2
+  ret = avrdx_ws2812_register("/dev/ledUSART2", CONFIG_WS2812_LED_COUNT,
+                              AVRDX_WS2812_LANE_USART2, FALSE);
+  if (ret != OK)
+    {
+      PANIC();
+    }
+
+#    endif
+#  endif
 }
 
 #endif /* CONFIG_BOARD_LATE_INITIALIZE */

Reply via email to