LibDriver SYN6658
Loading...
Searching...
No Matches
driver_syn6658_synthesis_test.c
Go to the documentation of this file.
1
36
38
39static syn6658_handle_t gs_handle;
40
50{
51 uint8_t res;
52 syn6658_info_t info;
53 syn6658_status_t status;
54 char s[32];
55 uint8_t gb2312_text[] = {0xD3, 0xEE, 0xD2, 0xF4, 0xCC, 0xEC, 0xCF, 0xC2, 0x00};
56 uint8_t gbk_text[] = {0xD3, 0xEE, 0xD2, 0xF4, 0xCC, 0xEC, 0xCF, 0xC2, 0x00};
57 uint8_t big5_text[] = {0xA6, 0x74, 0xAD, 0xB5, 0xA4, 0xD1, 0xA4, 0x55, 0x00};
58 uint8_t unicode_little_text[] = {0x87, 0x5B, 0xF3, 0x97, 0x29, 0x59, 0x0B, 0x4E, 0x00};
59 uint8_t unicode_big_text[] = {0x5B, 0x87, 0x97, 0xF3, 0x59, 0x29, 0x4E, 0x0B, 0x00};
60 uint8_t text0[] = {0xB4, 0xCB, 0xB9, 0xA6, 0xC4, 0xDC, 0xBF, 0xC9, 0xD2, 0xD4, 0xBD, 0xAB, 0xB1, 0xBB, 0x00};
61 uint8_t text1[] = {0xB4, 0xF2, 0xC2, 0xD2, 0xCB, 0xB3, 0xD0, 0xF2, 0xB5, 0xC4, 0xD2, 0xBB, 0xB6, 0xCE, 0xCE, 0xC4, 0x00};
62 uint8_t text2[] = {0xB1, 0xBE, 0xB0, 0xB4, 0xBF, 0xCD, 0xBB, 0xA7, 0xCF, 0xA3, 0xCD, 0xFB, 0xB5, 0xC4, 0xCB, 0xB3, 0xD0, 0xF2, 0xB7, 0xD6, 0x00};
63 uint8_t text3[] = {0xB6, 0xCE, 0xBB, 0xBA, 0xB4, 0xE6, 0xBA, 0xF3, 0xD2, 0xBB, 0xC6, 0xF0, 0xB2, 0xA5, 0xB7, 0xC5, 0xA1, 0xA3, 0x00};
64
65 /* link interface function */
80
81 /* get syn6658 information */
82 res = syn6658_info(&info);
83 if (res != 0)
84 {
85 syn6658_interface_debug_print("syn6658: get info failed.\n");
86
87 return 1;
88 }
89 else
90 {
91 /* print chip information */
92 syn6658_interface_debug_print("syn6658: chip is %s.\n", info.chip_name);
93 syn6658_interface_debug_print("syn6658: manufacturer is %s.\n", info.manufacturer_name);
94 syn6658_interface_debug_print("syn6658: interface is %s.\n", info.interface);
95 syn6658_interface_debug_print("syn6658: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
96 syn6658_interface_debug_print("syn6658: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
97 syn6658_interface_debug_print("syn6658: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
98 syn6658_interface_debug_print("syn6658: max current is %0.2fmA.\n", info.max_current_ma);
99 syn6658_interface_debug_print("syn6658: max temperature is %0.1fC.\n", info.temperature_max);
100 syn6658_interface_debug_print("syn6658: min temperature is %0.1fC.\n", info.temperature_min);
101 }
102
103 /* set interface */
104 res = syn6658_set_interface(&gs_handle, interface);
105 if (res != 0)
106 {
107 syn6658_interface_debug_print("syn6658: set interface failed.\n");
108
109 return 1;
110 }
111
112 /* syn6658 init */
113 res = syn6658_init(&gs_handle);
114 if (res != 0)
115 {
116 syn6658_interface_debug_print("syn6658: init failed.\n");
117
118 return 1;
119 }
120
121 /* synthesis text test */
122 syn6658_interface_debug_print("syn6658: synthesis text test.\n");
123
124 /* gb2312 synthesis text */
125 syn6658_interface_debug_print("syn6658: gb2312 synthesis text.\n");
126
127 /* set text type gb2312 */
129 if (res != 0)
130 {
131 syn6658_interface_debug_print("syn6658: set text type failed.\n");
132 (void)syn6658_deinit(&gs_handle);
133
134 return 1;
135 }
136
137 /* synthesis text */
138 res = syn6658_synthesis_text(&gs_handle, (char const *)gb2312_text);
139 if (res != 0)
140 {
141 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
142 (void)syn6658_deinit(&gs_handle);
143
144 return 1;
145 }
146
147 /* wait for finished */
148 status = SYN6658_STATUS_BUSY;
149 while (status == SYN6658_STATUS_BUSY)
150 {
152 res = syn6658_get_status(&gs_handle, &status);
153 if (res != 0)
154 {
155 syn6658_interface_debug_print("syn6658: get status failed.\n");
156 (void)syn6658_deinit(&gs_handle);
157
158 return 1;
159 }
160 }
161
162 /* gbk synthesis text */
163 syn6658_interface_debug_print("syn6658: gbk synthesis text.\n");
164
165 /* set text type gbk */
166 res = syn6658_set_text_type(&gs_handle, SYN6658_TYPE_GBK);
167 if (res != 0)
168 {
169 syn6658_interface_debug_print("syn6658: set text type failed.\n");
170 (void)syn6658_deinit(&gs_handle);
171
172 return 1;
173 }
174
175 /* synthesis text */
176 res = syn6658_synthesis_text(&gs_handle, (char const *)gbk_text);
177 if (res != 0)
178 {
179 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
180 (void)syn6658_deinit(&gs_handle);
181
182 return 1;
183 }
184
185 /* wait for finished */
186 status = SYN6658_STATUS_BUSY;
187 while (status == SYN6658_STATUS_BUSY)
188 {
190 res = syn6658_get_status(&gs_handle, &status);
191 if (res != 0)
192 {
193 syn6658_interface_debug_print("syn6658: get status failed.\n");
194 (void)syn6658_deinit(&gs_handle);
195
196 return 1;
197 }
198 }
199
200 /* big5 synthesis text */
201 syn6658_interface_debug_print("syn6658: big5 synthesis text.\n");
202
203 /* set text type big5 */
204 res = syn6658_set_text_type(&gs_handle, SYN6658_TYPE_BIG5);
205 if (res != 0)
206 {
207 syn6658_interface_debug_print("syn6658: set text type failed.\n");
208 (void)syn6658_deinit(&gs_handle);
209
210 return 1;
211 }
212
213 /* synthesis text */
214 res = syn6658_synthesis_text(&gs_handle, (char const *)big5_text);
215 if (res != 0)
216 {
217 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
218 (void)syn6658_deinit(&gs_handle);
219
220 return 1;
221 }
222
223 /* wait for finished */
224 status = SYN6658_STATUS_BUSY;
225 while (status == SYN6658_STATUS_BUSY)
226 {
228 res = syn6658_get_status(&gs_handle, &status);
229 if (res != 0)
230 {
231 syn6658_interface_debug_print("syn6658: get status failed.\n");
232 (void)syn6658_deinit(&gs_handle);
233
234 return 1;
235 }
236 }
237
238 /* unicode little endian synthesis text */
239 syn6658_interface_debug_print("syn6658: unicode little endian synthesis text.\n");
240
241 /* set text type unicode little endian */
243 if (res != 0)
244 {
245 syn6658_interface_debug_print("syn6658: set text type failed.\n");
246 (void)syn6658_deinit(&gs_handle);
247
248 return 1;
249 }
250
251 /* synthesis text */
252 res = syn6658_synthesis_text(&gs_handle, (char const *)unicode_little_text);
253 if (res != 0)
254 {
255 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
256 (void)syn6658_deinit(&gs_handle);
257
258 return 1;
259 }
260
261 /* wait for finished */
262 status = SYN6658_STATUS_BUSY;
263 while (status == SYN6658_STATUS_BUSY)
264 {
266 res = syn6658_get_status(&gs_handle, &status);
267 if (res != 0)
268 {
269 syn6658_interface_debug_print("syn6658: get status failed.\n");
270 (void)syn6658_deinit(&gs_handle);
271
272 return 1;
273 }
274 }
275
276 /* unicode big endian synthesis text */
277 syn6658_interface_debug_print("syn6658: unicode big endian synthesis text.\n");
278
279 /* set text type unicode big endian */
281 if (res != 0)
282 {
283 syn6658_interface_debug_print("syn6658: set text type failed.\n");
284 (void)syn6658_deinit(&gs_handle);
285
286 return 1;
287 }
288
289 /* synthesis text */
290 res = syn6658_synthesis_text(&gs_handle, (char const *)unicode_big_text);
291 if (res != 0)
292 {
293 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
294 (void)syn6658_deinit(&gs_handle);
295
296 return 1;
297 }
298
299 /* wait for finished */
300 status = SYN6658_STATUS_BUSY;
301 while (status == SYN6658_STATUS_BUSY)
302 {
304 res = syn6658_get_status(&gs_handle, &status);
305 if (res != 0)
306 {
307 syn6658_interface_debug_print("syn6658: get status failed.\n");
308 (void)syn6658_deinit(&gs_handle);
309
310 return 1;
311 }
312 }
313
314 /* sound synthesis text */
315 syn6658_interface_debug_print("syn6658: sound synthesis text.\n");
316
317 /* set text type gb2312 */
319 if (res != 0)
320 {
321 syn6658_interface_debug_print("syn6658: set text type failed.\n");
322 (void)syn6658_deinit(&gs_handle);
323
324 return 1;
325 }
326
327 /* sound text */
328 res = syn6658_synthesis_text(&gs_handle, (char const *)SYN6658_SOUND_202);
329 if (res != 0)
330 {
331 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
332 (void)syn6658_deinit(&gs_handle);
333
334 return 1;
335 }
336
337 /* wait for finished */
338 status = SYN6658_STATUS_BUSY;
339 while (status == SYN6658_STATUS_BUSY)
340 {
342 res = syn6658_get_status(&gs_handle, &status);
343 if (res != 0)
344 {
345 syn6658_interface_debug_print("syn6658: get status failed.\n");
346 (void)syn6658_deinit(&gs_handle);
347
348 return 1;
349 }
350 }
351
352 /* message synthesis text */
353 syn6658_interface_debug_print("syn6658: message synthesis text.\n");
354
355 /* message text */
356 res = syn6658_synthesis_text(&gs_handle, (char const *)SYN6658_MESSAGE_A);
357 if (res != 0)
358 {
359 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
360 (void)syn6658_deinit(&gs_handle);
361
362 return 1;
363 }
364
365 /* wait for finished */
366 status = SYN6658_STATUS_BUSY;
367 while (status == SYN6658_STATUS_BUSY)
368 {
370 res = syn6658_get_status(&gs_handle, &status);
371 if (res != 0)
372 {
373 syn6658_interface_debug_print("syn6658: get status failed.\n");
374 (void)syn6658_deinit(&gs_handle);
375
376 return 1;
377 }
378 }
379
380 if (interface == SYN6658_INTERFACE_UART)
381 {
382 /* synthesis control test */
383 syn6658_interface_debug_print("syn6658: synthesis control test.\n");
384 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
385 if (res != 0)
386 {
387 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
388 (void)syn6658_deinit(&gs_handle);
389
390 return 1;
391 }
393 res = syn6658_pause(&gs_handle);
394 if (res != 0)
395 {
396 syn6658_interface_debug_print("syn6658: pause failed.\n");
397 (void)syn6658_deinit(&gs_handle);
398
399 return 1;
400 }
401 syn6658_interface_debug_print("syn6658: synthesis control pause.\n");
403 res = syn6658_resume(&gs_handle);
404 if (res != 0)
405 {
406 syn6658_interface_debug_print("syn6658: resume failed.\n");
407 (void)syn6658_deinit(&gs_handle);
408
409 return 1;
410 }
411 syn6658_interface_debug_print("syn6658: synthesis control resume.\n");
412 status = SYN6658_STATUS_BUSY;
413 while (status == SYN6658_STATUS_BUSY)
414 {
416 res = syn6658_get_status(&gs_handle, &status);
417 if (res != 0)
418 {
419 syn6658_interface_debug_print("syn6658: get status failed.\n");
420 (void)syn6658_deinit(&gs_handle);
421
422 return 1;
423 }
424 }
425 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
426 if (res != 0)
427 {
428 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
429 (void)syn6658_deinit(&gs_handle);
430
431 return 1;
432 }
434 res = syn6658_stop(&gs_handle);
435 if (res != 0)
436 {
437 syn6658_interface_debug_print("syn6658: stop failed.\n");
438 (void)syn6658_deinit(&gs_handle);
439
440 return 1;
441 }
442 syn6658_interface_debug_print("syn6658: synthesis control stop.\n");
444 }
445
446 /* synthesis volume test */
447 syn6658_interface_debug_print("syn6658: synthesis volume test.\n");
448 res = syn6658_set_synthesis_volume(&gs_handle, 5);
449 if (res != 0)
450 {
451 syn6658_interface_debug_print("syn6658: set synthesis volume failed.\n");
452 (void)syn6658_deinit(&gs_handle);
453
454 return 1;
455 }
456 syn6658_interface_debug_print("syn6658: set synthesis volume 5.\n");
457 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
458 if (res != 0)
459 {
460 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
461 (void)syn6658_deinit(&gs_handle);
462
463 return 1;
464 }
465 status = SYN6658_STATUS_BUSY;
466 while (status == SYN6658_STATUS_BUSY)
467 {
469 res = syn6658_get_status(&gs_handle, &status);
470 if (res != 0)
471 {
472 syn6658_interface_debug_print("syn6658: get status failed.\n");
473 (void)syn6658_deinit(&gs_handle);
474
475 return 1;
476 }
477 }
478 res = syn6658_set_synthesis_volume(&gs_handle, 10);
479 if (res != 0)
480 {
481 syn6658_interface_debug_print("syn6658: set synthesis volume failed.\n");
482 (void)syn6658_deinit(&gs_handle);
483
484 return 1;
485 }
486
487 /* synthesis speed test */
488 syn6658_interface_debug_print("syn6658: synthesis speed test.\n");
489 res = syn6658_set_synthesis_speed(&gs_handle, 10);
490 if (res != 0)
491 {
492 syn6658_interface_debug_print("syn6658: set synthesis speed failed.\n");
493 (void)syn6658_deinit(&gs_handle);
494
495 return 1;
496 }
497 syn6658_interface_debug_print("syn6658: set synthesis speed 10.\n");
498 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
499 if (res != 0)
500 {
501 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
502 (void)syn6658_deinit(&gs_handle);
503
504 return 1;
505 }
506 status = SYN6658_STATUS_BUSY;
507 while (status == SYN6658_STATUS_BUSY)
508 {
510 res = syn6658_get_status(&gs_handle, &status);
511 if (res != 0)
512 {
513 syn6658_interface_debug_print("syn6658: get status failed.\n");
514 (void)syn6658_deinit(&gs_handle);
515
516 return 1;
517 }
518 }
519 res = syn6658_set_synthesis_speed(&gs_handle, 5);
520 if (res != 0)
521 {
522 syn6658_interface_debug_print("syn6658: set synthesis speed failed.\n");
523 (void)syn6658_deinit(&gs_handle);
524
525 return 1;
526 }
527
528 /* synthesis speaker test */
529 syn6658_interface_debug_print("syn6658: synthesis speaker test.\n");
531 if (res != 0)
532 {
533 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
534 (void)syn6658_deinit(&gs_handle);
535
536 return 1;
537 }
538 syn6658_interface_debug_print("syn6658: set synthesis speaker xiaoling.\n");
539 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
540 if (res != 0)
541 {
542 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
543 (void)syn6658_deinit(&gs_handle);
544
545 return 1;
546 }
547 status = SYN6658_STATUS_BUSY;
548 while (status == SYN6658_STATUS_BUSY)
549 {
551 res = syn6658_get_status(&gs_handle, &status);
552 if (res != 0)
553 {
554 syn6658_interface_debug_print("syn6658: get status failed.\n");
555 (void)syn6658_deinit(&gs_handle);
556
557 return 1;
558 }
559 }
560
561 /* set synthesis speaker yixiaojian */
563 if (res != 0)
564 {
565 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
566 (void)syn6658_deinit(&gs_handle);
567
568 return 1;
569 }
570 syn6658_interface_debug_print("syn6658: set synthesis speaker yixiaojian.\n");
571 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
572 if (res != 0)
573 {
574 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
575 (void)syn6658_deinit(&gs_handle);
576
577 return 1;
578 }
579 status = SYN6658_STATUS_BUSY;
580 while (status == SYN6658_STATUS_BUSY)
581 {
583 res = syn6658_get_status(&gs_handle, &status);
584 if (res != 0)
585 {
586 syn6658_interface_debug_print("syn6658: get status failed.\n");
587 (void)syn6658_deinit(&gs_handle);
588
589 return 1;
590 }
591 }
592
593 /* set synthesis speaker yixiaoqiang */
595 if (res != 0)
596 {
597 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
598 (void)syn6658_deinit(&gs_handle);
599
600 return 1;
601 }
602 syn6658_interface_debug_print("syn6658: set synthesis speaker yixiaoqiang.\n");
603 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
604 if (res != 0)
605 {
606 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
607 (void)syn6658_deinit(&gs_handle);
608
609 return 1;
610 }
611 status = SYN6658_STATUS_BUSY;
612 while (status == SYN6658_STATUS_BUSY)
613 {
615 res = syn6658_get_status(&gs_handle, &status);
616 if (res != 0)
617 {
618 syn6658_interface_debug_print("syn6658: get status failed.\n");
619 (void)syn6658_deinit(&gs_handle);
620
621 return 1;
622 }
623 }
624
625 /* set synthesis speaker yixiaoqiang */
627 if (res != 0)
628 {
629 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
630 (void)syn6658_deinit(&gs_handle);
631
632 return 1;
633 }
634 syn6658_interface_debug_print("syn6658: set synthesis speaker tianpeipei.\n");
635 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
636 if (res != 0)
637 {
638 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
639 (void)syn6658_deinit(&gs_handle);
640
641 return 1;
642 }
643 status = SYN6658_STATUS_BUSY;
644 while (status == SYN6658_STATUS_BUSY)
645 {
647 res = syn6658_get_status(&gs_handle, &status);
648 if (res != 0)
649 {
650 syn6658_interface_debug_print("syn6658: get status failed.\n");
651 (void)syn6658_deinit(&gs_handle);
652
653 return 1;
654 }
655 }
656
657 /* set synthesis speaker yixiaoqiang */
659 if (res != 0)
660 {
661 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
662 (void)syn6658_deinit(&gs_handle);
663
664 return 1;
665 }
666 syn6658_interface_debug_print("syn6658: set synthesis speaker tanglaoya.\n");
667 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
668 if (res != 0)
669 {
670 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
671 (void)syn6658_deinit(&gs_handle);
672
673 return 1;
674 }
675 status = SYN6658_STATUS_BUSY;
676 while (status == SYN6658_STATUS_BUSY)
677 {
679 res = syn6658_get_status(&gs_handle, &status);
680 if (res != 0)
681 {
682 syn6658_interface_debug_print("syn6658: get status failed.\n");
683 (void)syn6658_deinit(&gs_handle);
684
685 return 1;
686 }
687 }
688
689 /* set synthesis speaker yixiaoqiang */
691 if (res != 0)
692 {
693 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
694 (void)syn6658_deinit(&gs_handle);
695
696 return 1;
697 }
698 syn6658_interface_debug_print("syn6658: set synthesis speaker xiaoyanzi.\n");
699 res = syn6658_synthesis_text(&gs_handle, (char *)gb2312_text);
700 if (res != 0)
701 {
702 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
703 (void)syn6658_deinit(&gs_handle);
704
705 return 1;
706 }
707 status = SYN6658_STATUS_BUSY;
708 while (status == SYN6658_STATUS_BUSY)
709 {
711 res = syn6658_get_status(&gs_handle, &status);
712 if (res != 0)
713 {
714 syn6658_interface_debug_print("syn6658: get status failed.\n");
715 (void)syn6658_deinit(&gs_handle);
716
717 return 1;
718 }
719 }
721 if (res != 0)
722 {
723 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
724 (void)syn6658_deinit(&gs_handle);
725
726 return 1;
727 }
728
729 /* command test */
730 syn6658_interface_debug_print("syn6658: command test.\n");
731 syn6658_interface_debug_print("syn6658: set command 0.\n");
732 memset(s, 0, sizeof(char) * 32);
733 strncpy(s, "[b0]", 32);
734 res = syn6658_synthesis_text(&gs_handle, s);
735 if (res != 0)
736 {
737 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
738 (void)syn6658_deinit(&gs_handle);
739
740 return 1;
741 }
742 memset(s, 0, sizeof(char) * 32);
743 strncpy(s, "abc,def,ghi", 32);
744 res = syn6658_synthesis_text(&gs_handle, s);
745 if (res != 0)
746 {
747 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
748 (void)syn6658_deinit(&gs_handle);
749
750 return 1;
751 }
752 status = SYN6658_STATUS_BUSY;
753 while (status == SYN6658_STATUS_BUSY)
754 {
756 res = syn6658_get_status(&gs_handle, &status);
757 if (res != 0)
758 {
759 syn6658_interface_debug_print("syn6658: get status failed.\n");
760 (void)syn6658_deinit(&gs_handle);
761
762 return 1;
763 }
764 }
765 syn6658_interface_debug_print("syn6658: set command 1.\n");
766 memset(s, 0, sizeof(char) * 32);
767 strncpy(s, "[b1]", 32);
768 res = syn6658_synthesis_text(&gs_handle, s);
769 if (res != 0)
770 {
771 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
772 (void)syn6658_deinit(&gs_handle);
773
774 return 1;
775 }
776 memset(s, 0, sizeof(char) * 32);
777 strncpy(s, "abc,def,ghi", 32);
778 res = syn6658_synthesis_text(&gs_handle, s);
779 if (res != 0)
780 {
781 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
782 (void)syn6658_deinit(&gs_handle);
783
784 return 1;
785 }
786 status = SYN6658_STATUS_BUSY;
787 while (status == SYN6658_STATUS_BUSY)
788 {
790 res = syn6658_get_status(&gs_handle, &status);
791 if (res != 0)
792 {
793 syn6658_interface_debug_print("syn6658: get status failed.\n");
794 (void)syn6658_deinit(&gs_handle);
795
796 return 1;
797 }
798 }
799 memset(s, 0, sizeof(char) * 32);
800 strncpy(s, "[b0]", 32);
801 res = syn6658_synthesis_text(&gs_handle, s);
802 if (res != 0)
803 {
804 syn6658_interface_debug_print("syn6658: synthesis text failed.\n");
805 (void)syn6658_deinit(&gs_handle);
806
807 return 1;
808 }
809
810 if (interface == SYN6658_INTERFACE_UART)
811 {
812 /* save and play text test */
813 syn6658_interface_debug_print("syn6658: save and play text test.\n");
814
815 /* save text to buffer 3 */
816 syn6658_interface_debug_print("syn6658: save text to buffer 3.\n");
817
818 /* save text */
819 res = syn6658_save_text(&gs_handle, 3, (char *)text3);
820 if (res != 0)
821 {
822 syn6658_interface_debug_print("syn6658: save text failed.\n");
823 (void)syn6658_deinit(&gs_handle);
824
825 return 1;
826 }
827
828 /* save text to buffer 1 */
829 syn6658_interface_debug_print("syn6658: save text to buffer 1.\n");
830
831 /* save text */
832 res = syn6658_save_text(&gs_handle, 1, (char *)text1);
833 if (res != 0)
834 {
835 syn6658_interface_debug_print("syn6658: save text failed.\n");
836 (void)syn6658_deinit(&gs_handle);
837
838 return 1;
839 }
840
841 /* save text to buffer 0 */
842 syn6658_interface_debug_print("syn6658: save text to buffer 0.\n");
843
844 /* save text */
845 res = syn6658_save_text(&gs_handle, 0, (char *)text0);
846 if (res != 0)
847 {
848 syn6658_interface_debug_print("syn6658: save text failed.\n");
849 (void)syn6658_deinit(&gs_handle);
850
851 return 1;
852 }
853
854 /* save text to buffer 2 */
855 syn6658_interface_debug_print("syn6658: save text to buffer 2.\n");
856
857 /* save text */
858 res = syn6658_save_text(&gs_handle, 2, (char *)text2);
859 if (res != 0)
860 {
861 syn6658_interface_debug_print("syn6658: save text failed.\n");
862 (void)syn6658_deinit(&gs_handle);
863
864 return 1;
865 }
866
867 /* play text test */
868 syn6658_interface_debug_print("syn6658: play text test.\n");
869
870 /* play text */
871 res = syn6658_play_text(&gs_handle, 1, SYN6658_TYPE_GB2312);
872 if (res != 0)
873 {
874 syn6658_interface_debug_print("syn6658: play text failed.\n");
875 (void)syn6658_deinit(&gs_handle);
876
877 return 1;
878 }
879 status = SYN6658_STATUS_BUSY;
880 while (status == SYN6658_STATUS_BUSY)
881 {
883 res = syn6658_get_status(&gs_handle, &status);
884 if (res != 0)
885 {
886 syn6658_interface_debug_print("syn6658: get status failed.\n");
887 (void)syn6658_deinit(&gs_handle);
888
889 return 1;
890 }
891 }
892
893 /* syn6658 standby test */
894 syn6658_interface_debug_print("syn6658: syn6658 standby test.\n");
895
896 /* standby */
897 res = syn6658_standby(&gs_handle);
898 if (res != 0)
899 {
900 syn6658_interface_debug_print("syn6658: standby failed.\n");
901 (void)syn6658_deinit(&gs_handle);
902
903 return 1;
904 }
905
906 /* standby ok */
907 syn6658_interface_debug_print("syn6658: standby ok.\n");
908
909 /* syn6658 wake up test */
910 syn6658_interface_debug_print("syn6658: syn6658 wake up test.\n");
911
912 /* wake up */
913 res = syn6658_wake_up(&gs_handle);
914 if (res != 0)
915 {
916 syn6658_interface_debug_print("syn6658: wake up failed.\n");
917 (void)syn6658_deinit(&gs_handle);
918
919 return 1;
920 }
921
922 /* wake up ok */
923 syn6658_interface_debug_print("syn6658: wake up ok.\n");
924 }
925
926 /* finish synthesis test */
927 syn6658_interface_debug_print("syn6658: finish synthesis test.\n");
928 (void)syn6658_deinit(&gs_handle);
929
930 return 0;
931}
driver syn6658 synthesis test header file
struct syn6658_info_s syn6658_info_t
syn6658 information structure definition
uint8_t syn6658_info(syn6658_info_t *info)
get chip's information
#define SYN6658_MESSAGE_A
syn6658 message enumeration definition
uint8_t syn6658_init(syn6658_handle_t *handle)
initialize the chip
uint8_t syn6658_play_text(syn6658_handle_t *handle, uint8_t times, syn6658_type_t type)
play text
uint8_t syn6658_set_synthesis_speaker(syn6658_handle_t *handle, syn6658_speaker_t speaker)
set the synthesis speaker
uint8_t syn6658_resume(syn6658_handle_t *handle)
resume the chip
uint8_t syn6658_get_status(syn6658_handle_t *handle, syn6658_status_t *status)
get the current status
uint8_t syn6658_set_synthesis_speed(syn6658_handle_t *handle, uint8_t speed)
set the synthesis speed
uint8_t syn6658_save_text(syn6658_handle_t *handle, uint8_t offset, char *text)
save text to the buffer
uint8_t syn6658_standby(syn6658_handle_t *handle)
set the chip to standby mode
uint8_t syn6658_set_synthesis_volume(syn6658_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6658_deinit(syn6658_handle_t *handle)
close the chip
struct syn6658_handle_s syn6658_handle_t
syn6658 handle structure definition
uint8_t syn6658_pause(syn6658_handle_t *handle)
pause the chip
uint8_t syn6658_set_text_type(syn6658_handle_t *handle, syn6658_type_t type)
set the chip text type
uint8_t syn6658_synthesis_text(syn6658_handle_t *handle, const char *const fmt,...)
synthesis the test
syn6658_status_t
syn6658 status enumeration definition
uint8_t syn6658_set_interface(syn6658_handle_t *handle, syn6658_interface_t interface)
set the chip interface
syn6658_interface_t
syn6658 interface enumeration definition
uint8_t syn6658_wake_up(syn6658_handle_t *handle)
wake up the chip
#define SYN6658_SOUND_202
uint8_t syn6658_stop(syn6658_handle_t *handle)
stop the chip
@ SYN6658_TYPE_UNICODE_BIG
@ SYN6658_TYPE_GB2312
@ SYN6658_TYPE_BIG5
@ SYN6658_TYPE_UNICODE_LITTLE
@ SYN6658_TYPE_GBK
@ SYN6658_SPEAKER_XIAOLING
@ SYN6658_SPEAKER_TIANPEIPEI
@ SYN6658_SPEAKER_TANGLAOYA
@ SYN6658_SPEAKER_YIXIAOQIANG
@ SYN6658_SPEAKER_XIAOYANZI
@ SYN6658_SPEAKER_YIXIAOJIAN
@ SYN6658_STATUS_BUSY
@ SYN6658_INTERFACE_UART
uint8_t syn6658_interface_gpio_ready_deinit(void)
interface gpio ready deinit
uint8_t syn6658_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
interface spi transmit
uint8_t syn6658_interface_gpio_ready_init(void)
interface gpio ready init
uint8_t syn6658_interface_uart_init(void)
interface uart init
uint8_t syn6658_interface_spi_init(void)
interface spi init
void syn6658_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t syn6658_interface_gpio_ready_read(uint8_t *value)
interface gpio ready read
uint8_t syn6658_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint8_t syn6658_interface_uart_deinit(void)
interface uart deinit
void syn6658_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t syn6658_interface_uart_flush(void)
interface uart flush
uint8_t syn6658_interface_spi_deinit(void)
interface spi deinit
uint16_t syn6658_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
uint8_t syn6658_synthesis_test(syn6658_interface_t interface)
synthesis test
uint32_t driver_version
char manufacturer_name[32]