Merge pull request #1091 from openmv/nrf_audio_fixes

Add Arduino fixes.
This commit is contained in:
Ibrahim Abd Elkader 2021-01-03 16:57:30 +02:00 committed by GitHub
commit 0d830d15a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,9 +81,17 @@ static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
.interrupt_priority = PDM_IRQ_PRIORITY,
};
// Enable high frequency oscillator if not already enabled
if (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
}
}
// configure the sample rate and channels
switch (frequency) {
case 16000:
NRF_PDM->RATIO = ((PDM_RATIO_RATIO_Ratio80 << PDM_RATIO_RATIO_Pos) & PDM_RATIO_RATIO_Msk);
nrfx_pdm_config.clock_freq = NRF_PDM_FREQ_1280K;
break;
case 41667: