dts: esp32: full ledc configuration in binding
This commit moves the hardware configuration for ledc peripheral to the device-tree instead of Kconfig. Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
This commit is contained in:
parent
cb32d8e8e9
commit
02675bbc80
13 changed files with 228 additions and 614 deletions
|
|
@ -67,4 +67,34 @@
|
|||
output-high;
|
||||
};
|
||||
|
||||
ledc0_ch0_gpio0: ledc0_ch0_gpio0 {
|
||||
pinmux = <LEDC_CH0_GPIO0>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
ledc0_ch1_gpio2: ledc0_ch1_gpio2 {
|
||||
pinmux = <LEDC_CH1_GPIO2>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
ledc0_ch2_gpio4: ledc0_ch2_gpio4 {
|
||||
pinmux = <LEDC_CH2_GPIO4>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
ledc0_ch8_gpio0: ledc0_ch8_gpio0 {
|
||||
pinmux = <LEDC_CH8_GPIO0>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
ledc0_ch9_gpio2: ledc0_ch9_gpio2 {
|
||||
pinmux = <LEDC_CH9_GPIO2>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
ledc0_ch10_gpio4: ledc0_ch10_gpio4 {
|
||||
pinmux = <LEDC_CH10_GPIO4>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@
|
|||
led0 = &blue_led;
|
||||
led1 = &green_led;
|
||||
led2 = &red_led;
|
||||
pwm-led0 = &pwm_led_red;
|
||||
pwm-led1 = &pwm_led_green;
|
||||
pwm-led2 = &pwm_led_blue;
|
||||
red-pwm-led = &pwm_led_red;
|
||||
green-pwm-led = &pwm_led_green;
|
||||
blue-pwm-led = &pwm_led_blue;
|
||||
uart-0 = &uart0;
|
||||
i2c-0 = &i2c0;
|
||||
};
|
||||
|
|
@ -46,6 +52,22 @@
|
|||
label = "Red - LED2";
|
||||
};
|
||||
};
|
||||
|
||||
pwmleds {
|
||||
compatible = "pwm-leds";
|
||||
pwm_led_red: pwm_led_0 {
|
||||
label = "Red PWM LED";
|
||||
pwms = <&ledc0 0 PWM_HZ(100) PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
pwm_led_green: pwm_led_1 {
|
||||
label = "Green PWM LED";
|
||||
pwms = <&ledc0 1 PWM_HZ(100) PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
pwm_led_blue: pwm_led_2 {
|
||||
label = "Blue PWM LED";
|
||||
pwms = <&ledc0 2 PWM_HZ(100) PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
|
|
@ -111,6 +133,26 @@
|
|||
};
|
||||
};
|
||||
|
||||
&ledc0 {
|
||||
pinctrl-0 = <&ledc0_ch0_gpio0 &ledc0_ch1_gpio2 &ledc0_ch2_gpio4>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
channel0@0 {
|
||||
reg = <0x0>;
|
||||
timer = <0>;
|
||||
};
|
||||
channel1@1 {
|
||||
reg = <0x1>;
|
||||
timer = <1>;
|
||||
};
|
||||
channel2@2 {
|
||||
reg = <0x2>;
|
||||
timer = <2>;
|
||||
};
|
||||
};
|
||||
|
||||
&timer0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,3 +23,7 @@ CONFIG_GEN_IRQ_VECTOR_TABLE=n
|
|||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
CONFIG_LED=y
|
||||
CONFIG_LED_PWM=y
|
||||
CONFIG_PWM_LED_ESP32=y
|
||||
|
|
|
|||
|
|
@ -3,554 +3,8 @@
|
|||
# Copyright (c) 2017 Vitor Massaru Iha <vitor@massaru.org>
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig PWM_LED_ESP32
|
||||
config PWM_LED_ESP32
|
||||
bool "ESP32 PWM LED driver"
|
||||
help
|
||||
This option enables the PWM LED driver for ESP32 family of
|
||||
processors. Say y if you wish to use PWM LED port on ESP32.
|
||||
|
||||
if PWM_LED_ESP32
|
||||
|
||||
config PWM_LED_ESP32_DEV_NAME_0
|
||||
string "ESP32 PWM LED Name"
|
||||
default "PWM_LED"
|
||||
help
|
||||
Specify the device name for the PWM driver.
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH
|
||||
bool "Set high speed channels"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH0
|
||||
bool "Channel 0"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH0
|
||||
|
||||
config PWM_LED_ESP32_HS_CH0_GPIO
|
||||
int "GPIO number"
|
||||
default 13
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH0_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH0
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH1
|
||||
bool "Channel 1"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH1
|
||||
|
||||
config PWM_LED_ESP32_HS_CH1_GPIO
|
||||
int "GPIO number"
|
||||
default 12
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH1_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH1
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH2
|
||||
bool "Channel 2"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH2
|
||||
|
||||
config PWM_LED_ESP32_HS_CH2_GPIO
|
||||
int "GPIO number"
|
||||
default 14
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH2_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH2
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH3
|
||||
bool "Channel 3"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH3
|
||||
|
||||
config PWM_LED_ESP32_HS_CH3_GPIO
|
||||
int "GPIO number"
|
||||
default 27
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH3_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH3
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH4
|
||||
bool "Channel 4"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH4
|
||||
|
||||
config PWM_LED_ESP32_HS_CH4_GPIO
|
||||
int "GPIO number"
|
||||
default 26
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH4_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH4
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH5
|
||||
bool "Channel 5"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH5
|
||||
|
||||
config PWM_LED_ESP32_HS_CH5_GPIO
|
||||
int "GPIO number"
|
||||
default 25
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH5_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH5
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH6
|
||||
bool "Channel 6"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH6
|
||||
|
||||
config PWM_LED_ESP32_HS_CH6_GPIO
|
||||
int "GPIO number"
|
||||
default 33
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH6_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH6
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_CH7
|
||||
bool "Channel 7"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_CH7
|
||||
|
||||
config PWM_LED_ESP32_HS_CH7_GPIO
|
||||
int "GPIO number"
|
||||
default 32
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_HS_CH7_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH7
|
||||
|
||||
endif # PWM_LED_ESP32_HS_CH
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH
|
||||
bool "Set low speed channels"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH0
|
||||
bool "Channel 0"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH0
|
||||
|
||||
config PWM_LED_ESP32_LS_CH0_GPIO
|
||||
int "GPIO number"
|
||||
default 6
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH0_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH0
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH1
|
||||
bool "Channel 1"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH1
|
||||
|
||||
config PWM_LED_ESP32_LS_CH1_GPIO
|
||||
int "GPIO number"
|
||||
default 7
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH1_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH1
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH2
|
||||
bool "Channel 2"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH2
|
||||
|
||||
config PWM_LED_ESP32_LS_CH2_GPIO
|
||||
int "GPIO number"
|
||||
default 8
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH2_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH2
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH3
|
||||
bool "Channel 3"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH3
|
||||
|
||||
config PWM_LED_ESP32_LS_CH3_GPIO
|
||||
int "GPIO number"
|
||||
default 15
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH3_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH3
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH4
|
||||
bool "Channel 4"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH4
|
||||
|
||||
config PWM_LED_ESP32_LS_CH4_GPIO
|
||||
int "GPIO number"
|
||||
default 16
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH4_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH4
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH5
|
||||
bool "Channel 5"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH5
|
||||
|
||||
config PWM_LED_ESP32_LS_CH5_GPIO
|
||||
int "GPIO number"
|
||||
default 17
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH5_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH5
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH6
|
||||
bool "Channel 6"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH6
|
||||
|
||||
config PWM_LED_ESP32_LS_CH6_GPIO
|
||||
int "GPIO number"
|
||||
default 19
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH6_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH6
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_CH7
|
||||
bool "Channel 7"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_CH7
|
||||
|
||||
config PWM_LED_ESP32_LS_CH7_GPIO
|
||||
int "GPIO number"
|
||||
default 21
|
||||
range 0 39
|
||||
help
|
||||
GPIO number, allowed values: 0 - 19, 21 - 23, 25 - 27 and 32 - 39.
|
||||
|
||||
config PWM_LED_ESP32_LS_CH7_TIMER
|
||||
int "Set timer"
|
||||
default 0
|
||||
range 0 3
|
||||
help
|
||||
Timer source channel, allowed values: 0 - 4.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH7
|
||||
|
||||
endif # PWM_LED_ESP32_LS_CH
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_TIMER
|
||||
bool "Set high speed timers"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_TIMER
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_TIMER0
|
||||
bool "Set timer 0"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_TIMER0
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER0_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER0_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_TIMER0
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_TIMER1
|
||||
bool "Set timer 1"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_TIMER1
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER1_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER1_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_TIMER1
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_TIMER2
|
||||
bool "Set timer 2"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_TIMER2
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER2_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER2_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_TIMER2
|
||||
|
||||
menuconfig PWM_LED_ESP32_HS_TIMER3
|
||||
bool "Set timer 3"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_HS_TIMER3
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER3_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_HS_TIMER3_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_HS_TIMER3
|
||||
|
||||
endif # PWM_LED_ESP32_HS_TIMER
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_TIMER
|
||||
bool "Set low speed timers"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_TIMER
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_TIMER0
|
||||
bool "Set timer 0"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_TIMER0
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER0_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER0_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_TIMER0
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_TIMER1
|
||||
bool "Set timer 1"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_TIMER1
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER1_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER1_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_TIMER1
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_TIMER2
|
||||
bool "Set timer 2"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_TIMER2
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER2_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER2_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_TIMER2
|
||||
|
||||
menuconfig PWM_LED_ESP32_LS_TIMER3
|
||||
bool "Set timer 3"
|
||||
default y
|
||||
|
||||
if PWM_LED_ESP32_LS_TIMER3
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER3_FREQ
|
||||
int "Set frequency"
|
||||
default 5000
|
||||
|
||||
config PWM_LED_ESP32_LS_TIMER3_BIT_NUM
|
||||
int "Timer counter precision"
|
||||
default 10
|
||||
range 10 15
|
||||
help
|
||||
PWM timer precision, allowed values: 10 - 15.
|
||||
|
||||
endif # PWM_LED_ESP32_LS_TIMER3
|
||||
|
||||
endif # PWM_LED_ESP32_LS_TIMER
|
||||
|
||||
endif # PWM_LED_ESP32
|
||||
|
|
|
|||
|
|
@ -1,15 +1,117 @@
|
|||
description: ESP32 LEDC
|
||||
# Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
|
||||
Espressif's LEDC controller Node
|
||||
|
||||
The LEDC controller is primarily designed to control the intensity of LEDs, although it can be used to generate
|
||||
PWM signals for other purposes as well.
|
||||
|
||||
The mapping between the channel and GPIO is done through pinctrl
|
||||
|
||||
&ledc0 {
|
||||
pinctrl-0 = <&ledc0_ch0_gpio0>;
|
||||
pinctrl-names = "default";
|
||||
}
|
||||
|
||||
The 'ledc0_ch0_gpio0' node is defined in <board>-pinctrl.dtsi.
|
||||
|
||||
ledc0_ch0_gpio0: ledc0_ch0_gpio0 {
|
||||
pinmux = <LEDC_CH0_GPIO0>;
|
||||
output-enable;
|
||||
};
|
||||
|
||||
If another mapping is desired, just check if the <board>-pinctrl.dtsi already have it defined, or feel free to include a new node.
|
||||
The 'pinmux' property uses a macro defined in https://github.com/zephyrproject-rtos/hal_espressif/tree/zephyr/include/dt-bindings/pinctrl
|
||||
Before including a new node, check if the desired mapping is available according to the SoC.
|
||||
|
||||
It is possible to include multiple channel's mapping in the 'pinmux' property:
|
||||
|
||||
&ledc0 {
|
||||
pinctrl-0 = <&ledc0_ch0_gpio0 &ledc0_ch9_gpio2 &ledc0_ch10_gpio4>;
|
||||
pinctrl-names = "default";
|
||||
}
|
||||
|
||||
Use the child bindings to configure the desired channel:
|
||||
|
||||
&ledc0 {
|
||||
pinctrl-0 = <&ledc0_ch0_gpio0 &ledc0_ch9_gpio2 &ledc0_ch10_gpio4>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
channel0@0 {
|
||||
reg = <0x0>;
|
||||
timer = <0>;
|
||||
};
|
||||
channel9@9 {
|
||||
reg = <0x9>;
|
||||
timer = <0>;
|
||||
};
|
||||
channel10@a {
|
||||
reg = <0xa>;
|
||||
timer = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
Note: The channel's 'reg' property defines the ID of the channel. It must match the channel used in the 'pinmux'.
|
||||
|
||||
|
||||
compatible: "espressif,esp32-ledc"
|
||||
|
||||
include: [pwm-controller.yaml, base.yaml]
|
||||
include: [pwm-controller.yaml, pinctrl-device.yaml, base.yaml]
|
||||
|
||||
properties:
|
||||
label:
|
||||
required: true
|
||||
label:
|
||||
required: true
|
||||
|
||||
"#pwm-cells":
|
||||
const: 3
|
||||
"#pwm-cells":
|
||||
const: 3
|
||||
|
||||
child-binding:
|
||||
description: Channel configuration.
|
||||
|
||||
properties:
|
||||
reg:
|
||||
type: int
|
||||
required: true
|
||||
enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
- 5
|
||||
- 6
|
||||
- 7
|
||||
- 8
|
||||
- 9
|
||||
- 10
|
||||
- 11
|
||||
- 12
|
||||
- 13
|
||||
- 14
|
||||
- 15
|
||||
|
||||
description: |
|
||||
The esp32 has 8 low speed channel and 8 high speed channels.
|
||||
The low speed channel are mapped from channel 0 to 7, and the high speed are mapped from channel 8 to 15.
|
||||
|
||||
High speed channels are only available in the esp32 SoC. Esp32s2 has only 8 available channels, and esp32c3
|
||||
has 6. In these SoCs there is no differentiation between low or high speed.
|
||||
|
||||
timer:
|
||||
type: int
|
||||
required: true
|
||||
enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
description: |
|
||||
Timer selection.
|
||||
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.
|
||||
|
||||
pwm-cells:
|
||||
- channel
|
||||
|
|
|
|||
|
|
@ -134,6 +134,16 @@
|
|||
current-speed = <115200>;
|
||||
};
|
||||
|
||||
ledc0: ledc@60019000 {
|
||||
compatible = "espressif,esp32-ledc";
|
||||
pwm-controller;
|
||||
#pwm-cells = <3>;
|
||||
reg = <0x60019000 0x1000>;
|
||||
label = "LEDC_0";
|
||||
clocks = <&rtc ESP32_LEDC_MODULE>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
timer0: counter@6001f000 {
|
||||
compatible = "espressif,esp32-timer";
|
||||
reg = <0x6001F000 DT_SIZE_K(4)>;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <zephyr/dt-bindings/clock/esp32_clock.h>
|
||||
#include <zephyr/dt-bindings/interrupt-controller/esp-xtensa-intmux.h>
|
||||
#include <dt-bindings/pinctrl/esp32-pinctrl.h>
|
||||
#include <zephyr/dt-bindings/pwm/pwm.h>
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
|
|
@ -135,10 +136,10 @@
|
|||
|
||||
ledc0: ledc@3ff59000 {
|
||||
compatible = "espressif,esp32-ledc";
|
||||
pwm-controller;
|
||||
#pwm-cells = <3>;
|
||||
reg = <0x3ff59000 0x800>;
|
||||
label = "LEDC_0";
|
||||
clocks = <&rtc ESP32_LEDC_MODULE>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,16 @@
|
|||
current-speed = <115200>;
|
||||
};
|
||||
|
||||
ledc0: ledc@3f419000 {
|
||||
compatible = "espressif,esp32-ledc";
|
||||
pwm-controller;
|
||||
#pwm-cells = <3>;
|
||||
reg = <0x3f419000 0x1000>;
|
||||
label = "LEDC_0";
|
||||
clocks = <&rtc ESP32_LEDC_MODULE>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
gpio0: gpio@3f404000 {
|
||||
compatible = "espressif,esp32-gpio";
|
||||
gpio-controller;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 Andrei-Edward Popa
|
||||
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/pwm/pwm.h>
|
||||
#include <dt-bindings/pinctrl/esp32-pinctrl.h>
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
|
|
@ -15,12 +17,27 @@
|
|||
pwmleds {
|
||||
compatible = "pwm-leds";
|
||||
pwm_led_blue: pwm_led_gpio0_2 {
|
||||
label = "PWM LED0";
|
||||
pwms = <&ledc0 2 1000 PWM_POLARITY_NORMAL>;
|
||||
label = "PWM LED0";
|
||||
pwms = <&ledc0 0 1000 PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&ledc0 {
|
||||
status = "okay";
|
||||
&pinctrl {
|
||||
ledc0_ch0_gpio2: ledc0_ch0_gpio2 {
|
||||
pinmux = <LEDC_CH0_GPIO2>;
|
||||
output-enable;
|
||||
};
|
||||
};
|
||||
|
||||
&ledc0 {
|
||||
pinctrl-0 = <&ledc0_ch0_gpio2>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
channel0@0 {
|
||||
reg = <0x0>;
|
||||
timer = <0>;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_LED=y
|
||||
CONFIG_LED_PWM=y
|
||||
CONFIG_PWM_LED_ESP32=y
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/pwm/pwm.h>
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
pwm-0 = &ledc0;
|
||||
pwm-led0 = &pwm_led_blue;
|
||||
};
|
||||
|
||||
pwmleds {
|
||||
compatible = "pwm-leds";
|
||||
pwm_led_blue: pwm_led_gpio0_2 {
|
||||
label = "PWM LED0";
|
||||
pwms = <&ledc0 2 1000 PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&ledc0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
@ -1 +0,0 @@
|
|||
CONFIG_PWM_LED_ESP32=y
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 Andrei-Edward Popa
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/pwm/pwm.h>
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
pwm-0 = &ledc0;
|
||||
pwm-led0 = &pwm_led_blue;
|
||||
};
|
||||
|
||||
pwmleds {
|
||||
compatible = "pwm-leds";
|
||||
pwm_led_blue: pwm_led_gpio0_2 {
|
||||
label = "PWM LED0";
|
||||
pwms = <&ledc0 2 1000 PWM_POLARITY_NORMAL>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&ledc0 {
|
||||
status = "okay";
|
||||
};
|
||||
Loading…
Reference in a new issue