Skip to content

Commit a38eb9b

Browse files
manuarguecarlescufi
authored andcommitted
boards: arm: ucans32k1sic: enable FlexTimer/PWM support
Enable FlexTimer (FTM) as a PWM controller for this board. Use the RGB LED controlled by FTM0 as PWM-LEDs for the samples and tests. Signed-off-by: Manuel Argüelles <[email protected]>
1 parent aeebe48 commit a38eb9b

File tree

4 files changed

+99
-9
lines changed

4 files changed

+99
-9
lines changed

boards/arm/ucans32k1sic/doc/index.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ GPIO on-chip gpio
4949
LPUART on-chip serial
5050
LPI2C on-chip i2c
5151
LPSPI on-chip spi
52+
FTM on-chip pwm
5253
============ ========== ================================
5354

5455
The default configuration can be found in the Kconfig file
@@ -67,15 +68,30 @@ children nodes with the desired pinmux configuration to the singleton node
6768
LEDs
6869
----
6970

70-
The UCANS32K1SIC board has one user RGB LED:
71-
72-
======================= ============== =====
73-
Devicetree node Label Pin
74-
======================= ============== =====
75-
led0 / led1_red LED1_RGB_RED PTD15
76-
led1 / led1_green LED1_RGB_GREEN PTD16
77-
led2 / led1_blue LED1_RGB_BLUE PTD0
78-
======================= ============== =====
71+
The UCANS32K1SIC board has one user RGB LED that can be used either as a GPIO
72+
LED or as a PWM LED.
73+
74+
.. table:: RGB LED as GPIO LED
75+
:widths: auto
76+
77+
=============== ================ =============== =====
78+
Devicetree node Devicetree alias Label Pin
79+
=============== ================ =============== =====
80+
led1_red led0 LED1_RGB_RED PTD15
81+
led1_green led1 LED1_RGB_GREEN PTD16
82+
led1_blue led2 LED1_RGB_BLUE PTD0
83+
=============== ================ =============== =====
84+
85+
.. table:: RGB LED as PWM LED
86+
:widths: auto
87+
88+
=============== ======================== ================== ================
89+
Devicetree node Devicetree alias Label Pin
90+
=============== ======================== ================== ================
91+
led1_red_pwm pwm-led0 / red-pwm-led LED1_RGB_RED_PWM PTD15 / FTM0_CH0
92+
led1_green_pwm pwm-led1 / green-pwm-led LED1_RGB_GREEN_PWM PTD16 / FTM0_CH1
93+
led1_blue_pwm pwm-led2 / blue-pwm-led LED1_RGB_BLUE_PWM PTD0 / FTM0_CH2
94+
=============== ======================== ================== ================
7995

8096
The user can control the LEDs in any way. An output of ``0`` illuminates the LED.
8197

boards/arm/ucans32k1sic/ucans32k1sic-pinctrl.dtsi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,27 @@
3737
drive-strength = "low";
3838
};
3939
};
40+
41+
ftm0_default: ftm0_default {
42+
group0 {
43+
pinmux = <FTM0_CH0_PTD15>,
44+
<FTM0_CH1_PTD16>,
45+
<FTM0_CH2_PTD0>;
46+
drive-strength = "low";
47+
};
48+
};
49+
50+
ftm1_default: ftm1_default {
51+
group0 {
52+
pinmux = <FTM1_CH1_PTA1>;
53+
drive-strength = "low";
54+
};
55+
};
56+
57+
ftm2_default: ftm2_default {
58+
group0 {
59+
pinmux = <FTM2_CH1_PTA0>;
60+
drive-strength = "low";
61+
};
62+
};
4063
};

boards/arm/ucans32k1sic/ucans32k1sic.dts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/dts-v1/;
88
#include <zephyr/dt-bindings/gpio/gpio.h>
99
#include <zephyr/dt-bindings/input/input-event-codes.h>
10+
#include <zephyr/dt-bindings/pwm/pwm.h>
1011
#include <arm/nxp/nxp_s32k146.dtsi>
1112
#include "ucans32k1sic-pinctrl.dtsi"
1213

@@ -26,6 +27,13 @@
2627
led0 = &led1_red;
2728
led1 = &led1_green;
2829
led2 = &led1_blue;
30+
pwm-led0 = &led1_red_pwm;
31+
pwm-led1 = &led1_green_pwm;
32+
pwm-led2 = &led1_blue_pwm;
33+
red-pwm-led = &led1_red_pwm;
34+
green-pwm-led = &led1_green_pwm;
35+
blue-pwm-led = &led1_blue_pwm;
36+
pwm-0 = &ftm0;
2937
sw0 = &button_3;
3038
i2c-0 = &lpi2c0;
3139
};
@@ -47,6 +55,23 @@
4755
};
4856
};
4957

58+
pwmleds {
59+
compatible = "pwm-leds";
60+
61+
led1_red_pwm: led_pwm_0 {
62+
pwms = <&ftm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
63+
label = "LED1_RGB_RED_PWM";
64+
};
65+
led1_green_pwm: led_pwm_1 {
66+
pwms = <&ftm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
67+
label = "LED1_RGB_GREEN_PWM";
68+
};
69+
led1_blue_pwm: led_pwm_2 {
70+
pwms = <&ftm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
71+
label = "LED1_RGB_BLUE_PWM";
72+
};
73+
};
74+
5075
gpio_keys {
5176
compatible = "gpio-keys";
5277

@@ -104,3 +129,28 @@
104129
pinctrl-names = "default";
105130
status = "okay";
106131
};
132+
133+
&ftm0 {
134+
compatible = "nxp,kinetis-ftm-pwm";
135+
pinctrl-0 = <&ftm0_default>;
136+
pinctrl-names = "default";
137+
prescaler = <128>;
138+
#pwm-cells = <3>;
139+
status = "okay";
140+
};
141+
142+
&ftm1 {
143+
compatible = "nxp,kinetis-ftm-pwm";
144+
pinctrl-0 = <&ftm1_default>;
145+
pinctrl-names = "default";
146+
#pwm-cells = <3>;
147+
status = "okay";
148+
};
149+
150+
&ftm2 {
151+
compatible = "nxp,kinetis-ftm-pwm";
152+
pinctrl-0 = <&ftm2_default>;
153+
pinctrl-names = "default";
154+
#pwm-cells = <3>;
155+
status = "okay";
156+
};

boards/arm/ucans32k1sic/ucans32k1sic.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ supported:
1717
- pinctrl
1818
- i2c
1919
- spi
20+
- pwm

0 commit comments

Comments
 (0)