fix pdm issue when bluefruit is enabled
This commit is contained in:
1 parent
831b003906
commit
f5ceb9332d
2 files changed
+25
-5
No files matched your search
@@ -18,7 +18,7 @@ volatile int samplesRead;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
while (!Serial) yield();
|
||||
|
||||
// configure the data receive callback
|
||||
PDM.onReceive(onPDMdata);
|
||||
@@ -31,7 +31,7 @@ void setup() {
|
||||
// - a 16 kHz sample rate
|
||||
if (!PDM.begin(1, 16000)) {
|
||||
Serial.println("Failed to start PDM!");
|
||||
while (1);
|
||||
while (1) yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,29 @@ int PDMClass::begin(int channels, long sampleRate)
|
||||
_channels = channels;
|
||||
|
||||
// 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) { }
|
||||
uint8_t sd_en = 0;
|
||||
sd_softdevice_is_enabled(&sd_en);
|
||||
|
||||
if (sd_en)
|
||||
{
|
||||
uint32_t is_running;
|
||||
sd_clock_hfclk_is_running(&is_running);
|
||||
|
||||
if (!is_running) {
|
||||
sd_clock_hfclk_request();
|
||||
|
||||
while(!is_running) {
|
||||
yield();
|
||||
sd_clock_hfclk_is_running(&is_running);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
|
||||
NRF_CLOCK->TASKS_HFCLKSTART = 1;
|
||||
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) yield();
|
||||
}
|
||||
}
|
||||
|
||||
// configure the sample rate and channels
|
||||
|
||||
Reference in new issue
Block a user