|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
Abstract base class for PWM implementations. More...
#include <BasePwm.h>
Public Member Functions | |
| virtual | ~BasePwm () noexcept=default |
| virtual hf_pwm_err_t | Initialize () noexcept=0 |
| Initialize the PWM system. | |
| virtual hf_pwm_err_t | Deinitialize () noexcept=0 |
| Deinitialize the PWM system. | |
| bool | IsInitialized () const noexcept |
| Check if PWM system is initialized. | |
| bool | EnsureInitialized () noexcept |
| Ensure PWM is initialized (lazy initialization pattern) | |
| bool | EnsureDeinitialized () noexcept |
| Ensure PWM is deinitialized (lazy deinitialization pattern) | |
| virtual hf_pwm_err_t | EnableChannel (hf_channel_id_t channel_id) noexcept=0 |
| Enable a PWM channel. | |
| virtual hf_pwm_err_t | DisableChannel (hf_channel_id_t channel_id) noexcept=0 |
| Disable a PWM channel. | |
| virtual bool | IsChannelEnabled (hf_channel_id_t channel_id) const noexcept=0 |
| Check if a channel is enabled. | |
| virtual hf_pwm_err_t | SetDutyCycle (hf_channel_id_t channel_id, float duty_cycle) noexcept=0 |
| Set duty cycle for a channel. | |
| virtual hf_pwm_err_t | SetDutyCycleRaw (hf_channel_id_t channel_id, hf_u32_t raw_value) noexcept=0 |
| Set raw duty value for a channel. | |
| virtual hf_pwm_err_t | SetFrequency (hf_channel_id_t channel_id, hf_frequency_hz_t frequency_hz) noexcept=0 |
| Set frequency for a channel. | |
| virtual hf_pwm_err_t | SetPhaseShift (hf_channel_id_t channel_id, float phase_shift_degrees) noexcept=0 |
| Set phase shift for a channel (if supported) | |
| virtual hf_pwm_err_t | StartAll () noexcept=0 |
| Start all enabled channels simultaneously. | |
| virtual hf_pwm_err_t | StopAll () noexcept=0 |
| Stop all channels. | |
| virtual hf_pwm_err_t | UpdateAll () noexcept=0 |
| Update all channel outputs simultaneously (for synchronized updates) | |
| virtual hf_pwm_err_t | SetComplementaryOutput (hf_channel_id_t primary_channel, hf_channel_id_t complementary_channel, hf_u32_t deadtime_ns) noexcept=0 |
| Set complementary output configuration (for motor control) | |
| virtual float | GetDutyCycle (hf_channel_id_t channel_id) const noexcept=0 |
| Get current duty cycle for a channel. | |
| virtual hf_frequency_hz_t | GetFrequency (hf_channel_id_t channel_id) const noexcept=0 |
| Get current frequency for a channel. | |
| virtual hf_pwm_err_t | GetStatistics (hf_pwm_statistics_t &statistics) const noexcept |
| Get PWM statistics. | |
| virtual hf_pwm_err_t | GetDiagnostics (hf_pwm_diagnostics_t &diagnostics) const noexcept |
| Get PWM diagnostics. | |
| virtual hf_pwm_err_t | ResetStatistics () noexcept |
| Reset PWM operation statistics. | |
| virtual hf_pwm_err_t | ResetDiagnostics () noexcept |
| Reset PWM diagnostic information. | |
Static Public Member Functions | |
| static constexpr hf_u32_t | DutyCycleToRaw (float duty_cycle, hf_u8_t resolution_bits) noexcept |
| Calculate raw duty value from percentage. | |
| static constexpr float | RawToDutyCycle (hf_u32_t raw_value, hf_u8_t resolution_bits) noexcept |
| Calculate duty cycle percentage from raw value. | |
| static constexpr bool | IsValidDutyCycle (float duty_cycle) noexcept |
| Validate duty cycle range. | |
| static constexpr bool | IsValidFrequency (hf_u32_t frequency_hz, hf_u32_t min_freq_hz, hf_u32_t max_freq_hz) noexcept |
| Validate frequency range. | |
| static constexpr bool | IsValidRawDuty (hf_u32_t raw_value, hf_u8_t resolution_bits) noexcept |
| Validate raw duty value against resolution. | |
| static constexpr float | CalculateFrequencyAccuracy (hf_u32_t target_freq, hf_u32_t actual_freq) noexcept |
| Calculate frequency accuracy percentage. | |
| static constexpr float | ClampDutyCycle (float duty_cycle) noexcept |
| Clamp duty cycle to valid range. | |
Protected Member Functions | |
| BasePwm () noexcept | |
| BasePwm (const BasePwm &)=delete | |
| BasePwm & | operator= (const BasePwm &)=delete |
| BasePwm (BasePwm &&)=delete | |
| BasePwm & | operator= (BasePwm &&)=delete |
Protected Attributes | |
| bool | initialized_ |
| Initialization state. | |
| hf_pwm_statistics_t | statistics_ |
| PWM operation statistics. | |
| hf_pwm_diagnostics_t | diagnostics_ |
| PWM diagnostic information. | |
Abstract base class for PWM implementations.
This class defines the common interface that all PWM implementations must provide. It supports both on-chip PWM peripherals and external PWM controllers.
Key features:
Possible implementations include on-chip controllers or dedicated PWM chips.
|
virtualdefaultnoexcept |
|
inlineprotectednoexcept |
|
protecteddelete |
|
protecteddelete |
|
inlinestaticconstexprnoexcept |
Calculate frequency accuracy percentage.
| target_freq | Target frequency |
| actual_freq | Actual achieved frequency |
|
inlinestaticconstexprnoexcept |
Clamp duty cycle to valid range.
| duty_cycle | Duty cycle to clamp |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
inlinestaticconstexprnoexcept |
Calculate raw duty value from percentage.
| duty_cycle | Duty cycle (0.0 - 1.0) |
| resolution_bits | PWM resolution in bits |
|
pure virtualnoexcept |
|
inlinenoexcept |
Ensure PWM is deinitialized (lazy deinitialization pattern)
|
inlinenoexcept |
Ensure PWM is initialized (lazy initialization pattern)
|
inlinevirtualnoexcept |
Get PWM diagnostics.
| diagnostics | Diagnostics structure to fill |
Reimplemented in EspPwm.
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
inlinevirtualnoexcept |
Get PWM statistics.
| statistics | Statistics structure to fill |
Reimplemented in EspPwm.
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
inlinenoexcept |
Check if PWM system is initialized.
|
inlinestaticconstexprnoexcept |
Validate duty cycle range.
| duty_cycle | Duty cycle to validate |
|
inlinestaticconstexprnoexcept |
Validate frequency range.
| frequency_hz | Frequency to validate |
| min_freq_hz | Minimum allowed frequency |
| max_freq_hz | Maximum allowed frequency |
|
inlinestaticconstexprnoexcept |
Validate raw duty value against resolution.
| raw_value | Raw duty value to validate |
| resolution_bits | PWM resolution in bits |
|
inlinestaticconstexprnoexcept |
Calculate duty cycle percentage from raw value.
| raw_value | Raw duty value |
| resolution_bits | PWM resolution in bits |
|
inlinevirtualnoexcept |
Reset PWM diagnostic information.
|
inlinevirtualnoexcept |
Reset PWM operation statistics.
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
pure virtualnoexcept |
|
protected |
PWM diagnostic information.
|
protected |
Initialization state.
|
protected |
PWM operation statistics.