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)
123
123
ap3_pdm_handle = this ;
124
124
125
125
// 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 ;
128
128
129
129
// Start the data transfer.
130
130
am_hal_pdm_enable (_PDMhandle);
@@ -287,10 +287,14 @@ uint32_t AP3_PDM::getData(uint32_t *externalBuffer, uint32_t bufferSize)
287
287
288
288
// Move data from internal buffer to external caller
289
289
for (int x = 0 ; x < bufferSize; x++)
290
- externalBuffer[x] = _pdmCircularBuffer[x];
290
+ {
291
+ externalBuffer[x] = _pdmCircularBuffer[tail];
292
+ if (tail++ == circularBufferSize)
293
+ }
291
294
292
295
interrupts ();
293
- }
296
+
297
+ return (bufferSize)
294
298
}
295
299
296
300
inline void AP3_PDM::pdm_isr (void )
Original file line number Diff line number Diff line change @@ -133,10 +133,10 @@ class AP3_PDM
133
133
volatile bool _tail = 0 ;
134
134
volatile bool _overrun = false ;
135
135
136
- const int pdmDataBufferSize = 512 ; // Default is array of 4096 * 32bit
136
+ # define pdmDataBufferSize 512 // Default is array of 4096 * 32bit
137
137
volatile uint32_t _pdmDataBuffer[pdmDataBufferSize]; // This has been filled previous to ISR being called
138
138
139
- const int circularBufferSize = 4096 ;
139
+ # define circularBufferSize 4096
140
140
volatile uint32_t _pdmCircularBuffer[circularBufferSize]; // This is filled by ISR and read by getData
141
141
};
142
142
You can’t perform that action at this time.
0 commit comments