|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Output-only PWM wrapper with period and duty configuration. More...
#include <pwm.hpp>


Classes | |
| struct | Config |
| Configuration structure for PWM output setup. More... | |
Public Member Functions | |
| PwmOut (uint32_t pin) | |
| Create a PWM output with default configuration. | |
| PwmOut (uint32_t pin, const Config &config) | |
| Create a PWM output with the given configuration. | |
| virtual | ~PwmOut () |
| Destructor. | |
| void | Configure (const Config &config) |
| Apply a new configuration. | |
| void | SetPeriodUs (float period_us) |
| Set PWM period in microseconds. | |
| void | SetDutyCycle (float duty_cycle) |
| Set PWM duty cycle fraction [0.0, 1.0]. | |
| void | SetActiveLow (bool active_low) |
| Set PWM polarity (active-low when true). | |
| void | Enable (bool on) |
| Enable or disable the PWM output. | |
| uint32_t | GetPin () const |
| Return the GPIO number. | |
| Config | GetConfig () const |
| Return the cached configuration. | |
Public Member Functions inherited from c7222::NonCopyable | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable (NonCopyable &&)=default | |
| NonCopyable & | operator= (NonCopyable &&)=default |
Public Member Functions inherited from c7222::NonMovable | |
| NonMovable (const NonMovable &)=default | |
| NonMovable & | operator= (const NonMovable &)=default |
| NonMovable (NonMovable &&)=delete | |
| NonMovable & | operator= (NonMovable &&)=delete |
Protected Member Functions | |
| void | ApplyConfig () |
| Apply internal configuration to the hardware. | |
Protected Member Functions inherited from c7222::NonCopyableNonMovable | |
| NonCopyableNonMovable ()=default | |
| ~NonCopyableNonMovable ()=default | |
Protected Member Functions inherited from c7222::NonCopyable | |
| NonCopyable ()=default | |
| ~NonCopyable ()=default | |
Protected Member Functions inherited from c7222::NonMovable | |
| NonMovable ()=default | |
| ~NonMovable ()=default | |
Protected Attributes | |
| uint32_t | pin_ |
| GPIO pin number managed by this instance. | |
| Config | config_ |
| Cached configuration used to (re)apply platform settings. | |
Output-only PWM wrapper with period and duty configuration.
This class provides a minimal PWM interface:
Platform backends map this to the underlying PWM hardware and enforce single ownership per GPIO pin.
|
explicit |
Create a PWM output with default configuration.
|
explicit |
Create a PWM output with the given configuration.
| pin | GPIO number. |
| config | Initial configuration. |
|
virtual |
Destructor.
Platform backends may unregister pin ownership here.
|
protected |
Apply internal configuration to the hardware.
Implemented by the platform backend.
| void c7222::PwmOut::Configure | ( | const Config & | config | ) |
Apply a new configuration.
| config | New configuration. |
| void c7222::PwmOut::Enable | ( | bool | on | ) |
Enable or disable the PWM output.
|
inline |
Return the cached configuration.
|
inline |
Return the GPIO number.
| void c7222::PwmOut::SetActiveLow | ( | bool | active_low | ) |
Set PWM polarity (active-low when true).
| void c7222::PwmOut::SetDutyCycle | ( | float | duty_cycle | ) |
Set PWM duty cycle fraction [0.0, 1.0].
| void c7222::PwmOut::SetPeriodUs | ( | float | period_us | ) |
Set PWM period in microseconds.
|
protected |
Cached configuration used to (re)apply platform settings.
|
protected |
GPIO pin number managed by this instance.