File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 66
66
#endif
67
67
68
68
// Set by interrupt handler when DMA block has finished transferring.
69
- static bool pdmin_dma_block_done ;
69
+ static volatile bool pdmin_dma_block_done ;
70
70
// Event channel used to trigger interrupt. Set to invalid value EVSYS_SYNCH_NUM when not in use.
71
71
static uint8_t pdmin_event_channel ;
72
72
@@ -77,6 +77,7 @@ void pdmin_evsys_handler(void) {
77
77
}
78
78
79
79
void pdmin_reset (void ) {
80
+ pdmin_dma_block_done = false;
80
81
pdmin_event_channel = EVSYS_SYNCH_NUM ;
81
82
82
83
while (I2S -> SYNCBUSY .reg & I2S_SYNCBUSY_ENABLE ) {}
@@ -409,6 +410,20 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se
409
410
init_event_channel_interrupt (pdmin_event_channel , CORE_GCLK , EVSYS_ID_GEN_DMAC_CH_0 + dma_channel );
410
411
// Turn on serializer now to get it in sync with DMA.
411
412
i2s_set_serializer_enable (self -> serializer , true);
413
+
414
+ #ifdef SAM_D5X_E5X
415
+ int irq = pdmin_event_channel < 4 ? EVSYS_0_IRQn + pdmin_event_channel : EVSYS_4_IRQn ;
416
+ // Only disable and clear on SAMD51 because the SAMD21 shares EVSYS with ticks.
417
+ NVIC_DisableIRQ (irq );
418
+ NVIC_ClearPendingIRQ (irq );
419
+ #endif
420
+
421
+ #ifdef SAMD21
422
+ int irq = EVSYS_IRQn ;
423
+ #endif
424
+
425
+ // Don't bother to disable when done. It doesn't hurt to leave it on.
426
+ NVIC_EnableIRQ (irq );
412
427
audio_dma_enable_channel (dma_channel );
413
428
414
429
// Record
Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ void reset_port(void) {
386
386
audioout_reset ();
387
387
#endif
388
388
#if CIRCUITPY_AUDIOBUSIO
389
- // pdmin_reset();
389
+ pdmin_reset ();
390
390
#endif
391
391
#if CIRCUITPY_AUDIOBUSIO_I2SOUT
392
392
i2sout_reset ();
You can’t perform that action at this time.
0 commit comments