Skip to content

Commit 886d225

Browse files
authored
Merge pull request #9385 from Bruin-Spacecraft-Group/main
SAMD51 SPI Secondary Mode
2 parents e5e7c9e + 3b0b4d3 commit 886d225

File tree

34 files changed

+632
-47
lines changed

34 files changed

+632
-47
lines changed

docs/porting.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ as a natural "TODO" list. An example minimal build list is shown below:
7272
CIRCUITPY_FRAMEBUFFERIO = 0
7373
CIRCUITPY_FREQUENCYIO = 0
7474
CIRCUITPY_I2CTARGET = 0
75+
CIRCUITPY_SPITARGET = 0
7576
# Requires SPI, PulseIO (stub ok):
7677
CIRCUITPY_DISPLAYIO = 0
7778

locale/circuitpython.pot

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ msgstr ""
594594
msgid "Array values should be single bytes."
595595
msgstr ""
596596

597+
#: ports/atmel-samd/common-hal/spitarget/SPITarget.c
598+
msgid "Async SPI transfer in progress on this bus, keep awaiting."
599+
msgstr ""
600+
597601
#: shared-module/memorymonitor/AllocationAlarm.c
598602
#, c-format
599603
msgid "Attempt to allocate %d blocks"
@@ -1725,6 +1729,10 @@ msgstr ""
17251729
msgid "PWM slice channel A already in use"
17261730
msgstr ""
17271731

1732+
#: shared-bindings/spitarget/SPITarget.c
1733+
msgid "Packet buffers for an SPI transfer must have the same length."
1734+
msgstr ""
1735+
17281736
#: shared-module/jpegio/JpegDecoder.c
17291737
msgid "Parameter error"
17301738
msgstr ""
@@ -2017,8 +2025,8 @@ msgstr ""
20172025
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
20182026
msgstr ""
20192027

2020-
#: shared-module/audiodelays/Echo.c shared-module/audiofilters/Filter.c
2021-
#: shared-module/audiomixer/MixerVoice.c
2028+
#: shared-module/audiodelays/Echo.c shared-module/audiofilters/Distortion.c
2029+
#: shared-module/audiofilters/Filter.c shared-module/audiomixer/MixerVoice.c
20222030
msgid "The sample's %q does not match"
20232031
msgstr ""
20242032

@@ -2570,8 +2578,8 @@ msgstr ""
25702578
msgid "bits must be 32 or less"
25712579
msgstr ""
25722580

2573-
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Filter.c
2574-
#: shared-bindings/audiomixer/Mixer.c
2581+
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c
2582+
#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c
25752583
msgid "bits_per_sample must be 8 or 16"
25762584
msgstr ""
25772585

ports/atmel-samd/audio_dma.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ static audio_dma_t *audio_dma_state[AUDIO_DMA_CHANNEL_COUNT];
3030
// This cannot be in audio_dma_state because it's volatile.
3131
static volatile bool audio_dma_pending[AUDIO_DMA_CHANNEL_COUNT];
3232

33-
static bool audio_dma_allocated[AUDIO_DMA_CHANNEL_COUNT];
34-
3533
uint8_t find_sync_event_channel_raise() {
3634
uint8_t event_channel = find_sync_event_channel();
3735
if (event_channel >= EVSYS_SYNCH_NUM) {
@@ -40,24 +38,6 @@ uint8_t find_sync_event_channel_raise() {
4038
return event_channel;
4139
}
4240

43-
uint8_t dma_allocate_channel(void) {
44-
uint8_t channel;
45-
for (channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) {
46-
if (!audio_dma_allocated[channel]) {
47-
audio_dma_allocated[channel] = true;
48-
return channel;
49-
}
50-
}
51-
return channel; // i.e., return failure
52-
}
53-
54-
void dma_free_channel(uint8_t channel) {
55-
assert(channel < AUDIO_DMA_CHANNEL_COUNT);
56-
assert(audio_dma_allocated[channel]);
57-
audio_dma_disable_channel(channel);
58-
audio_dma_allocated[channel] = false;
59-
}
60-
6141
void audio_dma_disable_channel(uint8_t channel) {
6242
if (channel >= AUDIO_DMA_CHANNEL_COUNT) {
6343
return;
@@ -191,7 +171,7 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
191171
bool output_signed,
192172
uint32_t output_register_address,
193173
uint8_t dma_trigger_source) {
194-
uint8_t dma_channel = dma_allocate_channel();
174+
uint8_t dma_channel = dma_allocate_channel(true);
195175
if (dma_channel >= AUDIO_DMA_CHANNEL_COUNT) {
196176
return AUDIO_DMA_DMA_BUSY;
197177
}
@@ -342,8 +322,7 @@ void audio_dma_reset(void) {
342322
for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) {
343323
audio_dma_state[i] = NULL;
344324
audio_dma_pending[i] = false;
345-
audio_dma_allocated[i] = false;
346-
audio_dma_disable_channel(i);
325+
dma_free_channel(i);
347326
dma_descriptor(i)->BTCTRL.bit.VALID = false;
348327
MP_STATE_PORT(playing_audio)[i] = NULL;
349328
}

ports/atmel-samd/audio_dma.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ typedef enum {
4444
void audio_dma_init(audio_dma_t *dma);
4545
void audio_dma_reset(void);
4646

47-
uint8_t dma_allocate_channel(void);
48-
void dma_free_channel(uint8_t channel);
49-
5047
// This sets everything up but doesn't start the timer.
5148
// Sample is the python object for the sample to play.
5249
// loop is true if we should loop the sample.

ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ LONGINT_IMPL = MPZ
1212

1313
CIRCUITPY_PS2IO = 1
1414
CIRCUITPY_JPEGIO = 0
15+
CIRCUITPY_SPITARGET = 0
1516
CIRCUITPY_SYNTHIO = 0

ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ, W25Q16JVxM"
1111
LONGINT_IMPL = MPZ
1212
CIRCUITPY_SYNTHIO = 0
1313
CIRCUITPY_JPEGIO = 0
14+
CIRCUITPY_SPITARGET = 0

ports/atmel-samd/boards/pybadge/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CIRCUITPY_I2CDISPLAYBUS = 0
1818
CIRCUITPY_JPEGIO = 0
1919
CIRCUITPY_KEYPAD = 1
2020
CIRCUITPY_PARALLELDISPLAYBUS= 0
21+
CIRCUITPY_SPITARGET = 0
2122
CIRCUITPY_STAGE = 1
2223

2324
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge

ports/atmel-samd/boards/pygamer/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CIRCUITPY_I2CDISPLAYBUS = 0
1818
CIRCUITPY_JPEGIO = 0
1919
CIRCUITPY_KEYPAD = 1
2020
CIRCUITPY_PARALLELDISPLAYBUS= 0
21+
CIRCUITPY_SPITARGET = 0
2122
CIRCUITPY_STAGE = 1
2223

2324
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pygamer

ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ EXTERNAL_FLASH_DEVICES = GD25Q16C
1111
LONGINT_IMPL = MPZ
1212

1313
CIRCUITPY_JPEGIO = 0
14+
CIRCUITPY_SPITARGET = 0
1415
CIRCUITPY_SYNTHIO = 0

ports/atmel-samd/boards/uartlogger2/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ"
1111
LONGINT_IMPL = MPZ
12+
CIRCUITPY_SPITARGET = 0
1213
CIRCUITPY_SYNTHIO = 0
1314
CIRCUITPY_JPEGIO = 0

0 commit comments

Comments
 (0)