Step 4: Include Application-specific Source Files, Add Required Code, and Build the Project
Copy source files into your project's source files folder:
- app_sdcard_audio_task.c
- app_sdcard_audio_task.h
- decoder.c
- decoder.h
Copy them from this folder:
apps/training/solutions/audio_player/audio_player_lab4/dev_files
to this one:
apps/training/solutions/dev/audio_player/audio_player_lab4/firmware/src
Add the copied source files to your project.
- Add app_sdcard_audio_task.c and decoder.c to Source Files\app by right clicking and selecting Add Existing Items…
- Add app_sdcard_audio_task.h and decoder.h to Header Files\app by right clicking and selecting Add Existing Items…
Remove app_tone_textfile_sdcard.c and app_tone_textfile_sdcard.h from the folder.
- Right-click on the app_tone_textfile_sdcard.h file and select Remove From Project.
- Right-click on the app_tone_textfile_sdcard.c file and select Remove From Project.
After performing this step, the files under the project should look like this:
Next, we need to tell the compiler about the path of the decoders and include files.
- To include this path, right click on the project name audio_player_lab4 in the MPLAB® X IDE Projects pane and select Properties.
- In the Categories pane, select Conf:[default] > XC32 (Global Options) > xc32-gcc.
- Now, click on the Option categories dropdown menu and select the Preprocessing and Messages option.
- Click on the box beside Include directories.
Browse to the following path:
..firmware\src\config\default\audio\decoder\audio_decoders.
Select OK.
As we did with the previous exercise, we will modify the app.c and app.h files from the previous exercise in order to change function names to match the function names in the newly included app_sdcard_audio_task.c file. Open the file app.c and find the APP_Initialize function. Change the function named:
APP_TONE_TEXTFILE_SDCARD_Initialize()
to:
APP_SDCARD_AUDIO_Initialize() as shown in the accompanying image.
Find the APP_Tasks function and change the function named:
APP_TONE_TEXTFILE_SDCARD_Tasks()
to:
APP_SDCARD_AUDIO_Tasks() as shown in the accompanying image.
At the top of app.c, change the name of the prototypes as shown in the accompanying image.
Next, open app_button_press_task.c and change the name of the prototype/function from:
APP_TONE_TEXTFILE_SDCARD_SuspendStreaming
to:
APP_SDCARD_AUDIO_SuspendStreaming.
Also, change the name of the prototype/function from:
APP_TONE_TEXTFILE_SDCARD_Initialize
to:
APP_SDCARD_AUDIO_Initialize, as shown in the accompanying image.