idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::pwm Namespace Reference

Classes

class  output
 An active PWM output binding a timer, channel, and GPIO pin. More...
 
struct  output_config
 Output configuration parameters. More...
 
class  timer
 A lightweight identifier for a hardware PWM timer. More...
 

Enumerations

enum class  speed_mode : int { speed_mode::low_speed = 0 }
 PWM speed mode selection. More...
 
enum class  channel : int {
  channel::ch_0 = 0 ,
  channel::ch_1 ,
  channel::ch_2 ,
  channel::ch_3 ,
  channel::ch_4 ,
  channel::ch_5
}
 PWM channel slot identifiers. More...
 
enum class  clk_source : int { clk_source::auto_select = 0 }
 PWM timer clock source. More...
 
enum class  fade_mode : int {
  fade_mode::no_wait = 0 ,
  fade_mode::wait_done
}
 Fade operation blocking mode. More...
 
enum class  sleep_mode : int {
  sleep_mode::no_alive_no_pd = 0 ,
  sleep_mode::no_alive_allow_pd ,
  sleep_mode::keep_alive
}
 Channel behavior during light sleep. More...
 

Functions

output start (idfxx::gpio gpio, const timer &tmr, enum channel ch)
 Starts PWM output on a GPIO pin.
 
output start (idfxx::gpio gpio, const timer &tmr, enum channel ch, const output_config &cfg)
 Starts PWM output on a GPIO pin with custom configuration.
 
output start (idfxx::gpio gpio, const timer::config &cfg)
 Starts PWM output with automatic timer and channel allocation.
 
output start (idfxx::gpio gpio, const timer::config &cfg, const output_config &out_cfg)
 Starts PWM output with automatic allocation and custom output configuration.
 
void stop (enum channel ch, enum speed_mode mode=speed_mode::low_speed, idfxx::gpio::level idle_level=idfxx::gpio::level::low)
 Stops PWM output on a channel and sets it to an idle level.
 
result< outputtry_start (idfxx::gpio gpio, const timer &tmr, enum channel ch)
 Starts PWM output on a GPIO pin.
 
result< outputtry_start (idfxx::gpio gpio, const timer &tmr, enum channel ch, const output_config &cfg)
 Starts PWM output on a GPIO pin with custom configuration.
 
result< outputtry_start (idfxx::gpio gpio, const timer::config &cfg)
 Starts PWM output with automatic timer and channel allocation.
 
result< outputtry_start (idfxx::gpio gpio, const timer::config &cfg, const output_config &out_cfg)
 Starts PWM output with automatic allocation and custom output configuration.
 
bool is_active (enum channel ch, enum speed_mode mode=speed_mode::low_speed)
 Returns true if the specified channel currently has an active output.
 
std::optional< timerget_timer (enum channel ch, enum speed_mode mode=speed_mode::low_speed)
 Returns the timer associated with an active channel, if any.
 
result< voidtry_stop (enum channel ch, enum speed_mode mode=speed_mode::low_speed, idfxx::gpio::level idle_level=idfxx::gpio::level::low)
 Stops PWM output on a channel and sets it to an idle level.
 

Variables

constexpr timer timer_0 = timer_constant<0, speed_mode::low_speed>::value
 
constexpr timer timer_1 = timer_constant<1, speed_mode::low_speed>::value
 
constexpr timer timer_2 = timer_constant<2, speed_mode::low_speed>::value
 
constexpr timer timer_3 = timer_constant<3, speed_mode::low_speed>::value