Skip to content

Commit 839b791

Browse files
authored
Merge pull request adafruit#1204 from tannewt/merge_3x
Merge in AudioOut fix from 3.x
2 parents 0015db1 + a9d094a commit 839b791

File tree

8 files changed

+85
-42
lines changed

8 files changed

+85
-42
lines changed

locale/circuitpython.pot

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
11+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -291,12 +291,12 @@ msgid "Too many channels in sample."
291291
msgstr ""
292292

293293
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
294-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
294+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
295295
msgid "No DMA channel found"
296296
msgstr ""
297297

298298
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
299-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
299+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
300300
msgid "Unable to allocate buffers for signed conversion"
301301
msgstr ""
302302

@@ -338,16 +338,21 @@ msgstr ""
338338
msgid "Cannot output both channels on the same pin"
339339
msgstr ""
340340

341-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
341+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
342342
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
343343
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
344344
msgid "All timers in use"
345345
msgstr ""
346346

347-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
347+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
348348
msgid "All event channels in use"
349349
msgstr ""
350350

351+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
352+
#, c-format
353+
msgid "Sample rate too high. It must be less than %d"
354+
msgstr ""
355+
351356
#: ports/atmel-samd/common-hal/busio/I2C.c:71
352357
msgid "Not enough pins available"
353358
msgstr ""

locale/de_DE.po

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
10+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1111
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
1212
"Last-Translator: Sebastian Plamauer\n"
1313
"Language-Team: \n"
@@ -300,12 +300,12 @@ msgid "Too many channels in sample."
300300
msgstr "Zu viele Kanäle im sample"
301301

302302
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
303-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
303+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
304304
msgid "No DMA channel found"
305305
msgstr "Kein DMA Kanal gefunden"
306306

307307
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
308-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
308+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
309309
msgid "Unable to allocate buffers for signed conversion"
310310
msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren"
311311

@@ -347,16 +347,21 @@ msgstr "Ungültiger Pin für rechten Kanal"
347347
msgid "Cannot output both channels on the same pin"
348348
msgstr "Kann nicht beite Kanäle auf dem gleichen Pin ausgeben"
349349

350-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
350+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
351351
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
352352
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
353353
msgid "All timers in use"
354354
msgstr "Alle timer werden benutzt"
355355

356-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
356+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
357357
msgid "All event channels in use"
358358
msgstr "Alle event Kanälre werden benutzt"
359359

360+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
361+
#, c-format
362+
msgid "Sample rate too high. It must be less than %d"
363+
msgstr ""
364+
360365
#: ports/atmel-samd/common-hal/busio/I2C.c:71
361366
msgid "Not enough pins available"
362367
msgstr "Nicht genug Pins vorhanden"

locale/en_US.po

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
10+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1111
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
@@ -291,12 +291,12 @@ msgid "Too many channels in sample."
291291
msgstr ""
292292

293293
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
294-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
294+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
295295
msgid "No DMA channel found"
296296
msgstr ""
297297

298298
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
299-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
299+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
300300
msgid "Unable to allocate buffers for signed conversion"
301301
msgstr ""
302302

@@ -338,16 +338,21 @@ msgstr ""
338338
msgid "Cannot output both channels on the same pin"
339339
msgstr ""
340340

341-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
341+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
342342
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
343343
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
344344
msgid "All timers in use"
345345
msgstr ""
346346

347-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
347+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
348348
msgid "All event channels in use"
349349
msgstr ""
350350

351+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
352+
#, c-format
353+
msgid "Sample rate too high. It must be less than %d"
354+
msgstr ""
355+
351356
#: ports/atmel-samd/common-hal/busio/I2C.c:71
352357
msgid "Not enough pins available"
353358
msgstr ""

locale/es.po

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
10+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1111
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
@@ -307,12 +307,12 @@ msgid "Too many channels in sample."
307307
msgstr ""
308308

309309
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
310-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
310+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
311311
msgid "No DMA channel found"
312312
msgstr ""
313313

314314
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
315-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
315+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
316316
msgid "Unable to allocate buffers for signed conversion"
317317
msgstr "No se pudieron asignar buffers para la conversión con signo"
318318

@@ -354,16 +354,21 @@ msgstr ""
354354
msgid "Cannot output both channels on the same pin"
355355
msgstr "No es posible utilizar el mismo pin para ambos canales"
356356

357-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
357+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
358358
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
359359
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
360360
msgid "All timers in use"
361361
msgstr "Todos los timers estan siendo utilizados"
362362

363-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
363+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
364364
msgid "All event channels in use"
365365
msgstr "Todos los canales de eventos estan siendo utilizados"
366366

367+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
368+
#, c-format
369+
msgid "Sample rate too high. It must be less than %d"
370+
msgstr ""
371+
367372
#: ports/atmel-samd/common-hal/busio/I2C.c:71
368373
msgid "Not enough pins available"
369374
msgstr "No hay suficientes pines disponibles"

locale/fil.po

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
10+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1111
"PO-Revision-Date: 2018-08-30 23:04-0700\n"
1212
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
1313
"Language-Team: fil\n"
@@ -303,12 +303,12 @@ msgid "Too many channels in sample."
303303
msgstr "Sobra ang channels sa sample."
304304

305305
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
306-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
306+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
307307
msgid "No DMA channel found"
308308
msgstr "Walang DMA channel na mahanap"
309309

310310
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
311-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
311+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
312312
msgid "Unable to allocate buffers for signed conversion"
313313
msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion"
314314

@@ -350,16 +350,21 @@ msgstr "Mali ang pin para sa kanang channel"
350350
msgid "Cannot output both channels on the same pin"
351351
msgstr "Hindi maaaring output ang mga parehong channel sa parehong pin"
352352

353-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
353+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
354354
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
355355
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
356356
msgid "All timers in use"
357357
msgstr "Lahat ng timer ginagamit"
358358

359-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
359+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
360360
msgid "All event channels in use"
361361
msgstr "Lahat ng event channels ginagamit"
362362

363+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
364+
#, c-format
365+
msgid "Sample rate too high. It must be less than %d"
366+
msgstr ""
367+
363368
#: ports/atmel-samd/common-hal/busio/I2C.c:71
364369
msgid "Not enough pins available"
365370
msgstr "Hindi sapat ang magagamit na pins"

locale/fr.po

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: 0.1\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
10+
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
1111
"PO-Revision-Date: 2018-08-14 11:01+0200\n"
1212
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
1313
"Language-Team: fr\n"
@@ -298,12 +298,12 @@ msgid "Too many channels in sample."
298298
msgstr "Trop de canaux dans l'échantillon."
299299

300300
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305
301-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:326
301+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:339
302302
msgid "No DMA channel found"
303303
msgstr "Aucun canal DMA trouvé"
304304

305305
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308
306-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:328
306+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:341
307307
msgid "Unable to allocate buffers for signed conversion"
308308
msgstr "Impossible d'allouer des tampons pour une conversion signée"
309309

@@ -345,16 +345,21 @@ msgstr "Broche invalide pour le canal droit"
345345
msgid "Cannot output both channels on the same pin"
346346
msgstr "On ne peut mettre les deux canaux sur la même broche"
347347

348-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
348+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
349349
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
350350
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
351351
msgid "All timers in use"
352352
msgstr "Tous les timers sont utilisés"
353353

354-
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:215
354+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:218
355355
msgid "All event channels in use"
356356
msgstr "Tous les canaux d'événements sont utilisés"
357357

358+
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
359+
#, c-format
360+
msgid "Sample rate too high. It must be less than %d"
361+
msgstr ""
362+
358363
#: ports/atmel-samd/common-hal/busio/I2C.c:71
359364
msgid "Not enough pins available"
360365
msgstr "Pas assez de broches disponibles"
@@ -2400,10 +2405,10 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés"
24002405
msgid "too many arguments provided with the given format"
24012406
msgstr "trop d'arguments fournis avec ce format"
24022407

