@@ -30,8 +30,6 @@ static audio_dma_t *audio_dma_state[AUDIO_DMA_CHANNEL_COUNT];
30
30
// This cannot be in audio_dma_state because it's volatile.
31
31
static volatile bool audio_dma_pending [AUDIO_DMA_CHANNEL_COUNT ];
32
32
33
- static bool audio_dma_allocated [AUDIO_DMA_CHANNEL_COUNT ];
34
-
35
33
uint8_t find_sync_event_channel_raise () {
36
34
uint8_t event_channel = find_sync_event_channel ();
37
35
if (event_channel >= EVSYS_SYNCH_NUM ) {
@@ -40,24 +38,6 @@ uint8_t find_sync_event_channel_raise() {
40
38
return event_channel ;
41
39
}
42
40
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
-
61
41
void audio_dma_disable_channel (uint8_t channel ) {
62
42
if (channel >= AUDIO_DMA_CHANNEL_COUNT ) {
63
43
return ;
@@ -191,7 +171,7 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
191
171
bool output_signed ,
192
172
uint32_t output_register_address ,
193
173
uint8_t dma_trigger_source ) {
194
- uint8_t dma_channel = dma_allocate_channel ();
174
+ uint8_t dma_channel = dma_allocate_channel (true );
195
175
if (dma_channel >= AUDIO_DMA_CHANNEL_COUNT ) {
196
176
return AUDIO_DMA_DMA_BUSY ;
197
177
}
@@ -342,8 +322,7 @@ void audio_dma_reset(void) {
342
322
for (uint8_t i = 0 ; i < AUDIO_DMA_CHANNEL_COUNT ; i ++ ) {
343
323
audio_dma_state [i ] = NULL ;
344
324
audio_dma_pending [i ] = false;
345
- audio_dma_allocated [i ] = false;
346
- audio_dma_disable_channel (i );
325
+ dma_free_channel (i );
347
326
dma_descriptor (i )-> BTCTRL .bit .VALID = false;
348
327
MP_STATE_PORT (playing_audio )[i ] = NULL ;
349
328
}
0 commit comments