8000 Merge in AudioOut fix from 3.x by tannewt · Pull Request #1204 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Merge in AudioOut fix from 3.x #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Crea 8000 tion-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -291,12 +291,12 @@ msgid "Too many channels in sample."
msgstr ""

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

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

Expand Down Expand Up @@ -338,16 +338,21 @@ msgstr ""
msgid "Cannot output both channels on the same pin"
msgstr ""

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
msgid "All timers in use"
msgstr ""

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr ""
Expand Down
15 changes: 10 additions & 5 deletions locale/de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Sebastian Plamauer\n"
"Language-Team: \n"
Expand Down Expand Up @@ -300,12 +300,12 @@ msgid "Too many channels in sample."
msgstr "Zu viele Kanäle im sample"

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

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

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

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

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr "Nicht genug Pins vorhanden"
Expand Down
15 changes: 10 additions & 5 deletions locale/en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -291,12 +291,12 @@ msgid "Too many channels in sample."
msgstr ""

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

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

Expand Down Expand Up @@ -338,16 +338,21 @@ msgstr ""
msgid "Cannot output both channels on the same pin"
msgstr ""

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173
#: ports/atmel-samd/common-hal/audioio/AudioOut.c:176
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110
msgid "All timers in use"
msgstr ""

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr ""
Expand Down
15 changes: 10 additions & 5 deletions locale/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -307,12 +307,12 @@ msgid "Too many channels in sample."
msgstr ""

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

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

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

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

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr "No hay suficientes pines disponibles"
Expand Down
15 changes: 10 additions & 5 deletions locale/fil.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: 2018-08-30 23:04-0700\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
Expand Down Expand Up @@ -303,12 +303,12 @@ msgid "Too many channels in sample."
msgstr "Sobra ang channels sa sample."

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

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

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

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

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr "Hindi sapat ang magagamit na pins"
Expand Down
23 changes: 14 additions & 9 deletions locale/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-20 21:52-0400\n"
"POT-Creation-Date: 2018-09-21 12:23-0400\n"
"PO-Revision-Date: 2018-08-14 11:01+0200\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
Expand Down Expand Up @@ -298,12 +298,12 @@ msgid "Too many channels in sample."
msgstr "Trop de canaux dans l'échantillon."

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

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

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

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

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

#: ports/atmel-samd/common-hal/audioio/AudioOut.c:297
#, c-format
msgid "Sample rate too high. It must be less than %d"
msgstr ""

#: ports/atmel-samd/common-hal/busio/I2C.c:71
msgid "Not enough pins available"
msgstr "Pas assez de broches disponibles"
Expand Down Expand Up @@ -2400,10 +2405,10 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés"
msgid "too many arguments provided with the given format"
msgstr "trop d'arguments fournis avec ce format"

#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "la palette doit être longue de 32 octets"

#, fuzzy
#~ msgid "value_size must be power of two"
#~ msgstr "'len' doit être un multiple de 4"

#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "la palette doit être longue de 32 octets"
4 changes: 2 additions & 2 deletions ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@

// <i> Select the clock source for DAC.
#ifndef CONF_GCLK_DAC_SRC
#define CONF_GCLK_DAC_SRC GCLK_CLKCTRL_GEN_GCLK1_Val
#define CONF_GCLK_DAC_SRC GCLK_CLKCTRL_GEN_GCLK0_Val
#endif

/**
* \def CONF_GCLK_DAC_FREQUENCY
* \brief DAC's Clock frequency
*/
#ifndef CONF_GCLK_DAC_FREQUENCY
#define CONF_GCLK_DAC_FREQUENCY 320000
#define CONF_GCLK_DAC_FREQUENCY 48000000
#endif

// <y> USB Clock Source
Expand Down
25 changes: 19 additions & 6 deletions ports/atmel-samd/common-hal/audioio/AudioOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
_pm_enable_bus_clock(PM_BUS_APBC, DAC);
#endif

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


DAC->CTRLA.bit.SWRST = 1;
while (DAC->CTRLA.bit.SWRST == 1) {}
DAC->CTRLA.bit.SWRST = 1;
while (DAC->CTRLA.bit.SWRST == 1) {}

bool channel0_enabled = true;
#ifdef SAMD51
Expand All @@ -127,9 +128,11 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
if (channel0_enabled) {
#ifdef SAMD21
DAC->EVCTRL.reg |= DAC_EVCTRL_STARTEI;
// We disable the voltage pump because we always run at 3.3v.
DAC->CTRLB.reg = DAC_CTRLB_REFSEL_AVCC |
DAC_CTRLB_LEFTADJ |
DAC_CTRLB_EOEN;
DAC_CTRLB_EOEN |
DAC_CTRLB_VPD;
#endif
#ifdef SAMD51
DAC->EVCTRL.reg |= DAC_EVCTRL_STARTEI0;
Expand Down Expand Up @@ -283,6 +286,16 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t* self,
common_hal_audioio_audioout_stop(self);
}
audio_dma_result result = AUDIO_DMA_OK;
uint32_t sample_rate = audiosample_sample_rate(sample);
#ifdef SAMD21
uint32_t max_sample_rate = 350000;
#endif
#ifdef SAMD51
uint32_t max_sample_rate = 1000000;
#endif
if (sample_rate > max_sample_rate) {
mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate);
}
#ifdef SAMD21
result = audio_dma_setup_playback(&self->left_dma, sample, loop, true, 0,
false /* output unsigned */,
Expand Down
0