ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::PwmOut Class Reference

Output-only PWM wrapper with period and duty configuration. More...

#include <pwm.hpp>

Inheritance diagram for c7222::PwmOut:
Inheritance graph
Collaboration diagram for c7222::PwmOut:
Collaboration graph

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
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from c7222::NonMovable
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (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.
 

Detailed Description

Output-only PWM wrapper with period and duty configuration.

This class provides a minimal PWM interface:

  • Period in microseconds
  • Duty cycle as a fraction [0.0, 1.0]

Platform backends map this to the underlying PWM hardware and enforce single ownership per GPIO pin.

Constructor & Destructor Documentation

◆ PwmOut() [1/2]

c7222::PwmOut::PwmOut ( uint32_t  pin)
explicit

Create a PWM output with default configuration.

◆ PwmOut() [2/2]

c7222::PwmOut::PwmOut ( uint32_t  pin,
const Config config 
)
explicit

Create a PWM output with the given configuration.

Parameters
pinGPIO number.
configInitial configuration.

◆ ~PwmOut()

virtual c7222::PwmOut::~PwmOut ( )
virtual

Destructor.

Platform backends may unregister pin ownership here.

Member Function Documentation

◆ ApplyConfig()

void c7222::PwmOut::ApplyConfig ( )
protected

Apply internal configuration to the hardware.

Implemented by the platform backend.

◆ Configure()

void c7222::PwmOut::Configure ( const Config config)

Apply a new configuration.

Parameters
configNew configuration.

◆ Enable()

void c7222::PwmOut::Enable ( bool  on)

Enable or disable the PWM output.

◆ GetConfig()

Config c7222::PwmOut::GetConfig ( ) const
inline

Return the cached configuration.

◆ GetPin()

uint32_t c7222::PwmOut::GetPin ( ) const
inline

Return the GPIO number.

◆ SetActiveLow()

void c7222::PwmOut::SetActiveLow ( bool  active_low)

Set PWM polarity (active-low when true).

◆ SetDutyCycle()

void c7222::PwmOut::SetDutyCycle ( float  duty_cycle)

Set PWM duty cycle fraction [0.0, 1.0].

◆ SetPeriodUs()

void c7222::PwmOut::SetPeriodUs ( float  period_us)

Set PWM period in microseconds.

Member Data Documentation

◆ config_

Config c7222::PwmOut::config_
protected

Cached configuration used to (re)apply platform settings.

◆ pin_

uint32_t c7222::PwmOut::pin_
protected

GPIO pin number managed by this instance.


The documentation for this class was generated from the following file: