port by Thomas Friedrichsmeier
Port status and notes
Compiles and runs using this core. Can probably be ported to the Mbed core for RP2040, relatively easily, as it relies mostly on the RP2040 SDK API. Tested on a Pi Pico.
- This is a recent addition, implementation details may still change (currently just PWM driven by a timer; this may be worth changing to a DMA driven output)
- Wavetables and samples are not kept in progmem on this platform. While apparently speed (of the external flash) is not much of an issue, the data always seems to be copied into RAM, anyway.
- Note that getAudioInput() and mozziAnalogRead() return values in the RP2040's full ADC resolution of 0-4095 rather than AVR's 0-1023.
- twi_nonblock is not ported
- Code uses only one CPU core
Output modes
The following audio modes (see MOZZI_AUDIO_MODE) are currently supported on this hardware:
- MOZZI_OUTPUT_EXTERNAL_TIMED
- MOZZI_OUTPUT_EXTERNAL_CUSTOM
- MOZZI_OUTPUT_PWM
- MOZZI_OUTPUT_I2S_DAC
The default mode is MOZZI_OUTPUT_PWM .
MOZZI_OUTPUT_PWM
Audio output is written to pin 0 (mono) or 0 and 1 (stereo), by default, with 11 bits of ouput resolution. One hardware timer interrupt and one DMA channel are claimed (number not hardcoded), a non-exclusive handler is installed on DMA_IRQ_0.
Configuration options:
#define MOZZI_AUDIO_PIN_1 ...
#define MOZZI_AUDIO_BITS ...
#define MOZZI_AUDIO_PIN_2 ...
MOZZI_OUTPUT_I2S_DAC
Output to an external DAC, connected via I2S. This uses 16 bit (per audio channel), but can be changed to 8, 16, 24 (left aligned) and 32 resolution. Both plain I2S and LSBJ format (PT8211 needs this, for instance) are available. Plain format is used by default. The GPIO pins to use can be configured,
- almost - freely (see below). Two DMA channels are claimed (numbers not hardcoded), non-exclusive handlers are installed on DMA_IRQ_0.
Configuration options:
#define MOZZI_AUDIO_BITS ...
#define MOZZI_I2S_PIN_BCK ...
#define MOZZI_I2S_PIN_DATA ...
#define MOZZI_I2S_FORMAT ...
- Note
- The MOZZI_I2S_FORMAT_LSBJ option may require a relatively recent git-hub checkout of the arduino-pico core.
MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM
See External audio output