Skip to content

Commit

Permalink
boards: arm: ucans32k1sic: enable FlexTimer/PWM support
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
manuargue committed Dec 26, 2023
1 parent 0a717e1 commit d9ca916
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 9 deletions.
34 changes: 25 additions & 9 deletions boards/arm/ucans32k1sic/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GPIO on-chip gpio
LPUART on-chip serial
LPI2C on-chip i2c
LPSPI on-chip spi
FTM on-chip pwm
============ ========== ================================

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

The UCANS32K1SIC board has one user RGB LED:

======================= ============== =====
Devicetree node Label Pin
======================= ============== =====
led0 / led1_red LED1_RGB_RED PTD15
led1 / led1_green LED1_RGB_GREEN PTD16
led2 / led1_blue LED1_RGB_BLUE PTD0
======================= ============== =====
The UCANS32K1SIC board has one user RGB LED that can be used either as a GPIO
LED or as a PWM LED.

.. table:: RGB LED as GPIO LED
:widths: auto

=============== ================ =============== =====
Devicetree node Devicetree alias Label Pin
=============== ================ =============== =====
led1_red led0 LED1_RGB_RED PTD15
led1_green led1 LED1_RGB_GREEN PTD16
led1_blue led2 LED1_RGB_BLUE PTD0
=============== ================ =============== =====

.. table:: RGB LED as PWM LED
:widths: auto

=============== ======================== ================== ================
Devicetree node Devicetree alias Label Pin
=============== ======================== ================== ================
led1_red_pwm pwm-led0 / red-pwm-led LED1_RGB_RED_PWM PTD15 / FTM0_CH0
led1_green_pwm pwm-led1 / green-pwm-led LED1_RGB_GREEN_PWM PTD16 / FTM0_CH1
led1_blue_pwm pwm-led2 / blue-pwm-led LED1_RGB_BLUE_PWM PTD0 / FTM0_CH2
=============== ======================== ================== ================

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

Expand Down
23 changes: 23 additions & 0 deletions boards/arm/ucans32k1sic/ucans32k1sic-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,27 @@
drive-strength = "low";
};
};

ftm0_default: ftm0_default {
group0 {
pinmux = <FTM0_CH0_PTD15>,
<FTM0_CH1_PTD16>,
<FTM0_CH2_PTD0>;
drive-strength = "low";
};
};

ftm1_default: ftm1_default {
group0 {
pinmux = <FTM1_CH1_PTA1>;
drive-strength = "low";
};
};

ftm2_default: ftm2_default {
group0 {
pinmux = <FTM2_CH1_PTA0>;
drive-strength = "low";
};
};
};
50 changes: 50 additions & 0 deletions boards/arm/ucans32k1sic/ucans32k1sic.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dts-v1/;
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <arm/nxp/nxp_s32k146.dtsi>
#include "ucans32k1sic-pinctrl.dtsi"

Expand All @@ -26,6 +27,13 @@
led0 = &led1_red;
led1 = &led1_green;
led2 = &led1_blue;
pwm-led0 = &led1_red_pwm;
pwm-led1 = &led1_green_pwm;
pwm-led2 = &led1_blue_pwm;
red-pwm-led = &led1_red_pwm;
green-pwm-led = &led1_green_pwm;
blue-pwm-led = &led1_blue_pwm;
pwm-0 = &ftm0;
sw0 = &button_3;
i2c-0 = &lpi2c0;
};
Expand All @@ -47,6 +55,23 @@
};
};

pwmleds {
compatible = "pwm-leds";

led1_red_pwm: led_pwm_0 {
pwms = <&ftm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
label = "LED1_RGB_RED_PWM";
};
led1_green_pwm: led_pwm_1 {
pwms = <&ftm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
label = "LED1_RGB_GREEN_PWM";
};
led1_blue_pwm: led_pwm_2 {
pwms = <&ftm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
label = "LED1_RGB_BLUE_PWM";
};
};

gpio_keys {
compatible = "gpio-keys";

Expand Down Expand Up @@ -104,3 +129,28 @@
pinctrl-names = "default";
status = "okay";
};

&ftm0 {
compatible = "nxp,kinetis-ftm-pwm";
pinctrl-0 = <&ftm0_default>;
pinctrl-names = "default";
prescaler = <128>;
#pwm-cells = <3>;
status = "okay";
};

&ftm1 {
compatible = "nxp,kinetis-ftm-pwm";
pinctrl-0 = <&ftm1_default>;
pinctrl-names = "default";
#pwm-cells = <3>;
status = "okay";
};

&ftm2 {
compatible = "nxp,kinetis-ftm-pwm";
pinctrl-0 = <&ftm2_default>;
pinctrl-names = "default";
#pwm-cells = <3>;
status = "okay";
};
1 change: 1 addition & 0 deletions boards/arm/ucans32k1sic/ucans32k1sic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ supported:
- pinctrl
- i2c
- spi
- pwm

0 comments on commit d9ca916

Please sign in to comment.