The "GR-PEACH_Audio_Playback_7InchLCD_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

Dependencies:   GR-PEACH_video R_BSP TLV320_RBSP USBHost_custom

Fork of GR-PEACH_Audio_Playback_Sample by Renesas

Note

For a sample program of without LCD Board, please refer to GR-PEACH_Audio_Playback_Sample.

Introduction

The "GR-PEACH_Audio_Playback_7InchLCD_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

1. Overview of the Sample Code

1.1 Software Block Diagram

Figure 1.1 shows the software block diagram.

/media/uploads/1050186/lcd_figure1_1.png

1.2 Pin Definitions

Table 1.1 shows the pins used in this sample code.

/media/uploads/1050186/lcd_table1_1.png

2. Sample Code Operating Environment

In order to operate this sample code, GR-PEACH, Audio Camera Shield and 7.1 inch LCD Shield must be needed. For details on Audio Camera Shield and 7.1 inch LCD Shield, please refer to the following links, respectively:

In this section, it is described that how board is configured and to control audio playback via command line and touch screen.

2.1 Operating Environment

Figure 2.1 shows the overview of the operating environment for this sample code.

/media/uploads/1050186/lcd_figure2_1.png

Figure 2.2 and 2.3 show how to configure GR-PEACH, Audio Camera Shield and 7.1 inch LCD shield when using USB0 and USB1, respectively.

/media/uploads/1050186/lcd_figure2_2.png /media/uploads/1050186/lcd_figure2_3.png

Table 2.1 lists the overview of Graphical User Interface (GUI) of this sample code.

/media/uploads/1050186/lcd_table2_1.png

2.2 List of User Operations

Table 2.2 shows the relationship among Audio Playback, Command Line and Onboard Switch.

/media/uploads/1050186/lcd_table2_2.png

3. Function Outline

Table 3.1, 3.2 and 3.3 shows the overview of functions implemented in this sample code.

/media/uploads/1050186/lcd_table3_1.png /media/uploads/1050186/lcd_table3_2.png /media/uploads/1050186/lcd_table3_3.png /media/uploads/1050186/lcd_figure3_1.png

3.1 Playback Control

This sample program supports the operation "play", "pause", "stop", "play next song" and "play previous song".

3.2 Trick Play Control

In order to enable/disable Repeat Mode, user need to type "repeat" on command line or click the corresponding icon shown in Table 2.2. By derault, Repeat Mode is enabled. When Repeat Mode is enabled, the first song is played back after the playback of the last song is finished. Otherwise, the playback is shopped when finishing to play back the last song.

3.3 How to see Song Information

The information of the song being played back can be seen by typing playinfo on command line. Table 3.4 lists the items user can see on the terminal.

/media/uploads/dkato/audioplayback_table3_4.png

3.4 How to analyze the folder structure in USB stick

In this sample code, the folder structure in USB stick is analyzed in the breadth-first order. Table 3.5 shows how the files in USB stick are numbered.

/media/uploads/dkato/audioplayback_table3_5.png

4.Others

4.1 Serial Communication Setting

With respect to the default serial communication related setting on mbed, please refer to the follwing link:
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication
Please set up the terminal software you would like to use on your PC in consideration of the above. For example, 9600 should be specified for the baud rate on the terminal in order to control this sample via command line.

4.2 Necessary modification when using GCC ARM Embedded

If you would like to use GCC ARM Embedded, you must revise the following linker script incorporated in mbed OS 5 package as follows:

  • Linker Script to be modified
    $(PROJECT_ROOT)/mbed-os/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/TOOLCHAIN_GCC_ARM/RZA1H.ld

    Please note that $(PROJECT_ROOT) in the above denotes the root directory of this sample code

  • Before Modification

RZA1H.ld

/* Linker script for mbed RZ_A1H */

/* Linker script to configure memory regions. */
MEMORY
{
  ROM   (rx)  : ORIGIN = 0x00000000, LENGTH = 0x02000000
  BOOT_LOADER (rx) : ORIGIN = 0x18000000, LENGTH = 0x00004000 
  SFLASH (rx) : ORIGIN = 0x18004000, LENGTH = 0x07FFC000 
  L_TTB (rw)  : ORIGIN = 0x20000000, LENGTH = 0x00004000 
  RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 0x00700000
  RAM_NC (rwx) : ORIGIN = 0x20900000, LENGTH = 0x00100000
}
(snip)
  • After Modification

