Step 4: Include Application-specific Source Files, Add Required Code, and Build the Project

Last modified by Microchip on 2024/02/06 09:50

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

Copied files

Note: This snapshot has the audio_player_lab3 application source and header files (app_tone_textfile_sdcard.c and app_tone_textfile_sdcard.h) already removed from the apps/training/solutions/dev/audio_player/audio_player_lab4/firmware/src folder to avoid any confusion. You will likely see those files in this folder when you are executing this step.

Back to Top


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 existing item

Select items

  • Add app_sdcard_audio_task.h and decoder.h to Header Files\app by right clicking and selecting Add Existing Items…

Add existing item

Select item

Back to Top


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.

Remove from project

  • Right-click on the app_tone_textfile_sdcard.c file and select Remove From Project.

Remove from project

After performing this step, the files under the project should look like this:

View project files

Back to Top


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.

Preprocessing and messages

  • Click on the box beside Include directories.

Include directories

Browse to the following path:
..firmware\src\config\default\audio\decoder\audio_decoders.
Select OK.

Browse

Audio decoders

Browse

Back to Top


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.

Audio initialize

Back to Top


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.

Audio tasks

Back to Top


At the top of app.c, change the name of the prototypes as shown in the accompanying image.

Prototypes

Back to Top


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.

Audio initializeButton task change

 

Back to Top


Save all files and build the code. Click on the Clean and Build icon rebuild-project icon and verify that the project builds successfully.

Back to Top