File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -123,8 +123,8 @@ ap3_err_t AP3_PDM::_begin(void)
123123 ap3_pdm_handle = this ;
124124
125125 // Configure DMA and set target address of internal buffer.
126- sTransfer .ui32TargetAddr = (uint32_t )internalPDMDataBuffer ;
127- sTransfer .ui32TotalCount = internalPDMDataBufferSize * 2 ;
126+ sTransfer .ui32TargetAddr = (uint32_t )_pdmDataBuffer ;
127+ sTransfer .ui32TotalCount = pdmDataBufferSize * 2 ;
128128
129129 // Start the data transfer.
130130 am_hal_pdm_enable (_PDMhandle);
@@ -287,10 +287,14 @@ uint32_t AP3_PDM::getData(uint32_t *externalBuffer, uint32_t bufferSize)
287287
288288 // Move data from internal buffer to external caller
289289 for (int x = 0 ; x < bufferSize; x++)
290- externalBuffer[x] = _pdmCircularBuffer[x];
290+ {
291+ externalBuffer[x] = _pdmCircularBuffer[tail];
292+ if (tail++ == circularBufferSize)
293+ }
291294
292295 interrupts ();
293- }
296+
297+ return (bufferSize)
294298}
295299
296300inline void AP3_PDM::pdm_isr (void )
Original file line number Diff line number Diff line change @@ -133,10 +133,10 @@ class AP3_PDM
133133 volatile bool _tail = 0 ;
134134 volatile bool _overrun = false ;
135135
136- const int pdmDataBufferSize = 512 ; // Default is array of 4096 * 32bit
136+ # define pdmDataBufferSize 512 // Default is array of 4096 * 32bit
137137 volatile uint32_t _pdmDataBuffer[pdmDataBufferSize]; // This has been filled previous to ISR being called
138138
139- const int circularBufferSize = 4096 ;
139+ # define circularBufferSize 4096
140140 volatile uint32_t _pdmCircularBuffer[circularBufferSize]; // This is filled by ISR and read by getData
141141};
142142
You can’t perform that action at this time.
0 commit comments