Step 4: Include Application-Specific Source Files, Add Required Code and Build the Project
Copy the source files into your project's Source Files folder:
- app_sdcard_reader_task.c
- app_sdcard_reader_task.h
- app_button_press_task.c
- app_button_press_task.h
Copy them from the following folder:
apps/training/solutions/audio_player/audio_player_lab3/dev_files
to this one:
apps/training/solutions/dev/audio_player/audio_player_lab3/firmware/src
Add the copied source files to your project.
Add app_sdcard_reader_task.c and app_button_press_task.c to the Source Files folder (in the MPLAB® X IDE Projects pane) by right-clicking and selecting Add Existing Item…
Add app_sdcard_reader_task.h and app_button_press_task.h to the Header Files folder by right-clicking and selecting Add Existing Item…
The files under the project should look like this:
Open the app.c file and add the function prototypes for the SD card reader and button press tasks.
Add the initialization routines for the SD card reader and button press tasks.
Modify the APP_Tasks function to add the two newly added tasks, under the APP_STATE_SERVICE_TASKS state.
Add two functions that will set and get the current mode of the application. This will execute either the player functionality implemented by the APP_TONE_TEXTFILE_SDCARD_Tasks, or the SD card reader functionality implemented by the APP_SDCARD_READER_Tasks.
Now, open the app.h file and add the following enumeration. This will be used to manage the application modes.
Next, modify the APP_DATA structure to include the application's mode related information.
You also need to expose the set and get mode functions to other tasks. Include the following declarations in the app.h file.
Finally, open app_tone_textfile_sdcard.c and add the following include file and condition. This will ensure the APP_TONE_TEXTFILE_SDCARD_Tasks function runs only when the audio playback mode is selected.