Partial fix for speaker pop when a voiceprompt begins

This commit is contained in:
Silvano Seva 2022-10-06 07:48:26 +02:00
parent 5ee3a2e9f0
commit 0692bea269
3 changed files with 11 additions and 7 deletions

View File

@ -411,15 +411,17 @@ void vp_terminate()
void vp_stop()
{
voicePromptActive = false;
voicePromptActive = false;
disableSpkOutput();
codec_stop();
// Clear voice prompt sequence data
vpCurrentSequence.pos = 0;
vpCurrentSequence.c2DataIndex = 0;
vpCurrentSequence.c2DataLength = 0;
codec_stop();
// If any beep is playing, immediately stop it.
beep_flush();
disableSpkOutput();
}
void vp_flush()
@ -562,8 +564,8 @@ void vp_play()
voicePromptActive = true;
enableSpkOutput();
codec_startDecode(SINK_SPK);
enableSpkOutput();
}
void vp_tick()
@ -619,11 +621,11 @@ void vp_tick()
// see if we've finished.
if(vpCurrentSequence.pos == vpCurrentSequence.length)
{
disableSpkOutput();
voicePromptActive = false;
vpCurrentSequence.pos = 0;
vpCurrentSequence.c2DataIndex = 0;
vpCurrentSequence.c2DataLength = 0;
disableSpkOutput();
codec_stop();
}
}
@ -657,8 +659,8 @@ void vp_beep(uint16_t freq, uint16_t duration)
beepSeriesBuffer[1].duration = 0;
currentBeepDuration = duration;
beepSeriesIndex = 0;
enableSpkOutput();
platform_beepStart(freq);
enableSpkOutput();
}
void vp_beepSeries(const uint16_t* beepSeries)

View File

@ -51,6 +51,8 @@ void audio_init()
#endif
#endif
gpio_setMode(BEEP_OUT, INPUT);
gpio_setPin(SPK_MUTE); // Speaker muted
#ifndef PLATFORM_MD9600
gpio_clearPin(AUDIO_AMP_EN); // Audio PA off

View File

@ -178,7 +178,7 @@ streamId outputStream_start(const enum AudioSink destination,
NVIC_EnableIRQ(DMA1_Stream2_IRQn);
// Enable compare channel
TIM3->CCR3 = 0;
TIM3->CCR3 = buf[0];
TIM3->CCER |= TIM_CCER_CC3E;
TIM3->CR1 |= TIM_CR1_CEN;