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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers display.h Source File

display.h

00001 /*******************************************************************************
00002 * DISCLAIMER
00003 * This software is supplied by Renesas Electronics Corporation and is only
00004 * intended for use with Renesas products. No other uses are authorized. This
00005 * software is owned by Renesas Electronics Corporation and is protected under
00006 * all applicable laws, including copyright laws.
00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00016 * Renesas reserves the right, without notice, to make changes to this software
00017 * and to discontinue the availability of this software. By using this software,
00018 * you agree to the additional terms and conditions found by accessing the
00019 * following link:
00020 * http://www.renesas.com/disclaimer*
00021 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
00022 *******************************************************************************/
00023 
00024 #ifndef DISPLAY_H
00025 #define DISPLAY_H
00026 
00027 #include "r_typedefs.h"
00028 #include "system.h"
00029 
00030 /*--- Macro definition ---*/
00031 #define DSP_STACK_SIZE      (2048u)     /* Stack size of display thread */
00032 
00033 /* The maximum length of display character string. */
00034 #define DSP_DISP_STR_MAX_LEN        (64)
00035 /* The maximum length of input character string by the command-line. */
00036 #define DSP_CMD_INPT_STR_MAX_LEN    (63)
00037 
00038 /* The baud rate of the serial port for PC communication. */
00039 #define DSP_PC_COM_BAUDRATE         (9600)
00040 
00041 /* Display mode */
00042 #define DSP_DISPMODE_1              (1u)
00043 #define DSP_DISPMODE_2              (2u)
00044 #define DSP_DISPMODE_3              (3u)
00045 
00046 /*--- User defined types ---*/
00047 typedef enum {
00048     DSP_MAILID_DUMMY = 0,
00049     DSP_MAILID_CYCLE_IND,   /* Cyclic notice */
00050     DSP_MAILID_CMD_STR,     /* Notifies display thread of input string. */
00051     DSP_MAILID_PRINT_STR,   /* Notifies display thread of output string. */
00052     DSP_MAILID_PLAY_TIME,   /* Notifies display thread of playback time. */
00053     DSP_MAILID_PLAY_INFO,   /* Notifies display thread of playback information. */
00054     DSP_MAILID_PLAY_MODE,   /* Notifies display thread of repeat mode. */
00055     DSP_MAILID_FILE_NAME,   /* Notifies display thread of file name. */
00056     DSP_MAILID_HELP,        /* Requests display thread to display help message. */
00057     DSP_MAILID_DISP_MODE,   /* Notifies display thread of display mode. */
00058     DSP_MAILID_TFT_KEY,     /* Notifies display thread of tft keycode. */
00059     DSP_MAILID_AUDIO_FIN,   /* Notifies display thread of completion */
00060                             /* of audio data acquisition. */
00061     DSP_MAILID_PLAY_STAT,   /* Notifies display thread of play state. */
00062     DSP_MAILID_NUM
00063 } DSP_MAIL_ID;
00064 
00065 /* These data are used in all display modules. */
00066 typedef struct {
00067     uint32_t        disp_mode;      /* Display mode */
00068     SYS_PlayStat    play_stat;      /* Playback status */
00069     uint32_t        track_id;       /* Track number */
00070     uint32_t        play_time;      /* Playback time (sec) */
00071     uint32_t        total_time;     /* Total playback time (sec) */
00072     uint32_t        samp_freq;      /* Sampling frequency (Hz) */
00073     uint32_t        channel;        /* Channel number */
00074     bool            repeat_mode;    /* Repeat mode */
00075     char_t          file_name[DSP_DISP_STR_MAX_LEN];/* Character string of file name */
00076     char_t          dspl_str[DSP_DISP_STR_MAX_LEN]; /* Display character string */
00077     bool            edge_track_change; /* Indicates the change of track number. */
00078 } dsp_com_ctrl_t;
00079 
00080 /* These data are used only in the terminal-output module. */
00081 typedef struct {
00082     bool        edge_fin_inpt;      /* Completion status of the input by the command-line.*/
00083                                     /* [true = input completion, false = input now] */
00084     char_t      inpt_str[DSP_CMD_INPT_STR_MAX_LEN];/* Input character string by the command-line. */
00085 } dsp_trm_ctrl_t;
00086 
00087 /** Display Thread
00088  *
00089  *  @param argument Pointer to the thread function as start argument.
00090  */
00091 void dsp_thread(void const *argument);
00092 
00093 /** Notifies the display thread of the cyclic event.
00094  *
00095  *  @returns 
00096  *    Returns true if the API is successful. Returns false if the API fails.
00097  *    This function fails when:
00098  *     Failed to secure memory for mailbox communication.
00099  *     Failed to perform transmit processing for mailbox communication.
00100  */
00101 bool dsp_notify_cycle_time(void);
00102 
00103 /** Notifies the display thread of the song information (file number, play time, total play time, play state).
00104  *
00105  *  @param play_stat Playback state
00106  *                     Stopped : SYS_PLAYSTAT_STOP
00107  *                     Playing : SYS_PLAYSTAT_PLAY
00108  *                     Paused : SYS_PLAYSTAT_PAUSE
00109  *  @param file_no File number
00110  *                   1 to 999
00111  *  @param play_time Playback time (in seconds)
00112  *                     0 to 359999
00113  *                     * 0 hour, 0 minute, 0 second to 99 hours, 59 minutes, 59 seconds
00114  *  @param total_time Total play time (in seconds)
00115  *                      0 to 359999
00116  *                      * 0 hour, 0 minute, 0 second to 99 hours, 59 minutes, 59 seconds
00117  *
00118  *  @returns 
00119  *    Returns true if the API is successful. Returns false if the API fails.
00120  *    This function fails when:
00121  *     Failed to secure memory for mailbox communication.
00122  *     Failed to perform transmit processing for mailbox communication.
00123  */
00124 bool dsp_notify_play_time(const SYS_PlayStat play_stat, const uint32_t file_no, 
00125                             const uint32_t play_time, const uint32_t total_time);
00126 
00127 /** Notifies the display thread of the song information (file number, sampling frequency, and number of channels).
00128  *
00129  *  @param file_no File number
00130  *                   1 to 999
00131  *  @param sample_freq Sampling frequency (Hz)
00132  *                       22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000
00133  *  @param channel_num Number of channels
00134  *                       1, 2
00135  *
00136  *  @returns 
00137  *    Returns true if the API is successful. Returns false if the API fails.
00138  *    This function fails when:
00139  *     Failed to secure memory for mailbox communication.
00140  *     Failed to perform transmit processing for mailbox communication.
00141  */
00142 bool dsp_notify_play_info(const uint32_t file_no, 
00143                     const uint32_t sample_freq, const uint32_t channel_num);
00144 
00145 /** Notifies the display thread of the playback mode (repeat mode).
00146  *
00147  *  @param rep_mode Repeat mode
00148  *                    Repeat mode OFF : false
00149  *                    Repeat mode ON : true
00150  *
00151  *  @returns 
00152  *    Returns true if the API is successful. Returns false if the API fails.
00153  *    This function fails when:
00154  *     Failed to secure memory for mailbox communication.
00155  *     Failed to perform transmit processing for mailbox communication.
00156  */
00157 bool dsp_notify_play_mode(const bool rep_mode);
00158 
00159 /** Notifies the display thread of the file name.
00160  *
00161  *  @param p_str File name string
00162  *                 * The string must be terminated by '\0'.
00163  *                   The character code must be the local character code. Since the end of
00164  *                   a string is identified by the presence of '\0', a file name of 
00165  *                   multi-byte code may not be displayed correctly. 
00166  *                   The maximum length of the string that the display thread can notify
00167  *                   is 64 bytes including '\0'.
00168  *
00169  *  @returns 
00170  *    Returns true if the API is successful. Returns false if the API fails.
00171  *    This function fails when:
00172  *     The argument p_str is set to NULL.
00173  *     Failed to secure memory for mailbox communication.
00174  *     Failed to perform transmit processing for mailbox communication.
00175  */
00176 bool dsp_notify_file_name(const char_t * const p_str);
00177 
00178 /** Notifies the display thread of the string to be output on the terminal.
00179  *
00180  *  @param p_str String to be output on the terminal
00181  *                 * The string must be terminated by '\0'.
00182  *                   The character code must be the local character code. Since the end of
00183  *                   a string is identified by the presence of '\0', a file name of
00184  *                   multi-byte code may not be displayed correctly. 
00185  *                   The maximum length of the string that the display thread can notify
00186  *                   is 64 bytes including '\0'.
00187  *
00188  *  @returns 
00189  *    Returns true if the API is successful. Returns false if the API fails.
00190  *    This function fails when:
00191  *     The argument p_str is set to NULL.
00192  *     Failed to secure memory for mailbox communication.
00193  *     Failed to perform transmit processing for mailbox communication.
00194  */
00195 bool dsp_notify_print_string(const char_t * const p_str);
00196 
00197 /** Notifies the display thread of the command line input string.
00198  *  * Used to echo back the string entered from the command line. 
00199  *
00200  *  @param p_str Command line input string
00201  *                 * The string must contain no control characters and terminate with '\0'.
00202  *                   The character code must be the local character code. Since the end of
00203  *                   a string is identified by the presence of '\0', a file name of
00204  *                   multi-byte code may not be displayed correctly.
00205  *                   The maximum length of the string that the display thread can notify
00206  *                   is 63 bytes including '\0'.
00207  *
00208  *  @param flag_fin Input completion flag
00209  *                   Middle of input : false
00210  *                   Input complete : true
00211  *
00212  *  @returns 
00213  *    Returns true if the API is successful. Returns false if the API fails.
00214  *    This function fails when:
00215  *     The argument p_str is set to NULL.
00216  *     Failed to secure memory for mailbox communication.
00217  *     Failed to perform transmit processing for mailbox communication.
00218  */
00219 bool dsp_notify_input_string(const char_t * const p_str, const bool flag_fin);
00220 
00221 /** Requests the display thread to display help message.
00222  *
00223  *  @returns 
00224  *    Returns true if the API is successful. Returns false if the API fails.
00225  *    This function fails when:
00226  *     Failed to secure memory for mailbox communication.
00227  *     Failed to perform transmit processing for mailbox communication.
00228  */
00229 bool dsp_req_help(void);
00230 
00231 /** Notifies the display thread of the display mode.
00232  *
00233  *  @param disp_mode display mode
00234  *
00235  *  @returns 
00236  *    Returns true if the API is successful. Returns false if the API fails.
00237  *    This function fails when:
00238  *     Failed to secure memory for mailbox communication.
00239  *     Failed to perform transmit processing for mailbox communication.
00240  */
00241 bool dsp_notify_disp_mode(const uint32_t disp_mode);
00242 
00243 /** Notifies the display thread of the information of the pushed key on TFT display.
00244  *
00245  *  @param key_code pushed key code
00246  *                    Play/pause : SYS_KEYCODE_PLAYPAUSE
00247  *                    Play next song : SYS_KEYCODE_NEXT
00248  *                    Play previous song : SYS_KEYCODE_PREV
00249  *                    Switch repeat mode : SYS_KEYCODE_REPEAT
00250  *                    Switch display mode : SYS_KEYCODE_MODE
00251  *
00252  *  @returns 
00253  *    Returns true if the API is successful. Returns false if the API fails.
00254  *    This function fails when:
00255  *     Failed to secure memory for mailbox communication.
00256  *     Failed to perform transmit processing for mailbox communication.
00257  */
00258 bool dsp_notify_tft_key(const SYS_KeyCode key_code);
00259 
00260 /** Notifies the display thread of the playback status.
00261  *
00262  *  @param play_stat pushed key code
00263  *                    Stopped : SYS_PLAYSTAT_STOP
00264  *                    Playing : SYS_PLAYSTAT_PLAY
00265  *                    Paused : SYS_PLAYSTAT_PAUSE
00266  *
00267  *  @returns 
00268  *    Returns true if the API is successful. Returns false if the API fails.
00269  *    This function fails when:
00270  *     Failed to secure memory for mailbox communication.
00271  *     Failed to perform transmit processing for mailbox communication.
00272  */
00273 bool dsp_notify_play_status(const SYS_PlayStat play_stat);
00274 
00275 /** This function converts the touch position of current screen into the key code.
00276  *
00277  *  @param disp_mode Display mode
00278  *  @param pos_x Touch X position
00279  *  @param pos_y Touch Y position
00280  *
00281  *  @returns 
00282  *    If touch position is on the picture of key, this function returns key code.
00283  *    Otherwise this function returns "SYS_KEYCODE_NON".
00284  */
00285 SYS_KeyCode dsp_convert_key(const uint32_t disp_mode, 
00286                                     const uint32_t pos_x, const uint32_t pos_y);
00287 
00288 #endif /* DISPLAY_H */