2403-
#, fuzzy
2404-
#~ msgid "palette must be displayio.Palette"
2405-
#~ msgstr "la palette doit être longue de 32 octets"
2406-
24072408
#, fuzzy
24082409
#~ msgid "value_size must be power of two"
24092410
#~ msgstr "'len' doit être un multiple de 4"
2411+
2412+
#, fuzzy
2413+
#~ msgid "palette must be displayio.Palette"
2414+
#~ msgstr "la palette doit être longue de 32 octets"

ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,15 @@
385385

386386
// <i> Select the clock source for DAC.
387387
#ifndef CONF_GCLK_DAC_SRC
388-
#define CONF_GCLK_DAC_SRC GCLK_CLKCTRL_GEN_GCLK1_Val
388+
#define CONF_GCLK_DAC_SRC GCLK_CLKCTRL_GEN_GCLK0_Val
389389
#endif
390390

391391
/**
392392
* \def CONF_GCLK_DAC_FREQUENCY
393393
* \brief DAC's Clock frequency
394394
*/
395395
#ifndef CONF_GCLK_DAC_FREQUENCY
396-
#define CONF_GCLK_DAC_FREQUENCY 320000
396+
#define CONF_GCLK_DAC_FREQUENCY 48000000
397397
#endif
398398

399399
// <y> USB Clock Source

ports/atmel-samd/common-hal/audioio/AudioOut.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
110110
_pm_enable_bus_clock(PM_BUS_APBC, DAC);
111111
#endif
112112

113-
// SAMD21: This clock should be <= 12 MHz, per datasheet section 47.6.3.
114-
// SAMD51: This clock should be <= 350kHz, per datasheet table 37-6.
113+
// SAMD51: This clock should be <= 12 MHz, per datasheet section 47.6.3.
114+
// SAMD21: This clock is 48mhz despite the datasheet saying it must only be <= 350kHz, per
115+
// datasheet table 37-6. It's incorrect because the max output rate is 350ksps and is only
116+
// achieved when the GCLK is more than 8mhz.
115117
_gclk_enable_channel(DAC_GCLK_ID, CONF_GCLK_DAC_SRC);
116118

117-
118-
DAC->CTRLA.bit.SWRST = 1;
119-
while (DAC->CTRLA.bit.SWRST == 1) {}
119+
DAC->CTRLA.bit.SWRST = 1;
120+
while (DAC->CTRLA.bit.SWRST == 1) {}
120121

121122
bool channel0_enabled = true;
122123
#ifdef SAMD51
@@ -127,9 +128,11 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
127128
if (channel0_enabled) {
128129
#ifdef SAMD21
129130
DAC->EVCTRL.reg |= DAC_EVCTRL_STARTEI;
131+
// We disable the voltage pump because we always run at 3.3v.
130132
DAC->CTRLB.reg = DAC_CTRLB_REFSEL_AVCC |
131133
DAC_CTRLB_LEFTADJ |
132-
DAC_CTRLB_EOEN;
134+
DAC_CTRLB_EOEN |
135+
DAC_CTRLB_VPD;
133136
#endif
134137
#ifdef SAMD51
135138
DAC->EVCTRL.reg |= DAC_EVCTRL_STARTEI0;
@@ -283,6 +286,16 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t* self,
283286
common_hal_audioio_audioout_stop(self);
284287
}
285288
audio_dma_result result = AUDIO_DMA_OK;
289+
uint32_t sample_rate = audiosample_sample_rate(sample);
290+
#ifdef SAMD21
291+
uint32_t max_sample_rate = 350000;
292+
#endif
293+
#ifdef SAMD51
294+
uint32_t max_sample_rate = 1000000;
295+
#endif
296+
if (sample_rate > max_sample_rate) {
297+
mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate);
298+
}
286299
#ifdef SAMD21
287300
result = audio_dma_setup_playback(&self->left_dma, sample, loop, true, 0,
288301
false /* output unsigned */,

0 commit comments

Comments
 (0)