3#if defined(ARDUINO_ARCH_MBED) || defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_ARCH_MBED_NANO) || defined(ARDUINO_ARCH_MBED_NICLA) || defined(ARDUINO_ARCH_MBED_GIGA) || defined(ARDUINO_ARCH_MBED_PORTENTA) || defined(ARDUINO_NANO33BLE) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA)
5#include "AudioTools/CoreAudio/AudioPWM/PWMDriverBase.h"
6#include "AudioTools/CoreAudio/AudioTimer/AudioTimer.h"
17using PWMDriver = PWMDriverMBED;
31 virtual void end()
override {
35 is_timer_started =
false;
38 for (
int j = 0; j < audio_config.
channels; j++) {
39 if (pins[j] !=
nullptr) {
57 if (!is_timer_started) {
59 long wait_time = 1000000l / audio_config.
sample_rate;
60 ticker.setCallbackParameter(
this);
62 is_timer_started =
true;
73 unsigned long period =
76 for (
int j = 0; j < audio_config.
channels; j++) {
77 LOGD(
"Processing channel %d", j);
78 auto gpio = audio_config.pins()[j];
79 mbed::PwmOut* pin =
new mbed::PwmOut(digitalPinToPinName(gpio));
80 LOGI(
"PWM Pin: %d", gpio);
81 pin->period_us(period);
99 virtual void pwmWrite(
int channel,
int value) {
101 pins[channel]->write(float_value);
107 if (accessAudioPWM !=
nullptr) {