I'm trying to play audio file using FaTFs library on Open 4X9I-C board with UDA1380 audio decoder.
I looked over examples for my board and other eval boards and found AudioPlay() function which sends the data over I2S and updates Position and Remainig Size. However when I try to read data from a file on a SD-card and send it over I2S it just ends in massive noise.
Here's what I have so far:
extern uint32_t AudioRemSize;
extern uint16_t *CurrentPos;
res = f_mount(&fs, "", 0);
res = f_open(&fil, "0:ob.wav", FA_READ);
res = f_lseek(&fil, position);
res = f_read(&fil, rtext, BUFSIZE, (UINT*)&bytesread);
position += BUFSIZE;
uint32_t AUDIO_Play(uint16_t* pBuffer, uint32_t Size)
/* Set the total number of data to be played (count in half-word) */
AudioTotalSize = Size;
/* Update the Media layer and enable it for play */
/* Update the remaining number of data to be played */
AudioRemSize = Size/2 - DMA_MAX(AudioTotalSize);
/* Update the current audio pointer position */
CurrentPos = pBuffer + DMA_MAX(AudioTotalSize);
I would be greatly appreciated if someone could suggest anything.
I know I must be using f_forward instead of f_read and there is also an I2S Callback function which doesn't affect anything, but I'm just stuck.