13 # error "Wrong implementation included for this platform"
19 #if MOZZI_IS(MOZZI_ANALOG_READ, NOZZI_ANALOG_READ_STANDARD)
20 #error not yet implemented
21 #define getADCReading() 0
22 #define channelNumToIndex(channel) channel
23 uint8_t adcPinToChannelNum(uint8_t pin) {
26 void adcStartConversion(uint8_t channel) {
28 void startSecondADCReadOnCurrentChannel() {
30 void setupFastAnalogRead(int8_t speed) {
32 void setupMozziADC(int8_t speed) {
40 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC, MOZZI_OUTPUT_EXTERNAL_TIMED)
42 static bool tcIsSyncing() {
43 return TC5->COUNT16.STATUS.reg & TC_STATUS_SYNCBUSY;
46 static void tcReset() {
48 TC5->COUNT16.CTRLA.reg = TC_CTRLA_SWRST;
51 while (TC5->COUNT16.CTRLA.bit.SWRST)
64 static void tcConfigure(uint32_t sampleRate) {
66 GCLK->CLKCTRL.reg = (uint16_t)(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 |
67 GCLK_CLKCTRL_ID(GCM_TC4_TC5));
68 while (GCLK->STATUS.bit.SYNCBUSY)
74 TC5->COUNT16.CTRLA.reg |= TC_CTRLA_MODE_COUNT16;
77 TC5->COUNT16.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ;
79 TC5->COUNT16.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE;
81 TC5->COUNT16.CC[0].reg = (uint16_t)(SystemCoreClock / sampleRate - 1);
86 NVIC_DisableIRQ(TC5_IRQn);
87 NVIC_ClearPendingIRQ(TC5_IRQn);
88 NVIC_SetPriority(TC5_IRQn, 0);
89 NVIC_EnableIRQ(TC5_IRQn);
92 TC5->COUNT16.INTENSET.bit.MC0 = 1;
99 void TC5_Handler(
void) __attribute__((weak, alias(
"samd21AudioOutput")));
104 void samd21AudioOutput() {
105 MozziPrivate::defaultAudioOutput();
106 TC5->COUNT16.INTFLAG.bit.MC0 = 1;
116 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
122 static void startAudio() {
123 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
124 # ifdef ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS
126 static const int CPLAY_SPEAKER_SHUTDOWN = 11;
127 pinMode(CPLAY_SPEAKER_SHUTDOWN, OUTPUT);
128 digitalWrite(CPLAY_SPEAKER_SHUTDOWN, HIGH);
137 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC, MOZZI_OUTPUT_EXTERNAL_TIMED)
149 void MozziRandPrivate::autoSeed() {
150 #warning Automatic random seeding is not implemented on this platform
#define MOZZI_AUDIO_BITS
Output resolution of audio samples.
#define MOZZI_AUDIO_PIN_1
Only for MOZZI_AUDIO_MODE s MOZZI_OUTPUT_PWM and MOZZI_OUTPUT_2PIN_PWM: The IO pin to use as (first) ...
#define MOZZI_AUDIO_RATE
Defines the audio rate, i.e.
void stopMozzi()
Stops audio and control interrupts and restores the timers to the values they had before Mozzi was st...
This struct encapsulates one frame of mono audio output.