|
|
|
|
|
|
|
|
DMAMEM static uint16_t analog_rx_buffer[AUDIO_BLOCK_SAMPLES]; |
|
|
DMAMEM static uint16_t analog_rx_buffer[AUDIO_BLOCK_SAMPLES]; |
|
|
audio_block_t * AudioInputAnalog::block_left = NULL; |
|
|
audio_block_t * AudioInputAnalog::block_left = NULL; |
|
|
uint16_t AudioInputAnalog::block_offset = 0; |
|
|
uint16_t AudioInputAnalog::block_offset = 0; |
|
|
|
|
|
bool AudioInputAnalog::update_responsibility = false; |
|
|
|
|
|
|
|
|
#define PDB_CONFIG (PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | PDB_SC_CONT) |
|
|
#define PDB_CONFIG (PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | PDB_SC_CONT) |
|
|
#define PDB_PERIOD 1087 // 48e6 / 44100 |
|
|
#define PDB_PERIOD 1087 // 48e6 / 44100 |
|
|
|
|
|
|
|
|
DMA_TCD2_CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR; |
|
|
DMA_TCD2_CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR; |
|
|
DMAMUX0_CHCFG2 = DMAMUX_DISABLE; |
|
|
DMAMUX0_CHCFG2 = DMAMUX_DISABLE; |
|
|
DMAMUX0_CHCFG2 = DMAMUX_SOURCE_ADC0 | DMAMUX_ENABLE; |
|
|
DMAMUX0_CHCFG2 = DMAMUX_SOURCE_ADC0 | DMAMUX_ENABLE; |
|
|
//update_responsibility = update_setup(); |
|
|
|
|
|
|
|
|
update_responsibility = update_setup(); |
|
|
DMA_SERQ = 2; |
|
|
DMA_SERQ = 2; |
|
|
NVIC_ENABLE_IRQ(IRQ_DMA_CH2); |
|
|
NVIC_ENABLE_IRQ(IRQ_DMA_CH2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// need to remove data from the second half |
|
|
// need to remove data from the second half |
|
|
src = (uint16_t *)&analog_rx_buffer[AUDIO_BLOCK_SAMPLES/2]; |
|
|
src = (uint16_t *)&analog_rx_buffer[AUDIO_BLOCK_SAMPLES/2]; |
|
|
end = (uint16_t *)&analog_rx_buffer[AUDIO_BLOCK_SAMPLES]; |
|
|
end = (uint16_t *)&analog_rx_buffer[AUDIO_BLOCK_SAMPLES]; |
|
|
//if (AudioInputI2S::update_responsibility) AudioStream::update_all(); |
|
|
|
|
|
|
|
|
if (AudioInputAnalog::update_responsibility) AudioStream::update_all(); |
|
|
} else { |
|
|
} else { |
|
|
// DMA is receiving to the second half of the buffer |
|
|
// DMA is receiving to the second half of the buffer |
|
|
// need to remove data from the first half |
|
|
// need to remove data from the first half |