Skip to content

Commit 144eb5d

Browse files
committed
fix lost DMA IRQ
1 parent ebc426d commit 144eb5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ports/raspberrypi/audio_dma.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ void isr_dma_0(void) {
448448
if ((dma_hw->intr & mask) == 0) {
449449
continue;
450450
}
451+
// acknowledge interrupt early. Doing so late means that you could lose an
452+
// interrupt if the buffer is very small and the DMA operation
453+
// completed by the time callback_add() / dma_complete() returned. This
454+
// affected PIO continuous write more than audio.
455+
dma_hw->ints0 = mask;
451456
if (MP_STATE_PORT(playing_audio)[i] != NULL) {
452457
audio_dma_t *dma = MP_STATE_PORT(playing_audio)[i];
453458
// Record all channels whose DMA has completed; they need loading.
@@ -458,7 +463,6 @@ void isr_dma_0(void) {
458463
rp2pio_statemachine_obj_t *pio = MP_STATE_PORT(continuous_pio)[i];
459464
rp2pio_statemachine_dma_complete(pio, i);
460465
}
461-
dma_hw->ints0 = mask;
462466
}
463467
}
464468

0 commit comments

Comments
 (0)