Struct stm32f4xx_hal::timer::pwm_input::PwmInput
source · pub struct PwmInput<TIM>{ /* private fields */ }
Expand description
Represents a TIMer configured as a PWM input. This peripheral will emit an interrupt on CC2 events, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. An example interrupt handler is provided:
use stm32f4xx_hal::{pac::TIM8, pwm_input::PwmInput};
type Monitor = PwmInput<TIM8>;
fn tim8_cc2(monitor: &Monitor) {
let duty_clocks = monitor.get_duty_cycle_clocks();
let period_clocks = monitor.get_period_clocks();
// check if this interrupt was caused by a capture at the wrong CC2,
// peripheral limitation.
if !monitor.is_valid_capture() {
return;
}
let duty = monitor.get_duty_cycle();
}
Implementations§
source§impl PwmInput<TIM1>
impl PwmInput<TIM1>
sourcepub fn get_period_clocks(&self) -> <TIM1 as General>::Width
pub fn get_period_clocks(&self) -> <TIM1 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM1 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM1 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM2>
impl PwmInput<TIM2>
sourcepub fn get_period_clocks(&self) -> <TIM2 as General>::Width
pub fn get_period_clocks(&self) -> <TIM2 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM2 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM2 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM3>
impl PwmInput<TIM3>
sourcepub fn get_period_clocks(&self) -> <TIM3 as General>::Width
pub fn get_period_clocks(&self) -> <TIM3 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM3 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM3 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM4>
impl PwmInput<TIM4>
sourcepub fn get_period_clocks(&self) -> <TIM4 as General>::Width
pub fn get_period_clocks(&self) -> <TIM4 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM4 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM4 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM5>
impl PwmInput<TIM5>
sourcepub fn get_period_clocks(&self) -> <TIM5 as General>::Width
pub fn get_period_clocks(&self) -> <TIM5 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM5 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM5 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM8>
impl PwmInput<TIM8>
sourcepub fn get_period_clocks(&self) -> <TIM8 as General>::Width
pub fn get_period_clocks(&self) -> <TIM8 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM8 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM8 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM9>
impl PwmInput<TIM9>
sourcepub fn get_period_clocks(&self) -> <TIM9 as General>::Width
pub fn get_period_clocks(&self) -> <TIM9 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM9 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM9 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).
source§impl PwmInput<TIM12>
impl PwmInput<TIM12>
sourcepub fn get_period_clocks(&self) -> <TIM12 as General>::Width
pub fn get_period_clocks(&self) -> <TIM12 as General>::Width
Period of PWM signal in terms of clock cycles
sourcepub fn get_duty_cycle_clocks(&self) -> <TIM12 as General>::Width
pub fn get_duty_cycle_clocks(&self) -> <TIM12 as General>::Width
Duty cycle in terms of clock cycles
sourcepub fn get_duty_cycle(&self) -> f32
pub fn get_duty_cycle(&self) -> f32
Observed duty cycle as a float in range [0.00, 1.00]
sourcepub fn is_valid_capture(&self) -> bool
pub fn is_valid_capture(&self) -> bool
Returns whether the timer’s duty cycle is a valid observation (Limitation of how the captures work is extra CC2 interrupts are generated when the PWM cycle enters a new period).