11#include <soc/gpio_num.h>
12#include <driver/ledc.h>
13#include <freertos/FreeRTOS.h>
38 static constexpr const char* TAG =
"HAL::LEDC";
41 static constexpr ledc_mode_t SPEED_MODE = LEDC_LOW_SPEED_MODE;
43 mutable SemaphoreHandle_t mutex;
45 struct saved_channel_config_t {
46 ledc_channel_t channel;
50 std::vector<ledc_timer_t> registered_timers;
51 std::vector<saved_channel_config_t> registered_channels;
54 explicit Controller();
68 static Controller _instance;
97 void set_frequency(ledc_timer_t ledc_timer, uint32_t frequency)
const;
105 void set_duty(ledc_channel_t ledc_channel, uint32_t duty)
const;
void shutdown()
Resets all channels and shuts down the controller.
Definition ledc.cpp:38
void set_frequency(ledc_timer_t ledc_timer, uint32_t frequency) const
Sets the frequency of a specific LEDC timer.
Definition ledc.cpp:111
Controller(const Controller &)=delete
void add_channel(const channel_config_t &config)
Configures a new LEDC channel using the given config.
Definition ledc.cpp:81
Controller & operator=(const Controller &)=delete
void set_duty(ledc_channel_t ledc_channel, uint32_t duty) const
Sets the duty cycle of a specific LEDC channel.
Definition ledc.cpp:118
static Controller & get_instance()
Gets the controller instance.
Definition ledc.h:67
void add_timer(const timer_config_t &config)
Configures a new LEDC timer using the given config.
Definition ledc.cpp:63
log_source
Definition log_sources.h:12
@ LOG_SOURCE_HAL_LEDC
Definition log_sources.h:16
A namespace containing all components of the LEDC hardware abstraction layer.
Definition ledc.h:19
uint32_t duty
Definition ledc.h:30
ledc_timer_t timer
Definition ledc.h:28
gpio_num_t gpio_pin
Definition ledc.h:29
ledc_channel_t channel
Definition ledc.h:27
ledc_timer_t timer
Definition ledc.h:21
uint32_t frequency
Definition ledc.h:22
ledc_timer_bit_t resolution
Definition ledc.h:23