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

xiaoxiang 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 fd4dd59c3c Made the PWM frequency of the RGB driver configurable from 
the menu.
fd4dd59c3c is described below

commit fd4dd59c3c43082d7a2b26a6dc91eb5790ba0610
Author: simonatoaca <[email protected]>
AuthorDate: Tue Jul 4 11:35:16 2023 +0300

    Made the PWM frequency of the RGB driver configurable from the menu.
    
    Signed-off-by: simonatoaca <[email protected]>
---
 drivers/leds/Kconfig  | 7 +++++++
 drivers/leds/rgbled.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 176b448278..15dcb5f664 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -71,6 +71,13 @@ config RGBLED
                This selection enables building of the "upper-half" RGB LED 
driver.
                See include/nuttx/rgbled.h for further PWM driver information.
 
+config RGBLED_PWM_FREQ
+       int "PWM Frequency (Hz)"
+       depends on RGBLED
+       default 100
+       ---help---
+               This controls the frequency of the PWM channel powering each 
led.
+
 config RGBLED_INVERT
        bool "Invert RGB LED Output"
        depends on RGBLED
diff --git a/drivers/leds/rgbled.c b/drivers/leds/rgbled.c
index 4fad504425..b20380de70 100644
--- a/drivers/leds/rgbled.c
+++ b/drivers/leds/rgbled.c
@@ -360,7 +360,7 @@ static ssize_t rgbled_write(FAR struct file *filep, FAR 
const char *buffer,
 
 #ifdef CONFIG_PWM_MULTICHAN
   memset(&pwm, 0, sizeof(struct pwm_info_s));
-  pwm.frequency = 100;
+  pwm.frequency = CONFIG_RGBLED_PWM_FREQ;
 
   i = 0;
   pwm.channels[i].duty = red;
@@ -433,7 +433,7 @@ static ssize_t rgbled_write(FAR struct file *filep, FAR 
const char *buffer,
       ledb->ops->start(ledb, &pwm);
     }
 #else
-  pwm.frequency = 100;
+  pwm.frequency = CONFIG_RGBLED_PWM_FREQ;
 
   pwm.duty = red;
   ledr->ops->start(ledr, &pwm);

Reply via email to