14#include "pico/stdlib.h"
15#include "hardware/pwm.h"
16#include "hardware/clocks.h"
67 bool phase_correct =
false,
68 bool ch_A_inverted =
false,
69 bool ch_B_inverted =
false);
76 void start(
bool enabled);
99 void set_irq(irq_handler_t handler);
void clear_irq()
clear the slice IRQ
Definition hw_pwm.cpp:67
PWM(uint gpio_ch_A, uint gpio_ch_B, int step_ns, int period_us, bool phase_correct=false, bool ch_A_inverted=false, bool ch_B_inverted=false)
Construct a new PWM object assuming free running sys_clk @125 MHz => sys_clk_period = 8 ns PERIOD = 8...
Definition hw_pwm.cpp:7
uint period_us
the period of the signal provided by PWM
Definition hw_pwm.h:30
void set_width_nb_of_step(uint gpio_pin, uint16_t level)
Set the pulse width in terms number of step object.
Definition hw_pwm.cpp:47
void set_irq(irq_handler_t handler)
Set the irq handler, executed each time the PWM counter wrap to 0.
Definition hw_pwm.cpp:58
static void StartTogether()
All the defined PWM slices will be synchronised.
Definition hw_pwm.cpp:37
static uint32_t slice_mask
a class variable that hold the slice number for the PWM object
Definition hw_pwm.h:37
void set_duty_cycle(uint gpio_pin, float duty_cycle)
Set the pulse width in terms of duty cycle.
Definition hw_pwm.cpp:52
void start(bool enabled)
start and stop the current PWM slice
Definition hw_pwm.cpp:42
uint step_ns
the minimal pulse provided by the PWM
Definition hw_pwm.h:28
uint8_t slice
the hardware PWM slice of the Pico that handle this PWM signal
Definition hw_pwm.h:26
float measure_duty_cycle()
compute the time the channel B is HI over the time of observation
Definition hw_pwm.cpp:91
uint16_t count_cycles()
gives the number of step while the signal on channel B is HI
Definition hw_pwm.cpp:97
uint measure_duration_us
the operture windows during witch the PWM will count signal
Definition hw_pwm.h:118
uint resolution_ns
the minimum time slot as measure LSB
Definition hw_pwm.h:120
PWMgatedMeasure(uint pin_gate, uint resolution_ns, uint measure_duration_us)
Construct a new PWMgatedMeasure object.
Definition hw_pwm.cpp:72
uint8_t slice
the hardware PWM slice of the Pico that handle this PWM signal
Definition hw_pwm.h:116