[9XR-PRO] HiFi audio now :)

This commit is contained in:
Bertrand Songis
2015-08-08 10:58:52 +02:00
parent 26a38913a8
commit 3d792ea4df
+32 -14
View File
@@ -111,33 +111,51 @@ void dacInit()
bool dacQueue(AudioBuffer *buffer)
{
dacStart();
return false;
if (DACC->DACC_TCR == 0 && DACC->DACC_TNCR == 0) {
DACC->DACC_TPR = CONVERT_PTR_UINT(buffer->data);
DACC->DACC_TCR = buffer->size/2;
DACC->DACC_PTCR = DACC_PTCR_TXTEN;
dacStart();
return true;
}
else if (DACC->DACC_TNCR == 0) {
DACC->DACC_TNPR = CONVERT_PTR_UINT(buffer->data);
DACC->DACC_TNCR = buffer->size/2;
DACC->DACC_PTCR = DACC_PTCR_TXTEN;
dacStart();
return true;
}
else {
dacStart();
return false;
}
}
extern "C" void DAC_IRQHandler()
{
uint32_t sr = DACC->DACC_ISR;
if (sr & DACC_ISR_ENDTX) {
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
if (nextBuffer) {
// Try the first PDC buffer
if ((DACC->DACC_TCR == 0) && (DACC->DACC_TNCR == 0)) {
// Try the first PDC buffer
if (DACC->DACC_TCR == 0 && DACC->DACC_TNCR == 0) {
AudioBuffer * nextBuffer = audioQueue.getNextFilledBuffer();
if (nextBuffer) {
DACC->DACC_TPR = CONVERT_PTR_UINT(nextBuffer->data);
DACC->DACC_TCR = nextBuffer->size/2;
DACC->DACC_PTCR = DACC_PTCR_TXTEN;
return;
}
// Try the second PDC buffer
if (DACC->DACC_TNCR == 0) {
DACC->DACC_TNPR = CONVERT_PTR_UINT(nextBuffer->data);
DACC->DACC_TNCR = nextBuffer->size/2;
DACC->DACC_PTCR = DACC_PTCR_TXTEN;
else {
dacStop();
return;
}
}
else {
dacStop();
// Try the second PDC buffer
if (DACC->DACC_TNCR == 0) {
AudioBuffer * nextBuffer = audioQueue.getNextFilledBuffer();
if (nextBuffer) {
DACC->DACC_TNPR = CONVERT_PTR_UINT(nextBuffer->data);
DACC->DACC_TNCR = nextBuffer->size/2;
DACC->DACC_PTCR = DACC_PTCR_TXTEN;
}
}
}
}