|
Internal Interface Wrap
API reference
|
STM32 PWM implementation. More...
#include <StmPwm.h>
Static Public Attributes | |
| static constexpr hf_u8_t | kMaxChannels = 4 |
Private Member Functions | |
| bool | ApplyFrequency (hf_frequency_hz_t freq_hz) noexcept |
| Apply freq by recalculating PSC + ARR. | |
| void | ReapplyDuties () noexcept |
| Reapply all cached duty cycles after ARR change. | |
Static Private Member Functions | |
| static hf_u32_t | ChannelToHal (hf_channel_id_t ch) noexcept |
| Get HAL channel constant from 0-based index. | |
Private Attributes | |
| TIM_HandleTypeDef * | htim_ |
| hf_u32_t | timer_clock_hz_ |
| bool | channel_enabled_ [kMaxChannels] |
| float | duty_ [kMaxChannels] |
| Cached duty 0.0–1.0. | |
| hf_frequency_hz_t | frequency_hz_ |
| Current frequency (shared) | |
Additional Inherited Members | |
Static Public Member Functions inherited from BasePwm | |
| 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 inherited from BasePwm | |
| BasePwm () noexcept | |
| BasePwm (const BasePwm &)=delete | |
| BasePwm & | operator= (const BasePwm &)=delete |
| BasePwm (BasePwm &&)=delete | |
| BasePwm & | operator= (BasePwm &&)=delete |
Protected Attributes inherited from BasePwm | |
| bool | initialized_ |
| Initialization state. | |
| hf_pwm_statistics_t | statistics_ |
| PWM operation statistics. | |
| hf_pwm_diagnostics_t | diagnostics_ |
| PWM diagnostic information. | |
STM32 PWM implementation.
Design:
|
explicitnoexcept |
Construct from HAL timer handle.
| htim | CubeMX timer handle. |
| timer_clock_hz | APB timer input clock (e.g. 84 MHz). |
|
explicitnoexcept |
Construct from config struct.
|
overridenoexcept |
|
privatenoexcept |
Apply freq by recalculating PSC + ARR.
|
staticprivatenoexcept |
Get HAL channel constant from 0-based index.
|
overridevirtualnoexcept |
Deinitialize the PWM system.
Implements BasePwm.
|
overridevirtualnoexcept |
Disable a PWM channel.
| channel_id | Channel to disable |
Implements BasePwm.
|
overridevirtualnoexcept |
Enable a PWM channel.
| channel_id | Channel to enable |
Implements BasePwm.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get current frequency for a channel.
| channel_id | Channel identifier |
Implements BasePwm.
|
inlinenoexcept |
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Check if a channel is enabled.
| channel_id | Channel to check |
Implements BasePwm.
|
privatenoexcept |
Reapply all cached duty cycles after ARR change.
|
overridevirtualnoexcept |
Set complementary output configuration (for motor control)
| primary_channel | Primary channel |
| complementary_channel | Complementary channel |
| deadtime_ns | Deadtime in nanoseconds |
Implements BasePwm.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Set raw duty value for a channel.
| channel_id | Channel identifier |
| raw_value | Raw duty register value |
Implements BasePwm.
|
overridevirtualnoexcept |
Set frequency for a channel.
| channel_id | Channel identifier |
| frequency_hz | Frequency in Hz |
Implements BasePwm.
|
overridevirtualnoexcept |
Set phase shift for a channel (if supported)
| channel_id | Channel identifier |
| phase_shift_degrees | Phase shift in degrees (0-360) |
Implements BasePwm.
|
overridevirtualnoexcept |
Start all enabled channels simultaneously.
Implements BasePwm.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Update all channel outputs simultaneously (for synchronized updates)
Implements BasePwm.
|
private |
|
private |
Cached duty 0.0–1.0.
|
private |
Current frequency (shared)
|
private |
|
private |