arduino-audio-tools
Loading...
Searching...
No Matches
AudioTimerDriverZephyr Class Reference

Repeating Timer driver for Zephyr using k_timer. More...

#include <CodecOpusOgg.h>

Inheritance diagram for AudioTimerDriverZephyr:
AudioTimerDriverBase AudioTimerDriverBase

Public Member Functions

 AudioTimerDriverZephyr ()=default
 AudioTimerDriverZephyr ()=default
 ~AudioTimerDriverZephyr ()
 ~AudioTimerDriverZephyr ()
bool begin (repeating_timer_callback_t callback_f, uint32_t time, TimeUnit unit=MS) override
 Starts the repeating timer.
bool begin (repeating_timer_callback_t callback_f, uint32_t time, TimeUnit unit=MS) override
 Starts the repeating timer.
void * callbackParameter ()
void * callbackParameter ()
bool end () override
 Stops the timer.
bool end () override
 Stops the timer.
void setCallbackParameter (void *obj)
void setCallbackParameter (void *obj)
void setIsSave (bool is_save) override
 Sets whether timer callbacks should be safe (execute in thread context).
void setIsSave (bool is_save) override
 Sets whether timer callbacks should be safe (execute in thread context).
virtual void setTimer (int timer)
virtual void setTimer (int timer)
void setTimerFunction (TimerFunction function) override
 Sets the callback execution mode.
void setTimerFunction (TimerFunction function) override
 Sets the callback execution mode.

Protected Member Functions

void executeCallback ()
void executeCallback ()
const char * toString (TimeUnit unit)
const char * toString (TimeUnit unit)

Static Protected Member Functions

static void timerExpiredCallback (struct k_timer *timer_ptr)
static void timerExpiredCallback (struct k_timer *timer_ptr)
static void workCallback (k_work *work_ptr)
static void workCallback (k_work *work_ptr)

Protected Attributes

repeating_timer_callback_t callback = nullptr
bool is_running = false
void * object = nullptr
uint64_t period_us = 0
struct k_timer timer = {}
TimerFunction timer_function = DirectTimerCallback
bool timer_initialized = false
struct k_work work = {}

Detailed Description

Repeating Timer driver for Zephyr using k_timer.

Author
Phil Schatzmann

Implements AudioTimerDriverBase using Zephyr's kernel timer API (k_timer). Supports both callback-based and thread-based execution modes.

Characteristics:

  • Supports US / MS / HZ time specifications
  • Uses k_timer_init() and k_timer_start() for efficient scheduling
  • Defers callback execution to system workqueue when TimerCallbackInThread mode is set
  • Precision limited by Zephyr's kernel tick resolution

Constructor & Destructor Documentation

◆ AudioTimerDriverZephyr() [1/2]

AudioTimerDriverZephyr ( )
default

◆ ~AudioTimerDriverZephyr() [1/2]

◆ AudioTimerDriverZephyr() [2/2]

AudioTimerDriverZephyr ( )
default

◆ ~AudioTimerDriverZephyr() [2/2]

Member Function Documentation

◆ begin() [1/2]

bool begin ( repeating_timer_callback_t callback_f,
uint32_t time,
TimeUnit unit = MS )
inlineoverridevirtual

Starts the repeating timer.

Implements AudioTimerDriverBase.

◆ begin() [2/2]

bool begin ( repeating_timer_callback_t callback_f,
uint32_t time,
TimeUnit unit = MS )
inlineoverridevirtual

Starts the repeating timer.

Implements AudioTimerDriverBase.

◆ callbackParameter() [1/2]

void * callbackParameter ( )
inlineinherited

◆ callbackParameter() [2/2]

void * callbackParameter ( )
inlineinherited

◆ end() [1/2]

bool end ( )
inlineoverridevirtual

Stops the timer.

Reimplemented from AudioTimerDriverBase.

◆ end() [2/2]

bool end ( )
inlineoverridevirtual

Stops the timer.

Reimplemented from AudioTimerDriverBase.

◆ executeCallback() [1/2]

void executeCallback ( )
inlineprotected

◆ executeCallback() [2/2]

void executeCallback ( )
inlineprotected

◆ setCallbackParameter() [1/2]

void setCallbackParameter ( void * obj)
inlineinherited

◆ setCallbackParameter() [2/2]

void setCallbackParameter ( void * obj)
inlineinherited

◆ setIsSave() [1/2]

void setIsSave ( bool is_save)
inlineoverridevirtual

Sets whether timer callbacks should be safe (execute in thread context).

Reimplemented from AudioTimerDriverBase.

◆ setIsSave() [2/2]

void setIsSave ( bool is_save)
inlineoverridevirtual

Sets whether timer callbacks should be safe (execute in thread context).

Reimplemented from AudioTimerDriverBase.

◆ setTimer() [1/2]

◆ setTimer() [2/2]

◆ setTimerFunction() [1/2]

void setTimerFunction ( TimerFunction function)
inlineoverridevirtual

Sets the callback execution mode.

Reimplemented from AudioTimerDriverBase.

◆ setTimerFunction() [2/2]

void setTimerFunction ( TimerFunction function)
inlineoverridevirtual

Sets the callback execution mode.

Reimplemented from AudioTimerDriverBase.

◆ timerExpiredCallback() [1/2]

void timerExpiredCallback ( struct k_timer * timer_ptr)
inlinestaticprotected

Static callback wrapper for k_timer This is invoked in interrupt context, so we either call directly or defer to system workqueue.

◆ timerExpiredCallback() [2/2]

void timerExpiredCallback ( struct k_timer * timer_ptr)
inlinestaticprotected

Static callback wrapper for k_timer This is invoked in interrupt context, so we either call directly or defer to system workqueue.

◆ toString() [1/2]

const char * toString ( TimeUnit unit)
inlineprotectedinherited

◆ toString() [2/2]

const char * toString ( TimeUnit unit)
inlineprotectedinherited

◆ workCallback() [1/2]

void workCallback ( k_work * work_ptr)
inlinestaticprotected

◆ workCallback() [2/2]

void workCallback ( k_work * work_ptr)
inlinestaticprotected

Member Data Documentation

◆ callback

repeating_timer_callback_t callback = nullptr
protected

◆ is_running

bool is_running = false
protected

◆ object

void * object = nullptr
protectedinherited

◆ period_us

uint64_t period_us = 0
protected

◆ timer

struct k_timer timer = {}
protected

◆ timer_function

TimerFunction timer_function = DirectTimerCallback
protected

◆ timer_initialized

bool timer_initialized = false
protected

◆ work

struct k_work work = {}
protected

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