|
USB EPROM/Flash Programmer
|
Pico PWM Class. More...
#include <pwm.hpp>
Public Member Functions | |
| Pwm (uint pin) | |
| Constructor. More... | |
| ~Pwm () | |
| Destructor. More... | |
| uint | getPin () const |
| Gets the pin number. More... | |
| uint | getSlice () const |
| Gets the slice number of PWM. More... | |
| uint | getChannel () const |
| Gets the PWM channel number. More... | |
| void | setFreq (uint32_t freq) |
| Sets the PWM frequency. More... | |
| uint32_t | getFreq () const |
| Gets the PWM frequency. More... | |
| void | setDuty (float duty) |
| Sets the duty cycle of PWM. More... | |
| float | getDuty () const |
| Gets the duty cycle. More... | |
| void | start () |
| Enables the PWM on the pin. More... | |
| void | stop () |
| Disables the PWM on the pin. More... | |
| bool | isRunning () const |
| Returns if the PWM is enabled on the pin. More... | |
Static Public Attributes | |
| static constexpr uint32_t | kPwmDefaultFreq = 40'000UL |
| PWM default frequency, in Hertz. More... | |
Pico PWM Class.
The purpose of this class is to manipulate the PWM on the board.
Note: Each instance of this class controls only one PWM pin.
|
explicit |
Constructor.
Creates a Pwm class instance with kPwmDefaultFreq frequency and zero duty cycle.
| pin | The pin number. |
| ~Pwm | ( | ) |
Destructor.
| uint getPin | ( | ) | const |
Gets the pin number.
| uint getSlice | ( | ) | const |
Gets the slice number of PWM.
| uint getChannel | ( | ) | const |
Gets the PWM channel number.
| void setFreq | ( | uint32_t | freq | ) |
Sets the PWM frequency.
| freq | PWM frequency, in Hertz. Note: This value must be greater than zero and less than 6.25MHz. |
| uint32_t getFreq | ( | ) | const |
Gets the PWM frequency.
| void setDuty | ( | float | duty | ) |
Sets the duty cycle of PWM.
| duty | Duty cycle, in percent (%). Note: This value must be positive and less than/equal 100%. |
| float getDuty | ( | ) | const |
Gets the duty cycle.
| void start | ( | ) |
Enables the PWM on the pin.
Starts the output of the PWM signal on the pin.
| void stop | ( | ) |
Disables the PWM on the pin.
Stops the output of the PWM signal on the pin, and puts its in low state.
| bool isRunning | ( | ) | const |
Returns if the PWM is enabled on the pin.
|
staticconstexpr |
PWM default frequency, in Hertz.