3 #if defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)
8 #include "AudioTools/CoreAudio/AudioTimer/AudioTimerBase.h"
9 #include "hardware/timer.h"
10 #include "pico/time.h"
14 typedef void (*my_repeating_timer_callback_t)(
void *obj);
24 class TimerAlarmRepeatingDriverRP2040 :
public TimerAlarmRepeatingDriverBase {
26 TimerAlarmRepeatingDriverRP2040() {
27 alarm_pool_init_default();
28 ap = alarm_pool_get_default();
34 bool begin(
const my_repeating_timer_callback_t callback_f, uint32_t time,
37 LOGI(
"timer time: %u %s", (
unsigned int)time, toString(unit));
38 this->instanceCallback = callback_f;
43 result = alarm_pool_add_repeating_timer_ms(ap, time, &staticCallback,
47 result = alarm_pool_add_repeating_timer_us(ap, time, &staticCallback,
53 result = alarm_pool_add_repeating_timer_us(ap, time_us, &staticCallback,
61 inline static bool staticCallback(repeating_timer *ptr) {
62 TimerAlarmRepeatingDriverRP2040 *
self =
63 (TimerAlarmRepeatingDriverRP2040 *)ptr->user_data;
64 self->instanceCallback(self->object);
69 bool end() {
return cancel_repeating_timer(&timer); }
72 alarm_pool_t *ap =
nullptr;
73 repeating_timer_t timer;
74 my_repeating_timer_callback_t instanceCallback =
nullptr;
TimeUnit
Time Units.
Definition: AudioTypes.h:45