Skip to content
Permalink
Browse files

boards: arm: twr_ke18f: add PWM LEDs

Add support for driving the on-board LEDs present on the NXP TWR-KE18F
development board using FlexTimer (FTM) PWM modulation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
  • Loading branch information...
henrikbrixandersen authored and MaureenHelm committed May 19, 2019
1 parent 67126be commit 9fae4b03105294f5d90c2517b4ca356d91007440
@@ -89,4 +89,14 @@ config ADC_0

endif # ADC

if PWM

config PWM_0
default y

config PWM_3
default y

endif # PWM

endif # BOARD_TWR_KE18F
@@ -82,6 +82,8 @@ features:
+-----------+------------+-------------------------------------+
| WDT | on-chip | watchdog |
+-----------+------------+-------------------------------------+
| PWM | on-chip | pwm |
+-----------+------------+-------------------------------------+

The default configuration can be found in the defconfig file:
``boards/arm/twr_ke18f/twr_ke18f_defconfig``.
@@ -34,14 +34,31 @@ static int twr_ke18f_pinmux_init(struct device *dev)
device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME);
#endif

/* LEDs */
#ifdef CONFIG_PWM_0
/* Tri-color LED as PWM */
pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAlt2));
#else /* !CONFIG_PWM_0 */
/* Tri-color LED as GPIO */
pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif /* !CONFIG_PWM_0 */

#ifdef CONFIG_PWM_3
/* User LEDs as PWM */
pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portc, 12, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portc, 13, PORT_PCR_MUX(kPORT_MuxAlt2));
#else /* !CONFIG_PWM_3 */
/* User LEDs as GPIO */
pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 12, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 13, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif /* !CONFIG_PWM_3 */

/* Buttons */
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAsGpio));
@@ -21,6 +21,13 @@
led4 = &tri_red_led;
led5 = &tri_green_led;
led6 = &tri_blue_led;
pwm-led0 = &orange_pwm_led;
pwm-led1 = &yellow_pwm_led;
pwm-led2 = &green_pwm_led;
pwm-led3 = &red_pwm_led;
red-pwm-led = &tri_red_pwm_led;
green-pwm-led = &tri_green_pwm_led;
blue-pwm-led = &tri_blue_pwm_led;
sw0 = &user_button_3;
sw1 = &user_button_2;
};
@@ -67,6 +74,39 @@
};
};

pwmleds {
compatible = "pwm-leds";
orange_pwm_led: led_pwm_0 {
pwms = <&ftm3 7 60000>;
label = "User PWM LED D9";
};
yellow_pwm_led: led_pwm_1 {
pwms = <&ftm3 6 60000>;
label = "User PWM LED D8";
};
green_pwm_led: led_pwm_2 {
pwms = <&ftm3 5 60000>;
label = "User PWM LED D7";
};
red_pwm_led: led_pwm_3 {
pwms = <&ftm3 4 60000>;
label = "User PWM LED D6";
};

tri_red_pwm_led: led_pwm_4 {
pwms = <&ftm0 1 60000>;
label = "User Tricolor PWM LED D5 (Red)";
};
tri_green_pwm_led: led_pwm_5 {
pwms = <&ftm0 0 60000>;
label = "User Tricolor PWM LED D5 (Green)";
};
tri_blue_pwm_led: led_pwm_6 {
pwms = <&ftm0 5 60000>;
label = "User Tricolor PWM LED D5 (Blue)";
};
};

gpio_keys {
compatible = "gpio-keys";
user_button_2: button_0 {
@@ -118,6 +158,14 @@
current-speed = <115200>;
};

&ftm0 {
status = "okay";
};

&ftm3 {
status = "okay";
};

&i2c0 {
status = "okay";

@@ -17,3 +17,4 @@ supported:
- adc
- can
- watchdog
- pwm

0 comments on commit 9fae4b0

Please sign in to comment.
You can’t perform that action at this time.