RZA1H.ld

/* Linker script for mbed RZ_A1H */

/* Linker script to configure memory regions. */
MEMORY
{
  ROM   (rx)  : ORIGIN = 0x00000000, LENGTH = 0x02000000
  BOOT_LOADER (rx) : ORIGIN = 0x18000000, LENGTH = 0x00004000 
  SFLASH (rx) : ORIGIN = 0x18004000, LENGTH = 0x07FFC000 
  L_TTB (rw)  : ORIGIN = 0x20000000, LENGTH = 0x00004000 
  RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 0x00180000
  RAM_NC (rwx) : ORIGIN = 0x20200000, LENGTH = 0x00680000
}
(snip)

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Thu Nov 05 02:46:24 2015 +0000
Parent:
1:315326ec910b
Child:
3:44c8558c3a83
Commit message:
The output frequency was changed to 96kHz. The help command was added.

Changed in this revision

TLV320_RBSP.lib Show annotated file Show diff for this revision Revisions of this file
audio_out/audio_out.cpp Show annotated file Show diff for this revision Revisions of this file
decode/decode.cpp Show annotated file Show diff for this revision Revisions of this file
decode/decode.h Show annotated file Show diff for this revision Revisions of this file
display/disp_term.cpp Show annotated file Show diff for this revision Revisions of this file
display/display.cpp Show annotated file Show diff for this revision Revisions of this file
display/display.h Show annotated file Show diff for this revision Revisions of this file
key/key_cmd.cpp Show annotated file Show diff for this revision Revisions of this file
main/system.cpp Show annotated file Show diff for this revision Revisions of this file
main/system.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/TLV320_RBSP.lib	Tue Oct 20 10:22:12 2015 +0000
+++ b/TLV320_RBSP.lib	Thu Nov 05 02:46:24 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Renesas/code/TLV320_RBSP/#db6504d3f914
+http://mbed.org/teams/Renesas/code/TLV320_RBSP/#15487e571d9f
--- a/audio_out/audio_out.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/audio_out/audio_out.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -67,7 +67,7 @@
 #define OUTPUT_UPDATE_TRIGGER       (1)     /* Numerical value of the trigger */
                                             /* to update the output of PCM data */
 
-#define PCM_BUF_NUM                 (9u)
+#define PCM_BUF_NUM                 (DEC_SCUX_READ_NUM)
 #define TOTAL_SAMPLE_NUM            (SAMPLE_PER_UNIT_MS * DEC_OUTPUT_CHANNEL_NUM)
 
 /*--- Macro definition of TLV320_RBSP ---*/
--- a/decode/decode.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/decode/decode.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -83,7 +83,7 @@
 
 /*--- Macro definition of R_BSP_Scux ---*/
 #define SCUX_INT_LEVEL              (0x80)
-#define SCUX_READ_NUM               (PCM_BUF_NUM)
+#define SCUX_READ_NUM               (DEC_SCUX_READ_NUM)
 #define SCUX_WRITE_NUM              (PCM_BUF_NUM)
 
 /* 4 bytes aligned. No cache memory. */
@@ -393,7 +393,7 @@
             /* Sets SCUX config */
             conf.src_enable           = true;
             conf.word_len             = SCUX_DATA_LEN_24;
-            conf.mode_sync            = false;
+            conf.mode_sync            = true;
             conf.input_rate           = p_ctrl->sample_rate;
             conf.output_rate          = DEC_OUTPUT_SAMPLE_RATE;
             conf.select_in_data_ch[0] = SELECT_IN_DATA_CH_0;
--- a/decode/decode.h	Tue Oct 20 10:22:12 2015 +0000
+++ b/decode/decode.h	Thu Nov 05 02:46:24 2015 +0000
@@ -36,13 +36,14 @@
 #define DEC_24BITS_PER_SAMPLE       (24u)       /* Bit count per sample */
 #define DEC_MAX_CHANNEL_NUM         (2u)        /* Maximum number of channel */
 #define DEC_OUTPUT_PADDING_BITS     (8u)        /* Padding of lower 8 bits */
