Currently I have project using VS1003B.
How about to send WAV file? I try to send MP3 and it's OK but when try send WAV file there is no sound on output.
Here my init code
Code: Select all
uint8_t VSInitSoftware()
{
WriteSci(SCI_MODE, SM_SDINEW | SM_OUTOFWAV | SM_RESET ); //|SM_SDISHARE|SM_TESTS|SM_RESET);
WriteSci(SCI_CLOCKF,
HZ_TO_SC_FREQ(12288000) | SC_MULT_03_30X | SC_ADD_03_10X);
/*Set volume level at 0 db (0.5 db Steps) -> ((leftchannelx256)+rightchannel */
WriteSci(SCI_VOL, 0x0000); //Full Volume
//WriteSci(SCI_BASS, 0x0055);
WriteSci(SCI_DECODE_TIME, 0); //Reset Decode Time
return 0;
}
Code: Select all
void playFile()
{
uint32_t bytesInBuffer;
uint32_t pos = 0;
long nextReportPos=0;
FRESULT result;
result = f_read(&AudioFile, playBuf, FILE_BUFFER_SIZE, (void*)&bytesInBuffer);
if( result == FR_OK)
{
uint8_t *bufP = playBuf;
while(bytesInBuffer){
int t = min(SDI_MAX_TRANSFER_SIZE, bytesInBuffer);
SendSDI(bufP, t);
bufP += t;
bytesInBuffer -= t;
pos += t;
/*If playback is going on as normal, see if we need to collect and update display lcd*/
if(pos >= nextReportPos)
{
h1 = ReceiveSci(SCI_HDAT1); //global variable
nextReportPos += 4096;
sampleRate = ReceiveSci(SCI_AUDATA); //global variable
time = ReceiveSci(SCI_DECODE_TIME); //global variable
}
}
}else
{
Player_Close();
}
}
Code: Select all
uint8_t SendSDI(uint8_t* buffer, uint8_t size)
{
Mp3SelectData(); //xDCS = 0
while(!CheckVS1003B_DRQ()); //Check DREQ pin
if(HAL_SPI_Transmit(&VSSpiHandle, (uint8_t*)buffer, size, 500) != HAL_OK)
{
return 1;
}
Mp3DeselectData(); //xDCS = 1
Mp3DeselectControl(); //xCS = 1
return 0;
}