HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
hf_pwm_channel_config_t Struct Reference

ESP32 PWM channel configuration with comprehensive LEDC feature support. More...

#include <EspTypes_PWM.h>

Public Member Functions

 hf_pwm_channel_config_t () noexcept
 

Public Attributes

hf_gpio_num_t gpio_pin
 GPIO pin for PWM output (check pin matrix)
 
uint8_t channel_id
 Channel ID (0 to variant max)
 
uint8_t timer_id
 Timer ID (0 to variant max)
 
hf_pwm_mode_t speed_mode
 Speed mode configuration.
 
uint32_t frequency_hz
 PWM frequency in Hz (validated against clock source)
 
uint8_t resolution_bits
 PWM resolution in bits (4-14, validated)
 
hf_pwm_clock_source_t clock_source
 Preferred clock source for this channel.
 
uint32_t duty_initial
 Initial duty cycle value (RAW for specified resolution)
 
hf_pwm_intr_type_t intr_type
 Interrupt type configuration.
 
bool invert_output
 Invert output signal polarity.
 
uint32_t hpoint
 High point timing for phase shift (0 to max_duty)
 
uint8_t idle_level
 Idle state level when disabled (0 or 1)
 
bool output_invert
 Hardware output inversion (different from invert_output)
 
hf_pwm_channel_priority_t priority
 Channel priority for eviction decisions.
 
bool is_critical
 Mark as critical (never evict)
 
const char * description
 Optional description for debugging/logging.
 

Detailed Description

ESP32 PWM channel configuration with comprehensive LEDC feature support.

This structure provides complete control over LEDC channel configuration, including advanced features like hardware fade, phase shifting, and resource protection. All parameters are validated against hardware constraints.

Core Configuration:

  • GPIO Pin: Any valid GPIO pin (check ESP32 variant pin matrix)
  • Channel/Timer: Automatic assignment or manual control
  • Frequency/Resolution: Explicit control with validation
  • Clock Source: Per-channel preference (subject to variant constraints)

Advanced Features:

  • Phase Shift (hpoint): Delay PWM start within period (0 to max_duty)
  • Output Inversion: Hardware-level signal inversion
  • Idle Level: Output state when PWM is disabled
  • Priority System: Protection against resource eviction

Usage Examples:

// Basic LED dimming
hf_pwm_channel_config_t led_config = {};
led_config.gpio_pin = 2;
led_config.frequency_hz = 1000; // 1kHz
led_config.resolution_bits = 10; // 10-bit (0-1023)
led_config.duty_initial = 512; // 50% brightness
// Motor control with high resolution
hf_pwm_channel_config_t motor_config = {};
motor_config.gpio_pin = 4;
motor_config.frequency_hz = 20000; // 20kHz (above audible range)
motor_config.resolution_bits = 12; // 12-bit (0-4095) for smooth control
motor_config.is_critical = true; // Protect from eviction
motor_config.description = "Motor PWM";
// Servo control with precise timing
hf_pwm_channel_config_t servo_config = {};
servo_config.gpio_pin = 18;
servo_config.frequency_hz = 50; // 50Hz (20ms period)
servo_config.resolution_bits = 14; // 14-bit for microsecond precision
servo_config.clock_source = HF_PWM_CLK_SRC_APB; // Stable timing
@ HF_PWM_CLK_SRC_APB
APB clock (80MHz) - recommended for most uses.
ESP32 PWM channel configuration with comprehensive LEDC feature support.
Definition EspTypes_PWM.h:306
hf_pwm_clock_source_t clock_source
Preferred clock source for this channel.
Definition EspTypes_PWM.h:315
const char * description
Optional description for debugging/logging.
Definition EspTypes_PWM.h:329
hf_gpio_num_t gpio_pin
GPIO pin for PWM output (check pin matrix)
Definition EspTypes_PWM.h:307
uint32_t duty_initial
Initial duty cycle value (RAW for specified resolution)
Definition EspTypes_PWM.h:317
uint32_t frequency_hz
PWM frequency in Hz (validated against clock source)
Definition EspTypes_PWM.h:313
bool is_critical
Mark as critical (never evict)
Definition EspTypes_PWM.h:328
uint8_t resolution_bits
PWM resolution in bits (4-14, validated)
Definition EspTypes_PWM.h:314

Constructor & Destructor Documentation

◆ hf_pwm_channel_config_t()

hf_pwm_channel_config_t::hf_pwm_channel_config_t ( )
inlinenoexcept

Member Data Documentation

◆ channel_id

uint8_t hf_pwm_channel_config_t::channel_id

Channel ID (0 to variant max)

◆ clock_source

hf_pwm_clock_source_t hf_pwm_channel_config_t::clock_source

Preferred clock source for this channel.

◆ description

const char* hf_pwm_channel_config_t::description

Optional description for debugging/logging.

◆ duty_initial

uint32_t hf_pwm_channel_config_t::duty_initial

Initial duty cycle value (RAW for specified resolution)

◆ frequency_hz

uint32_t hf_pwm_channel_config_t::frequency_hz

PWM frequency in Hz (validated against clock source)

◆ gpio_pin

hf_gpio_num_t hf_pwm_channel_config_t::gpio_pin

GPIO pin for PWM output (check pin matrix)

◆ hpoint

uint32_t hf_pwm_channel_config_t::hpoint

High point timing for phase shift (0 to max_duty)

◆ idle_level

uint8_t hf_pwm_channel_config_t::idle_level

Idle state level when disabled (0 or 1)

◆ intr_type

hf_pwm_intr_type_t hf_pwm_channel_config_t::intr_type

Interrupt type configuration.

◆ invert_output

bool hf_pwm_channel_config_t::invert_output

Invert output signal polarity.

◆ is_critical

bool hf_pwm_channel_config_t::is_critical

Mark as critical (never evict)

◆ output_invert

bool hf_pwm_channel_config_t::output_invert

Hardware output inversion (different from invert_output)

◆ priority

hf_pwm_channel_priority_t hf_pwm_channel_config_t::priority

Channel priority for eviction decisions.

◆ resolution_bits

uint8_t hf_pwm_channel_config_t::resolution_bits

PWM resolution in bits (4-14, validated)

◆ speed_mode

hf_pwm_mode_t hf_pwm_channel_config_t::speed_mode

Speed mode configuration.

◆ timer_id

uint8_t hf_pwm_channel_config_t::timer_id

Timer ID (0 to variant max)


The documentation for this struct was generated from the following file: