Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::gpio::Pwm Class Reference

#include <pwm.hpp>

Public Types

enum  Pin {
  C1 , C2 , C3 , C4 ,
  C5 , C6 , C7 , Buzzer ,
  ImuHeater
}
 
enum  Timer { TIMER1 , TIMER8 , TIMER4 , TIMER10 }
 

Public Member Functions

 Pwm ()=default
 
mockable ~Pwm ()=default
 
mockable void init ()
 
mockable void writeAllZeros ()
 
mockable void write (float duty, Pwm::Pin pin)
 
mockable void setTimerFrequency (Timer timer, uint32_t frequency)
 
mockable void pause (Timer timer)
 
mockable void start (Timer timer)
 

Static Public Attributes

static constexpr uint32_t DEFAULT_TIMER1_FREQUENCY = 2000
 
static constexpr uint32_t DEFAULT_TIMER8_FREQUENCY = 2000
 
static constexpr uint32_t DEFAULT_TIMER4_FREQUENCY = 2000
 
static constexpr uint32_t DEFAULT_TIMER10_FREQUENCY = 2000
 

Detailed Description

PWM input pins are pins S, T, U, and V (board pins PAO, PA1, PA2, PA3) To write a PWM frequency to a pin call write and pass the function a value (W - Z) from the analog outPin enum and a PWM duty from 0.0-1.0 (where 1 is all HIGH and 0 is all LOW). To set the duty for all pins call the writeAll function with only the duty.

Member Enumeration Documentation

◆ Pin

Enumerator
C1 
C2 
C3 
C4 
C5 
C6 
C7 
Buzzer 
ImuHeater 

◆ Timer

Enumerator
TIMER1 
TIMER8 
TIMER4 
TIMER10 

Constructor & Destructor Documentation

◆ Pwm()

tap::gpio::Pwm::Pwm ( )
default

◆ ~Pwm()

mockable tap::gpio::Pwm::~Pwm ( )
default

Member Function Documentation

◆ init()

void tap::gpio::Pwm::init ( )

◆ pause()

void tap::gpio::Pwm::pause ( Timer  timer)

◆ setTimerFrequency()

void tap::gpio::Pwm::setTimerFrequency ( Timer  timer,
uint32_t  frequency 
)

Set the frequency of the timer, in Hz. Does nothing if frequency == 0

◆ start()

void tap::gpio::Pwm::start ( Timer  timer)

◆ write()

void tap::gpio::Pwm::write ( float  duty,
Pwm::Pin  pin 
)

Sets the PWM duty for a specified pin.

Parameters
[in]dutythe duty cycle to be set. If the duty is outside of the range of [0, 1] the duty is limited to within the range.
[in]pinthe PWM pin to be set.

◆ writeAllZeros()

void tap::gpio::Pwm::writeAllZeros ( )

Sets all configured timer channels to 0% duty cycle.

Member Data Documentation

◆ DEFAULT_TIMER10_FREQUENCY

constexpr uint32_t tap::gpio::Pwm::DEFAULT_TIMER10_FREQUENCY = 2000
staticconstexpr

◆ DEFAULT_TIMER1_FREQUENCY

constexpr uint32_t tap::gpio::Pwm::DEFAULT_TIMER1_FREQUENCY = 2000
staticconstexpr

◆ DEFAULT_TIMER4_FREQUENCY

constexpr uint32_t tap::gpio::Pwm::DEFAULT_TIMER4_FREQUENCY = 2000
staticconstexpr

◆ DEFAULT_TIMER8_FREQUENCY

constexpr uint32_t tap::gpio::Pwm::DEFAULT_TIMER8_FREQUENCY = 2000
staticconstexpr

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