+#define DEC_SCUX_READ_NUM           (9u)        /* The number of buffuer for SCUX read */
 
 /* Minimum sampling rate in Hz of input file */
 #define DEC_INPUT_MIN_SAMPLE_RATE   (SAMPLING_RATE_22050HZ)
 /* Maximum sampling rate in Hz of input file */
 #define DEC_INPUT_MAX_SAMPLE_RATE   (SAMPLING_RATE_96000HZ)
 /* Sampling rate in Hz of audio output */
-#define DEC_OUTPUT_SAMPLE_RATE      (SAMPLING_RATE_88200HZ)
+#define DEC_OUTPUT_SAMPLE_RATE      (SAMPLING_RATE_96000HZ)
 /* Channel number of audio output */
 #define DEC_OUTPUT_CHANNEL_NUM      (DEC_MAX_CHANNEL_NUM)
 /* Bit count per sample of audio output */
--- a/display/disp_term.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/display/disp_term.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -46,6 +46,17 @@
 #define MSG_MODE_ON             "on"
 #define MSG_MODE_OFF            "off"
 
+#define HELP_CMD_NUM            (7u)
+
+/* help information */
+#define HELP_INFO_HELP          "help      : Show help information for commands."
+#define HELP_INFO_NEXT          "next      : Select the next song."
+#define HELP_INFO_PLAYINFO      "playinfo  : Show the song information."
+#define HELP_INFO_PLAYPAUSE     "playpause : Control playback/pause."
+#define HELP_INFO_PREV          "prev      : Select the previous song."
+#define HELP_INFO_REPEAT        "repeat    : Turn on and off the repeat mode."
+#define HELP_INFO_STOP          "stop      : Stop playback."
+
 #define MIN_TO_SEC              (60u)
 #define HOUR_TO_SEC             (3600u)
 
@@ -53,6 +64,7 @@
 
 static void output_prompt(const dsp_com_ctrl_t * const p_com);
 static void output_playinfo(const dsp_com_ctrl_t * const p_com);
+static void output_help_info(void);
 static void clear_current_line(void);
 static void output_cr(void);
 static void output_string(const char_t * const p_str);
@@ -109,6 +121,11 @@
                 output_string(&p_com->file_name[0]);
                 output_cr();
                 break;
+            case DSP_MAILID_HELP:        /* Help information */
+                is_update = true;
+                clear_current_line();
+                output_help_info();
+                break;
             case DSP_MAILID_CYCLE_IND:  /* Cyclic notice */
             default:                    /* Unexpected cases : mail id was illegal. */
                 is_update = false;
@@ -186,6 +203,31 @@
     }
 }
 
+/** Prints the command help informations.
+ *
+ */
+static void output_help_info(void)
+{
+    uint32_t i;
+    struct {
+        const char_t    *p_help_info;
+    } static const info_list[HELP_CMD_NUM] = {
+        {   HELP_INFO_HELP        },
+        {   HELP_INFO_NEXT        },
+        {   HELP_INFO_PLAYINFO    },
+        {   HELP_INFO_PLAYPAUSE   },
+        {   HELP_INFO_PREV        },
+        {   HELP_INFO_REPEAT      },
+        {   HELP_INFO_STOP        }
+    };
+
+    /* Prints the help information in alphabetical order. */
+    for (i = 0u; i < HELP_CMD_NUM; i++) {
+        output_string(info_list[i].p_help_info);
+        output_cr();
+    }
+}
+
 /** Clears a cursor line
  *
  */
--- a/display/display.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/display/display.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -70,6 +70,11 @@
 #define MAIL_FILENAME_STR_START     (0)     /* Start position of file name string */
 #define MAIL_FILENAME_STR_SIZE      (64)    /* Size of file name string */
 
