Skip to content

Implement audiobusio and enhance PIO for it #4251

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 3 commits into from
Feb 25, 2021
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
43 changes: 39 additions & 4 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ msgstr ""
msgid "%q must be a tuple of length 2"
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#: shared-bindings/canio/Match.c
msgid "%q out of range"
msgstr ""
Expand Down Expand Up @@ -453,6 +454,10 @@ msgstr ""
msgid "Below minimum frame rate"
msgstr ""

#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must be sequential pins"
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must share a clock unit"
msgstr ""
Expand Down Expand Up @@ -494,6 +499,10 @@ msgstr ""
msgid "Buffer + offset too small %d %d %d"
msgstr ""

#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
msgid "Buffer elements must be 4 bytes long or less"
msgstr ""

#: shared-module/usb_hid/Device.c
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
Expand Down Expand Up @@ -1074,6 +1083,10 @@ msgstr ""
msgid "IV must be %d bytes long"
msgstr ""

#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
msgid "In buffer elements must be 4 bytes long or less"
msgstr ""

#: py/persistentcode.c
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
Expand All @@ -1088,6 +1101,14 @@ msgstr ""
msgid "Init program size invalid"
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "Initial set pin direcion conflicts with initial out pin direction"
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "Initial set pin state conflicts with initial out pin state"
msgstr ""

#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c
msgid "Initialization failed due to lack of memory"
msgstr ""
Expand Down Expand Up @@ -1452,6 +1473,7 @@ msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
msgid "No DMA channel found"
msgstr ""
Expand Down Expand Up @@ -1518,6 +1540,14 @@ msgstr ""
msgid "No hardware support on pin"
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "No in in program"
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "No in or out in program"
msgstr ""

#: shared-bindings/aesio/aes.c
msgid "No key was specified"
msgstr ""
Expand Down Expand Up @@ -1604,13 +1634,10 @@ msgid "Odd parity is not supported"
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c
msgid "Only 8 or 16 bit mono with "
msgstr ""

#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "Only IN/OUT of up to 8 supported"
msgstr ""

#: ports/esp32s2/common-hal/wifi/__init__.c
msgid "Only IPv4 addresses supported"
msgstr ""
Expand Down Expand Up @@ -1656,6 +1683,10 @@ msgstr ""
msgid "Operation timed out"
msgstr ""

#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
msgid "Out buffer elements must be 4 bytes long or less"
msgstr ""

#: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c
msgid "Out of memory"
msgstr ""
Expand Down Expand Up @@ -2085,6 +2116,7 @@ msgid "To exit, please reset the board without "
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
msgid "Too many channels in sample."
msgstr ""

Expand Down Expand Up @@ -2154,6 +2186,7 @@ msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
Expand Down Expand Up @@ -3682,6 +3715,7 @@ msgstr ""
#: ports/esp32s2/boards/targett_module_clip_wrover/mpconfigboard.h
#: ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
#: ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h
#: ports/esp32s2/boards/unexpectedmaker_tinys2/mpconfigboard.h
msgid "pressing boot button at start up.\n"
msgstr ""

Expand Down Expand Up @@ -3759,6 +3793,7 @@ msgid ""
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c
msgid "sampling rate out of range"
msgstr ""

Expand Down
17 changes: 17 additions & 0 deletions ports/raspberrypi/audio_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@

#define AUDIO_DMA_CHANNEL_COUNT NUM_DMA_CHANNELS

void audio_dma_reset(void) {
for (size_t channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) {
if (MP_STATE_PORT(playing_audio)[channel] == NULL) {
continue;
}

audio_dma_stop(MP_STATE_PORT(playing_audio)[channel]);
}
}

void audio_dma_convert_signed(audio_dma_t* dma, uint8_t* buffer, uint32_t buffer_length,
uint8_t** output_buffer, uint32_t* output_buffer_length) {
if (dma->first_buffer_free) {
Expand Down Expand Up @@ -292,9 +302,16 @@ void audio_dma_stop(audio_dma_t* dma) {
for (size_t i = 0; i < 2; i++) {
size_t channel = dma->channel[i];

dma_channel_config c = dma_channel_get_default_config(dma->channel[i]);
channel_config_set_enable(&c, false);
dma_channel_set_config(channel, &c, false /* trigger */);

if (dma_channel_is_busy(channel)) {
dma_channel_abort(channel);
}
dma_channel_set_read_addr(channel, NULL, false /* trigger */);
dma_channel_set_write_addr(channel, NULL, false /* trigger */);
dma_channel_set_trans_count(channel, 0, false /* trigger */);
dma_channel_unclaim(channel);
MP_STATE_PORT(playing_audio)[channel] = NULL;
dma->channel[i] = NUM_DMA_CHANNELS;
Expand Down
Loading