arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
PWMDriverSTM32 Class Reference

Audio output to PWM pins for STM32. We use one timer to generate the sample rate and one timer for the PWM signal. More...

#include <PWMDriverSTM32.h>

Inheritance diagram for PWMDriverSTM32:
DriverPWMBase

Public Member Functions

 PWMDriverSTM32 ()
 
PWMConfigaudioInfo ()
 
virtual int availableForWrite ()
 
bool begin (PWMConfig cfg)
 
virtual PWMConfig defaultConfig ()
 
virtual int effectiveOutputSampleRate ()
 Provides the effective sample rate.
 
virtual void end () override
 
uint32_t framesPerSecond ()
 
bool isTimerStarted ()
 
void setBuffer (BaseBuffer< uint8_t > *buffer)
 
void setPWMTimer (HardwareTimer &t)
 Defines the timer which is used to generate the PWM signal.
 
uint32_t underflowsPerSecond ()
 
void updateStatistics ()
 
virtual size_t write (const uint8_t *data, size_t len)
 

Protected Member Functions

virtual int decimation ()
 Decimation factor to reduce the sample rate.
 
void deleteBuffer ()
 
virtual bool isDecimateActive ()
 
virtual int maxChannels ()
 One timer supports max 4 output pins.
 
virtual int maxOutputValue ()
 provides the max value for the configured resulution
 
virtual int maxSampleRate ()
 Provides the max working sample rate.
 
virtual int nextValue ()
 determines the next scaled value
 
void playNextFrame ()
 writes the next frame to the output pins
 
virtual void pwmWrite (int channel, int value)
 
virtual void setupPWM ()
 Setup PWM Pins.
 
virtual void setupTimer ()
 
virtual void startTimer () override
 

Static Protected Member Functions

static void defaultPWMAudioOutputCallback (void *obj)
 timer callback: write the next frame to the pins
 

Protected Attributes

AudioInfo actual_info
 
PWMConfig audio_config
 
BaseBuffer< uint8_t > * buffer = nullptr
 
Decimate decimate
 
int decimation_factor = 0
 
uint32_t frame_count = 0
 
uint32_t frame_size = 0
 
uint32_t frames_per_second = 0
 
bool is_blocking_write = true
 
bool is_timer_started = false
 
int64_t max_value
 
HardwareTimerp_pwm_timer = nullptr
 
PWM pwm
 
TimerAlarmRepeating ticker
 
uint32_t time_1_sec
 
uint32_t underflow_count = 0
 
uint32_t underflow_per_second = 0
 

Detailed Description

Audio output to PWM pins for STM32. We use one timer to generate the sample rate and one timer for the PWM signal.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ PWMDriverSTM32()

PWMDriverSTM32 ( )
inline

Member Function Documentation

◆ audioInfo()

PWMConfig & audioInfo ( )
inlineinherited

◆ availableForWrite()

virtual int availableForWrite ( )
inlinevirtualinherited

◆ begin()

bool begin ( PWMConfig  cfg)
inlineinherited

◆ decimation()

virtual int decimation ( )
inlineprotectedvirtualinherited

Decimation factor to reduce the sample rate.

Reimplemented in PWMDriverRenesas.

◆ defaultConfig()

virtual PWMConfig defaultConfig ( )
inlinevirtualinherited

Reimplemented in PWMDriverRenesas.

◆ defaultPWMAudioOutputCallback()

static void defaultPWMAudioOutputCallback ( void obj)
inlinestaticprotected

timer callback: write the next frame to the pins

◆ deleteBuffer()

void deleteBuffer ( )
inlineprotectedinherited

◆ effectiveOutputSampleRate()

virtual int effectiveOutputSampleRate ( )
inlinevirtualinherited

Provides the effective sample rate.

◆ end()

virtual void end ( )
inlineoverridevirtual

Reimplemented from DriverPWMBase.

◆ framesPerSecond()

uint32_t framesPerSecond ( )
inlineinherited

◆ isDecimateActive()

virtual bool isDecimateActive ( )
inlineprotectedvirtualinherited

The requested sampling rate is too hight: we only process half of the samples so we can half the sampling rate

◆ isTimerStarted()

bool isTimerStarted ( )
inlineinherited

◆ maxChannels()

virtual int maxChannels ( )
inlineprotectedvirtual

One timer supports max 4 output pins.

Implements DriverPWMBase.

◆ maxOutputValue()

virtual int maxOutputValue ( )
inlineprotectedvirtual

provides the max value for the configured resulution

Implements DriverPWMBase.

◆ maxSampleRate()

virtual int maxSampleRate ( )
inlineprotectedvirtualinherited

Provides the max working sample rate.

Reimplemented in PWMDriverRenesas.

◆ nextValue()

virtual int nextValue ( )
inlineprotectedvirtualinherited

determines the next scaled value

◆ playNextFrame()

void playNextFrame ( )
inlineprotectedinherited

writes the next frame to the output pins

◆ pwmWrite()

virtual void pwmWrite ( int  channel,
int  value 
)
inlineprotectedvirtual

write a pwm value to the indicated channel. The max value depends on the resolution

Implements DriverPWMBase.

◆ setBuffer()

void setBuffer ( BaseBuffer< uint8_t > *  buffer)
inlineinherited

You can assign your own custom buffer impelementation: must be allocated on the heap and will be cleaned up by this class

◆ setPWMTimer()

void setPWMTimer ( HardwareTimer t)
inline

Defines the timer which is used to generate the PWM signal.

◆ setupPWM()

virtual void setupPWM ( )
inlineprotectedvirtual

Setup PWM Pins.

Implements DriverPWMBase.

◆ setupTimer()

virtual void setupTimer ( )
inlineprotectedvirtual

Implements DriverPWMBase.

◆ startTimer()

virtual void startTimer ( )
inlineoverrideprotectedvirtual

when we get the first write -> we activate the timer to start with the output of data

Implements DriverPWMBase.

◆ underflowsPerSecond()

uint32_t underflowsPerSecond ( )
inlineinherited

◆ updateStatistics()

void updateStatistics ( )
inlineinherited

◆ write()

virtual size_t write ( const uint8_t data,
size_t  len 
)
inlinevirtualinherited

Member Data Documentation

◆ actual_info

AudioInfo actual_info
protectedinherited

◆ audio_config

PWMConfig audio_config
protectedinherited

◆ buffer

BaseBuffer<uint8_t>* buffer = nullptr
protectedinherited

◆ decimate

Decimate decimate
protectedinherited

◆ decimation_factor

int decimation_factor = 0
protectedinherited

◆ frame_count

uint32_t frame_count = 0
protectedinherited

◆ frame_size

uint32_t frame_size = 0
protectedinherited

◆ frames_per_second

uint32_t frames_per_second = 0
protectedinherited

◆ is_blocking_write

bool is_blocking_write = true
protectedinherited

◆ is_timer_started

bool is_timer_started = false
protectedinherited

◆ max_value

int64_t max_value
protected

◆ p_pwm_timer

HardwareTimer* p_pwm_timer = nullptr
protected

◆ pwm

PWM pwm
protected

◆ ticker

TimerAlarmRepeating ticker
protected

◆ time_1_sec

uint32_t time_1_sec
protectedinherited

◆ underflow_count

uint32_t underflow_count = 0
protectedinherited

◆ underflow_per_second

uint32_t underflow_per_second = 0
protectedinherited

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