Last audio fix ?
This commit is contained in:
@@ -134,6 +134,12 @@ void audioSpiInit(void)
|
|||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TXE);
|
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)
|
void audioSpiSetSpeed(uint8_t speed)
|
||||||
{
|
{
|
||||||
AUDIO_SPI->CR1 &= 0xFFC7; // Fsck=Fcpu/256
|
AUDIO_SPI->CR1 &= 0xFFC7; // Fsck=Fcpu/256
|
||||||
|
|||||||
@@ -564,11 +564,7 @@ void audioConsumeCurrentBuffer();
|
|||||||
#define audioEnableIrq() // interrupts must stay enabled on Horus
|
#define audioEnableIrq() // interrupts must stay enabled on Horus
|
||||||
#if defined(PCBX12S)
|
#if defined(PCBX12S)
|
||||||
#define setSampleRate(freq)
|
#define setSampleRate(freq)
|
||||||
inline void audioWaitReady()
|
void audioWaitReady();
|
||||||
{
|
|
||||||
// The audio amp needs ~2s to start
|
|
||||||
RTOS_WAIT_MS(2000); // 2s
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
void setSampleRate(uint32_t frequency);
|
void setSampleRate(uint32_t frequency);
|
||||||
#define audioWaitReady()
|
#define audioWaitReady()
|
||||||
|
|||||||
@@ -378,11 +378,21 @@ void audioAmpInit()
|
|||||||
bool hardResetDone = false;
|
bool hardResetDone = false;
|
||||||
bool softResetDone = false;
|
bool softResetDone = false;
|
||||||
|
|
||||||
bool isAudioReady() {
|
bool isAudioReady()
|
||||||
|
{
|
||||||
return hardResetDone && softResetDone;
|
return hardResetDone && softResetDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audioChipReset(){
|
void audioWaitReady()
|
||||||
|
{
|
||||||
|
while (!isAudioReady()) {
|
||||||
|
audioChipReset();
|
||||||
|
RTOS_WAIT_MS(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool audioChipReset()
|
||||||
|
{
|
||||||
audioSpiSetSpeed(SPI_SPEED_64);
|
audioSpiSetSpeed(SPI_SPEED_64);
|
||||||
if (!hardResetDone) {
|
if (!hardResetDone) {
|
||||||
hardResetDone = audioHardReset() > 0;
|
hardResetDone = audioHardReset() > 0;
|
||||||
@@ -398,6 +408,7 @@ bool audioChipReset(){
|
|||||||
}
|
}
|
||||||
return hardResetDone && softResetDone;
|
return hardResetDone && softResetDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioInit()
|
void audioInit()
|
||||||
{
|
{
|
||||||
audioAmpInit();
|
audioAmpInit();
|
||||||
@@ -425,6 +436,7 @@ void audioConsumeCurrentBuffer()
|
|||||||
if (!hardResetDone || !softResetDone) {
|
if (!hardResetDone || !softResetDone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newVolume >= 0) {
|
if (newVolume >= 0) {
|
||||||
uint8_t value = newVolume;
|
uint8_t value = newVolume;
|
||||||
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
|
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
|
||||||
|
|||||||
@@ -464,13 +464,7 @@ void audioOn();
|
|||||||
void audioOff();
|
void audioOff();
|
||||||
bool isAudioReady();
|
bool isAudioReady();
|
||||||
bool audioChipReset();
|
bool audioChipReset();
|
||||||
inline void audioWaitReady()
|
void audioWaitReady();
|
||||||
{
|
|
||||||
while (!isAudioReady()) {
|
|
||||||
audioChipReset();
|
|
||||||
RTOS_WAIT_MS(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SPI_SPEED_2 0
|
#define SPI_SPEED_2 0
|
||||||
#define SPI_SPEED_4 1
|
#define SPI_SPEED_4 1
|
||||||
|
|||||||
Reference in New Issue
Block a user