+/* mail_id = DSP_MAILID_HELP */
+#define MAIL_HELP_PARAM             (0)     /* No mail parameter to be used */
+
+#define MAIL_PARAM_NON              (0u)    /* Value of unused element of mail parameter array */
+
 #define BYTE_SHIFT                  (8u)
 #define WORD_SHIFT                  (16u)
 
@@ -215,6 +220,17 @@
     return ret;
 }
 
+bool dsp_req_help(void)
+{
+    bool            ret = false;
+    dsp_mail_t      data;
+
+    data.mail_id = DSP_MAILID_HELP;
+    data.param[MAIL_HELP_PARAM] = (uint8_t)MAIL_PARAM_NON;
+    ret = send_mail(&data);
+    return ret;
+}
+
 /** initialises the control data of the display module
  *
  *  @param p_ctrl Pointer to control data of display module.
@@ -372,6 +388,9 @@
                               sizeof(p_ctrl->com.file_name));
                 p_ctrl->com.file_name[DSP_DISP_STR_MAX_LEN - 1] = '\0';
                 break;
+            case DSP_MAILID_HELP:            /* Help information */
+                ret = true; 
+                break;
             default:
                 /* Unexpected cases : mail id was illegal. */
                 ret = false;
--- a/display/display.h	Tue Oct 20 10:22:12 2015 +0000
+++ b/display/display.h	Thu Nov 05 02:46:24 2015 +0000
@@ -48,6 +48,7 @@
     DSP_MAILID_PLAY_INFO,   /* Notifies display thread of playback information. */
     DSP_MAILID_PLAY_MODE,   /* Notifies display thread of repeat mode. */
     DSP_MAILID_FILE_NAME,   /* Notifies display thread of file name. */
+    DSP_MAILID_HELP,        /* Requests display thread to display help message. */
     DSP_MAILID_NUM
 } DSP_MAIL_ID;
 
@@ -202,4 +203,14 @@
  */
 bool dsp_notify_input_string(const char_t * const p_str, const bool flag_fin);
 
+/** Requests the display thread to display help message.
+ *
+ *  @returns 
+ *    Returns true if the API is successful. Returns false if the API fails.
+ *    This function fails when:
+ *     Failed to secure memory for mailbox communication.
+ *     Failed to perform transmit processing for mailbox communication.
+ */
+bool dsp_req_help(void);
+
 #endif /* DISPLAY_H */
--- a/key/key_cmd.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/key/key_cmd.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -44,8 +44,9 @@
 #define CMD_PREV            "PREV"      /* Previous track */
 #define CMD_PLAYINFO        "PLAYINFO"  /* Play info */
 #define CMD_REPEAT          "REPEAT"    /* Repeat */
+#define CMD_HELP            "HELP"      /* Help */
 
-#define VALID_CMD_NUM       (6u)
+#define VALID_CMD_NUM       (7u)
 
 #define MAX_CNT_OF_ARG      (1u)
 
@@ -233,7 +234,8 @@
         {   CMD_NEXT,       SYS_KEYCODE_NEXT        },
         {   CMD_PREV,       SYS_KEYCODE_PREV        },
         {   CMD_PLAYINFO,   SYS_KEYCODE_PLAYINFO    },
