Skip to content

Class daisy::PWMHandle

ClassList > daisy > PWMHandle

Hardware PWM using the timer peripheral. More...

  • #include <pwm.h>

Classes

Type Name
class Channel
struct Config
Configuration struct for the timer peripheral.

Public Types

Type Name
enum Result
Return values for PWM functions.

Public Functions

Type Name
Channel & Channel1 ()
Get a reference to CH1 of this peripheral. Must be initialized before use.
Channel & Channel2 ()
Get a reference to CH2 of this peripheral. Must be initialized before use.
Channel & Channel3 ()
Get a reference to CH3 of this peripheral. Must be initialized before use.
Channel & Channel4 ()
Get a reference to CH4 of this peripheral. Must be initialized before use.
Result DeInit ()
Deinitialize the peripheral.
const Config & GetConfig () const
Returns a const reference to the Config struct.
Result Init (const Config & config)
Initialize the PWM peripheral according to the config.
PWMHandle ()
PWMHandle (const PWMHandle & other) = default
void SetPeriod (uint32_t period)
Set the period.
void SetPrescaler (uint32_t prescaler)
Set the prescaler.
PWMHandle & operator= (const PWMHandle & other) = default
~PWMHandle ()

Detailed Description

  • Supports the following TIM peripherals:
  • TIM3, TIM4, TIM5

A single TIM peripheral can be used to control up to four PWM output channels, which share the same resolution and frequency but have independent duty cycles.

Note that PWM interferes with the use of a TimerHandle on the same timer.

Some channels have the option to choose which output pin they connect to. Only one pin can be connected to a given channel. Use the following table to determine which pin corresponds to each timer and channel.

TIM3: * Channel 1: PA6 or PB4 (Daisy Seed D19, D9; default PA6/D19) * Channel 2: PA7, PB5, or PC7 (D18, D10, internal LED; default PC7/LED) * Channel 3: PC8 (D4) * Channel 4: PB1 or PC9 (D17, D3; default PB1/D17)

TIM4: * Channel 1: PB6 (D13) * Channel 2: PB7 (D14) * Channel 3: PB8 (D11) * Channel 4: PB9 (D12)

TIM5: * Channel 1: PA0 (D25) * Channel 2: PA1 (D24) * Channel 3: PA2 (D28) * Channel 4: PA3 (D16)

Future work: * Support other timers, including HRTIM, TIM1, TIM8 * DMA

Public Types Documentation

enum Result

Return values for PWM functions.

enum daisy::PWMHandle::Result {
    OK = 0,
    ERR = 1
};


Public Functions Documentation

function Channel1

Get a reference to CH1 of this peripheral. Must be initialized before use.

inline Channel & daisy::PWMHandle::Channel1 () 


function Channel2

Get a reference to CH2 of this peripheral. Must be initialized before use.

inline Channel & daisy::PWMHandle::Channel2 () 


function Channel3

Get a reference to CH3 of this peripheral. Must be initialized before use.

inline Channel & daisy::PWMHandle::Channel3 () 


function Channel4

Get a reference to CH4 of this peripheral. Must be initialized before use.

inline Channel & daisy::PWMHandle::Channel4 () 


function DeInit

Deinitialize the peripheral.

Result daisy::PWMHandle::DeInit () 


function GetConfig

Returns a const reference to the Config struct.

const  Config & daisy::PWMHandle::GetConfig () const


function Init

Initialize the PWM peripheral according to the config.

Result daisy::PWMHandle::Init (
    const  Config & config
) 


function PWMHandle [½]

daisy::PWMHandle::PWMHandle () 

function PWMHandle [2/2]

daisy::PWMHandle::PWMHandle (
    const  PWMHandle & other
) = default

function SetPeriod

Set the period.

void daisy::PWMHandle::SetPeriod (
    uint32_t period
) 


function SetPrescaler

Set the prescaler.

void daisy::PWMHandle::SetPrescaler (
    uint32_t prescaler
) 


function operator=

PWMHandle & daisy::PWMHandle::operator= (
    const  PWMHandle & other
) = default

function ~PWMHandle

inline daisy::PWMHandle::~PWMHandle () 


The documentation for this class was generated from the following file external-docs/libDaisy/src/per/pwm.h