Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Hexi_Click_Relay-v3_Example by
main.cpp
00001 /**************************************************************************** 00002 * Title : Hexiware Text To Speech Click 00003 * Filename : Hexi_talking_one_main 00004 * Author : Dave Clarke 00005 * Origin Date : 26/10/2016 00006 * Notes : mBed OS Text to Speech Click Interface (rough) 00007 *****************************************************************************/ 00008 /**************************CHANGE LIST ************************************** 00009 * 00010 * Date Software Version Initials Description 00011 * 26/10/16 1.0.0 DC Interface Created. 00012 * 00013 *****************************************************************************/ 00014 00015 /** 00016 * @page TEST_CFG Test Configurations 00017 * <h3> Test configuration : </h3> 00018 * @par 00019 * <ul> 00020 * <li><b> MCU </b> : MK64FN1M0XXX12 </li> 00021 * <li><b> Dev. Board </b> : HEXIWEAR </li> 00022 * <li><b> Oscillator </b> : 12 MHz external </li> 00023 * <li><b> Ext. Modules </b> : none </li> 00024 * <li><b> Ext. Modules </b> : TTS Click on mikroBUS 2 </li> 00025 * <li><b> SW </b> : mBed OS5 </li> 00026 * </ul> 00027 */ 00028 00029 /** 00030 * @mainpage 00031 * <h3> Text To Speech with HEXIWEAR and mBed OS 5 </h3> 00032 * @par Using mBed)S and a Hexiware you can now use the Text To Speech Click Board 00033 * 00034 * 00035 * 00036 00037 * <h3> Speech Features </h3> 00038 * @par Text to Speech Click, Hexiwear docking station, Hexiware 00039 */ 00040 00041 /****************************************************************************** 00042 * Includes 00043 *******************************************************************************/ 00044 00045 #include "mbed.h" 00046 #include "text_to_speech.h" 00047 #include "text_to_speech_hal.h" 00048 #include "text_to_speech_hw.h" 00049 #include "text_to_speech_img.h" 00050 #include "string.h" 00051 #include <stdbool.h> 00052 #include <stdlib.h> 00053 00054 00055 00056 00057 /****************************************************************************** 00058 * Module Variable Definitions 00059 *******************************************************************************/ 00060 /* Indication Flags */ 00061 static volatile bool _tts_rdy_f; 00062 static volatile bool _spc_rdy_f; 00063 static volatile bool _tts_fin_f; 00064 static volatile bool _spc_fin_f; 00065 /* Error Buffers */ 00066 static uint16_t _req_err; 00067 static uint16_t _err_code; 00068 /* Default Configuration */ 00069 static ACONF_t _audio_conf; 00070 static TTSCONF_t _tts_conf; 00071 static PMANCONF_t _pman_conf; 00072 00073 static bool _flush_enable; 00074 /* Timer flag and counter */ 00075 static volatile bool _ticker_f; 00076 static volatile uint16_t _ticker; 00077 /* Input and output buffers */ 00078 static ISC_REQ_t _last_req; 00079 static ISC_RESP_t _last_rsp; 00080 /* Text Buffer */ 00081 char text[20]; 00082 static uint8_t test[ 8 ] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 00083 int frequency = 750000; 00084 VER_t *version; 00085 /****************************************************************************** 00086 * Function Prototypes 00087 *******************************************************************************/ 00088 /* Checks for indications */ 00089 static int _parse_ind( void ); 00090 /* Message block and error callback function pointers */ 00091 static void ( *_fatal_err_callback )( uint16_t *err_code ); 00092 static void ( *_err_callback )( uint16_t *err_code ); 00093 static void ( *_msg_block_callback )( uint16_t *msg_code, 00094 uint16_t *err_code ); 00095 00096 00097 /* Instantiate the Click Text to Speech pinout */ 00098 DigitalOut TTS_RST(PTB19); 00099 DigitalOut TTS_CS(PTC3); 00100 DigitalOut TTS_MUTE(PTB3); 00101 DigitalIn TTS_RDY(PTB8); 00102 00103 //Instantiate SPI for comms with Speak module 00104 SPI TextToSpeech(PTC6, PTC7, PTC5); // MOSI, MISO, SCK 00105 00106 00107 // Debug Serial 00108 Serial pc(USBTX, USBRX); 00109 00110 void SysInit(void) 00111 { 00112 tts_hal_cs_high(); 00113 TextToSpeech.format(8,3); 00114 TextToSpeech.frequency(frequency); 00115 00116 00117 } 00118 00119 void fatal_err( uint16_t *err ); 00120 void msg_blk( uint16_t *req, uint16_t *err ); 00121 00122 int main() 00123 { 00124 00125 SysInit(); 00126 pc.printf("System Init Done!\r\n"); 00127 tts_init(); 00128 pc.printf("tts Init Done!\r\n"); 00129 tts_setup(); 00130 pc.printf("tts setup Done!\r\n"); 00131 tts_msg_block_callback( msg_blk ); 00132 tts_fatal_err_callback( fatal_err ); 00133 tts_config( 0x01, false, TTSV_US, 0x0090 ); 00134 //tts_mute(); 00135 //tts_speak( "[:nw][:dv ap 195 pr 80]" ); 00136 //tts_speak( "[:np][:dv ap 100 pr 50]" ); 00137 //tts_speak( "[:nw]" ); 00138 //wait( 2 ); 00139 //tts_unmute(); 00140 00141 while(1) 00142 { 00143 /* frozen 00144 verse one 00145 tts_speak( "The snow glows white on the mountain tonight, Not a footprint to be seen. " ); 00146 wait(0.1); 00147 tts_speak( "A kingdom of isolation, and it looks like I'm the Queen. " ); 00148 wait(0.1); 00149 tts_speak( "The wind is howling like this swirling storm inside. " ); 00150 wait(0.1); 00151 tts_speak( "Couldn't keep it in. " ); 00152 wait(0.1); 00153 tts_speak( "Heaven knows I've tried. " ); 00154 wait(0.1); 00155 tts_speak( "Don't let them in, don't let them see. " ); 00156 wait(0.1); 00157 tts_speak( "Be the good girl you always have to be. " ); 00158 wait(0.1); 00159 tts_speak( "Conceal, don't feel, don't let them know. " ); 00160 wait(0.1); 00161 tts_speak( "Well now they know. " ); 00162 wait(0.1); 00163 00164 chorus one 00165 tts_speak( "Let it go, let it go. " ); 00166 wait(0.1); 00167 tts_speak( "Can't hold it back anymore. " ); 00168 wait(0.1); 00169 tts_speak( "I don't care " ); 00170 wait(0.1); 00171 tts_speak( "what they're going to say" ); 00172 wait(0.1); 00173 tts_speak( "Let the storm rage on." ); 00174 wait(0.1); 00175 tts_speak( "The cold never bothered me anyway" ); 00176 wait(0.1); 00177 00178 verse two 00179 tts_speak( "It's funny how some distance " ); 00180 wait(0.1); 00181 tts_speak( "Makes everything seem small " ); 00182 wait(0.1); 00183 tts_speak( "And the fears that once controlled me " ); 00184 wait(0.1); 00185 tts_speak( "Can't get to me at all " ); 00186 wait(0.1); 00187 tts_speak( "It's time to see what I can do " ); 00188 wait(0.1); 00189 tts_speak( "To test the limits and break through" ); 00190 wait(0.1); 00191 tts_speak( "No right, no wrong, no rules for me, " ); 00192 wait(0.1); 00193 tts_speak( "I'm free! " ); 00194 wait(0.1); 00195 00196 chorus two 00197 tts_speak( "Let it go, let it go. " ); 00198 wait(0.1); 00199 tts_speak( "I am one with the wind and sky " ); 00200 wait(0.1); 00201 tts_speak( "Let it go, let it go " ); 00202 wait(0.1); 00203 tts_speak( "You'll never see me cry" ); 00204 wait(0.1); 00205 tts_speak( "Here I stand" ); 00206 wait(0.1); 00207 tts_speak( "And here I'll stay" ); 00208 wait(0.1); 00209 tts_speak( "Let the storm rage on" ); 00210 wait(0.1); 00211 00212 middle eight 00213 tts_speak( "My power flurries through the air into the ground " ); 00214 wait(0.1); 00215 tts_speak( "My soul is spiraling in frozen fractals all around " ); 00216 wait(0.1); 00217 tts_speak( "And one thought crystallizes like an icy blast " ); 00218 wait(0.1); 00219 tts_speak( "I'm never going back, the past is in the past" ); 00220 wait(0.1); 00221 00222 last chorus 00223 tts_speak( "Let it go, let it go" ); 00224 wait(0.1); 00225 tts_speak( "And I'll rise like the break of dawn" ); 00226 wait(0.1); 00227 tts_speak( "Let it go, let it go" ); 00228 wait(0.1); 00229 tts_speak( "That perfect girl is gone" ); 00230 wait(0.1); 00231 tts_speak( "Here I stand" ); 00232 wait(0.1); 00233 tts_speak( "In the light of day" ); 00234 wait(0.1); 00235 tts_speak( "Let the storm rage on" ); 00236 wait(0.5); 00237 tts_speak( "The cold never bothered me anyway" ); 00238 wait(1); 00239 */ 00240 00241 // keep talking 00242 tts_speak( "For millions of years mankind lived just like the animals." ); 00243 wait(0.5); 00244 tts_speak( "Then something happenend which unleashed the power of our imagination" ); 00245 wait(0.5); 00246 tts_speak( "We learned to talk" ); 00247 wait(10); 00248 00249 } 00250 } 00251 00252 void msg_blk( uint16_t *req, uint16_t *err ) 00253 { 00254 char txt[ 6 ]; 00255 00256 pc.printf( " MSG BLOCKED \r\n" ); 00257 sprintf( txt, "%x\r\n", *req ); 00258 pc.printf( txt ); 00259 sprintf( txt, "%x\r\n", *err ); 00260 pc.printf( txt ); 00261 } 00262 00263 void fatal_err( uint16_t *err ) 00264 { 00265 pc.printf( "Fatal Error Detected" ); 00266 tts_init(); 00267 tts_fatal_err_callback( fatal_err ); 00268 } 00269 00270 00271 ///////////////////text_to_speech_hal.c/////////////// 00272 void tts_hal_cs_high() 00273 { 00274 00275 TTS_CS = 1; 00276 } 00277 00278 void tts_hal_cs_low() 00279 { 00280 TTS_CS = 0; 00281 00282 } 00283 00284 void tts_hal_mut_high() 00285 { 00286 TTS_MUTE = 1; 00287 } 00288 00289 void tts_hal_mut_low() 00290 { 00291 TTS_MUTE = 0; 00292 } 00293 /* 00294 void tts_hal_reset( void ) 00295 { 00296 TTS_RST = 0; 00297 wait(0.01); 00298 TTS_RST = 1; 00299 //wait(1); 00300 wait(POR_TIME / 1000); 00301 } 00302 */ 00303 void tts_hal_reset( void ) 00304 { 00305 tts_hal_cs_high(); 00306 TTS_RST = 0; 00307 tts_hal_write_pad(1); 00308 wait(0.01); 00309 TTS_RST = 1; 00310 wait(POR_TIME); 00311 } 00312 bool tts_hal_msg_rdy( void ) 00313 { 00314 return TTS_RDY; 00315 } 00316 00317 void tts_hal_init() 00318 { 00319 tts_hal_reset(); 00320 tts_hal_cs_high(); 00321 tts_hal_mut_low(); 00322 } 00323 00324 00325 void tts_hal_write( uint8_t *buffer, 00326 uint16_t count, bool boot ) 00327 { 00328 00329 while( count-- ) 00330 { 00331 if(!boot) 00332 pc.printf("%02X\r\n", *buffer); 00333 00334 TextToSpeech.write( *buffer++ ); 00335 00336 } 00337 } 00338 00339 void tts_hal_write_pad( int cnt ) 00340 { 00341 00342 tts_hal_cs_low(); 00343 while(cnt--) 00344 { 00345 TextToSpeech.write( PADDING_BYTE ); 00346 } 00347 00348 tts_hal_cs_high(); 00349 } 00350 00351 void tts_hal_read( uint8_t *buffer, 00352 uint16_t count ) 00353 { 00354 00355 while(count--) 00356 { 00357 *buffer++ = TextToSpeech.write( DUMMY_BYTE ); //read spi bus 00358 00359 00360 //pc.printf("buffer = %X\n\r", *buffer); 00361 } 00362 } 00363 00364 ////////////////text_to_speech.c/////////////////////////////// 00365 00366 static int _parse_ind( void ) 00367 { 00368 uint16_t rsp_idx = tts_rsp_idx(); 00369 if ( rsp_idx == ISC_MSG_BLOCKED_RESP ) 00370 { 00371 uint8_t rsp_data[ 4 ] = { 0 }; 00372 00373 _req_err = 0; 00374 _err_code = 0; 00375 00376 tts_rsp_data( rsp_data ); 00377 00378 _req_err |= rsp_data[ 0 ]; 00379 _req_err |= rsp_data[ 1 ] << 8; 00380 _err_code |= rsp_data[ 2 ]; 00381 _err_code |= rsp_data[ 3 ] << 8; 00382 00383 if( _msg_block_callback != NULL ) 00384 _msg_block_callback( &_req_err, &_err_code ); 00385 00386 return 1; 00387 00388 } else if ( rsp_idx == ISC_ERROR_IND ) { 00389 00390 uint8_t rsp_data[ 4 ] = { 0 }; 00391 00392 _req_err = 0; 00393 _err_code = 0; 00394 00395 tts_rsp_data( rsp_data ); 00396 00397 _err_code |= rsp_data[ 0 ]; 00398 _err_code |= rsp_data[ 1 ] << 8; 00399 00400 if ( _err_code && _err_code < 0x8000 ) 00401 { 00402 if( _err_callback != NULL ) 00403 _err_callback( &_err_code ); 00404 00405 } else if ( _err_code && _err_code > 0x7FFF ) { 00406 00407 if( _fatal_err_callback != NULL ) 00408 _fatal_err_callback( &_err_code ); 00409 } 00410 00411 return 1; 00412 00413 } else if ( rsp_idx == ISC_TTS_READY_IND ) { 00414 00415 _tts_rdy_f = 1; 00416 00417 } else if ( rsp_idx == ISC_SPCODEC_READY_IND ) { 00418 00419 _spc_rdy_f = 1; 00420 00421 } else if ( rsp_idx == ISC_TTS_FINISHED_IND ) { 00422 00423 _tts_fin_f = 1; 00424 00425 } else if ( rsp_idx == ISC_SPCODEC_FINISHED_IND ) { 00426 00427 _spc_fin_f = 1; 00428 } 00429 00430 return 0; 00431 } 00432 /****************************************************************************** 00433 * Public Function Definitions 00434 *******************************************************************************/ 00435 00436 00437 void tts_init() 00438 { 00439 _req_err = 0; 00440 _err_code = 0; 00441 00442 _tts_rdy_f = true; 00443 _spc_rdy_f = true; 00444 _tts_fin_f = true; 00445 _spc_fin_f = true; 00446 00447 _audio_conf.as = 0x00; 00448 _audio_conf.ag = 0x43; 00449 _audio_conf.amp = 0x00; 00450 _audio_conf.asr = ASR_11KHZ; 00451 _audio_conf.ar = 0x00; 00452 _audio_conf.atc = 0x00; 00453 _audio_conf.acs = 0x00; 00454 _audio_conf.dc = 0x00; 00455 00456 _tts_conf.sr = 0x01; 00457 _tts_conf.voice = 0x00; 00458 _tts_conf.ep = 0x00; 00459 _tts_conf.lang = TTSV_US; 00460 _tts_conf.sr_wpm_lsb = 0xc8; 00461 _tts_conf.sr_wpm_msb = 0x00; 00462 _tts_conf.ds = 0x00; 00463 _tts_conf.res = 0x00; 00464 00465 _pman_conf.am_lsb = 0x01; 00466 _pman_conf.am_msb = 0x00; 00467 _pman_conf.spi_clk = 0x01; 00468 _pman_conf.pad = PADDING_BYTE; 00469 00470 _flush_enable = false; 00471 00472 _msg_block_callback = NULL; 00473 _fatal_err_callback = NULL; 00474 _err_callback = NULL; 00475 00476 tts_hw_init(); 00477 } 00478 00479 void tts_msg_block_callback( void( *msg_blk_ptr )( uint16_t *req_ptr, 00480 uint16_t *err_ptr ) ) 00481 { 00482 _msg_block_callback = msg_blk_ptr; 00483 } 00484 00485 void tts_fatal_err_callback( void( *fatal_err_ptr )( uint16_t *err_ptr ) ) 00486 { 00487 _fatal_err_callback = fatal_err_ptr; 00488 } 00489 00490 void tts_err_callback( void( *error_ptr )( uint16_t *err_ptr ) ) 00491 { 00492 _err_callback = error_ptr; 00493 } 00494 00495 void tts_mute() 00496 { 00497 tts_mute_cmd( true ); 00498 } 00499 00500 void tts_unmute() 00501 { 00502 tts_mute_cmd( false ); 00503 } 00504 00505 00506 void tts_setup() 00507 { 00508 00509 00510 00511 // pc.printf( "tts init data size: %i\n\r", sizeof(TTS_INIT_DATA2)); 00512 00513 tts_version_boot(); 00514 int succ = tts_image_load( (uint8_t*)TTS_INIT_DATA, sizeof( TTS_INIT_DATA ) ); 00515 00516 if ( succ != 0x0001 ) 00517 { 00518 pc.printf("tts init data failed!\n\r"); 00519 pc.printf("returned value: %04X\n\r", succ); 00520 wait(100); 00521 } 00522 pc.printf("tts image load done\n\r"); //executes OK 00523 succ = tts_image_exec(); // executes ok 00524 00525 if ( succ != 0x0001 ) 00526 { 00527 pc.printf("tts image exec failed!\n\r"); 00528 pc.printf("returned value: %04X\n\r", succ); 00529 wait(100); 00530 } 00531 pc.printf("tts image exec done\n\r"); 00532 tts_interface_test(); 00533 pc.printf("tts interface test done\n\r"); 00534 tts_power_default_config(); 00535 pc.printf("tts power default done\n\r"); 00536 tts_audio_default_config(); 00537 pc.printf("tts audio default done\n\r"); 00538 tts_volume_set( 0 ); 00539 pc.printf("tts volume set done\n\r"); 00540 tts_default_config(); 00541 pc.printf("tts default config done\n\r"); 00542 } 00543 00544 void tts_version_boot( void ) 00545 { 00546 00547 uint8_t tmp_resp[ 16 ] = { 0 }; 00548 00549 wait( RESET_TO_BOOT_TIME ); 00550 00551 00552 tts_parse_req( ISC_VERSION_REQ_BOOT, NULL, 0 ); 00553 00554 00555 while( !tts_rsp_chk( ISC_VERSION_RESP_BOOT ) ) 00556 { 00557 tts_get_resp(); 00558 00559 } 00560 tts_hal_write_pad( 16); 00561 tts_rsp_data( tmp_resp ); 00562 pc.printf("hwver0 %X \n\r", tmp_resp[ 0 ]); 00563 pc.printf("hwver1 %X \n\r", tmp_resp[ 1 ]); 00564 } 00565 00566 00567 00568 uint16_t tts_image_load(const uint8_t *image, 00569 uint16_t count ) 00570 { 00571 00572 uint16_t tmp_resp = 0; 00573 uint16_t index = 0; 00574 uint8_t raw_resp[ 2 ] = { 0 }; 00575 00576 while ( ( count - index ) > ( BOOT_MESSAGE_MAX - 4 ) ) 00577 { 00578 00579 tts_parse_boot_img( image + index, BOOT_MESSAGE_MAX - 4 ); 00580 wait(0.01); 00581 index += ( BOOT_MESSAGE_MAX - 4 ); 00582 } 00583 tts_parse_boot_img( image + index, count - index ); 00584 wait(0.01); 00585 00586 while( !tts_rsp_chk( ISC_BOOT_LOAD_RESP ) ) 00587 { 00588 tts_get_resp(); 00589 00590 if( _parse_ind() ) 00591 return _err_code; 00592 } 00593 tts_rsp_data( raw_resp ); 00594 00595 tmp_resp |= raw_resp[ 0 ]; 00596 tmp_resp |= raw_resp[ 1 ] << 8; 00597 00598 return tmp_resp; 00599 //return ( tmp_resp == 1 ) ? tmp_resp : 0x0000; 00600 } 00601 00602 uint16_t tts_image_exec() 00603 { 00604 uint16_t tmp_resp = 0; 00605 uint8_t raw_resp[ 2 ] = { 0 }; 00606 00607 00608 tts_parse_req( ISC_BOOT_RUN_REQ, NULL, 0 ); 00609 00610 00611 00612 00613 while( !tts_rsp_chk( ISC_BOOT_RUN_RESP ) ) 00614 { 00615 00616 tts_get_resp(); 00617 00618 if( _parse_ind() ) 00619 return _err_code; 00620 } 00621 tts_rsp_data( raw_resp ); 00622 00623 tmp_resp |= raw_resp[ 0 ]; 00624 tmp_resp |= raw_resp[ 1 ] << 8; 00625 00626 return tmp_resp; 00627 } 00628 00629 uint16_t tts_interface_test() 00630 { 00631 uint16_t tmp_resp = 0; 00632 uint8_t raw_resp[ 2 ] = { 0 }; 00633 00634 00635 wait( BOOT_TO_MAIN_MODE ); 00636 00637 tts_parse_req( ISC_TEST_REQ, test, 8 ); 00638 00639 while( !tts_rsp_chk( ISC_TEST_RESP ) ) 00640 { 00641 tts_get_resp(); 00642 00643 if( _parse_ind() ) 00644 return _err_code; 00645 } 00646 00647 tts_rsp_data( raw_resp ); 00648 00649 tmp_resp |= raw_resp[ 0 ]; 00650 tmp_resp |= raw_resp[ 1 ] << 8; 00651 00652 return tmp_resp; 00653 } 00654 00655 uint16_t tts_version_main( VER_t *buffer ) 00656 { 00657 char tmp_char[ 3 ] = { 0 }; 00658 uint32_t tmp_fwf = 0; 00659 uint32_t tmp_fwef = 0; 00660 uint8_t tmp_resp[ 20 ] = { 0 }; 00661 00662 tts_parse_req( ISC_VERSION_REQ_MAIN, NULL, 0 ); 00663 00664 while( !tts_rsp_chk( ISC_VERSION_RESP_MAIN ) ) 00665 { 00666 tts_get_resp(); 00667 00668 if( _parse_ind() ) 00669 return _err_code; 00670 } 00671 00672 tts_rsp_data( tmp_resp ); 00673 sprintf(tmp_char, "%c", tmp_resp[ 0 ]); 00674 strcpy( buffer->hwver, tmp_char ); 00675 strcat( buffer->hwver, "." ); 00676 sprintf(tmp_char, "%c", tmp_resp[ 1 ]); 00677 strcat( buffer->hwver, tmp_char ); 00678 sprintf(tmp_char, "%c", tmp_resp[ 2 ]); 00679 strcpy( buffer->fwver, tmp_char ); 00680 strcat( buffer->fwver, "." ); 00681 sprintf(tmp_char, "%c", tmp_resp[ 3 ]); 00682 strcat( buffer->fwver, tmp_char ); 00683 strcat( buffer->fwver, "." ); 00684 sprintf(tmp_char, "%c", tmp_resp[ 12 ]); 00685 strcat( buffer->fwver, tmp_char ); 00686 00687 tmp_fwf |= tmp_resp[ 4 ]; 00688 tmp_fwf |= tmp_resp[ 5 ] << 8; 00689 tmp_fwf |= tmp_resp[ 6 ] << 16; 00690 tmp_fwf |= tmp_resp[ 7 ] << 24; 00691 buffer->fwf = (FF_t)tmp_fwf; 00692 tmp_fwef |= tmp_resp[ 8 ]; 00693 tmp_fwef |= tmp_resp[ 9 ] << 8; 00694 tmp_fwef |= tmp_resp[ 10 ] << 16; 00695 tmp_fwef |= tmp_resp[ 11 ] << 24; 00696 buffer->fwef = (EFF_t)tmp_fwef; 00697 00698 return 0x0000; 00699 } 00700 00701 uint16_t tts_power_default_config() 00702 { 00703 uint16_t tmp_resp = 0; 00704 uint8_t raw_resp[ 2 ] = { 0 }; 00705 00706 tts_parse_req( ISC_PMAN_CONFIG_REQ, ( uint8_t* )&_pman_conf, 4 ); 00707 00708 while( !tts_rsp_chk( ISC_PMAN_CONFIG_RESP ) ) 00709 { 00710 tts_get_resp(); 00711 00712 if( _parse_ind() ) 00713 return _err_code; 00714 } 00715 00716 tts_rsp_data( raw_resp ); 00717 00718 tmp_resp |= raw_resp[ 0 ]; 00719 tmp_resp |= raw_resp[ 1 ] << 8; 00720 00721 return tmp_resp; 00722 } 00723 00724 uint16_t tts_standby_enter() 00725 { 00726 uint16_t tmp_resp = 0; 00727 uint8_t raw_resp[ 2 ] = { 0 }; 00728 00729 tts_parse_req( ISC_PMAN_STANDBY_ENTRY_REQ, NULL, 0 ); 00730 00731 while( !tts_rsp_chk( ISC_PMAN_STANDBY_ENTRY_RESP ) ) 00732 { 00733 tts_get_resp(); 00734 00735 if( _parse_ind() ) 00736 return _err_code; 00737 } 00738 00739 tts_rsp_data( raw_resp ); 00740 00741 tmp_resp |= raw_resp[ 0 ]; 00742 tmp_resp |= raw_resp[ 1 ] << 8; 00743 00744 return tmp_resp; 00745 } 00746 00747 uint16_t tts_standby_exit() 00748 { 00749 wait( STBY_MODE_ENTERY ); 00750 tts_parse_req( ISC_PMAN_STANDBY_EXIT_IND, NULL, 0 ); 00751 00752 while( !tts_rsp_chk( ISC_PMAN_STANDBY_EXIT_IND ) ) 00753 { 00754 tts_get_resp(); 00755 00756 if( _parse_ind() ) 00757 return _err_code; 00758 } 00759 00760 return 0x0000; 00761 } 00762 00763 uint16_t tts_audio_default_config() 00764 { 00765 uint16_t tmp_resp = 0; 00766 uint8_t raw_resp[ 2 ] = { 0 }; 00767 00768 tts_parse_req( ISC_AUDIO_CONFIG_REQ, ( uint8_t* )&_audio_conf, 8 ); 00769 00770 while( !tts_rsp_chk( ISC_AUDIO_CONFIG_RESP ) ) 00771 { 00772 tts_get_resp(); 00773 00774 if( _parse_ind() ) 00775 return _err_code; 00776 } 00777 00778 tts_rsp_data( raw_resp ); 00779 00780 tmp_resp |= raw_resp[ 0 ]; 00781 tmp_resp |= raw_resp[ 1 ] << 8; 00782 00783 return tmp_resp; 00784 } 00785 00786 uint16_t tts_audio_config( int8_t audio_gain, 00787 ASR_t sample_rate, 00788 bool dac_control ) 00789 { 00790 ACONF_t audio_conf; 00791 uint16_t tmp_resp = 0; 00792 uint8_t raw_resp[ 2 ] = { 0 }; 00793 00794 if ( audio_gain < -48 || audio_gain > 18 ) 00795 return 0xFFFF; 00796 00797 if ( sample_rate != 0 || sample_rate != 1 || sample_rate != 3 ) 00798 return 0xFFFF; 00799 00800 audio_conf.ag = ( uint8_t )audio_gain; 00801 audio_conf.asr = sample_rate; 00802 audio_conf.dc = dac_control; 00803 00804 tts_parse_req( ISC_AUDIO_CONFIG_REQ, ( uint8_t* )&audio_conf, 8 ); 00805 00806 while( !tts_rsp_chk( ISC_AUDIO_CONFIG_RESP ) ) 00807 { 00808 tts_get_resp(); 00809 00810 if( _parse_ind() ) 00811 return _err_code; 00812 } 00813 00814 tts_rsp_data( raw_resp ); 00815 00816 tmp_resp |= raw_resp[ 0 ]; 00817 tmp_resp |= raw_resp[ 1 ] << 8; 00818 00819 return tmp_resp; 00820 } 00821 00822 uint16_t tts_volume_set( int16_t gain ) 00823 { 00824 uint16_t tmp_resp = 0; 00825 uint8_t raw_resp[ 2 ] = { 0 }; 00826 uint8_t tmp_gain[ 2 ] = { 0 }; 00827 00828 tmp_gain[ 0 ] = gain & 0x00FF; 00829 tmp_gain[ 1 ] = ( gain & 0xFF00 ) >> 8; 00830 00831 tts_parse_req( ISC_AUDIO_VOULME_REQ, tmp_gain, 2 ); 00832 00833 while( !tts_rsp_chk( ISC_AUDIO_VOLUME_RESP ) ) 00834 { 00835 tts_get_resp(); 00836 00837 if( _parse_ind() ) 00838 return _err_code; 00839 } 00840 00841 tts_rsp_data( raw_resp ); 00842 00843 tmp_resp |= raw_resp[ 0 ]; 00844 tmp_resp |= raw_resp[ 1 ] << 8; 00845 00846 return tmp_resp; 00847 } 00848 00849 uint16_t tts_audio_mute() 00850 { 00851 uint16_t tmp_resp = 0; 00852 uint8_t raw_resp[ 2 ] = { 0 }; 00853 uint8_t tmp_mute[ 2 ] = { 1, 0 }; 00854 00855 tts_parse_req( ISC_AUDIO_MUTE_REQ, tmp_mute, 2 ); 00856 00857 while( !tts_rsp_chk( ISC_AUDIO_MUTE_RESP ) ) 00858 { 00859 tts_get_resp(); 00860 00861 if( _parse_ind() ) 00862 return _err_code; 00863 } 00864 00865 tts_rsp_data( raw_resp ); 00866 00867 tmp_resp |= raw_resp[ 0 ]; 00868 tmp_resp |= raw_resp[ 1 ] << 8; 00869 00870 return tmp_resp; 00871 } 00872 00873 uint16_t tts_audio_unmute() 00874 { 00875 uint16_t tmp_resp = 0; 00876 uint8_t raw_resp[ 2 ] = { 0 }; 00877 uint8_t tmp_mute[ 2 ] = { 0, 0 }; 00878 00879 tts_parse_req( ISC_AUDIO_MUTE_REQ, tmp_mute, 2 ); 00880 00881 while( !tts_rsp_chk( ISC_AUDIO_MUTE_RESP ) ) 00882 { 00883 tts_get_resp(); 00884 00885 if( _parse_ind() ) 00886 return _err_code; 00887 } 00888 00889 tts_rsp_data( raw_resp ); 00890 00891 tmp_resp |= raw_resp[ 0 ]; 00892 tmp_resp |= raw_resp[ 1 ] << 8; 00893 00894 return tmp_resp; 00895 } 00896 00897 uint16_t tts_default_config() 00898 { 00899 uint16_t tmp_resp = 0; 00900 uint8_t raw_resp[ 2 ] = { 0 }; 00901 00902 tts_parse_req( ISC_TTS_CONFIG_REQ, ( uint8_t* )&_tts_conf, 8 ); 00903 00904 while( !tts_rsp_chk( ISC_TTS_CONFIG_RESP ) ) 00905 { 00906 tts_get_resp(); 00907 00908 if( _parse_ind() ) 00909 return _err_code; 00910 } 00911 00912 tts_rsp_data( raw_resp ); 00913 00914 tmp_resp |= raw_resp[ 0 ]; 00915 tmp_resp |= raw_resp[ 1 ] << 8; 00916 00917 return tmp_resp; 00918 } 00919 00920 uint16_t tts_config( uint8_t voice_type, 00921 bool epson_parse, 00922 TTSV_t language, 00923 uint16_t speaking_rate ) 00924 { 00925 TTSCONF_t tts_conf; 00926 uint16_t tmp_resp = 0; 00927 uint8_t raw_resp[ 2 ] = { 0 }; 00928 00929 if ( voice_type > 8 ) 00930 return 0xFFFF; 00931 00932 if ( language > 4 ) 00933 return 0xFFFF; 00934 00935 if ( speaking_rate < 0x004B || speaking_rate > 0x0258 ) 00936 return 0xFFFF; 00937 00938 tts_conf.voice = voice_type; 00939 tts_conf.ep = epson_parse; 00940 tts_conf.lang = language; 00941 tts_conf.sr_wpm_lsb = ( speaking_rate & 0x00FF ); 00942 tts_conf.sr_wpm_msb = ( speaking_rate & 0xFF00 ) >> 8; 00943 00944 tts_parse_req( ISC_TTS_CONFIG_REQ, ( uint8_t* )&tts_conf, 8 ); 00945 00946 while( !tts_rsp_chk( ISC_TTS_CONFIG_RESP ) ) 00947 { 00948 tts_get_resp(); 00949 00950 if( _parse_ind() ) 00951 return _err_code; 00952 } 00953 00954 tts_rsp_data( raw_resp ); 00955 00956 tmp_resp |= raw_resp[ 0 ]; 00957 tmp_resp |= raw_resp[ 1 ] << 8; 00958 00959 return tmp_resp; 00960 } 00961 00962 uint16_t tts_speak( char *word ) 00963 { 00964 bool tmp_f = false; 00965 char *wptr = word; 00966 uint8_t raw_resp[ 2 ] = { 0 }; 00967 uint16_t tmp_resp = 0; 00968 uint32_t wlen = strlen( wptr ); 00969 00970 tts_parse_speak_req( ISC_TTS_SPEAK_REQ, _flush_enable, wptr, wlen ); 00971 00972 _tts_rdy_f = 0; 00973 _tts_fin_f = 0; 00974 00975 while( !( tmp_f && _tts_rdy_f ) ) 00976 { 00977 tts_get_resp(); 00978 00979 if( _parse_ind() ) 00980 return _err_code; 00981 00982 if( tts_rsp_chk( ISC_TTS_SPEAK_RESP ) ) 00983 { 00984 tts_rsp_data( raw_resp ); 00985 00986 tmp_resp |= raw_resp[ 0 ]; 00987 tmp_resp |= raw_resp[ 1 ] << 8; 00988 tmp_f = true; 00989 } 00990 } 00991 00992 return tmp_resp; 00993 } 00994 00995 uint16_t tts_pause( void ) 00996 { 00997 uint16_t tmp_resp = 0; 00998 uint8_t raw_resp[ 2 ] = { 0 }; 00999 uint8_t tmp_pause[ 2 ] = { 1, 0 }; 01000 01001 tts_parse_req( ISC_TTS_PAUSE_REQ, tmp_pause, 2 ); 01002 01003 while( !tts_rsp_chk( ISC_TTS_PAUSE_RESP ) ) 01004 { 01005 tts_get_resp(); 01006 01007 if( _parse_ind() ) 01008 return _err_code; 01009 } 01010 01011 tts_rsp_data( raw_resp ); 01012 01013 tmp_resp |= raw_resp[ 0 ]; 01014 tmp_resp |= raw_resp[ 1 ] << 8; 01015 01016 return tmp_resp; 01017 } 01018 01019 uint16_t tts_unpause( void ) 01020 { 01021 uint16_t tmp_resp = 0; 01022 uint8_t raw_resp[ 2 ] = { 0 }; 01023 uint8_t tmp_pause[ 2 ] = { 0 }; 01024 01025 tts_parse_req( ISC_TTS_PAUSE_REQ, tmp_pause, 2 ); 01026 01027 while( !tts_rsp_chk( ISC_TTS_PAUSE_RESP ) ) 01028 { 01029 tts_get_resp(); 01030 01031 if( _parse_ind() ) 01032 return _err_code; 01033 } 01034 01035 tts_rsp_data( raw_resp ); 01036 01037 tmp_resp |= raw_resp[ 0 ]; 01038 tmp_resp |= raw_resp[ 1 ] << 8; 01039 01040 return tmp_resp; 01041 } 01042 01043 uint16_t tts_stop( bool reset ) 01044 { 01045 uint16_t tmp_resp = 0; 01046 uint8_t raw_resp[ 2 ] = { 0 }; 01047 uint8_t tmp_reset[ 2 ] = { 0 }; 01048 01049 if( reset ) 01050 tmp_reset[ 0 ] = 0x01; 01051 01052 tts_parse_req( ISC_TTS_STOP_REQ, tmp_reset, 2 ); 01053 01054 while( !tts_rsp_chk( ISC_TTS_STOP_RESP ) ) 01055 { 01056 tts_get_resp(); 01057 01058 if( _parse_ind() ) 01059 return _err_code; 01060 } 01061 01062 tts_rsp_data( raw_resp ); 01063 01064 tmp_resp |= raw_resp[ 0 ]; 01065 tmp_resp |= raw_resp[ 1 ] << 8; 01066 01067 return tmp_resp; 01068 } 01069 01070 uint16_t tts_user_dict( bool erase, 01071 uint8_t *udict_data, 01072 uint16_t count ) 01073 { 01074 uint16_t cnt = 2; 01075 uint16_t tmp_rsp = 0; 01076 uint8_t rsp_data[ 2 ] = { 0 }; 01077 uint8_t tmp_data[ BOOT_MESSAGE_MAX ] = { 0 }; 01078 01079 if ( erase ) 01080 tmp_data[ 0 ] = 1; 01081 01082 while ( count-- ) 01083 tmp_data[ cnt ++ ] = *( udict_data++ ); 01084 01085 tts_parse_req( ISC_TTS_UDICT_DATA_REQ, tmp_data, count + 2 ); 01086 01087 while( !tts_rsp_chk( ISC_TTS_UDICT_DATA_RESP ) ) 01088 { 01089 tts_get_resp(); 01090 01091 if( _parse_ind() ) 01092 return _err_code; 01093 } 01094 01095 tts_rsp_data( rsp_data ); 01096 01097 tmp_rsp |= rsp_data[ 0 ]; 01098 tmp_rsp |= rsp_data[ 1 ] << 8; 01099 01100 return tmp_rsp; 01101 } 01102 01103 uint16_t tts_codec_configure() 01104 { 01105 uint16_t tmp_resp = 0; 01106 uint8_t raw_resp[ 2 ] = { 0 }; 01107 uint8_t tmp_codec[ 32 ] = { 0 }; 01108 01109 tmp_codec[ 0 ] = 0x01; 01110 tmp_codec[ 1 ] = 0x01; 01111 tmp_codec[ 24 ] = 0x02; 01112 01113 tts_parse_req( ISC_SPCODEC_CONFIG_REQ , tmp_codec, 32 ); 01114 01115 while( !tts_rsp_chk( ISC_SPCODEC_CONFIG_RESP ) ) 01116 { 01117 tts_get_resp(); 01118 01119 if( _parse_ind() ) 01120 return _err_code; 01121 } 01122 01123 tts_rsp_data( raw_resp ); 01124 01125 tmp_resp |= raw_resp[ 0 ]; 01126 tmp_resp |= raw_resp[ 1 ] << 8; 01127 01128 return tmp_resp; 01129 } 01130 01131 uint16_t tts_codec_start( uint8_t *codec_data, 01132 uint16_t count ) 01133 { 01134 bool tmp_f = false; 01135 uint16_t tmp_resp = 0; 01136 uint8_t raw_resp[ 2 ] = { 0 }; 01137 01138 if ( count != 512 || count != 1024 || count != 2048 ) 01139 return 0xFFFF; 01140 01141 while( !_spc_fin_f ) 01142 { 01143 tts_get_resp(); 01144 01145 if( _parse_ind() ) 01146 return _err_code; 01147 } 01148 01149 tts_parse_req( ISC_SPCODEC_START_REQ , codec_data, count ); 01150 01151 _spc_rdy_f = 0; 01152 _spc_fin_f = 0; 01153 01154 while( !( tmp_f && _spc_rdy_f ) ) 01155 { 01156 tts_get_resp(); 01157 01158 if( _parse_ind() ) 01159 return _err_code; 01160 01161 if( tts_rsp_chk( ISC_TTS_SPEAK_RESP ) ) 01162 { 01163 tts_rsp_data( raw_resp ); 01164 01165 tmp_resp |= raw_resp[ 0 ]; 01166 tmp_resp |= raw_resp[ 1 ] << 8; 01167 tmp_f = true; 01168 } 01169 } 01170 01171 return tmp_resp; 01172 } 01173 01174 uint16_t tts_codec_pause() 01175 { 01176 uint16_t tmp_resp = 0; 01177 uint8_t raw_resp[ 2 ] = { 0 }; 01178 uint8_t tmp_data[ 2 ] = { 1, 0 }; 01179 01180 tts_parse_req( ISC_SPCODEC_PAUSE_REQ , tmp_data, 2 ); 01181 01182 while( !tts_rsp_chk( ISC_SPCODEC_PAUSE_RESP ) ) 01183 { 01184 tts_get_resp(); 01185 01186 if( _parse_ind() ) 01187 return _err_code; 01188 } 01189 01190 tts_rsp_data( raw_resp ); 01191 01192 tmp_resp |= raw_resp[ 0 ]; 01193 tmp_resp |= raw_resp[ 1 ] << 8; 01194 01195 return tmp_resp; 01196 } 01197 01198 uint16_t tts_codec_unpause() 01199 { 01200 uint16_t tmp_resp = 0; 01201 uint8_t raw_resp[ 2 ] = { 0 }; 01202 uint8_t tmp_data[ 2 ] = { 0 }; 01203 01204 tts_parse_req( ISC_SPCODEC_PAUSE_REQ , tmp_data, 2 ); 01205 01206 while( !tts_rsp_chk( ISC_SPCODEC_PAUSE_RESP ) ) 01207 { 01208 tts_get_resp(); 01209 01210 if( _parse_ind() ) 01211 return _err_code; 01212 } 01213 01214 tts_rsp_data( raw_resp ); 01215 01216 tmp_resp |= raw_resp[ 0 ]; 01217 tmp_resp |= raw_resp[ 1 ] << 8; 01218 01219 return tmp_resp; 01220 } 01221 01222 uint16_t tts_codec_stop( bool reset ) 01223 { 01224 uint16_t tmp_resp = 0; 01225 uint8_t raw_resp[ 2 ] = { 0 }; 01226 uint8_t tmp_data[ 2 ] = { 0 }; 01227 01228 if( reset ) 01229 tmp_data[ 0 ] = 1; 01230 01231 tts_parse_req( ISC_SPCODEC_STOP_REQ, tmp_data, 2 ); 01232 01233 while( !tts_rsp_chk( ISC_SPCODEC_PAUSE_RESP ) ) 01234 { 01235 tts_get_resp(); 01236 01237 if( _parse_ind() ) 01238 return _err_code; 01239 } 01240 01241 tts_rsp_data( raw_resp ); 01242 01243 tmp_resp |= raw_resp[ 0 ]; 01244 tmp_resp |= raw_resp[ 1 ] << 8; 01245 01246 return tmp_resp; 01247 } 01248 /****************************************************************************** 01249 * text_to_speech_hw.c 01250 *******************************************************************************/ 01251 void _read_rsp() 01252 { 01253 uint8_t tmp_byte = 0; 01254 uint16_t tmp_len = 0; 01255 01256 tts_hal_cs_low(); 01257 01258 tts_hal_read( &tmp_byte, 1 ); 01259 01260 if( tmp_byte == START_MESSAGE ) 01261 { 01262 01263 tts_hal_read( ( uint8_t* )&_last_rsp, 2 ); 01264 tmp_len |= _last_rsp.len[ 0 ]; 01265 tmp_len |= _last_rsp.len[ 1 ] << 8; 01266 tts_hal_read( ( uint8_t* )&_last_rsp + 2, tmp_len ); 01267 01268 } else { 01269 01270 wait( 0.005 ); 01271 } 01272 01273 tts_hal_cs_high(); 01274 } 01275 01276 void _write_req(bool boot) 01277 { 01278 uint16_t cnt = 0; 01279 uint8_t start = START_MESSAGE; 01280 01281 cnt |= _last_req.len[ 0 ]; 01282 cnt |= _last_req.len[ 1 ] << 8; 01283 01284 tts_hal_cs_low(); 01285 01286 01287 if(boot) 01288 { 01289 tts_hal_write( &start, 1, true ); 01290 tts_hal_write( ( uint8_t* )&_last_req, cnt, true); 01291 } 01292 else 01293 { 01294 tts_hal_write( &start, 1, false ); 01295 tts_hal_write( ( uint8_t* ) &_last_req, cnt, false ); 01296 } 01297 01298 tts_hal_cs_high(); 01299 01300 } 01301 01302 /****************************************************************************** 01303 * Public Function Definitions 01304 *******************************************************************************/ 01305 void tts_hw_init( void ) 01306 { 01307 tts_hal_init(); 01308 01309 _ticker_f = false; 01310 _ticker = 0; 01311 01312 _last_req.idx[ 0 ] = 0; 01313 _last_req.idx[ 1 ] = 0; 01314 _last_req.len[ 0 ] = 0; 01315 _last_req.len[ 1 ] = 0; 01316 memset( _last_req.payload, 0, MAIN_MESSAGE_MAX ); 01317 01318 _last_rsp.idx[ 0 ] = 255; 01319 _last_rsp.idx[ 1 ] = 255; 01320 _last_rsp.len[ 0 ] = 0; 01321 _last_rsp.len[ 1 ] = 0; 01322 memset( _last_rsp.payload, 0, RESP_MESSAGE_MAX ); 01323 } 01324 01325 void tts_tick_isr() 01326 { 01327 _ticker++; 01328 01329 if( _ticker > 500 ) 01330 _ticker_f == true; 01331 } 01332 01333 void tts_mute_cmd( bool cmd ) 01334 { 01335 if( cmd ) 01336 tts_hal_mut_high(); 01337 else 01338 tts_hal_mut_low(); 01339 } 01340 01341 void tts_parse_req( uint16_t req, 01342 uint8_t *payload, 01343 uint16_t pl_len ) 01344 { 01345 uint8_t *pl = payload; 01346 uint16_t i = 0; 01347 uint16_t tmp = pl_len + 4; 01348 01349 01350 01351 _last_req.len[ 0 ] = tmp & 0x00FF; 01352 _last_req.len[ 1 ] = ( tmp & 0xFF00 ) >> 8; 01353 _last_req.idx[ 0 ] = req & 0x00FF; 01354 _last_req.idx[ 1 ] = ( req & 0xFF00 ) >> 8; 01355 _last_rsp.idx[ 0 ] = 0xFF; 01356 _last_rsp.idx[ 1 ] = 0xFF; 01357 01358 if ( payload != NULL ) 01359 { 01360 while ( pl_len-- ) 01361 _last_req.payload[ i++ ] = *( pl++ ); 01362 01363 } 01364 01365 _write_req(true); 01366 } 01367 01368 void tts_parse_boot_img( const uint8_t *payload, 01369 uint16_t pl_len ) 01370 { 01371 01372 01373 uint16_t i = 0; 01374 uint16_t tmp = pl_len + 0x04; 01375 01376 _last_req.len[ 0 ] = tmp & 0x00FF; 01377 _last_req.len[ 1 ] = ( tmp & 0xFF00 ) >> 8; 01378 _last_req.idx[ 0 ] = 0x00; 01379 _last_req.idx[ 1 ] = 0x10; 01380 _last_rsp.idx[ 0 ] = 0xFF; 01381 _last_rsp.idx[ 1 ] = 0xFF; 01382 01383 if ( payload != NULL ) 01384 { 01385 while ( pl_len-- ) 01386 _last_req.payload[ i++ ] = payload[ i ]; 01387 } 01388 01389 _write_req(true); 01390 } 01391 01392 void tts_parse_speak_req( uint16_t req, 01393 uint8_t flush_en, 01394 char *word, 01395 uint16_t word_len ) 01396 { 01397 char *ptr = word; 01398 uint16_t i = 1; 01399 uint16_t tmp = word_len; 01400 01401 word_len += 7; 01402 01403 _last_req.len[ 0 ] = word_len & 0x00FF; 01404 _last_req.len[ 1 ] = ( word_len & 0xFF00 ) >> 8; 01405 _last_req.idx[ 0 ] = req & 0x00FF; 01406 _last_req.idx[ 1 ] = ( req & 0xFF00 ) >> 8; 01407 _last_rsp.idx[ 0 ] = 0xFF; 01408 _last_rsp.idx[ 1 ] = 0xFF; 01409 01410 if( flush_en ) 01411 { 01412 _last_req.payload[ 0 ] = 1; 01413 01414 } else { 01415 01416 _last_req.payload[ 0 ] = 0; 01417 } 01418 01419 while( tmp-- ) 01420 _last_req.payload[ i++ ] = *( ptr++ ); 01421 01422 _last_req.payload[ i++ ] = 0x20; 01423 _last_req.payload[ i ] = 0x00; 01424 01425 _write_req(true); 01426 } 01427 01428 void tts_get_resp() 01429 { 01430 if( tts_hal_msg_rdy() ) 01431 { 01432 _read_rsp(); 01433 } 01434 } 01435 01436 bool tts_rsp_chk( uint16_t idx ) 01437 { 01438 uint16_t tmp = 0; 01439 01440 tmp |= _last_rsp.idx[ 0 ]; 01441 tmp |= _last_rsp.idx[ 1 ] << 8; 01442 01443 // pc.printf(" idx = %X\n\r", tmp); 01444 01445 return ( idx == tmp ) ? true : false; 01446 } 01447 01448 uint16_t tts_rsp_idx() 01449 { 01450 uint16_t tmp = 0; 01451 01452 tmp |= _last_rsp.idx[ 0 ]; 01453 tmp |= _last_rsp.idx[ 1 ] << 8; 01454 01455 return tmp; 01456 } 01457 01458 void tts_rsp_data( uint8_t *buffer ) 01459 { 01460 uint8_t *bfr = buffer; 01461 uint16_t cnt = 0; 01462 uint8_t *ptr = _last_rsp.payload; 01463 01464 cnt |= _last_rsp.len[ 0 ]; 01465 cnt |= _last_rsp.len[ 1 ] << 8; 01466 cnt -= 4; 01467 01468 while( cnt-- ) 01469 *( bfr++ ) = *( ptr++ ); 01470 } 01471 01472 /*************** END OF FUNCTIONS *********************************************/
Generated on Fri Jul 15 2022 01:24:40 by
1.7.2
