11#include <soc/gpio_num.h>
12#include <driver/ledc.h>
13#include <freertos/FreeRTOS.h>
37 static constexpr const char* TAG =
"HAL::LEDC";
39 static constexpr ledc_mode_t SPEED_MODE = LEDC_LOW_SPEED_MODE;
41 mutable SemaphoreHandle_t mutex;
43 struct saved_channel_config_t {
44 ledc_channel_t channel;
48 std::vector<ledc_timer_t> registered_timers;
49 std::vector<saved_channel_config_t> registered_channels;
52 explicit Controller();
66 static Controller _instance;
95 void set_frequency(ledc_timer_t ledc_timer, uint32_t frequency)
const;
103 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:32
void set_frequency(ledc_timer_t ledc_timer, uint32_t frequency) const
Sets the frequency of a specific LEDC timer.
Definition ledc.cpp:99
Controller(const Controller &)=delete
void add_channel(const channel_config_t &config)
Configures a new LEDC channel using the given config.
Definition ledc.cpp:73
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:104
static Controller & get_instance()
Gets the controller instance.
Definition ledc.h:65
void add_timer(const timer_config_t &config)
Configures a new LEDC timer using the given config.
Definition ledc.cpp:57
A namespace containing all components of the LEDC hardware abstraction layer.
Definition ledc.h:18
uint32_t duty
Definition ledc.h:29
ledc_timer_t timer
Definition ledc.h:27
gpio_num_t gpio_pin
Definition ledc.h:28
ledc_channel_t channel
Definition ledc.h:26
ledc_timer_t timer
Definition ledc.h:20
uint32_t frequency
Definition ledc.h:21
ledc_timer_bit_t resolution
Definition ledc.h:22