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

commit 3ac88f0f97663426dc699e5e28d5d9a3ec8b7e35
Author: Ricard Rosson <[email protected]>
AuthorDate: Tue Aug 11 09:13:42 2026 +0100

    drivers/lcd: honour the LCD_APA102_* settings in the apa102 LCD driver
    
    drivers/lcd/Kconfig offers CONFIG_LCD_APA102_XRES, CONFIG_LCD_APA102_YRES 
and
    CONFIG_LCD_APA102_FREQUENCY under "if LCD_APA102", but apa102_lcd.c tests 
for
    CONFIG_APA102_XRES, CONFIG_APA102_YRES and CONFIG_APA102_FREQUENCY, which no
    Kconfig file defines.  The #ifndef fallbacks therefore always win and the
    matrix geometry is hard-wired to 16x16 no matter what is configured.  The
    frequency setting is doubly dead: even the fallback is unused, because
    apa102_configspi() calls SPI_SETFREQUENCY() with APA102_SPI_MAXFREQUENCY 
from
    include/nuttx/leds/apa102.h, which is 100 kHz (its "Default 4MHz" comment
    notwithstanding), so the chain is always clocked at 100 kHz.
    
    Use the names the Kconfig actually defines and drive the bus at the
    configured frequency.  The fallback definitions are kept for an
    out-of-Kconfig build and given the Kconfig defaults; 16x16 keeps the 
previous
    geometry for anyone who never set the options.
    
    Verified on stm32f4discovery:nsh with CONFIG_LCD_APA102_XRES=8,
    CONFIG_LCD_APA102_YRES=4 and CONFIG_LCD_APA102_FREQUENCY=4000000: the shadow
    framebuffer in g_apa102dev shrinks to 8x4 LEDs and the SPI frequency
    argument is 0x003d0900, where before the settings had no effect at all.
    
    Signed-off-by: Ricard Rosson <[email protected]>
    Assisted-by: Claude Opus 5 (Claude Code)
---
 drivers/lcd/apa102_lcd.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/lcd/apa102_lcd.c b/drivers/lcd/apa102_lcd.c
index 908fc44f50f..636a8cfdbf0 100644
--- a/drivers/lcd/apa102_lcd.c
+++ b/drivers/lcd/apa102_lcd.c
@@ -51,12 +51,14 @@
 
 /* APA102 Configuration Settings:
  *
- * CONFIG_APA102_XRES - Specifies the number of physical
+ * CONFIG_LCD_APA102_XRES - Specifies the number of physical
  *   APA102 devices that are connected together horizontally.
  *
- * CONFIG_APA102_YRES - Specifies the number of physical
+ * CONFIG_LCD_APA102_YRES - Specifies the number of physical
  *   APA102 devices that are connected together vertically.
  *
+ * CONFIG_LCD_APA102_FREQUENCY - SPI frequency used to drive the chain.
+ *
  * CONFIG_LCD_INTENSITY - Defines the default bright of LEDs.
  *
  * Required LCD driver settings:
@@ -68,24 +70,24 @@
 
 /* SPI frequency */
 
-#ifndef CONFIG_APA102_FREQUENCY
-#  define CONFIG_APA102_FREQUENCY 10000000
+#ifndef CONFIG_LCD_APA102_FREQUENCY
+#  define CONFIG_LCD_APA102_FREQUENCY 1000000
 #endif
 
 /* APA102_COLUMNS determines the number of physical LEDs
  * matrices that are used connected horizontally.
  */
 
-#ifndef CONFIG_APA102_XRES
-#  define CONFIG_APA102_XRES 16
+#ifndef CONFIG_LCD_APA102_XRES
+#  define CONFIG_LCD_APA102_XRES 16
 #endif
 
 /* APA102_LINES determines the number of physical LEDs
  * matrices that are used connected vertically.
  */
 
-#ifndef CONFIG_APA102_YRES
-#  define CONFIG_APA102_YRES 16
+#ifndef CONFIG_LCD_APA102_YRES
+#  define CONFIG_LCD_APA102_YRES 16
 #endif
 
 /* Check contrast selection */
@@ -98,8 +100,8 @@
 
 /* Display Resolution */
 
-#define APA102_XRES         CONFIG_APA102_XRES
-#define APA102_YRES         CONFIG_APA102_YRES
+#define APA102_XRES         CONFIG_LCD_APA102_XRES
+#define APA102_YRES         CONFIG_LCD_APA102_YRES
 
 /* Color depth and format */
 
@@ -318,7 +320,7 @@ static inline void apa102_configspi(FAR struct spi_dev_s 
*spi)
   SPI_SETMODE(spi, SPIDEV_MODE0);
   SPI_SETBITS(spi, 8);
   SPI_HWFEATURES(spi, 0);
-  SPI_SETFREQUENCY(spi, APA102_SPI_MAXFREQUENCY);
+  SPI_SETFREQUENCY(spi, CONFIG_LCD_APA102_FREQUENCY);
 }
 
 /****************************************************************************

Reply via email to