-        {   CMD_REPEAT,     SYS_KEYCODE_REPEAT      }
+        {   CMD_REPEAT,     SYS_KEYCODE_REPEAT      },
+        {   CMD_HELP,       SYS_KEYCODE_HELP        }
     };
 
     if (p != NULL) {
--- a/main/system.cpp	Tue Oct 20 10:22:12 2015 +0000
+++ b/main/system.cpp	Thu Nov 05 02:46:24 2015 +0000
@@ -111,6 +111,7 @@
     SYS_EV_KEY_PREV,            /* "PREV" key */
     SYS_EV_KEY_PLAYINFO,        /* "PLAYINFO" key */
     SYS_EV_KEY_REPEAT,          /* "REPEAT" key */
+    SYS_EV_KEY_HELP,            /* "HELP" key */
     /* Notification of decoder process */
     SYS_EV_DEC_OPEN_COMP,       /* Finished the opening process */
     SYS_EV_DEC_OPEN_COMP_ERR,   /* Finished the opening process (An error occured)*/
@@ -200,6 +201,7 @@
 static void print_play_info(const play_info_t * const p_info);
 static void print_file_name(const play_info_t * const p_info, 
                                     const fid_scan_folder_t * const p_data);
+static void print_help_info(void);
 static uint32_t convert_track_id(const uint32_t trk_id);
 static bool send_mail(const SYS_MAIL_ID mail_id, const uint32_t param0,
                             const uint32_t param1, const uint32_t param2);
@@ -341,9 +343,12 @@
                     case SYS_KEYCODE_PLAYINFO:
                         ret = SYS_EV_KEY_PLAYINFO;
                         break;
-                    case SYS_EV_KEY_REPEAT:
+                    case SYS_KEYCODE_REPEAT:
                         ret = SYS_EV_KEY_REPEAT;
                         break;
+                    case SYS_KEYCODE_HELP:
+                        ret = SYS_EV_KEY_HELP;
+                        break;
                     default:
                         /* Unexpected cases : This is fail-safe processing. */
                         ret = SYS_EV_NON;
@@ -512,6 +517,8 @@
             (void) exe_scan_folder_proc(&p_ctrl->play_info, &p_ctrl->scan_data);
             (void) dsp_notify_print_string(PRINT_MSG_USB_CONNECT);
             next_stat = SYS_ST_STOP;
+        } else if (event == SYS_EV_KEY_HELP) {
+            print_help_info();
         } else {
             /* DO NOTHING */
         }
@@ -545,6 +552,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_USB_DISCONNECT:
                 p_ctrl->usb_ctrl.usb_flag_detach = true;
                 next_stat = SYS_ST_WAIT_USB_CONNECT;
@@ -593,6 +603,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_DEC_OPEN_COMP:
                 result = is_track_changed(&p_ctrl->play_info);
                 if (result == true) {
@@ -661,6 +674,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_DEC_OPEN_COMP:
                 print_play_time(&p_ctrl->play_info);
                 result = exe_close_proc();
@@ -749,6 +765,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_STAT_STOP:
                 print_play_time(&p_ctrl->play_info);
                 result = exe_close_proc();
@@ -816,6 +835,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_DEC_CLOSE_COMP:
                 exe_end_proc(&p_ctrl->play_info);
                 if (p_ctrl->usb_ctrl.usb_flag_detach == true) {
@@ -886,6 +908,9 @@
             case SYS_EV_KEY_REPEAT:
                 change_repeat_mode(&p_ctrl->play_info);
                 break;
+            case SYS_EV_KEY_HELP:
+                print_help_info();
+                break;
             case SYS_EV_DEC_CLOSE_COMP:
                 exe_end_proc(&p_ctrl->play_info);
                 print_file_name(&p_ctrl->play_info, &p_ctrl->scan_data);
@@ -1227,6 +1252,14 @@
     }
 }
 
+/** Prints the command help information
+ *
+ */
+static void print_help_info(void)
+{
+    (void) dsp_req_help();
+}
+
 /** Converts the track ID of main thread into the track ID of display thread
  *
  *  @param trk_id Track ID of main thread
--- a/main/system.h	Tue Oct 20 10:22:12 2015 +0000
+++ b/main/system.h	Thu Nov 05 02:46:24 2015 +0000
@@ -47,6 +47,7 @@
     SYS_KEYCODE_PREV,           /* Previous track */
     SYS_KEYCODE_PLAYINFO,       /* Play info */
     SYS_KEYCODE_REPEAT,         /* Repeat */
+    SYS_KEYCODE_HELP,           /* Help */
     SYS_KEYCODE_NUM
 } SYS_KeyCode;
 
@@ -73,6 +74,7 @@
  *                    Play previous song : SYS_KEYCODE_PREV
  *                    Show song information : SYS_KEYCODE_PLAYINFO
  *                    Switch repeat mode : SYS_KEYCODE_REPEAT
+ *                    Show help message: SYS_KEYCODE_HELP
  *
  *  @returns 
  *    Returns true if the API is successful. Returns false if the API fails.
--- a/mbed.bld	Tue Oct 20 10:22:12 2015 +0000
+++ b/mbed.bld	Thu Nov 05 02:46:24 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file