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,26 +378,37 @@ 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;
|
||||||
softResetDone = false;
|
softResetDone = false;
|
||||||
}
|
}
|
||||||
if(!softResetDone) {
|
if (!softResetDone) {
|
||||||
softResetDone = audioSoftReset() > 0;
|
softResetDone = audioSoftReset() > 0;
|
||||||
}
|
}
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
if(hardResetDone && softResetDone) {
|
if (hardResetDone && softResetDone) {
|
||||||
audioSendRiffHeader();
|
audioSendRiffHeader();
|
||||||
audioOn();
|
audioOn();
|
||||||
}
|
}
|
||||||
return hardResetDone && softResetDone;
|
return hardResetDone && softResetDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioInit()
|
void audioInit()
|
||||||
{
|
{
|
||||||
audioAmpInit();
|
audioAmpInit();
|
||||||
@@ -422,9 +433,10 @@ void audioSetCurrentBuffer(const AudioBuffer * buffer)
|
|||||||
|
|
||||||
void audioConsumeCurrentBuffer()
|
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