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
display.cpp
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 #include "mbed.h" 00025 #include "rtos.h" 00026 #include "misratypes.h" 00027 #include "display.h" 00028 #include "disp_term.h" 00029 #include "disp_tft.h" 00030 #include "key.h" 00031 #include "audio_out.h" 00032 00033 /*--- Macro definition of mbed-rtos mail ---*/ 00034 #define MAIL_QUEUE_SIZE (32) /* Queue size */ 00035 #define MAIL_PARAM_NUM (64) /* Elements number of mail parameter array */ 00036 00037 /* dsp_mail_t */ 00038 /* mail_id = DSP_MAILID_CYCLE_IND : No parameter */ 00039 #define MAIL_CYCLEIND_PARAM (0) /* No mail parameter to be used */ 00040 00041 /* mail_id = DSP_MAILID_CMD_STR */ 00042 #define MAIL_CMDSTR_FIN_FLG (0) /* Completion status of the input by the command-line */ 00043 #define MAIL_CMDSTR_STR_START (1) /* Start position of input string by the command-line */ 00044 #define MAIL_CMDSTR_STR_SIZE (DSP_CMD_INPT_STR_MAX_LEN) 00045 /* Size of input string by the command-line */ 00046 00047 /* mail_id = DSP_MAILID_PRINT_STR */ 00048 #define MAIL_DISPSTR_STR_START (0) /* Start position of display string */ 00049 #define MAIL_DISPSTR_STR_SIZE (DSP_DISP_STR_MAX_LEN) /* Size of display string */ 00050 00051 /* mail_id = DSP_MAILID_PLAY_TIME */ 00052 #define MAIL_PLAYTIME_STAT (0) /* Playback status */ 00053 #define MAIL_PLAYTIME_TRACK_L (1) /* Track number */ 00054 #define MAIL_PLAYTIME_TRACK_H (2) /* Track number */ 00055 #define MAIL_PLAYTIME_PLAYTIME_L (3) /* Playback time */ 00056 #define MAIL_PLAYTIME_PLAYTIME_M (4) /* Playback time */ 00057 #define MAIL_PLAYTIME_PLAYTIME_H (5) /* Playback time */ 00058 #define MAIL_PLAYTIME_TOTALTIME_L (6) /* Total playback time */ 00059 #define MAIL_PLAYTIME_TOTALTIME_M (7) /* Total playback time */ 00060 #define MAIL_PLAYTIME_TOTALTIME_H (8) /* Total playback time */ 00061 00062 /* mail_id = DSP_MAILID_PLAY_INFO */ 00063 #define MAIL_PLAYINFO_TRACK_L (0) /* Track number */ 00064 #define MAIL_PLAYINFO_TRACK_H (1) /* Track number */ 00065 #define MAIL_PLAYINFO_SAMPFREQ_L (2) /* Sampling frequency */ 00066 #define MAIL_PLAYINFO_SAMPFREQ_M (3) /* Sampling frequency */ 00067 #define MAIL_PLAYINFO_SAMPFREQ_H (4) /* Sampling frequency */ 00068 #define MAIL_PLAYINFO_CHANNEL (5) /* Channel structure */ 00069 00070 /* mail_id = DSP_MAILID_PLAY_MODE */ 00071 #define MAIL_PLAYMODE_REPEAT (0) /* Repeat mode */ 00072 00073 /* mail_id = DSP_MAILID_FILE_NAME */ 00074 #define MAIL_FILENAME_STR_START (0) /* Start position of file name string */ 00075 #define MAIL_FILENAME_STR_SIZE (64) /* Size of file name string */ 00076 00077 /* mail_id = DSP_MAILID_HELP */ 00078 #define MAIL_HELP_PARAM (0) /* No mail parameter to be used */ 00079 00080 /* mail_id = DSP_MAILID_DISP_MODE */ 00081 #define MAIL_DISPMODE_MODE (0) /* Display mode */ 00082 00083 /* mail_id = DSP_MAILID_TFT_KEY */ 00084 #define MAIL_TFTKEY_KEYCODE (0) /* Key code */ 00085 00086 /* mail_id = DSP_MAILID_AUDIO_FIN */ 00087 #define MAIL_AUDIOFIN_PARAM (0) /* No mail parameter to be used */ 00088 00089 /* mail_id = DSP_MAILID_PLAY_STAT */ 00090 #define MAIL_PLAYSTAT_STAT (0) /* Playback status */ 00091 00092 #define MAIL_PARAM_NON (0u) /* Value of unused element of mail parameter array */ 00093 00094 00095 #define BYTE_SHIFT (8u) 00096 #define WORD_SHIFT (16u) 00097 #define AUDIO_DATA_SHIFT (24u) 00098 #define PROC_CNT_AUDIO_GET (6u) /* Counter for 100ms period */ 00099 00100 /*--- User defined types of mbed-rtos mail ---*/ 00101 typedef struct { 00102 DSP_MAIL_ID mail_id; 00103 uint8_t param[MAIL_PARAM_NUM]; 00104 } dsp_mail_t; 00105 00106 /* Control data of display thread */ 00107 typedef struct { 00108 dsp_com_ctrl_t com; /* Common data */ 00109 dsp_trm_ctrl_t trm; /* Terminal output module only */ 00110 dsp_tft_ctrl_t tft; /* TFT module only */ 00111 } dsp_ctrl_t; 00112 00113 static Mail<dsp_mail_t, MAIL_QUEUE_SIZE> mail_box; 00114 00115 static void init_ctrl_data(dsp_ctrl_t * const p_ctrl); 00116 static bool send_mail(const dsp_mail_t * const p_data); 00117 static bool recv_mail(dsp_mail_t * const p_data); 00118 static bool decode_mail(const dsp_mail_t * const p_mail, dsp_ctrl_t * const p_ctrl); 00119 static void clear_one_shot_data(dsp_ctrl_t * const p_ctrl); 00120 static void audio_data_callback( const bool result, int16_t * const p_buf, 00121 const uint32_t buf_num, const int32_t * const p_audio, const uint32_t audio_num); 00122 00123 void dsp_thread(void const *argument) 00124 { 00125 dsp_mail_t recv_data; 00126 bool result; 00127 static dsp_ctrl_t dsp_ctrl; 00128 00129 UNUSED_ARG(argument); 00130 00131 init_ctrl_data(&dsp_ctrl); 00132 dsp_init_term(); 00133 dsp_init_tft(&dsp_ctrl.tft); 00134 while (1) { 00135 result = recv_mail(&recv_data); 00136 if (result == true) { 00137 result = decode_mail(&recv_data, &dsp_ctrl); 00138 if (result == true) { 00139 /* Executes main function of tft output module */ 00140 dsp_output_tft(recv_data.mail_id, &dsp_ctrl.com, &dsp_ctrl.tft); 00141 /* Executes main function of terminal output module */ 00142 dsp_output_term(recv_data.mail_id, &dsp_ctrl.com, &dsp_ctrl.trm); 00143 /* Clears the one shot data */ 00144 clear_one_shot_data(&dsp_ctrl); 00145 } 00146 } 00147 } 00148 } 00149 00150 bool dsp_notify_cycle_time(void) 00151 { 00152 bool ret; 00153 dsp_mail_t data; 00154 00155 data.mail_id = DSP_MAILID_CYCLE_IND; 00156 data.param[MAIL_CYCLEIND_PARAM] = (uint8_t)MAIL_PARAM_NON; 00157 ret = send_mail(&data); 00158 00159 return ret; 00160 } 00161 00162 bool dsp_notify_play_time(const SYS_PlayStat play_stat, const uint32_t file_no, 00163 const uint32_t play_time, const uint32_t total_time) 00164 { 00165 bool ret; 00166 dsp_mail_t data; 00167 00168 data.mail_id = DSP_MAILID_PLAY_TIME; 00169 data.param[MAIL_PLAYTIME_STAT] = (uint8_t)play_stat; 00170 data.param[MAIL_PLAYTIME_TRACK_L] = (uint8_t)file_no; 00171 data.param[MAIL_PLAYTIME_TRACK_H] = (uint8_t)(file_no >> BYTE_SHIFT); 00172 data.param[MAIL_PLAYTIME_PLAYTIME_L] = (uint8_t)play_time; 00173 data.param[MAIL_PLAYTIME_PLAYTIME_M] = (uint8_t)(play_time >> BYTE_SHIFT); 00174 data.param[MAIL_PLAYTIME_PLAYTIME_H] = (uint8_t)(play_time >> WORD_SHIFT); 00175 data.param[MAIL_PLAYTIME_TOTALTIME_L] = (uint8_t)total_time; 00176 data.param[MAIL_PLAYTIME_TOTALTIME_M] = (uint8_t)(total_time >> BYTE_SHIFT); 00177 data.param[MAIL_PLAYTIME_TOTALTIME_H] = (uint8_t)(total_time >> WORD_SHIFT); 00178 ret = send_mail(&data); 00179 00180 return ret; 00181 } 00182 00183 bool dsp_notify_play_info(const uint32_t file_no, 00184 const uint32_t sample_freq, const uint32_t channel_num) 00185 { 00186 bool ret; 00187 dsp_mail_t data; 00188 00189 data.mail_id = DSP_MAILID_PLAY_INFO; 00190 data.param[MAIL_PLAYINFO_TRACK_L] = (uint8_t)file_no; 00191 data.param[MAIL_PLAYINFO_TRACK_H] = (uint8_t)(file_no >> BYTE_SHIFT); 00192 data.param[MAIL_PLAYINFO_SAMPFREQ_L] = (uint8_t)sample_freq; 00193 data.param[MAIL_PLAYINFO_SAMPFREQ_M] = (uint8_t)(sample_freq >> BYTE_SHIFT); 00194 data.param[MAIL_PLAYINFO_SAMPFREQ_H] = (uint8_t)(sample_freq >> WORD_SHIFT); 00195 data.param[MAIL_PLAYINFO_CHANNEL] = (uint8_t)channel_num; 00196 ret = send_mail(&data); 00197 00198 return ret; 00199 } 00200 00201 bool dsp_notify_play_mode(const bool rep_mode) 00202 { 00203 bool ret; 00204 dsp_mail_t data; 00205 00206 data.mail_id = DSP_MAILID_PLAY_MODE; 00207 data.param[MAIL_PLAYMODE_REPEAT] = (uint8_t)rep_mode; 00208 ret = send_mail(&data); 00209 00210 return ret; 00211 } 00212 00213 bool dsp_notify_file_name(const char_t * const p_str) 00214 { 00215 bool ret = false; 00216 dsp_mail_t data; 00217 00218 if (p_str != NULL) { 00219 data.mail_id = DSP_MAILID_FILE_NAME; 00220 (void) memcpy(&data.param[MAIL_FILENAME_STR_START], p_str, MAIL_FILENAME_STR_SIZE); 00221 data.param[(MAIL_FILENAME_STR_START + MAIL_FILENAME_STR_SIZE) - 1] = '\0'; 00222 ret = send_mail(&data); 00223 } 00224 00225 return ret; 00226 } 00227 00228 bool dsp_notify_print_string(const char_t * const p_str) 00229 { 00230 bool ret = false; 00231 dsp_mail_t data; 00232 00233 if (p_str != NULL) { 00234 data.mail_id = DSP_MAILID_PRINT_STR; 00235 (void) memcpy(&data.param[MAIL_DISPSTR_STR_START], p_str, MAIL_DISPSTR_STR_SIZE); 00236 data.param[(MAIL_DISPSTR_STR_START + MAIL_DISPSTR_STR_SIZE) - 1] = '\0'; 00237 ret = send_mail(&data); 00238 } 00239 00240 return ret; 00241 } 00242 00243 bool dsp_notify_input_string(const char_t * const p_str, const bool flag_fin) 00244 { 00245 bool ret = false; 00246 dsp_mail_t data; 00247 00248 if (p_str != NULL) { 00249 data.mail_id = DSP_MAILID_CMD_STR; 00250 data.param[MAIL_CMDSTR_FIN_FLG] = (uint8_t)flag_fin; 00251 (void) memcpy(&data.param[MAIL_CMDSTR_STR_START], p_str, MAIL_CMDSTR_STR_SIZE); 00252 data.param[(MAIL_CMDSTR_STR_START + MAIL_CMDSTR_STR_SIZE) - 1] = '\0'; 00253 ret = send_mail(&data); 00254 } 00255 00256 return ret; 00257 } 00258 00259 bool dsp_req_help(void) 00260 { 00261 bool ret = false; 00262 dsp_mail_t data; 00263 00264 data.mail_id = DSP_MAILID_HELP; 00265 data.param[MAIL_HELP_PARAM] = (uint8_t)MAIL_PARAM_NON; 00266 ret = send_mail(&data); 00267 return ret; 00268 } 00269 00270 bool dsp_notify_disp_mode(const uint32_t disp_mode) 00271 { 00272 bool ret = false; 00273 dsp_mail_t data; 00274 00275 data.mail_id = DSP_MAILID_DISP_MODE; 00276 data.param[MAIL_DISPMODE_MODE] = (uint8_t)disp_mode; 00277 ret = send_mail(&data); 00278 00279 return ret; 00280 } 00281 00282 bool dsp_notify_tft_key(const SYS_KeyCode key_code) 00283 { 00284 bool ret = false; 00285 dsp_mail_t data; 00286 00287 data.mail_id = DSP_MAILID_TFT_KEY; 00288 data.param[MAIL_TFTKEY_KEYCODE] = (uint8_t)key_code; 00289 ret = send_mail(&data); 00290 00291 return ret; 00292 } 00293 00294 bool dsp_notify_play_status(const SYS_PlayStat play_stat) 00295 { 00296 bool ret; 00297 dsp_mail_t data; 00298 00299 data.mail_id = DSP_MAILID_PLAY_STAT; 00300 data.param[MAIL_PLAYSTAT_STAT] = (uint8_t)play_stat; 00301 ret = send_mail(&data); 00302 00303 return ret; 00304 } 00305 00306 SYS_KeyCode dsp_convert_key(const uint32_t disp_mode, const uint32_t pos_x, const uint32_t pos_y) 00307 { 00308 SYS_KeyCode ret; 00309 00310 ret = dsp_convert_key_tft(disp_mode, pos_x, pos_y); 00311 00312 return ret; 00313 } 00314 00315 /** initialises the control data of the display module 00316 * 00317 * @param p_ctrl Pointer to control data of display module. 00318 */ 00319 static void init_ctrl_data(dsp_ctrl_t * const p_ctrl) 00320 { 00321 if (p_ctrl != NULL) { 00322 /* Initialises the common data of the display module. */ 00323 p_ctrl->com.disp_mode = DSP_DISPMODE_1; 00324 p_ctrl->com.play_stat = SYS_PLAYSTAT_STOP; 00325 p_ctrl->com.track_id = 0u; 00326 p_ctrl->com.play_time = 0u; 00327 p_ctrl->com.total_time = 0u; 00328 p_ctrl->com.samp_freq = 0u; 00329 p_ctrl->com.channel = 0u; 00330 p_ctrl->com.repeat_mode = false; 00331 p_ctrl->com.file_name[0] = '\0'; 00332 p_ctrl->com.dspl_str[0] = '\0'; 00333 p_ctrl->com.edge_track_change = false; 00334 00335 /* Initialises the data of the terminal output module. */ 00336 p_ctrl->trm.edge_fin_inpt = false; 00337 p_ctrl->trm.inpt_str[0] = '\0'; 00338 00339 /* Does not initialize the data of TFT module. */ 00340 /* Initial values are different by the display mode. */ 00341 /* Therefore the data of TFT module is initialized by tft_init_proc function. */ 00342 } 00343 } 00344 00345 /** Sends the mail to main thread 00346 * 00347 * @param p_data Pointer to the structure of the data 00348 * 00349 * @returns 00350 * Results of process. true is success. false is failure. 00351 */ 00352 static bool send_mail(const dsp_mail_t * const p_data) 00353 { 00354 bool ret = false; 00355 osStatus stat; 00356 dsp_mail_t *p_mail; 00357 00358 if (p_data != NULL) { 00359 p_mail = mail_box.alloc(); 00360 if (p_mail != NULL) { 00361 *p_mail = *p_data; 00362 stat = mail_box.put(p_mail); 00363 if (stat == osOK) { 00364 ret = true; 00365 } else { 00366 (void) mail_box.free(p_mail); 00367 } 00368 } 00369 } 00370 return ret; 00371 } 00372 00373 /** Receives the mail to main thread 00374 * 00375 * @param p_data Pointer to the structure of the data 00376 * 00377 * @returns 00378 * Results of process. true is success. false is failure. 00379 */ 00380 static bool recv_mail(dsp_mail_t * const p_data) 00381 { 00382 bool ret = false; 00383 osEvent evt; 00384 dsp_mail_t *p_mail; 00385 00386 if (p_data != NULL) { 00387 evt = mail_box.get(); 00388 if (evt.status == osEventMail) { 00389 p_mail = (dsp_mail_t *)evt.value.p; 00390 if (p_mail != NULL) { 00391 *p_data = *p_mail; 00392 ret = true; 00393 } 00394 (void) mail_box.free(p_mail); 00395 } 00396 } 00397 return ret; 00398 } 00399 00400 /** Decodes the display thread mail 00401 * 00402 * @param p_mail Pointer to the structure of the data 00403 * @param p_ctrl Pointer to control data of display module. 00404 * 00405 * @returns 00406 * Results of process. true is success. false is failure. 00407 */ 00408 static bool decode_mail(const dsp_mail_t * const p_mail, dsp_ctrl_t * const p_ctrl) 00409 { 00410 bool ret = false; 00411 dsp_audio_t *p_aud; 00412 SYS_PlayStat cur_stat; 00413 uint32_t trk_id; 00414 uint32_t cur_time; 00415 00416 00417 if ((p_mail != NULL) && (p_ctrl != NULL)) { 00418 /* Decodes the received mail */ 00419 switch(p_mail->mail_id) { 00420 case DSP_MAILID_CYCLE_IND: /* Cyclic notice */ 00421 p_aud = &p_ctrl->tft.audio_data; 00422 p_aud->req_cyc_cnt++; 00423 if (p_aud->req_cyc_cnt >= PROC_CNT_AUDIO_GET) { 00424 p_aud->req_cyc_cnt = 0u; 00425 (void) aud_get_audio_data(&audio_data_callback, &p_aud->req_buf[0], 00426 sizeof(p_aud->req_buf)/sizeof(p_aud->req_buf[0])); 00427 } 00428 ret = true; 00429 break; 00430 case DSP_MAILID_CMD_STR: /* Input character string by the command-line */ 00431 ret = true; 00432 if ((int32_t)p_mail->param[MAIL_CMDSTR_FIN_FLG] == true) { 00433 p_ctrl->trm.edge_fin_inpt = true; 00434 } else { 00435 p_ctrl->trm.edge_fin_inpt = false; 00436 } 00437 (void) memcpy(&p_ctrl->trm.inpt_str[0], 00438 &p_mail->param[MAIL_CMDSTR_STR_START], 00439 sizeof(p_ctrl->trm.inpt_str)); 00440 p_ctrl->trm.inpt_str[DSP_CMD_INPT_STR_MAX_LEN - 1] = '\0'; 00441 break; 00442 case DSP_MAILID_PRINT_STR: /* Character string for the status indication */ 00443 ret = true; 00444 (void) memcpy(&p_ctrl->com.dspl_str[0], 00445 &p_mail->param[MAIL_DISPSTR_STR_START], 00446 sizeof(p_ctrl->com.dspl_str)); 00447 p_ctrl->com.dspl_str[DSP_DISP_STR_MAX_LEN - 1] = '\0'; 00448 break; 00449 case DSP_MAILID_PLAY_TIME: /* Playback time */ 00450 ret = true; 00451 cur_stat = (SYS_PlayStat)p_mail->param[MAIL_PLAYTIME_STAT]; 00452 if ((cur_stat != p_ctrl->com.play_stat) && (cur_stat == SYS_PLAYSTAT_STOP)) { 00453 p_ctrl->com.edge_track_change = true; 00454 } 00455 p_ctrl->com.play_stat = cur_stat; 00456 trk_id = (((uint32_t)p_mail->param[MAIL_PLAYTIME_TRACK_H] << BYTE_SHIFT) | 00457 (uint32_t)p_mail->param[MAIL_PLAYTIME_TRACK_L]); 00458 if (trk_id != p_ctrl->com.track_id) { 00459 p_ctrl->com.edge_track_change = true; 00460 p_ctrl->com.track_id = trk_id; 00461 /* Clears the music information about the previous track. */ 00462 p_ctrl->com.samp_freq = 0u; 00463 p_ctrl->com.channel = 0u; 00464 } 00465 cur_time = (((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_H] << WORD_SHIFT) | 00466 ((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_M] << BYTE_SHIFT) | 00467 ((uint32_t)p_mail->param[MAIL_PLAYTIME_PLAYTIME_L])); 00468 if (p_ctrl->com.play_time != cur_time) { 00469 p_ctrl->com.play_time = cur_time; 00470 p_ctrl->tft.audio_data.m3_target_cnt = cur_time * DSP_TFT_M3_AUDIO_SAMPLE_PER_SEC; 00471 } 00472 p_ctrl->com.total_time = (((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_H] << WORD_SHIFT) | 00473 ((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_M] << BYTE_SHIFT) | 00474 ((uint32_t)p_mail->param[MAIL_PLAYTIME_TOTALTIME_L])); 00475 break; 00476 case DSP_MAILID_PLAY_INFO: /* Music information */ 00477 ret = true; 00478 trk_id = (((uint32_t)p_mail->param[MAIL_PLAYINFO_TRACK_H] << BYTE_SHIFT) | 00479 (uint32_t)p_mail->param[MAIL_PLAYINFO_TRACK_L]); 00480 if (trk_id != p_ctrl->com.track_id) { 00481 p_ctrl->com.edge_track_change = true; 00482 p_ctrl->com.track_id = trk_id; 00483 } 00484 p_ctrl->com.samp_freq = (((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_H] << WORD_SHIFT) | 00485 ((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_M] << BYTE_SHIFT) | 00486 ((uint32_t)p_mail->param[MAIL_PLAYINFO_SAMPFREQ_L])); 00487 p_ctrl->com.channel = p_mail->param[MAIL_PLAYINFO_CHANNEL]; 00488 break; 00489 case DSP_MAILID_PLAY_MODE: /* Repeat mode */ 00490 ret = true; 00491 if ((int32_t)p_mail->param[MAIL_PLAYMODE_REPEAT] == true) { 00492 p_ctrl->com.repeat_mode = true; 00493 } else { 00494 p_ctrl->com.repeat_mode = false; 00495 } 00496 break; 00497 case DSP_MAILID_FILE_NAME: /* File name */ 00498 ret = true; 00499 (void) memcpy(&p_ctrl->com.file_name[0], 00500 &p_mail->param[MAIL_FILENAME_STR_START], 00501 sizeof(p_ctrl->com.file_name)); 00502 p_ctrl->com.file_name[DSP_DISP_STR_MAX_LEN - 1] = '\0'; 00503 break; 00504 case DSP_MAILID_HELP: /* Help information */ 00505 ret = true; 00506 break; 00507 case DSP_MAILID_DISP_MODE: /* Display mode */ 00508 ret = true; 00509 p_ctrl->com.disp_mode = p_mail->param[MAIL_DISPMODE_MODE]; 00510 (void) key_notify_disp_mode(p_ctrl->com.disp_mode); 00511 break; 00512 case DSP_MAILID_TFT_KEY: /* TFT key code */ 00513 ret = true; 00514 p_ctrl->tft.key_code = (SYS_KeyCode)p_mail->param[MAIL_TFTKEY_KEYCODE]; 00515 break; 00516 case DSP_MAILID_AUDIO_FIN: /* Completion of audio data acquisition. */ 00517 ret = true; 00518 break; 00519 case DSP_MAILID_PLAY_STAT: /* Playback status */ 00520 ret = true; 00521 cur_stat = (SYS_PlayStat)p_mail->param[MAIL_PLAYSTAT_STAT]; 00522 if ((cur_stat != p_ctrl->com.play_stat) && (cur_stat == SYS_PLAYSTAT_STOP)) { 00523 p_ctrl->com.edge_track_change = true; 00524 } 00525 p_ctrl->com.play_stat = cur_stat; 00526 break; 00527 default: 00528 /* Unexpected cases : mail id was illegal. */ 00529 ret = false; 00530 break; 00531 } 00532 } 00533 return ret; 00534 } 00535 00536 /** Clears the one shot data in the control data of display module 00537 * 00538 * @param p_ctrl Pointer to control data of display module. 00539 */ 00540 static void clear_one_shot_data(dsp_ctrl_t * const p_ctrl) 00541 { 00542 if (p_ctrl != NULL) { 00543 if (p_ctrl->trm.edge_fin_inpt == true) { 00544 /* Clears data of input character string. */ 00545 p_ctrl->trm.edge_fin_inpt = false; 00546 p_ctrl->trm.inpt_str[0] = '\0'; 00547 } 00548 p_ctrl->com.edge_track_change = false; 00549 } 00550 return; 00551 } 00552 00553 static void audio_data_callback( const bool result, int16_t * const p_buf, 00554 const uint32_t buf_num, const int32_t * const p_audio, const uint32_t audio_num) 00555 { 00556 uint32_t i; 00557 dsp_mail_t data; 00558 00559 if ((p_buf != NULL) && (p_audio != NULL)) { 00560 if ((result == true) && (buf_num > 0u) && (audio_num >= buf_num)) { 00561 for (i = 0; i < buf_num; i++) { 00562 p_buf[i] = (int16_t)(p_audio[i] >> AUDIO_DATA_SHIFT); 00563 } 00564 } 00565 } 00566 data.mail_id = DSP_MAILID_AUDIO_FIN; 00567 data.param[MAIL_AUDIOFIN_PARAM] = (uint8_t)MAIL_PARAM_NON; 00568 (void) send_mail(&data); 00569 }
Generated on Tue Jul 12 2022 19:32:28 by 1.7.2