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

PWM controller classes. More...

#include <idfxx/error>
#include <idfxx/gpio>
#include <idfxx/intr_alloc>
#include <algorithm>
#include <chrono>
#include <frequency/frequency>
#include <optional>
#include <string>
#include <utility>
#include "sdkconfig.h"

Go to the source code of this file.

Classes

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

Namespaces

namespace  idfxx
 
namespace  idfxx::pwm
 

Enumerations

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

Functions

output idfxx::pwm::start (idfxx::gpio gpio, const timer &tmr, enum channel ch)
 Starts PWM output on a GPIO pin.
 
output idfxx::pwm::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 idfxx::pwm::start (idfxx::gpio gpio, const timer::config &cfg)
 Starts PWM output with automatic timer and channel allocation.
 
output idfxx::pwm::start (idfxx::gpio gpio, const timer::config &cfg, const output_config &out_cfg)
 Starts PWM output with automatic allocation and custom output configuration.
 
void idfxx::pwm::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< outputidfxx::pwm::try_start (idfxx::gpio gpio, const timer &tmr, enum channel ch)
 Starts PWM output on a GPIO pin.
 
result< outputidfxx::pwm::try_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< outputidfxx::pwm::try_start (idfxx::gpio gpio, const timer::config &cfg)
 Starts PWM output with automatic timer and channel allocation.
 
result< outputidfxx::pwm::try_start (idfxx::gpio gpio, const timer::config &cfg, const output_config &out_cfg)
 Starts PWM output with automatic allocation and custom output configuration.
 
bool idfxx::pwm::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< timeridfxx::pwm::get_timer (enum channel ch, enum speed_mode mode=speed_mode::low_speed)
 Returns the timer associated with an active channel, if any.
 
result< voididfxx::pwm::try_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 idfxx::pwm::timer_0 = timer_constant<0, speed_mode::low_speed>::value
 
constexpr timer idfxx::pwm::timer_1 = timer_constant<1, speed_mode::low_speed>::value
 
constexpr timer idfxx::pwm::timer_2 = timer_constant<2, speed_mode::low_speed>::value
 
constexpr timer idfxx::pwm::timer_3 = timer_constant<3, speed_mode::low_speed>::value
 

Detailed Description

PWM controller classes.

Definition in file pwm.hpp.