Last audio fix ?

This commit is contained in:
3djc
2020-03-04 18:53:42 +01:00
parent 9c925457b4
commit f7cb20f665
4 changed files with 26 additions and 18 deletions
@@ -134,6 +134,12 @@ void audioSpiInit(void)
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TXE);
}
void audioWaitReady()
{
// The audio amp needs ~2s to start
RTOS_WAIT_MS(2000); // 2s
}
void audioSpiSetSpeed(uint8_t speed)
{
AUDIO_SPI->CR1 &= 0xFFC7; // Fsck=Fcpu/256
+1 -5
View File
@@ -564,11 +564,7 @@ void audioConsumeCurrentBuffer();
#define audioEnableIrq() // interrupts must stay enabled on Horus
#if defined(PCBX12S)
#define setSampleRate(freq)
inline void audioWaitReady()
{
// The audio amp needs ~2s to start
RTOS_WAIT_MS(2000); // 2s
}
void audioWaitReady();
#else
void setSampleRate(uint32_t frequency);
#define audioWaitReady()
+18 -6
View File
@@ -378,26 +378,37 @@ void audioAmpInit()
bool hardResetDone = false;
bool softResetDone = false;
bool isAudioReady() {
bool isAudioReady()
{
return hardResetDone && softResetDone;
}
bool audioChipReset(){
void audioWaitReady()
{
while (!isAudioReady()) {
audioChipReset();
RTOS_WAIT_MS(1000);
}
}
bool audioChipReset()
{
audioSpiSetSpeed(SPI_SPEED_64);
if(!hardResetDone) {
if (!hardResetDone) {
hardResetDone = audioHardReset() > 0;
softResetDone = false;
}
if(!softResetDone) {
if (!softResetDone) {
softResetDone = audioSoftReset() > 0;
}
audioSpiSetSpeed(SPI_SPEED_8);
if(hardResetDone && softResetDone) {
if (hardResetDone && softResetDone) {
audioSendRiffHeader();
audioOn();
}
return hardResetDone && softResetDone;
}
void audioInit()
{
audioAmpInit();
@@ -422,9 +433,10 @@ void audioSetCurrentBuffer(const AudioBuffer * buffer)
void audioConsumeCurrentBuffer()
{
if(!hardResetDone || !softResetDone) {
if (!hardResetDone || !softResetDone) {
return;
}
if (newVolume >= 0) {
uint8_t value = newVolume;
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
+1 -7
View File
@@ -464,13 +464,7 @@ void audioOn();
void audioOff();
bool isAudioReady();
bool audioChipReset();
inline void audioWaitReady()
{
while (!isAudioReady()) {
audioChipReset();
RTOS_WAIT_MS(1000);
}
}
void audioWaitReady();
#define SPI_SPEED_2 0
#define SPI_SPEED_4 1