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

Audio output to PWM pins for Zephyr RTOS. More...

#include <PWMDriverZephyr.h>

Inheritance diagram for PWMDriverZephyr:
PWMDriverBase

Public Member Functions

 PWMDriverZephyr ()=default
 
PWMConfigaudioInfo ()
 
virtual int availableForWrite ()
 
bool begin (PWMConfig cfg)
 
virtual PWMConfig defaultConfig ()
 
virtual int effectiveOutputSampleRate ()
 Provides the effective sample rate.
 
virtual void end () override
 Ends PWM output.
 
uint32_t framesPerSecond ()
 
bool isTimerStarted ()
 
void setBuffer (BaseBuffer< uint8_t > *buffer)
 
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 () override
 Maximum supported PWM channels.
 
virtual int maxOutputValue () override
 Maximum output value (resolution-dependent)
 
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) override
 Write PWM value to a specific channel.
 
virtual void setupPWM () override
 Setup PWM pins and devices.
 
virtual void setupTimer () override
 Configure timer parameters (called after setupPWM)
 
virtual void startTimer () override
 Start the timer for periodic playback.
 

Static Protected Member Functions

static void defaultPWMAudioOutputCallback (void *obj)
 Timer callback: invoked periodically to write the next audio frame.
 

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
 
uint32_t period_ns = 0
 
uint32_t time_1_sec
 
AudioTimer timer
 
uint32_t underflow_count = 0
 
uint32_t underflow_per_second = 0
 

Detailed Description

Audio output to PWM pins for Zephyr RTOS.

Author
Phil Schatzmann

Supports PWM audio output on Zephyr targets using the native PWM driver API. Manages multiple PWM channels with configurable frequency and resolution.

Characteristics:

Constructor & Destructor Documentation

◆ PWMDriverZephyr()

PWMDriverZephyr ( )
default

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: invoked periodically to write the next audio frame.

◆ deleteBuffer()

void deleteBuffer ( )
inlineprotectedinherited

◆ effectiveOutputSampleRate()

virtual int effectiveOutputSampleRate ( )
inlinevirtualinherited

Provides the effective sample rate.

◆ end()

virtual void end ( )
inlineoverridevirtual

Ends PWM output.

Reimplemented from PWMDriverBase.

◆ 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 ( )
inlineoverrideprotectedvirtual

Maximum supported PWM channels.

Implements PWMDriverBase.

◆ maxOutputValue()

virtual int maxOutputValue ( )
inlineoverrideprotectedvirtual

Maximum output value (resolution-dependent)

Implements PWMDriverBase.

◆ 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 
)
inlineoverrideprotectedvirtual

Write PWM value to a specific channel.

Implements PWMDriverBase.

◆ 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

◆ setupPWM()

virtual void setupPWM ( )
inlineoverrideprotectedvirtual

Setup PWM pins and devices.

Implements PWMDriverBase.

◆ setupTimer()

virtual void setupTimer ( )
inlineoverrideprotectedvirtual

Configure timer parameters (called after setupPWM)

Implements PWMDriverBase.

◆ startTimer()

virtual void startTimer ( )
inlineoverrideprotectedvirtual

Start the timer for periodic playback.

Implements PWMDriverBase.

◆ 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

◆ period_ns

uint32_t period_ns = 0
protected

◆ time_1_sec

uint32_t time_1_sec
protectedinherited

◆ timer

AudioTimer timer
protected

◆ 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: