boards: arm: nucleo_l4r5zi: define PWM LEDs

The board had PWM LEDs defined in the blinky_pwm sample, mainly because
it conflicts with SPI1 pinmux. A better approach is to still define the
PWM LEDs in the board but keep the PWM controller disabled by default.
Then, samples just need to enable the PWM controller (and disable SPI if
used simultaneously).

Also updated period to 20ms (reasonable value for a PWM-driven LED).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-04-05 21:12:27 +02:00 committed by Carles Cufí
parent a65cec3042
commit 855cb90b6a
2 changed files with 27 additions and 24 deletions

View file

@ -46,11 +46,23 @@
};
};
pwmleds: pwmleds {
compatible = "pwm-leds";
/* NOTE: disabled by default, PWM1 conflicts with SPI2 */
status = "disabled";
red_pwm_led: red_pwm_led {
pwms = <&pwm1 2 PWM_MSEC(20) (PWM_POLARITY_NORMAL |
PWM_STM32_COMPLEMENTARY)>;
};
};
aliases {
led0 = &green_led_0;
led1 = &blue_led_0;
led2 = &red_led_0;
sw0 = &user_button;
pwm-led0 = &red_pwm_led;
};
};
@ -139,6 +151,16 @@ zephyr_udc0: &usbotg_fs {
status = "okay";
};
&timers1 {
status = "okay";
pwm1: pwm {
/* NOTE: disabled by default, PWM1 conflicts with SPI2 */
pinctrl-0 = <&tim1_ch2n_pb14>;
pinctrl-names = "default";
};
};
&timers2 {
status = "okay";

View file

@ -4,29 +4,10 @@
* Copyright (c) 2022 STMicroelectronics
*/
#include <dt-bindings/pwm/pwm.h>
#include <dt-bindings/pwm/stm32_pwm.h>
/ {
pwmleds {
compatible = "pwm-leds";
red_pwm_led: red_pwm_led {
pwms = <&pwm1 2 4 (PWM_POLARITY_NORMAL | PWM_STM32_COMPLEMENTARY)>;
};
};
aliases {
pwm-led0 = &red_pwm_led;
};
};
&timers1 {
&pwmleds {
status = "okay";
};
&pwm1 {
status = "okay";
pwm1: pwm {
status = "okay";
pinctrl-0 = <&tim1_ch2n_pb14>;
pinctrl-names = "default";
};
};