From 1930a1e20bc45acd5a18b27ba6dc982e6ebfaaac Mon Sep 17 00:00:00 2001 From: Klaus Nagel Date: Fri, 6 Sep 2024 11:57:31 +0200 Subject: [PATCH] boards: st: nucleo_g431kb: add pwm Add support for pwm to run the bliky_pwm sample. Signed-off-by: Klaus Nagel --- boards/st/nucleo_g431kb/doc/index.rst | 5 ++++- boards/st/nucleo_g431kb/nucleo_g431kb.dts | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/boards/st/nucleo_g431kb/doc/index.rst b/boards/st/nucleo_g431kb/doc/index.rst index 071fb14bc83a843..3ea55476583b752 100644 --- a/boards/st/nucleo_g431kb/doc/index.rst +++ b/boards/st/nucleo_g431kb/doc/index.rst @@ -51,6 +51,8 @@ The Zephyr nucleo_g431kb board configuration supports the following hardware fea +-----------+------------+-------------------------------------+ | GPIO | on-chip | gpio | +-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ Other hardware features are not yet supported on this Zephyr port. @@ -74,6 +76,7 @@ Default Zephyr Peripheral Mapping: - LPUART_1_TX : PA2 - LPUART_1_RX : PA3 - LD2 : PB8 +- PWM_4_CH_3 : PB8 System Clock ------------ @@ -136,7 +139,7 @@ You should see the following message on the console: .. code-block:: console - $ Hello World! arm + $ Hello World! nucleo_g431kb/stm32g431xx Debugging diff --git a/boards/st/nucleo_g431kb/nucleo_g431kb.dts b/boards/st/nucleo_g431kb/nucleo_g431kb.dts index c71b0ac9547b82c..4f1a5d971b0d268 100644 --- a/boards/st/nucleo_g431kb/nucleo_g431kb.dts +++ b/boards/st/nucleo_g431kb/nucleo_g431kb.dts @@ -28,8 +28,18 @@ }; + pwmleds { + compatible = "pwm-leds"; + + green_pwm_led: green_pwm_led { + pwms = <&pwm4 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; + + aliases { led0 = &green_led; + pwm-led0 = &green_pwm_led; watchdog0 = &iwdg; }; }; @@ -69,6 +79,18 @@ status = "okay"; }; +&timers4 { + st,prescaler = <10000>; + status = "okay"; + + pwm4: pwm { + status = "okay"; + pinctrl-0 = <&tim4_ch3_pb8>; + pinctrl-names = "default"; + }; +}; + + &flash0 { partitions {