Skip to content

Commit

Permalink
drivers: pwm_led: esp32: Add inverted flag
Browse files Browse the repository at this point in the history
Add inverted flag to bindings, as pwms field is supposed
to be used by application only.

Signed-off-by: Raffael Rostagno <[email protected]>
  • Loading branch information
Raffael Rostagno authored and kartben committed Jan 18, 2025
1 parent 17752ad commit fc8119d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/pwm/pwm_led_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ PINCTRL_DT_INST_DEFINE(0);
.timer_num = DT_PROP(node_id, timer), \
.speed_mode = DT_REG_ADDR(node_id) < SOC_LEDC_CHANNEL_NUM ? LEDC_LOW_SPEED_MODE \
: !LEDC_LOW_SPEED_MODE, \
.inverted = DT_PWMS_FLAGS(node_id), \
.inverted = DT_PROP(node_id, inverted), \
},

static struct pwm_ledc_esp32_channel_config channel_config[] = {
Expand Down
14 changes: 13 additions & 1 deletion dts/bindings/pwm/espressif,esp32-ledc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

description: |
Expand Down Expand Up @@ -64,13 +64,17 @@ description: |
channel9@9 {
reg = <0x9>;
timer = <0>;
inverted;
};
channel10@a {
reg = <0xa>;
timer = <1>;
};
};
For the channel to be initially inverted after the driver's init, the flag 'inverted' can
be declared, as shown above for channel 9.
Note: The channel's 'reg' property defines the ID of the channel. It must match the channel used
in the 'pinmux'.
Expand Down Expand Up @@ -130,6 +134,14 @@ child-binding:
For maximum flexibility, the high-speed as well as the low-speed channels can be driven from
one of four high-speed/low-speed timers.
inverted:
type: boolean
description: |
Initial channel output level.
This flag defines if the channel will remain initially inverted after driver init,
as any pwm_set() operation will re-evaluate if the output is inverted or not
according to the flag passed as parameter.
pwm-cells:
- channel
- period
Expand Down

0 comments on commit fc8119d

Please sign in to comment.