diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-06-08 14:03:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-08 14:03:53 -0700 |
| commit | 4e4d795da54605b3a541861b4ed387119808f1b4 (patch) | |
| tree | a4f0f7567d4283f343ecca4a8156a90202b8856f | |
| parent | c01ce175bb63aab3f44a3efb31bcfd57a58b22bd (diff) | |
| parent | 218930d18b5d6c4fbe67c87cec4771b39cc69d1f (diff) | |
Merge pull request #916 from dhalbert/pdmin_hack_fix
Check for PDMIn DMA getting stuck.
| -rw-r--r-- | ports/atmel-samd/common-hal/audiobusio/PDMIn.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index 5502fcd81..f16b17770 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -392,7 +392,18 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se break; } // Wait for the next buffer to fill + uint32_t wait_counts = 0; + #ifdef SAMD21 + #define MAX_WAIT_COUNTS 1000 + #endif + #ifdef SAMD51 + #define MAX_WAIT_COUNTS 6000 + #endif while (!event_interrupt_active(event_channel)) { + if (wait_counts++ > MAX_WAIT_COUNTS) { + // Buffer has stopped filling; DMA may have missed an I2S trigger event. + break; + } #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif |
