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)
Committer:
Osamu Nakamura
Date:
Tue Apr 11 12:42:10 2017 +0900
Revision:
6:a957aaa284f0
Parent:
4:2672de88a46b
Update R-BSP from rev. cbb9d60c8748 to fb9eda52224e so that this program can be compiled with IAR toolchain.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:ee40da884cfc 1 /*******************************************************************************
dkato 0:ee40da884cfc 2 * DISCLAIMER
dkato 0:ee40da884cfc 3 * This software is supplied by Renesas Electronics Corporation and is only
dkato 0:ee40da884cfc 4 * intended for use with Renesas products. No other uses are authorized. This
dkato 0:ee40da884cfc 5 * software is owned by Renesas Electronics Corporation and is protected under
dkato 0:ee40da884cfc 6 * all applicable laws, including copyright laws.
dkato 0:ee40da884cfc 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
dkato 0:ee40da884cfc 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
dkato 0:ee40da884cfc 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
dkato 0:ee40da884cfc 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
dkato 0:ee40da884cfc 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
dkato 0:ee40da884cfc 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
dkato 0:ee40da884cfc 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
dkato 0:ee40da884cfc 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
dkato 0:ee40da884cfc 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
dkato 0:ee40da884cfc 16 * Renesas reserves the right, without notice, to make changes to this software
dkato 0:ee40da884cfc 17 * and to discontinue the availability of this software. By using this software,
dkato 0:ee40da884cfc 18 * you agree to the additional terms and conditions found by accessing the
dkato 0:ee40da884cfc 19 * following link:
dkato 0:ee40da884cfc 20 * http://www.renesas.com/disclaimer*
dkato 0:ee40da884cfc 21 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
dkato 0:ee40da884cfc 22 *******************************************************************************/
dkato 0:ee40da884cfc 23
dkato 0:ee40da884cfc 24 #include "mbed.h"
dkato 0:ee40da884cfc 25 #include "rtos.h"
dkato 0:ee40da884cfc 26 #include "misratypes.h"
dkato 0:ee40da884cfc 27 #include "display.h"
dkato 0:ee40da884cfc 28 #include "disp_term.h"
1050186 4:2672de88a46b 29 #include "disp_tft.h"
1050186 4:2672de88a46b 30 #include "key.h"
1050186 4:2672de88a46b 31 #include "audio_out.h"
dkato 0:ee40da884cfc 32
dkato 0:ee40da884cfc 33 /*--- Macro definition of mbed-rtos mail ---*/
1050186 4:2672de88a46b 34 #define MAIL_QUEUE_SIZE (32) /* Queue size */
dkato 0:ee40da884cfc 35 #define MAIL_PARAM_NUM (64) /* Elements number of mail parameter array */
dkato 0:ee40da884cfc 36
dkato 0:ee40da884cfc 37 /* dsp_mail_t */
dkato 0:ee40da884cfc 38 /* mail_id = DSP_MAILID_CYCLE_IND : No parameter */
1050186 4:2672de88a46b 39 #define MAIL_CYCLEIND_PARAM (0) /* No mail parameter to be used */
dkato 0:ee40da884cfc 40
dkato 0:ee40da884cfc 41 /* mail_id = DSP_MAILID_CMD_STR */
dkato 0:ee40da884cfc 42 #define MAIL_CMDSTR_FIN_FLG (0) /* Completion status of the input by the command-line */
dkato 0:ee40da884cfc 43 #define MAIL_CMDSTR_STR_START (1) /* Start position of input string by the command-line */
dkato 0:ee40da884cfc 44 #define MAIL_CMDSTR_STR_SIZE (DSP_CMD_INPT_STR_MAX_LEN)
dkato 0:ee40da884cfc 45 /* Size of input string by the command-line */
dkato 0:ee40da884cfc 46
dkato 0:ee40da884cfc 47 /* mail_id = DSP_MAILID_PRINT_STR */
dkato 0:ee40da884cfc 48 #define MAIL_DISPSTR_STR_START (0) /* Start position of display string */
dkato 0:ee40da884cfc 49 #define MAIL_DISPSTR_STR_SIZE (DSP_DISP_STR_MAX_LEN) /* Size of display string */
dkato 0:ee40da884cfc 50
dkato 0:ee40da884cfc 51 /* mail_id = DSP_MAILID_PLAY_TIME */
dkato 0:ee40da884cfc 52 #define MAIL_PLAYTIME_STAT (0) /* Playback status */
dkato 0:ee40da884cfc 53 #define MAIL_PLAYTIME_TRACK_L (1) /* Track number */
dkato 0:ee40da884cfc 54 #define MAIL_PLAYTIME_TRACK_H (2) /* Track number */
dkato 0:ee40da884cfc 55 #define MAIL_PLAYTIME_PLAYTIME_L (3) /* Playback time */
dkato 0:ee40da884cfc 56 #define MAIL_PLAYTIME_PLAYTIME_M (4) /* Playback time */
dkato 0:ee40da884cfc 57 #define MAIL_PLAYTIME_PLAYTIME_H (5) /* Playback time */
dkato 0:ee40da884cfc 58 #define MAIL_PLAYTIME_TOTALTIME_L (6) /* Total playback time */
dkato 0:ee40da884cfc 59 #define MAIL_PLAYTIME_TOTALTIME_M (7) /* Total playback time */
dkato 0:ee40da884cfc 60 #define MAIL_PLAYTIME_TOTALTIME_H (8) /* Total playback time */
dkato 0:ee40da884cfc 61
dkato 0:ee40da884cfc 62 /* mail_id = DSP_MAILID_PLAY_INFO */
dkato 0:ee40da884cfc 63 #define MAIL_PLAYINFO_TRACK_L (0) /* Track number */
dkato 0:ee40da884cfc 64 #define MAIL_PLAYINFO_TRACK_H (1) /* Track number */
dkato 0:ee40da884cfc 65 #define MAIL_PLAYINFO_SAMPFREQ_L (2) /* Sampling frequency */
dkato 0:ee40da884cfc 66 #define MAIL_PLAYINFO_SAMPFREQ_M (3) /* Sampling frequency */
dkato 0:ee40da884cfc 67 #define MAIL_PLAYINFO_SAMPFREQ_H (4) /* Sampling frequency */
dkato 0:ee40da884cfc 68 #define MAIL_PLAYINFO_CHANNEL (5) /* Channel structure */
dkato 0:ee40da884cfc 69
dkato 0:ee40da884cfc 70 /* mail_id = DSP_MAILID_PLAY_MODE */
dkato 0:ee40da884cfc 71 #define MAIL_PLAYMODE_REPEAT (0) /* Repeat mode */
dkato 0:ee40da884cfc 72
dkato 0:ee40da884cfc 73 /* mail_id = DSP_MAILID_FILE_NAME */
dkato 0:ee40da884cfc 74 #define MAIL_FILENAME_STR_START (0) /* Start position of file name string */
dkato 0:ee40da884cfc 75 #define MAIL_FILENAME_STR_SIZE (64) /* Size of file name string */
dkato 0:ee40da884cfc 76
dkato 2:d9fca8cd7f03 77 /* mail_id = DSP_MAILID_HELP */
dkato 2:d9fca8cd7f03 78 #define MAIL_HELP_PARAM (0) /* No mail parameter to be used */
dkato 2:d9fca8cd7f03 79
1050186 4:2672de88a46b 80 /* mail_id = DSP_MAILID_DISP_MODE */
1050186 4:2672de88a46b 81 #define MAIL_DISPMODE_MODE (0) /* Display mode */
1050186 4:2672de88a46b 82
1050186 4:2672de88a46b 83 /* mail_id = DSP_MAILID_TFT_KEY */
1050186 4:2672de88a46b 84 #define MAIL_TFTKEY_KEYCODE (0) /* Key code */
1050186 4:2672de88a46b 85
1050186 4:2672de88a46b 86 /* mail_id = DSP_MAILID_AUDIO_FIN */
1050186 4:2672de88a46b 87 #define MAIL_AUDIOFIN_PARAM (0) /* No mail parameter to be used */
1050186 4:2672de88a46b 88
1050186 4:2672de88a46b 89 /* mail_id = DSP_MAILID_PLAY_STAT */
1050186 4:2672de88a46b 90 #define MAIL_PLAYSTAT_STAT (0) /* Playback status */
1050186 4:2672de88a46b 91
dkato 2:d9fca8cd7f03 92 #define MAIL_PARAM_NON (0u) /* Value of unused element of mail parameter array */
dkato 2:d9fca8cd7f03 93
1050186 4:2672de88a46b 94
dkato 0:ee40da884cfc 95 #define BYTE_SHIFT (8u)
dkato 0:ee40da884cfc 96 #define WORD_SHIFT (16u)
1050186 4:2672de88a46b 97 #define AUDIO_DATA_SHIFT (24u)
1050186 4:2672de88a46b 98 #define PROC_CNT_AUDIO_GET (6u) /* Counter for 100ms period */
dkato 0:ee40da884cfc 99
dkato 0:ee40da884cfc 100 /*--- User defined types of mbed-rtos mail ---*/
dkato 0:ee40da884cfc 101 typedef struct {
dkato 0:ee40da884cfc 102 DSP_MAIL_ID mail_id;
dkato 0:ee40da884cfc 103 uint8_t param[MAIL_PARAM_NUM];
dkato 0:ee40da884cfc 104 } dsp_mail_t;
dkato 0:ee40da884cfc 105
dkato 0:ee40da884cfc 106 /* Control data of display thread */
dkato 0:ee40da884cfc 107 typedef struct {
dkato 0:ee40da884cfc 108 dsp_com_ctrl_t com; /* Common data */
dkato 0:ee40da884cfc 109 dsp_trm_ctrl_t trm; /* Terminal output module only */
dkato 0:ee40da884cfc 110 dsp_tft_ctrl_t tft; /* TFT module only */
dkato 0:ee40da884cfc 111 } dsp_ctrl_t;
dkato 0:ee40da884cfc 112
dkato 0:ee40da884cfc 113 static Mail<dsp_mail_t, MAIL_QUEUE_SIZE> mail_box;
dkato 0:ee40da884cfc 114
dkato 0:ee40da884cfc 115 static void init_ctrl_data(dsp_ctrl_t * const p_ctrl);
dkato 0:ee40da884cfc 116 static bool send_mail(const dsp_mail_t * const p_data);
dkato 0:ee40da884cfc 117 static bool recv_mail(dsp_mail_t * const p_data);
dkato 0:ee40da884cfc 118 static bool decode_mail(const dsp_mail_t * const p_mail, dsp_ctrl_t * const p_ctrl);
dkato 0:ee40da884cfc 119 static void clear_one_shot_data(dsp_ctrl_t * const p_ctrl);
1050186 4:2672de88a46b 120 static void audio_data_callback( const bool result, int16_t * const p_buf,
1050186 4:2672de88a46b 121 const uint32_t buf_num, const int32_t * const p_audio, const uint32_t audio_num);
dkato 0:ee40da884cfc 122
dkato 0:ee40da884cfc 123 void dsp_thread(void const *argument)
dkato 0:ee40da884cfc 124 {
dkato 0:ee40da884cfc 125 dsp_mail_t recv_data;
dkato 0:ee40da884cfc 126 bool result;
dkato 0:ee40da884cfc 127 static dsp_ctrl_t dsp_ctrl;
dkato 0:ee40da884cfc 128
dkato 0:ee40da884cfc 129 UNUSED_ARG(argument);
dkato 0:ee40da884cfc 130
dkato 0:ee40da884cfc 131 init_ctrl_data(&dsp_ctrl);
dkato 0:ee40da884cfc 132 dsp_init_term();
1050186 4:2672de88a46b 133 dsp_init_tft(&dsp_ctrl.tft);
dkato 0:ee40da884cfc 134 while (1) {
dkato 0:ee40da884cfc 135 result = recv_mail(&recv_data);
dkato 0:ee40da884cfc 136 if (result == true) {
dkato 0:ee40da884cfc 137 result = decode_mail(&recv_data, &dsp_ctrl);
dkato 0:ee40da884cfc 138 if (result == true) {
1050186 4:2672de88a46b 139 /* Executes main function of tft output module */
1050186 4:2672de88a46b 140 dsp_output_tft(recv_data.mail_id, &dsp_ctrl.com, &dsp_ctrl.tft);
dkato 0:ee40da884cfc 141 /* Executes main function of terminal output module */
dkato 0:ee40da884cfc 142 dsp_output_term(recv_data.mail_id, &dsp_ctrl.com, &dsp_ctrl.trm);
dkato 0:ee40da884cfc 143 /* Clears the one shot data */
dkato 0:ee40da884cfc 144 clear_one_shot_data(&dsp_ctrl);
dkato 0:ee40da884cfc 145 }
dkato 0:ee40da884cfc 146 }
dkato 0:ee40da884cfc 147 }
dkato 0:ee40da884cfc 148 }
dkato 0:ee40da884cfc 149
1050186 4:2672de88a46b 150 bool dsp_notify_cycle_time(void)
1050186 4:2672de88a46b 151 {
1050186 4:2672de88a46b 152 bool ret;
1050186 4:2672de88a46b 153 dsp_mail_t data;
1050186 4:2672de88a46b 154
1050186 4:2672de88a46b 155 data.mail_id = DSP_MAILID_CYCLE_IND;
1050186 4:2672de88a46b 156 data.param[MAIL_CYCLEIND_PARAM] = (uint8_t)MAIL_PARAM_NON;
1050186 4:2672de88a46b 157 ret = send_mail(&data);
1050186 4:2672de88a46b 158
1050186 4:2672de88a46b 159 return ret;
1050186 4:2672de88a46b 160 }
1050186 4:2672de88a46b 161
dkato 0:ee40da884cfc 162 bool dsp_notify_play_time(const SYS_PlayStat play_stat, const uint32_t file_no,
dkato 0:ee40da884cfc 163 const uint32_t play_time, const uint32_t total_time)
dkato 0:ee40da884cfc 164 {
dkato 0:ee40da884cfc 165 bool ret;
dkato 0:ee40da884cfc 166 dsp_mail_t data;
dkato 0:ee40da884cfc 167
dkato 0:ee40da884cfc 168 data.mail_id = DSP_MAILID_PLAY_TIME;
dkato 0:ee40da884cfc 169 data.param[MAIL_PLAYTIME_STAT] = (uint8_t)play_stat;
dkato 0:ee40da884cfc 170 data.param[MAIL_PLAYTIME_TRACK_L] = (uint8_t)file_no;
dkato 0:ee40da884cfc 171 data.param[MAIL_PLAYTIME_TRACK_H] = (uint8_t)(file_no >> BYTE_SHIFT);
dkato 0:ee40da884cfc 172 data.param[MAIL_PLAYTIME_PLAYTIME_L] = (uint8_t)play_time;
dkato 0:ee40da884cfc 173 data.param[MAIL_PLAYTIME_PLAYTIME_M] = (uint8_t)(play_time >> BYTE_SHIFT);
dkato 0:ee40da884cfc 174 data.param[MAIL_PLAYTIME_PLAYTIME_H] = (uint8_t)(play_time >> WORD_SHIFT);
dkato 0:ee40da884cfc 175 data.param[MAIL_PLAYTIME_TOTALTIME_L] = (uint8_t)total_time;
dkato 0:ee40da884cfc 176 data.param[MAIL_PLAYTIME_TOTALTIME_M] = (uint8_t)(total_time >> BYTE_SHIFT);
dkato 0:ee40da884cfc 177 data.param[MAIL_PLAYTIME_TOTALTIME_H] = (uint8_t)(total_time >> WORD_SHIFT);
dkato 0:ee40da884cfc 178 ret = send_mail(&data);
dkato 0:ee40da884cfc 179
dkato 0:ee40da884cfc 180 return ret;
dkato 0:ee40da884cfc 181 }
dkato 0:ee40da884cfc 182
dkato 0:ee40da884cfc 183 bool dsp_notify_play_info(const uint32_t file_no,
dkato 0:ee40da884cfc 184 const uint32_t sample_freq, const uint32_t channel_num)
dkato 0:ee40da884cfc 185 {
dkato 0:ee40da884cfc 186 bool ret;
dkato 0:ee40da884cfc 187 dsp_mail_t data;
dkato 0:ee40da884cfc 188
dkato 0:ee40da884cfc 189 data.mail_id = DSP_MAILID_PLAY_INFO;
dkato 0:ee40da884cfc 190 data.param[MAIL_PLAYINFO_TRACK_L] = (uint8_t)file_no;
dkato 0:ee40da884cfc 191 data.param[MAIL_PLAYINFO_TRACK_H] = (uint8_t)(file_no >> BYTE_SHIFT);
dkato 0:ee40da884cfc 192 data.param[MAIL_PLAYINFO_SAMPFREQ_L] = (uint8_t)sample_freq;
dkato 0:ee40da884cfc 193 data.param[MAIL_PLAYINFO_SAMPFREQ_M] = (uint8_t)(sample_freq >> BYTE_SHIFT);
dkato 0:ee40da884cfc 194 data.param[MAIL_PLAYINFO_SAMPFREQ_H] = (uint8_t)(sample_freq >> WORD_SHIFT);
dkato 0:ee40da884cfc 195 data.param[MAIL_PLAYINFO_CHANNEL] = (uint8_t)channel_num;
dkato 0:ee40da884cfc 196 ret = send_mail(&data);
dkato 0:ee40da884cfc 197
dkato 0:ee40da884cfc 198 return ret;
dkato 0:ee40da884cfc 199 }
dkato 0:ee40da884cfc 200
dkato 0:ee40da884cfc 201 bool dsp_notify_play_mode(const bool rep_mode)
dkato 0:ee40da884cfc 202 {
dkato 0:ee40da884cfc 203 bool ret;
dkato 0:ee40da884cfc 204 dsp_mail_t data;
dkato 0:ee40da884cfc 205
dkato 0:ee40da884cfc 206 data.mail_id = DSP_MAILID_PLAY_MODE;
dkato 0:ee40da884cfc 207 data.param[MAIL_PLAYMODE_REPEAT] = (uint8_t)rep_mode;
dkato 0:ee40da884cfc 208 ret = send_mail(&data);
dkato 0:ee40da884cfc 209
dkato 0:ee40da884cfc 210 return ret;
dkato 0:ee40da884cfc 211 }
dkato 0:ee40da884cfc 212
dkato 0:ee40da884cfc 213 bool dsp_notify_file_name(const char_t * const p_str)
dkato 0:ee40da884cfc 214 {
dkato 0:ee40da884cfc 215 bool ret = false;
dkato 0:ee40da884cfc 216 dsp_mail_t data;
dkato 0:ee40da884cfc 217
dkato 0:ee40da884cfc 218 if (p_str != NULL) {
dkato 0:ee40da884cfc 219 data.mail_id = DSP_MAILID_FILE_NAME;
dkato 0:ee40da884cfc 220 (void) memcpy(&data.param[MAIL_FILENAME_STR_START], p_str, MAIL_FILENAME_STR_SIZE);
dkato 0:ee40da884cfc 221 data.param[(MAIL_FILENAME_STR_START + MAIL_FILENAME_STR_SIZE) - 1] = '\0';
dkato 0:ee40da884cfc 222 ret = send_mail(&data);
dkato 0:ee40da884cfc 223 }
dkato 0:ee40da884cfc 224
dkato 0:ee40da884cfc 225 return ret;
dkato 0:ee40da884cfc 226 }
dkato 0:ee40da884cfc 227
dkato 0:ee40da884cfc 228 bool dsp_notify_print_string(const char_t * const p_str)
dkato 0:ee40da884cfc 229 {
dkato 0:ee40da884cfc 230 bool ret = false;
dkato 0:ee40da884cfc 231 dsp_mail_t data;
dkato 0:ee40da884cfc 232
dkato 0:ee40da884cfc 233 if (p_str != NULL) {
dkato 0:ee40da884cfc 234 data.mail_id = DSP_MAILID_PRINT_STR;
dkato 0:ee40da884cfc 235 (void) memcpy(&data.param[MAIL_DISPSTR_STR_START], p_str, MAIL_DISPSTR_STR_SIZE);
dkato 0:ee40da884cfc 236 data.param[(MAIL_DISPSTR_STR_START + MAIL_DISPSTR_STR_SIZE) - 1] = '\0';
dkato 0:ee40da884cfc 237 ret = send_mail(&data);
dkato 0:ee40da884cfc 238 }
dkato 0:ee40da884cfc 239
dkato 0:ee40da884cfc 240 return ret;
dkato 0:ee40da884cfc 241 }
dkato 0:ee40da884cfc 242
dkato 0:ee40da884cfc 243 bool dsp_notify_input_string(const char_t * const p_str, const bool flag_fin)
dkato 0:ee40da884cfc 244 {
dkato 0:ee40da884cfc 245 bool ret = false;
dkato 0:ee40da884cfc 246 dsp_mail_t data;
dkato 0:ee40da884cfc 247
dkato 0:ee40da884cfc 248 if (p_str != NULL) {
dkato 0:ee40da884cfc 249 data.mail_id = DSP_MAILID_CMD_STR;
dkato 0:ee40da884cfc 250 data.param[MAIL_CMDSTR_FIN_FLG] = (uint8_t)flag_fin;
dkato 0:ee40da884cfc 251 (void) memcpy(&data.param[MAIL_CMDSTR_STR_START], p_str, MAIL_CMDSTR_STR_SIZE);
dkato 0:ee40da884cfc 252 data.param[(MAIL_CMDSTR_STR_START + MAIL_CMDSTR_STR_SIZE) - 1] = '\0';
dkato 0:ee40da884cfc 253 ret = send_mail(&data);
dkato 0:ee40da884cfc 254 }
dkato 0:ee40da884cfc 255
dkato 0:ee40da884cfc 256 return ret;
dkato 0:ee40da884cfc 257 }
dkato 0:ee40da884cfc 258
dkato 2:d9fca8cd7f03 259 bool dsp_req_help(void)
dkato 2:d9fca8cd7f03 260 {
dkato 2:d9fca8cd7f03 261 bool ret = false;
dkato 2:d9fca8cd7f03 262 dsp_mail_t data;
dkato 2:d9fca8cd7f03 263
dkato 2:d9fca8cd7f03 264 data.mail_id = DSP_MAILID_HELP;
dkato 2:d9fca8cd7f03 265 data.param[MAIL_HELP_PARAM] = (uint8_t)MAIL_PARAM_NON;
dkato 2:d9fca8cd7f03 266 ret = send_mail(&data);
dkato 2:d9fca8cd7f03 267 return ret;
dkato 2:d9fca8cd7f03 268 }
dkato 2:d9fca8cd7f03 269
1050186 4:2672de88a46b 270 bool dsp_notify_disp_mode(const uint32_t disp_mode)
1050186 4:2672de88a46b 271 {
1050186 4:2672de88a46b 272 bool ret = false;
1050186 4:2672de88a46b 273 dsp_mail_t data;
1050186 4:2672de88a46b 274
1050186 4:2672de88a46b 275 data.mail_id = DSP_MAILID_DISP_MODE;
1050186 4:2672de88a46b 276 data.param[MAIL_DISPMODE_MODE] = (uint8_t)disp_mode;
1050186 4:2672de88a46b 277 ret = send_mail(&data);
1050186 4:2672de88a46b 278
1050186 4:2672de88a46b 279 return ret;
1050186 4:2672de88a46b 280 }
1050186 4:2672de88a46b 281
1050186 4:2672de88a46b 282 bool dsp_notify_tft_key(const SYS_KeyCode key_code)
1050186 4:2672de88a46b 283 {
1050186 4:2672de88a46b 284 bool ret = false;
1050186 4:2672de88a46b 285 dsp_mail_t data;
1050186 4:2672de88a46b 286
1050186 4:2672de88a46b 287 data.mail_id = DSP_MAILID_TFT_KEY;
1050186 4:2672de88a46b 288 data.param[MAIL_TFTKEY_KEYCODE] = (uint8_t)key_code;
1050186 4:2672de88a46b 289 ret = send_mail(&data);
1050186 4:2672de88a46b 290
1050186 4:2672de88a46b 291 return ret;
1050186 4:2672de88a46b 292 }
1050186 4:2672de88a46b 293
1050186 4:2672de88a46b 294 bool dsp_notify_play_status(const SYS_PlayStat play_stat)
1050186 4:2672de88a46b 295 {
1050186 4:2672de88a46b 296 bool ret;
1050186 4:2672de88a46b 297 dsp_mail_t data;
1050186 4:2672de88a46b 298
1050186 4:2672de88a46b 299 data.mail_id = DSP_MAILID_PLAY_STAT;
1050186 4:2672de88a46b 300 data.param[MAIL_PLAYSTAT_STAT] = (uint8_t)play_stat;
1050186 4:2672de88a46b 301 ret = send_mail(&data);
1050186 4:2672de88a46b 302
1050186 4:2672de88a46b 303 return ret;
1050186 4:2672de88a46b 304 }
1050186 4:2672de88a46b 305
1050186 4:2672de88a46b 306 SYS_KeyCode dsp_convert_key(const uint32_t disp_mode, const uint32_t pos_x, const uint32_t pos_y)
1050186 4:2672de88a46b 307 {
1050186 4:2672de88a46b 308 SYS_KeyCode ret;
1050186 4:2672de88a46b 309
1050186 4:2672de88a46b 310 ret = dsp_convert_key_tft(disp_mode, pos_x, pos_y);
1050186 4:2672de88a46b 311
1050186 4:2672de88a46b 312 return ret;
1050186 4:2672de88a46b 313 }
1050186 4:2672de88a46b 314
dkato 0:ee40da884cfc 315 /** initialises the control data of the display module
dkato 0:ee40da884cfc 316 *
dkato 0:ee40da884cfc 317 * @param p_ctrl Pointer to control data of display module.
dkato 0:ee40da884cfc 318 */
dkato 0:ee40da884cfc 319 static void init_ctrl_data(dsp_ctrl_t * const p_ctrl)
dkato 0:ee40da884cfc 320 {
dkato 0:ee40da884cfc 321 if (p_ctrl != NULL) {
dkato 0:ee40da884cfc 322 /* Initialises the common data of the display module. */
1050186 4:2672de88a46b 323 p_ctrl->com.disp_mode = DSP_DISPMODE_1;
dkato 0:ee40da884cfc 324 p_ctrl->com.play_stat = SYS_PLAYSTAT_STOP;
dkato 0:ee40da884cfc 325 p_ctrl->com.track_id = 0u;
dkato 0:ee40da884cfc 326 p_ctrl->com.play_time = 0u;
dkato 0:ee40da884cfc 327 p_ctrl->com.total_time = 0u;
dkato 0:ee40da884cfc 328 p_ctrl->com.samp_freq = 0u;
dkato 0:ee40da884cfc 329 p_ctrl->com.channel = 0u;
dkato 0:ee40da884cfc 330 p_ctrl->com.repeat_mode = false;
dkato 0:ee40da884cfc 331 p_ctrl->com.file_name[0] = '\0';
dkato 0:ee40da884cfc 332 p_ctrl->com.dspl_str[0] = '\0';
1050186 4:2672de88a46b 333 p_ctrl->com.edge_track_change = false;
dkato 0:ee40da884cfc 334
dkato 0:ee40da884cfc 335 /* Initialises the data of the terminal output module. */
dkato 0:ee40da884cfc 336 p_ctrl->trm.edge_fin_inpt = false;
dkato 0:ee40da884cfc 337 p_ctrl->trm.inpt_str[0] = '\0';
dkato 0:ee40da884cfc 338
dkato 0:ee40da884cfc 339 /* Does not initialize the data of TFT module. */
dkato 0:ee40da884cfc 340 /* Initial values are different by the display mode. */
dkato 0:ee40da884cfc 341 /* Therefore the data of TFT module is initialized by tft_init_proc function. */
dkato 0:ee40da884cfc 342 }
dkato 0:ee40da884cfc 343 }
dkato 0:ee40da884cfc 344
dkato 0:ee40da884cfc 345 /** Sends the mail to main thread
dkato 0:ee40da884cfc 346 *
dkato 0:ee40da884cfc 347 * @param p_data Pointer to the structure of the data
dkato 0:ee40da884cfc 348 *
dkato 0:ee40da884cfc 349 * @returns
dkato 0:ee40da884cfc 350 * Results of process. true is success. false is failure.
dkato 0:ee40da884cfc 351 */
dkato 0:ee40da884cfc 352 static bool send_mail(const dsp_mail_t * const p_data)
dkato 0:ee40da884cfc 353 {
dkato 0:ee40da884cfc 354 bool ret = false;
dkato 0:ee40da884cfc 355 osStatus stat;
dkato 0:ee40da884cfc 356 dsp_mail_t *p_mail;
dkato 0:ee40da884cfc 357
dkato 0:ee40da884cfc 358 if (p_data != NULL) {
dkato 0:ee40da884cfc 359 p_mail = mail_box.alloc();
dkato 0:ee40da884cfc 360 if (p_mail != NULL) {
dkato 0:ee40da884cfc 361 *p_mail = *p_data;
dkato 0:ee40da884cfc 362 stat = mail_box.put(p_mail);
dkato 0:ee40da884cfc 363 if (stat == osOK) {
dkato 0:ee40da884cfc 364 ret = true;
dkato 0:ee40da884cfc 365 } else {
dkato 0:ee40da884cfc 366 (void) mail_box.free(p_mail);
dkato 0:ee40da884cfc 367 }
dkato 0:ee40da884cfc 368 }
dkato 0:ee40da884cfc 369 }
dkato 0:ee40da884cfc 370 return ret;
dkato 0:ee40da884cfc 371 }
dkato 0:ee40da884cfc 372
dkato 0:ee40da884cfc 373 /** Receives the mail to main thread
dkato 0:ee40da884cfc 374 *
dkato 0:ee40da884cfc 375 * @param p_data Pointer to the structure of the data
dkato 0:ee40da884cfc 376 *
dkato 0:ee40da884cfc 377 * @returns
dkato 0:ee40da884cfc 378 * Results of process. true is success. false is failure.
dkato 0:ee40da884cfc 379 */
dkato 0:ee40da884cfc 380 static bool recv_mail(dsp_mail_t * const p_data)
dkato 0:ee40da884cfc 381 {
dkato 0:ee40da884cfc 382 bool ret = false;
dkato 0:ee40da884cfc 383 osEvent evt;
dkato 0:ee40da884cfc 384 dsp_mail_t *p_mail;
dkato 0:ee40da884cfc 385
dkato 0:ee40da884cfc 386 if (p_data != NULL) {
dkato 0:ee40da884cfc 387 evt = mail_box.get();
dkato 0:ee40da884cfc 388 if (evt.status == osEventMail) {
dkato 0:ee40da884cfc 389 p_mail = (dsp_mail_t *)evt.value.p;
dkato 0:ee40da884cfc 390 if (p_mail != NULL) {
dkato 0:ee40da884cfc 391 *p_data = *p_mail;
dkato 0:ee40da884cfc 392 ret = true;
dkato 0:ee40da884cfc 393 }
dkato 0:ee40da884cfc 394 (void) mail_box.free(p_mail);
dkato 0:ee40da884cfc 395 }
dkato 0:ee40da884cfc 396 }
dkato 0:ee40da884cfc 397 return ret;
dkato 0:ee40da884cfc 398 }
dkato 0:ee40da884cfc 399
dkato 0:ee40da884cfc 400 /** Decodes the display thread mail
dkato 0:ee40da884cfc 401 *
dkato 0:ee40da884cfc 402 * @param p_mail Pointer to the structure of the data
dkato 0:ee40da884cfc 403 * @param p_ctrl Pointer to control data of display module.
dkato 0:ee40da884cfc 404 *
dkato 0:ee40da884cfc 405 * @returns
dkato 0:ee40da884cfc 406 * Results of process. true is success. false is failure.
dkato 0:ee40da884cfc 407 */
dkato 0:ee40da884cfc 408 static bool decode_mail(const dsp_mail_t * const p_mail, dsp_ctrl_t * const p_ctrl)
dkato 0:ee40da884cfc 409 {
dkato 0:ee40da884cfc 410 bool ret = false;
1050186 4:2672de88a46b 411 dsp_audio_t *p_aud;
1050186 4:2672de88a46b 412 SYS_PlayStat cur_stat;
1050186 4:2672de88a46b 413 uint32_t trk_id;
1050186 4:2672de88a46b 414 uint32_t cur_time;
1050186 4:2672de88a46b 415
1050186 4:2672de88a46b 416
dkato 0:ee40da884cfc 417 if ((p_mail != NULL) && (p_ctrl != NULL)) {
dkato 0:ee40da884cfc 418 /* Decodes the received mail */
dkato 0:ee40da884cfc 419 switch(p_mail->mail_id) {
dkato 0:ee40da884cfc 420 case DSP_MAILID_CYCLE_IND: /* Cyclic notice */
1050186 4:2672de88a46b 421 p_aud = &p_ctrl->tft.audio_data;
1050186 4:2672de88a46b 422 p_aud->req_cyc_cnt++;
1050186 4:2672de88a46b 423 if (p_aud->req_cyc_cnt >= PROC_CNT_AUDIO_GET) {
1050186 4:2672de88a46b 424 p_aud->req_cyc_cnt = 0u;
1050186 4:2672de88a46b 425 (void) aud_get_audio_data(&audio_data_callback, &p_aud->req_buf[0],
1050186 4:2672de88a46b 426 sizeof(p_aud->req_buf)/sizeof(p_aud->req_buf[0]));
1050186 4:2672de88a46b 427 }
dkato 0:ee40da884cfc 428 ret = true;
dkato 0:ee40da884cfc 429 break;
dkato 0:ee40da884cfc 430 case DSP_MAILID_CMD_STR: /* Input character string by the command-line */
dkato 0:ee40da884cfc 431 ret = true;
dkato 0:ee40da884cfc 432 if ((int32_t)p_mail->param[MAIL_CMDSTR_FIN_FLG] == true) {
dkato 0:ee40da884cfc 433 p_ctrl->trm.edge_fin_inpt = true;
dkato 0:ee40da884cfc 434 } else {
dkato 0:ee40da884cfc 435 p_ctrl->trm.edge_fin_inpt = false;
dkato 0:ee40da884cfc 436 }
dkato 0:ee40da884cfc 437 (void) memcpy(&p_ctrl->trm.inpt_str[0],
dkato 0:ee40da884cfc 438 &p_mail->param[MAIL_CMDSTR_STR_START],
dkato 0:ee40da884cfc 439 sizeof(p_ctrl->trm.inpt_str));
dkato 0:ee40da884cfc 440 p_ctrl->trm.inpt_str[DSP_CMD_INPT_STR_MAX_LEN - 1] = '\0';
dkato 0:ee40da884cfc 441 break;
dkato 0:ee40da884cfc 442 case DSP_MAILID_PRINT_STR: /* Character string for the status indication */
dkato 0:ee40da884cfc 443 ret = true;
dkato 0:ee40da884cfc 444 (void) memcpy(&p_ctrl->com.dspl_str[0],
dkato 0:ee40da884cfc 445 &p_mail->param[MAIL_DISPSTR_STR_START],
dkato 0:ee40da884cfc 446 sizeof(p_ctrl->com.dspl_str));
dkato 0:ee40da884cfc 447 p_ctrl->com.dspl_str[DSP_DISP_STR_MAX_LEN - 1] = '\0';
dkato 0:ee40da884cfc 448 break;
dkato 0:ee40da884cfc 449 case DSP_MAILID_PLAY_TIME: /* Playback time */
dkato 0:ee40da884cfc 450 ret = true;
1050186 4:2672de88a46b 451 cur_stat = (SYS_PlayStat)p_mail->param[MAIL_PLAYTIME_STAT];
1050186 4:2672de88a46b 452 if ((cur_stat != p_ctrl->com.play_stat) && (cur_stat == SYS_PLAYSTAT_STOP)) {
1050186 4:2672de88a46b 453 p_ctrl->com.edge_track_change = true;
1050186 4:2672de88a46b 454 }
1050186 4:2672de88a46b 455 p_ctrl->com.play_stat = cur_stat;
1050186 4:2672de88a46b 456 trk_id = (((uint32_t)p_mail->param[MAIL_PLAYTIME_TRACK_H] << BYTE_SHIFT) |
dkato 0:ee40da884cfc 457 (uint32_t)p_mail->param[MAIL_PLAYTIME_TRACK_L]);
1050186 4:2672de88a46b 458 if (trk_id != p_ctrl->com.track_id) {
1050186 4:2672de88a46b 459 p_ctrl->com.edge_track_change = true;
1050186 4:2672de88a46b 460 p_ctrl->com.track_id = trk_id;
1050186 4:2672de88a46b 461 /* Clears the music information about the previous track. */
1050186 4:2672de88a46b 462 p_ctrl->com.samp_freq = 0u;
1050186 4:2672de88a46b 463 p_ctrl->com.channel = 0u;
1050186 4:2672de88a46b 464 }
1050186 4:2672de88a46b 465 cur_time = (((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_H] << WORD_SHIFT) |
1050186 4:2672de88a46b 466 ((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_M] << BYTE_SHIFT) |
1050186 4:2672de88a46b 467 ((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_L]));
1050186 4:2672de88a46b 468 if (p_ctrl->com.play_time != cur_time) {
1050186 4:2672de88a46b 469 p_ctrl->com.play_time = cur_time;
1050186 4:2672de88a46b 470 p_ctrl->tft.audio_data.m3_target_cnt = cur_time * DSP_TFT_M3_AUDIO_SAMPLE_PER_SEC;
1050186 4:2672de88a46b 471 }
dkato 0:ee40da884cfc 472 p_ctrl->com.total_time = (((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_H] << WORD_SHIFT) |
dkato 0:ee40da884cfc 473 ((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_M] << BYTE_SHIFT) |
dkato 0:ee40da884cfc 474 ((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_L]));
dkato 0:ee40da884cfc 475 break;
dkato 0:ee40da884cfc 476 case DSP_MAILID_PLAY_INFO: /* Music information */
dkato 0:ee40da884cfc 477 ret = true;
1050186 4:2672de88a46b 478 trk_id = (((uint32_t)p_mail->param[MAIL_PLAYINFO_TRACK_H] << BYTE_SHIFT) |
1050186 4:2672de88a46b 479 (uint32_t)p_mail->param[MAIL_PLAYINFO_TRACK_L]);
1050186 4:2672de88a46b 480 if (trk_id != p_ctrl->com.track_id) {
1050186 4:2672de88a46b 481 p_ctrl->com.edge_track_change = true;
1050186 4:2672de88a46b 482 p_ctrl->com.track_id = trk_id;
1050186 4:2672de88a46b 483 }
dkato 0:ee40da884cfc 484 p_ctrl->com.samp_freq = (((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_H] << WORD_SHIFT) |
dkato 0:ee40da884cfc 485 ((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_M] << BYTE_SHIFT) |
dkato 0:ee40da884cfc 486 ((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_L]));
dkato 0:ee40da884cfc 487 p_ctrl->com.channel = p_mail->param[MAIL_PLAYINFO_CHANNEL];
dkato 0:ee40da884cfc 488 break;
dkato 0:ee40da884cfc 489 case DSP_MAILID_PLAY_MODE: /* Repeat mode */
dkato 0:ee40da884cfc 490 ret = true;
dkato 0:ee40da884cfc 491 if ((int32_t)p_mail->param[MAIL_PLAYMODE_REPEAT] == true) {
dkato 0:ee40da884cfc 492 p_ctrl->com.repeat_mode = true;
dkato 0:ee40da884cfc 493 } else {
dkato 0:ee40da884cfc 494 p_ctrl->com.repeat_mode = false;
dkato 0:ee40da884cfc 495 }
dkato 0:ee40da884cfc 496 break;
dkato 0:ee40da884cfc 497 case DSP_MAILID_FILE_NAME: /* File name */
dkato 0:ee40da884cfc 498 ret = true;
dkato 0:ee40da884cfc 499 (void) memcpy(&p_ctrl->com.file_name[0],
dkato 0:ee40da884cfc 500 &p_mail->param[MAIL_FILENAME_STR_START],
dkato 0:ee40da884cfc 501 sizeof(p_ctrl->com.file_name));
dkato 0:ee40da884cfc 502 p_ctrl->com.file_name[DSP_DISP_STR_MAX_LEN - 1] = '\0';
dkato 0:ee40da884cfc 503 break;
dkato 2:d9fca8cd7f03 504 case DSP_MAILID_HELP: /* Help information */
dkato 2:d9fca8cd7f03 505 ret = true;
dkato 2:d9fca8cd7f03 506 break;
1050186 4:2672de88a46b 507 case DSP_MAILID_DISP_MODE: /* Display mode */
1050186 4:2672de88a46b 508 ret = true;
1050186 4:2672de88a46b 509 p_ctrl->com.disp_mode = p_mail->param[MAIL_DISPMODE_MODE];
1050186 4:2672de88a46b 510 (void) key_notify_disp_mode(p_ctrl->com.disp_mode);
1050186 4:2672de88a46b 511 break;
1050186 4:2672de88a46b 512 case DSP_MAILID_TFT_KEY: /* TFT key code */
1050186 4:2672de88a46b 513 ret = true;
1050186 4:2672de88a46b 514 p_ctrl->tft.key_code = (SYS_KeyCode)p_mail->param[MAIL_TFTKEY_KEYCODE];
1050186 4:2672de88a46b 515 break;
1050186 4:2672de88a46b 516 case DSP_MAILID_AUDIO_FIN: /* Completion of audio data acquisition. */
1050186 4:2672de88a46b 517 ret = true;
1050186 4:2672de88a46b 518 break;
1050186 4:2672de88a46b 519 case DSP_MAILID_PLAY_STAT: /* Playback status */
1050186 4:2672de88a46b 520 ret = true;
1050186 4:2672de88a46b 521 cur_stat = (SYS_PlayStat)p_mail->param[MAIL_PLAYSTAT_STAT];
1050186 4:2672de88a46b 522 if ((cur_stat != p_ctrl->com.play_stat) && (cur_stat == SYS_PLAYSTAT_STOP)) {
1050186 4:2672de88a46b 523 p_ctrl->com.edge_track_change = true;
1050186 4:2672de88a46b 524 }
1050186 4:2672de88a46b 525 p_ctrl->com.play_stat = cur_stat;
1050186 4:2672de88a46b 526 break;
dkato 0:ee40da884cfc 527 default:
dkato 0:ee40da884cfc 528 /* Unexpected cases : mail id was illegal. */
dkato 0:ee40da884cfc 529 ret = false;
dkato 0:ee40da884cfc 530 break;
dkato 0:ee40da884cfc 531 }
dkato 0:ee40da884cfc 532 }
dkato 0:ee40da884cfc 533 return ret;
dkato 0:ee40da884cfc 534 }
dkato 0:ee40da884cfc 535
dkato 0:ee40da884cfc 536 /** Clears the one shot data in the control data of display module
dkato 0:ee40da884cfc 537 *
dkato 0:ee40da884cfc 538 * @param p_ctrl Pointer to control data of display module.
dkato 0:ee40da884cfc 539 */
dkato 0:ee40da884cfc 540 static void clear_one_shot_data(dsp_ctrl_t * const p_ctrl)
dkato 0:ee40da884cfc 541 {
dkato 0:ee40da884cfc 542 if (p_ctrl != NULL) {
dkato 0:ee40da884cfc 543 if (p_ctrl->trm.edge_fin_inpt == true) {
dkato 0:ee40da884cfc 544 /* Clears data of input character string. */
dkato 0:ee40da884cfc 545 p_ctrl->trm.edge_fin_inpt = false;
dkato 0:ee40da884cfc 546 p_ctrl->trm.inpt_str[0] = '\0';
dkato 0:ee40da884cfc 547 }
1050186 4:2672de88a46b 548 p_ctrl->com.edge_track_change = false;
dkato 0:ee40da884cfc 549 }
dkato 0:ee40da884cfc 550 return;
dkato 0:ee40da884cfc 551 }
1050186 4:2672de88a46b 552
1050186 4:2672de88a46b 553 static void audio_data_callback( const bool result, int16_t * const p_buf,
1050186 4:2672de88a46b 554 const uint32_t buf_num, const int32_t * const p_audio, const uint32_t audio_num)
1050186 4:2672de88a46b 555 {
1050186 4:2672de88a46b 556 uint32_t i;
1050186 4:2672de88a46b 557 dsp_mail_t data;
1050186 4:2672de88a46b 558
1050186 4:2672de88a46b 559 if ((p_buf != NULL) && (p_audio != NULL)) {
1050186 4:2672de88a46b 560 if ((result == true) && (buf_num > 0u) && (audio_num >= buf_num)) {
1050186 4:2672de88a46b 561 for (i = 0; i < buf_num; i++) {
1050186 4:2672de88a46b 562 p_buf[i] = (int16_t)(p_audio[i] >> AUDIO_DATA_SHIFT);
1050186 4:2672de88a46b 563 }
1050186 4:2672de88a46b 564 }
1050186 4:2672de88a46b 565 }
1050186 4:2672de88a46b 566 data.mail_id = DSP_MAILID_AUDIO_FIN;
1050186 4:2672de88a46b 567 data.param[MAIL_AUDIOFIN_PARAM] = (uint8_t)MAIL_PARAM_NON;
1050186 4:2672de88a46b 568 (void) send_mail(&data);
1050186 4:2672de88a46b 569 }