Thank you for your answer. But it's also not working.
There should be appear something like that (on the display):
Song1.wav but it shows a letter and/or pixels
The whole code is to much for a post.
So here's the main part.
Code:
typedef struct
{
CPU_INT08S pcFilename[16];
CPU_INT32U *pucFilePtr;
}
tWaveFileInfo;
Code:
//#define NUM_WAVE_FILES 6u
//static tWaveFileInfo g_psWaveFiles[NUM_WAVE_FILES];
static CPU_INT32U NUM_WAVE_FILES;
static tWaveFileInfo *g_psWaveFiles;
Code:
static void AppTaskRobotAudioPlayback (void *p_arg)
{
OS_ERR err;
CPU_TS ts;
(void)&p_arg;
/*
*********************************************************************************************************
* READ THE WAV-TITLES STORED ON THE SDCARD
*********************************************************************************************************
*/
FRESULT fresult;
CPU_INT32U CountFiles = 0;
//The number of files are counted during a loop... This part is not in the code.
//So i've passed the value manuell
NUM_WAVE_FILES = 6;
g_psWaveFiles = malloc(NUM_WAVE_FILES * sizeof(*g_psWaveFiles));
//Mount the file system (SDCard), using logical disk 0.
fresult=f_mount(0, &g_sFatFs);
// Open the current directory for access.
fresult = f_opendir(&g_sDirObject, "/");
// Give message if there's no SDcard.
if(fresult != FR_OK)
{
BSP_DisplayClear();
BSP_DisplayStringDraw("ERROR!", 30u, 0u);
BSP_DisplayStringDraw("-- NO SDCARD --", 2u, 1u);
while(1){}
}
while(1)
{
// Read an entry from the directory.
fresult = f_readdir(&g_sDirObject, &g_sFileInfo);
// Check for error and return if there is a problem.
if(fresult != FR_OK)
{
BSP_DisplayClear();
BSP_DisplayStringDraw("ERROR!", 30u, 0u);
BSP_DisplayStringDraw("-- READING --", 7u, 1u);
while(1){}
}
// If the file name is blank, then stop the loop.
if(!g_sFileInfo.fname[0])
{
break;
}
// Copy the title to g_psWaveFiles[] - name.ext
if((g_sFileInfo.fattrib & AM_DIR) == 0) //Ignore directories
{
strncpy(g_psWaveFiles[CountFiles].pcFilename, g_sFileInfo.fname,
MAX_FILENAME_STRING_LEN);
// Go to the next file
CountFiles++;
}//while
}//void AppTaskRobotAudioPlayback
g_ucCurrentWaveIdx = 0;
strcpy(pcCurrentWaveTitle, g_psWaveFiles[0].pcFilename); /* Set the pointer to the first wave in the list. */
/*
***********************************************************************************************************
***********************************************************************************************************
*/
while (DEF_ON) {
OSFlagPend(&AppRobotControlFlagGroup, /* Pend until the play button is pressed. */
FLAG_PUSH_BUTTON,
0u,
OS_OPT_PEND_FLAG_SET_ANY + OS_OPT_PEND_FLAG_CONSUME,
&ts,
&err);
/* Get the current wave file information. */
BSP_WaveOpen(&g_sFileObject, g_psWaveFiles[g_ucCurrentWaveIdx].pcFilename, &g_sWaveHeader);
BSP_WavePlay(&g_sFileObject, &g_sWaveHeader); /* Play the file. */
}
}