Fixed bug affecting management of data buffers inside MDx implementation of inputStream API

replace/4050cc3033ac31d7e1b89f970395b780f0b7b71b
Silvano Seva 2021-08-27 14:26:16 +02:00
rodzic 9650ff5925
commit 943838c263
1 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -29,12 +29,12 @@
using namespace miosix; using namespace miosix;
bool inUse = false; // Flag to determine if the input stream is already open. bool inUse = false; // Flag to determine if the input stream is already open.
Thread *sWaiting = 0; // Thread waiting on interrupt. Thread *sWaiting = 0; // Thread waiting on interrupt.
uint32_t bufAddr = 0; // Start address of data buffer, fixed. stream_sample_t *bufAddr = 0; // Start address of data buffer, fixed.
uint32_t bufCurr = 0; // Buffer address to be returned to application. stream_sample_t *bufCurr = 0; // Buffer address to be returned to application.
size_t bufLen = 0; // Buffer length. size_t bufLen = 0; // Buffer length.
uint8_t bufMode = BUF_LINEAR; // Buffer management mode. uint8_t bufMode = BUF_LINEAR; // Buffer management mode.
void __attribute__((used)) DmaHandlerImpl() void __attribute__((used)) DmaHandlerImpl()
{ {
@ -107,7 +107,7 @@ streamId inputStream_start(const enum AudioSource source,
} }
bufMode = mode; bufMode = mode;
bufAddr = reinterpret_cast< uint32_t >(buf); bufAddr = buf;
bufLen = bufLength; bufLen = bufLength;
RCC->APB2ENR |= RCC_APB2ENR_ADC2EN; // Enable ADC RCC->APB2ENR |= RCC_APB2ENR_ADC2EN; // Enable ADC
@ -237,7 +237,7 @@ dataBlock_t inputStream_getData(streamId id)
{ {
// Reload DMA configuration then start DMA and ADC, stopped in ISR // Reload DMA configuration then start DMA and ADC, stopped in ISR
DMA2_Stream2->PAR = reinterpret_cast< uint32_t >(&(ADC2->DR)); DMA2_Stream2->PAR = reinterpret_cast< uint32_t >(&(ADC2->DR));
DMA2_Stream2->M0AR = bufAddr; DMA2_Stream2->M0AR = reinterpret_cast< uint32_t >(bufAddr);
DMA2_Stream2->NDTR = bufLen; DMA2_Stream2->NDTR = bufLen;
DMA2_Stream2->CR |= DMA_SxCR_EN; DMA2_Stream2->CR |= DMA_SxCR_EN;
ADC2->CR2 |= ADC_CR2_ADON; ADC2->CR2 |= ADC_CR2_ADON;
@ -261,7 +261,7 @@ dataBlock_t inputStream_getData(streamId id)
} }
dataBlock_t block; dataBlock_t block;
block.data = reinterpret_cast< stream_sample_t *>(bufCurr); block.data = bufCurr;
block.len = bufLen; block.len = bufLen;
if(bufMode == BUF_CIRC_DOUBLE) block.len /= 2; if(bufMode == BUF_CIRC_DOUBLE) block.len /= 2;