14 # error "Wrong implementation included for this platform" 19 #define getADCReading() 0
20 #define channelNumToIndex(channel) channel 21 uint8_t adcPinToChannelNum(uint8_t pin) {
24 void adcStartConversion(uint8_t channel) {
25 #warning Fast analog read not implemented on this platform 27 void startSecondADCReadOnCurrentChannel() {
28 #warning Fast analog read not implemented on this platform 31 #warning Fast analog read not implemented on this platform 33 void setupMozziADC(int8_t speed) {
34 #warning Fast analog read not implemented on this platform 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;
97 void TC5_Handler(
void)
__attribute__((weak, alias(
"samd21AudioOutput")));
102 void samd21AudioOutput() {
103 defaultAudioOutput();
104 TC5->COUNT16.INTFLAG.bit.MC0 = 1;
110 #if (EXTERNAL_AUDIO_OUTPUT != true) 111 #include "AudioConfigSAMD21.h" 112 inline void audioOutput(
const AudioOutput f) {
117 static void startAudio() {
118 #ifdef ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS 120 static const int CPLAY_SPEAKER_SHUTDOWN = 11;
121 pinMode(CPLAY_SPEAKER_SHUTDOWN, OUTPUT);
122 digitalWrite(CPLAY_SPEAKER_SHUTDOWN, HIGH);
126 analogWriteResolution(10);
127 #if (EXTERNAL_AUDIO_OUTPUT != true) 131 tcConfigure(AUDIO_RATE);
void stopMozzi()
Stops audio and control interrupts and restores the timers to the values they had before Mozzi was st...
#define AUDIO_CHANNEL_1_PIN
void setupFastAnalogRead(int8_t speed)
NOTE: Code needed to set up faster than usual analog reads, e.g.