Skip to content

Commit

Permalink
nRF52: I2S Fix for double-buffering
Browse files Browse the repository at this point in the history
- Move TASKS_START down to after the buffers are loaded. Not sure if it matters...
  • Loading branch information
TMRh20 committed Nov 4, 2024
1 parent 142dcaa commit f31a831
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/NRF52840/AutoAnalogAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void AutoAnalog::getADC(uint32_t samples){
started = true;
}else{
while(NRF_I2S->EVENTS_RXPTRUPD == 0){}
}
}

if(adcWhichBuf == 0){
NRF_I2S->RXD.PTR = (uint32_t)&adcBuf0[0];
Expand All @@ -288,11 +288,7 @@ void AutoAnalog::getADC(uint32_t samples){
}

NRF_I2S->EVENTS_RXPTRUPD = 0;
if(started){
NRF_I2S->TASKS_START = 1;
}



if(adcBitsPerSample == 24){
if( NRF_I2S->CONFIG.SWIDTH != I2S_CONFIG_SWIDTH_SWIDTH_24BIT << I2S_CONFIG_SWIDTH_SWIDTH_Pos){
NRF_I2S->CONFIG.SWIDTH = I2S_CONFIG_SWIDTH_SWIDTH_24BIT << I2S_CONFIG_SWIDTH_SWIDTH_Pos;
Expand All @@ -319,7 +315,10 @@ void AutoAnalog::getADC(uint32_t samples){
}

adcWhichBuf = !adcWhichBuf;

if(started){
NRF_I2S->TASKS_START = 1;
}

}else
if(useI2S == 0){
while(!adcReady){__WFE();};
Expand Down

0 comments on commit f31a831

Please sign in to comment.