LibDriver ISD17XX
Loading...
Searching...
No Matches
driver_isd17xx_register_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static isd17xx_handle_t gs_handle;
41
51{
52 uint8_t res;
53 uint8_t id;
54 uint8_t vol;
55 uint8_t vol_check;
56 uint8_t status2;
57 uint16_t status1;
58 uint16_t point;
59 isd17xx_bool_t enable;
60 isd17xx_info_t info;
61 isd17xx_type_t type_check;
64
65 /* link function */
77
78 /* get information */
79 res = isd17xx_info(&info);
80 if (res != 0)
81 {
82 isd17xx_interface_debug_print("isd17xx: get info failed.\n");
83
84 return 1;
85 }
86 else
87 {
88 /* print chip info */
89 isd17xx_interface_debug_print("isd17xx: chip is %s.\n", info.chip_name);
90 isd17xx_interface_debug_print("isd17xx: manufacturer is %s.\n", info.manufacturer_name);
91 isd17xx_interface_debug_print("isd17xx: interface is %s.\n", info.interface);
92 isd17xx_interface_debug_print("isd17xx: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
93 isd17xx_interface_debug_print("isd17xx: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
94 isd17xx_interface_debug_print("isd17xx: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
95 isd17xx_interface_debug_print("isd17xx: max current is %0.2fmA.\n", info.max_current_ma);
96 isd17xx_interface_debug_print("isd17xx: max temperature is %0.1fC.\n", info.temperature_max);
97 isd17xx_interface_debug_print("isd17xx: min temperature is %0.1fC.\n", info.temperature_min);
98 }
99
100 /* start register test */
101 isd17xx_interface_debug_print("isd17xx: start register test.\n");
102
103 /* isd17xx_set_type/isd17xx_get_type test */
104 isd17xx_interface_debug_print("isd17xx: isd17xx_set_type/isd17xx_get_type test.\n");
105
106 /* set type isd1730 */
107 res = isd17xx_set_type(&gs_handle, ISD1730);
108 if (res != 0)
109 {
110 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
111
112 return 1;
113 }
114
115 /* output */
116 isd17xx_interface_debug_print("isd17xx: set type isd1730.\n");
117
118 /* get type */
119 res = isd17xx_get_type(&gs_handle, &type_check);
120 if (res != 0)
121 {
122 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
123
124 return 1;
125 }
126 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD1730 == type_check) ? "ok" : "error");
127
128 /* set type isd1740 */
129 res = isd17xx_set_type(&gs_handle, ISD1740);
130 if (res != 0)
131 {
132 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
133
134 return 1;
135 }
136
137 /* output */
138 isd17xx_interface_debug_print("isd17xx: set type isd1740.\n");
139
140 /* get type */
141 res = isd17xx_get_type(&gs_handle, &type_check);
142 if (res != 0)
143 {
144 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
145
146 return 1;
147 }
148 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD1740 == type_check) ? "ok" : "error");
149
150 /* set type isd1750 */
151 res = isd17xx_set_type(&gs_handle, ISD1750);
152 if (res != 0)
153 {
154 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
155
156 return 1;
157 }
158
159 /* output */
160 isd17xx_interface_debug_print("isd17xx: set type isd1750.\n");
161
162 /* get type */
163 res = isd17xx_get_type(&gs_handle, &type_check);
164 if (res != 0)
165 {
166 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
167
168 return 1;
169 }
170 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD1750 == type_check) ? "ok" : "error");
171
172 /* set type isd1760 */
173 res = isd17xx_set_type(&gs_handle, ISD1760);
174 if (res != 0)
175 {
176 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
177
178 return 1;
179 }
180
181 /* output */
182 isd17xx_interface_debug_print("isd17xx: set type isd1760.\n");
183
184 /* get type */
185 res = isd17xx_get_type(&gs_handle, &type_check);
186 if (res != 0)
187 {
188 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
189
190 return 1;
191 }
192 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD1760 == type_check) ? "ok" : "error");
193
194 /* set type isd1790 */
195 res = isd17xx_set_type(&gs_handle, ISD1790);
196 if (res != 0)
197 {
198 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
199
200 return 1;
201 }
202
203 /* output */
204 isd17xx_interface_debug_print("isd17xx: set type isd1790.\n");
205
206 /* get type */
207 res = isd17xx_get_type(&gs_handle, &type_check);
208 if (res != 0)
209 {
210 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
211
212 return 1;
213 }
214 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD1790 == type_check) ? "ok" : "error");
215
216 /* set type isd17120 */
217 res = isd17xx_set_type(&gs_handle, ISD17120);
218 if (res != 0)
219 {
220 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
221
222 return 1;
223 }
224
225 /* output */
226 isd17xx_interface_debug_print("isd17xx: set type isd17120.\n");
227
228 /* get type */
229 res = isd17xx_get_type(&gs_handle, &type_check);
230 if (res != 0)
231 {
232 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
233
234 return 1;
235 }
236 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD17120 == type_check) ? "ok" : "error");
237
238 /* set type isd17150 */
239 res = isd17xx_set_type(&gs_handle, ISD17150);
240 if (res != 0)
241 {
242 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
243
244 return 1;
245 }
246
247 /* output */
248 isd17xx_interface_debug_print("isd17xx: set type isd17150.\n");
249
250 /* get type */
251 res = isd17xx_get_type(&gs_handle, &type_check);
252 if (res != 0)
253 {
254 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
255
256 return 1;
257 }
258 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD17150 == type_check) ? "ok" : "error");
259
260 /* set type isd17180 */
261 res = isd17xx_set_type(&gs_handle, ISD17180);
262 if (res != 0)
263 {
264 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
265
266 return 1;
267 }
268
269 /* output */
270 isd17xx_interface_debug_print("isd17xx: set type isd17180.\n");
271
272 /* get type */
273 res = isd17xx_get_type(&gs_handle, &type_check);
274 if (res != 0)
275 {
276 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
277
278 return 1;
279 }
280 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD17180 == type_check) ? "ok" : "error");
281
282 /* set type isd17210 */
283 res = isd17xx_set_type(&gs_handle, ISD17210);
284 if (res != 0)
285 {
286 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
287
288 return 1;
289 }
290
291 /* output */
292 isd17xx_interface_debug_print("isd17xx: set type isd17210.\n");
293
294 /* get type */
295 res = isd17xx_get_type(&gs_handle, &type_check);
296 if (res != 0)
297 {
298 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
299
300 return 1;
301 }
302 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD17210 == type_check) ? "ok" : "error");
303
304 /* set type isd17240 */
305 res = isd17xx_set_type(&gs_handle, ISD17240);
306 if (res != 0)
307 {
308 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
309
310 return 1;
311 }
312
313 /* output */
314 isd17xx_interface_debug_print("isd17xx: set type isd17240.\n");
315
316 /* get type */
317 res = isd17xx_get_type(&gs_handle, &type_check);
318 if (res != 0)
319 {
320 isd17xx_interface_debug_print("isd17xx: get type failed.\n");
321
322 return 1;
323 }
324 isd17xx_interface_debug_print("isd17xx: check type %s.\n", (ISD17240 == type_check) ? "ok" : "error");
325
326 /* set the type */
327 res = isd17xx_set_type(&gs_handle, type);
328 if (res != 0)
329 {
330 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
331
332 return 1;
333 }
334
335 /* init */
336 res = isd17xx_init(&gs_handle);
337 if (res != 0)
338 {
339 isd17xx_interface_debug_print("isd17xx: init failed.\n");
340
341 return 1;
342 }
343
344 /* power up */
345 res = isd17xx_power_up(&gs_handle);
346 if (res != 0)
347 {
348 isd17xx_interface_debug_print("isd17xx: power up failed.\n");
349 (void)isd17xx_deinit(&gs_handle);
350
351 return 1;
352 }
353
354 /* isd17xx_set_volume_control/isd17xx_get_vol_control test */
355 isd17xx_interface_debug_print("isd17xx: isd17xx_set_volume_control/isd17xx_get_vol_control test.\n");
356
357 /* set button volume control */
359 if (res != 0)
360 {
361 isd17xx_interface_debug_print("isd17xx: set volume control failed.\n");
362 (void)isd17xx_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 isd17xx_interface_debug_print("isd17xx: set button volume control.\n");
368
369 /* get volume control */
370 res = isd17xx_get_volume_control(&gs_handle, &control);
371 if (res != 0)
372 {
373 isd17xx_interface_debug_print("isd17xx: get volume control failed.\n");
374 (void)isd17xx_deinit(&gs_handle);
375
376 return 1;
377 }
378 isd17xx_interface_debug_print("isd17xx: check volume control %s.\n", (ISD17XX_VOL_CONTROL_BUTTON == control) ? "ok" : "error");
379
380 /* set register volume control */
382 if (res != 0)
383 {
384 isd17xx_interface_debug_print("isd17xx: set volume control failed.\n");
385 (void)isd17xx_deinit(&gs_handle);
386
387 return 1;
388 }
389
390 isd17xx_interface_debug_print("isd17xx: set register volume control.\n");
391
392 /* get volume control */
393 res = isd17xx_get_volume_control(&gs_handle, &control);
394 if (res != 0)
395 {
396 isd17xx_interface_debug_print("isd17xx: get volume control failed.\n");
397 (void)isd17xx_deinit(&gs_handle);
398
399 return 1;
400 }
401 isd17xx_interface_debug_print("isd17xx: check volume control %s.\n", (ISD17XX_VOL_CONTROL_REG == control) ? "ok" : "error");
402
403 /* isd17xx_set_volume/isd17xx_get_volume test */
404 isd17xx_interface_debug_print("isd17xx: isd17xx_set_volume/isd17xx_get_volume test.\n");
405
406 /* set volume */
407 vol = rand() % 8;
408 res = isd17xx_set_volume(&gs_handle, vol);
409 if (res != 0)
410 {
411 isd17xx_interface_debug_print("isd17xx: set volume failed.\n");
412 (void)isd17xx_deinit(&gs_handle);
413
414 return 1;
415 }
416
417 /* set volume */
418 isd17xx_interface_debug_print("isd17xx: set volume 0x%0x.\n", vol);
419
420 /* get volume */
421 res = isd17xx_get_volume(&gs_handle, &vol_check);
422 if (res != 0)
423 {
424 isd17xx_interface_debug_print("isd17xx: get volume failed.\n");
425 (void)isd17xx_deinit(&gs_handle);
426
427 return 1;
428 }
429 isd17xx_interface_debug_print("isd17xx: check volume %s.\n", (vol == vol_check) ? "ok" : "error");
430
431 /* isd17xx_set_monitor_input/isd17xx_get_monitor_input test */
432 isd17xx_interface_debug_print("isd17xx: isd17xx_set_monitor_input/isd17xx_get_monitor_input test.\n");
433
434 /* set monitor input */
436 if (res != 0)
437 {
438 isd17xx_interface_debug_print("isd17xx: set monitor input failed.\n");
439 (void)isd17xx_deinit(&gs_handle);
440
441 return 1;
442 }
443
444 /* enable monitor input */
445 isd17xx_interface_debug_print("isd17xx: enable monitor input.\n");
446
447 /* get monitor input */
448 res = isd17xx_get_monitor_input(&gs_handle, &enable);
449 if (res != 0)
450 {
451 isd17xx_interface_debug_print("isd17xx: get monitor input failed.\n");
452 (void)isd17xx_deinit(&gs_handle);
453
454 return 1;
455 }
456 isd17xx_interface_debug_print("isd17xx: check monitor input %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
457
458 /* set monitor input */
460 if (res != 0)
461 {
462 isd17xx_interface_debug_print("isd17xx: set monitor input failed.\n");
463 (void)isd17xx_deinit(&gs_handle);
464
465 return 1;
466 }
467
468 /* disable monitor input */
469 isd17xx_interface_debug_print("isd17xx: disable monitor input.\n");
470
471 /* get monitor input */
472 res = isd17xx_get_monitor_input(&gs_handle, &enable);
473 if (res != 0)
474 {
475 isd17xx_interface_debug_print("isd17xx: get monitor input failed.\n");
476 (void)isd17xx_deinit(&gs_handle);
477
478 return 1;
479 }
480 isd17xx_interface_debug_print("isd17xx: check monitor input %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
481
482 /* isd17xx_set_mix_input/isd17xx_get_mix_input test */
483 isd17xx_interface_debug_print("isd17xx: isd17xx_set_mix_input/isd17xx_get_mix_input test.\n");
484
485 /* set mix input */
486 res = isd17xx_set_mix_input(&gs_handle, ISD17XX_BOOL_TRUE);
487 if (res != 0)
488 {
489 isd17xx_interface_debug_print("isd17xx: set mix input failed.\n");
490 (void)isd17xx_deinit(&gs_handle);
491
492 return 1;
493 }
494
495 /* enable mix input */
496 isd17xx_interface_debug_print("isd17xx: enable mix input.\n");
497
498 /* get mix input */
499 res = isd17xx_get_mix_input(&gs_handle, &enable);
500 if (res != 0)
501 {
502 isd17xx_interface_debug_print("isd17xx: get mix input failed.\n");
503 (void)isd17xx_deinit(&gs_handle);
504
505 return 1;
506 }
507 isd17xx_interface_debug_print("isd17xx: check mix input %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
508
509 /* set mix input */
510 res = isd17xx_set_mix_input(&gs_handle, ISD17XX_BOOL_FALSE);
511 if (res != 0)
512 {
513 isd17xx_interface_debug_print("isd17xx: set mix input failed.\n");
514 (void)isd17xx_deinit(&gs_handle);
515
516 return 1;
517 }
518
519 /* disable mix input */
520 isd17xx_interface_debug_print("isd17xx: disable mix input.\n");
521
522 /* get mix input */
523 res = isd17xx_get_mix_input(&gs_handle, &enable);
524 if (res != 0)
525 {
526 isd17xx_interface_debug_print("isd17xx: get mix input failed.\n");
527 (void)isd17xx_deinit(&gs_handle);
528
529 return 1;
530 }
531 isd17xx_interface_debug_print("isd17xx: check mix input %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
532
533 /* isd17xx_set_sound_effect_editing/isd17xx_get_sound_effect_editing test */
534 isd17xx_interface_debug_print("isd17xx: isd17xx_set_sound_effect_editing/isd17xx_get_sound_effect_editing test.\n");
535
536 /* set sound effect editing */
538 if (res != 0)
539 {
540 isd17xx_interface_debug_print("isd17xx: set sound effect editing failed.\n");
541 (void)isd17xx_deinit(&gs_handle);
542
543 return 1;
544 }
545
546 /* enable sound effect editing */
547 isd17xx_interface_debug_print("isd17xx: enable sound effect editing.\n");
548
549 /* get sound effect editing */
550 res = isd17xx_get_sound_effect_editing(&gs_handle, &enable);
551 if (res != 0)
552 {
553 isd17xx_interface_debug_print("isd17xx: get sound effect editing failed.\n");
554 (void)isd17xx_deinit(&gs_handle);
555
556 return 1;
557 }
558 isd17xx_interface_debug_print("isd17xx: check sound effect editing %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
559
560 /* set sound effect editing */
562 if (res != 0)
563 {
564 isd17xx_interface_debug_print("isd17xx: set sound effect editing failed.\n");
565 (void)isd17xx_deinit(&gs_handle);
566
567 return 1;
568 }
569
570 /* disable sound effect editing */
571 isd17xx_interface_debug_print("isd17xx: disable sound effect editing.\n");
572
573 /* get sound effect editing */
574 res = isd17xx_get_sound_effect_editing(&gs_handle, &enable);
575 if (res != 0)
576 {
577 isd17xx_interface_debug_print("isd17xx: get sound effect editing failed.\n");
578 (void)isd17xx_deinit(&gs_handle);
579
580 return 1;
581 }
582 isd17xx_interface_debug_print("isd17xx: check sound effect editing %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
583
584 /* isd17xx_set_spi_ft/isd17xx_get_spi_ft test */
585 isd17xx_interface_debug_print("isd17xx: isd17xx_set_spi_ft/isd17xx_get_spi_ft test.\n");
586
587 /* set spi ft */
588 res = isd17xx_set_spi_ft(&gs_handle, ISD17XX_BOOL_TRUE);
589 if (res != 0)
590 {
591 isd17xx_interface_debug_print("isd17xx: set spi ft failed.\n");
592 (void)isd17xx_deinit(&gs_handle);
593
594 return 1;
595 }
596
597 /* enable spi ft */
598 isd17xx_interface_debug_print("isd17xx: enable spi ft.\n");
599
600 /* get spi ft */
601 res = isd17xx_get_spi_ft(&gs_handle, &enable);
602 if (res != 0)
603 {
604 isd17xx_interface_debug_print("isd17xx: get spi ft failed.\n");
605 (void)isd17xx_deinit(&gs_handle);
606
607 return 1;
608 }
609 isd17xx_interface_debug_print("isd17xx: check spi ft %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
610
611 /* set spi ft */
612 res = isd17xx_set_spi_ft(&gs_handle, ISD17XX_BOOL_FALSE);
613 if (res != 0)
614 {
615 isd17xx_interface_debug_print("isd17xx: set spi ft failed.\n");
616 (void)isd17xx_deinit(&gs_handle);
617
618 return 1;
619 }
620
621 /* disable spi ft */
622 isd17xx_interface_debug_print("isd17xx: disable spi ft.\n");
623
624 /* get spi ft */
625 res = isd17xx_get_spi_ft(&gs_handle, &enable);
626 if (res != 0)
627 {
628 isd17xx_interface_debug_print("isd17xx: get spi ft failed.\n");
629 (void)isd17xx_deinit(&gs_handle);
630
631 return 1;
632 }
633 isd17xx_interface_debug_print("isd17xx: check spi ft %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
634
635 /* isd17xx_set_analog_output/isd17xx_get_analog_output test */
636 isd17xx_interface_debug_print("isd17xx: isd17xx_set_analog_output/isd17xx_get_analog_output test.\n");
637
638 /* set analog output */
640 if (res != 0)
641 {
642 isd17xx_interface_debug_print("isd17xx: set analog output failed.\n");
643 (void)isd17xx_deinit(&gs_handle);
644
645 return 1;
646 }
647
648 /* set analog output aud */
649 isd17xx_interface_debug_print("isd17xx: set analog output aud.\n");
650
651 /* get analog output */
652 res = isd17xx_get_analog_output(&gs_handle, &output);
653 if (res != 0)
654 {
655 isd17xx_interface_debug_print("isd17xx: get analog output failed.\n");
656 (void)isd17xx_deinit(&gs_handle);
657
658 return 1;
659 }
660 isd17xx_interface_debug_print("isd17xx: check analog output %s.\n", (output == ISD17XX_ANALOG_OUTPUT_AUD) ? "ok" : "error");
661
662 /* set analog output */
664 if (res != 0)
665 {
666 isd17xx_interface_debug_print("isd17xx: set analog output failed.\n");
667 (void)isd17xx_deinit(&gs_handle);
668
669 return 1;
670 }
671
672 /* set analog output aux */
673 isd17xx_interface_debug_print("isd17xx: set analog output aux.\n");
674
675 /* get analog output */
676 res = isd17xx_get_analog_output(&gs_handle, &output);
677 if (res != 0)
678 {
679 isd17xx_interface_debug_print("isd17xx: get analog output failed.\n");
680 (void)isd17xx_deinit(&gs_handle);
681
682 return 1;
683 }
684 isd17xx_interface_debug_print("isd17xx: check analog output %s.\n", (output == ISD17XX_ANALOG_OUTPUT_AUX) ? "ok" : "error");
685
686 /* isd17xx_set_pwm_speaker/isd17xx_get_pwm_speaker test */
687 isd17xx_interface_debug_print("isd17xx: isd17xx_set_pwm_speaker/isd17xx_get_pwm_speaker test.\n");
688
689 /* set pwm speaker */
691 if (res != 0)
692 {
693 isd17xx_interface_debug_print("isd17xx: set pwm speaker failed.\n");
694 (void)isd17xx_deinit(&gs_handle);
695
696 return 1;
697 }
698
699 /* enable pwm speaker */
700 isd17xx_interface_debug_print("isd17xx: enable pwm speaker.\n");
701
702 /* get pwm speaker */
703 res = isd17xx_get_pwm_speaker(&gs_handle, &enable);
704 if (res != 0)
705 {
706 isd17xx_interface_debug_print("isd17xx: get pwm speaker failed.\n");
707 (void)isd17xx_deinit(&gs_handle);
708
709 return 1;
710 }
711 isd17xx_interface_debug_print("isd17xx: check pwm speaker %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
712
713 /* set pwm speaker */
715 if (res != 0)
716 {
717 isd17xx_interface_debug_print("isd17xx: set pwm speaker failed.\n");
718 (void)isd17xx_deinit(&gs_handle);
719
720 return 1;
721 }
722
723 /* disable pwm speaker */
724 isd17xx_interface_debug_print("isd17xx: disable pwm speaker.\n");
725
726 /* get pwm speaker */
727 res = isd17xx_get_pwm_speaker(&gs_handle, &enable);
728 if (res != 0)
729 {
730 isd17xx_interface_debug_print("isd17xx: get pwm speaker failed.\n");
731 (void)isd17xx_deinit(&gs_handle);
732
733 return 1;
734 }
735 isd17xx_interface_debug_print("isd17xx: check pwm speaker %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
736
737 /* isd17xx_set_power_up_analog_output/isd17xx_get_power_up_analog_output test */
738 isd17xx_interface_debug_print("isd17xx: isd17xx_set_power_up_analog_output/isd17xx_get_power_up_analog_output test.\n");
739
740 /* set power up analog output */
742 if (res != 0)
743 {
744 isd17xx_interface_debug_print("isd17xx: set power up analog output failed.\n");
745 (void)isd17xx_deinit(&gs_handle);
746
747 return 1;
748 }
749
750 /* enable power up analog output */
751 isd17xx_interface_debug_print("isd17xx: enable power up analog output.\n");
752
753 /* get power up analog output */
754 res = isd17xx_get_power_up_analog_output(&gs_handle, &enable);
755 if (res != 0)
756 {
757 isd17xx_interface_debug_print("isd17xx: get power up analog output failed.\n");
758 (void)isd17xx_deinit(&gs_handle);
759
760 return 1;
761 }
762 isd17xx_interface_debug_print("isd17xx: check power up analog output %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
763
764 /* set power up analog output */
766 if (res != 0)
767 {
768 isd17xx_interface_debug_print("isd17xx: set power up analog output failed.\n");
769 (void)isd17xx_deinit(&gs_handle);
770
771 return 1;
772 }
773
774 /* disable power up analog output */
775 isd17xx_interface_debug_print("isd17xx: disable power up analog output.\n");
776
777 /* get power up analog output */
778 res = isd17xx_get_power_up_analog_output(&gs_handle, &enable);
779 if (res != 0)
780 {
781 isd17xx_interface_debug_print("isd17xx: get power up analog output failed.\n");
782 (void)isd17xx_deinit(&gs_handle);
783
784 return 1;
785 }
786 isd17xx_interface_debug_print("isd17xx: check power up analog output %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
787
788 /* isd17xx_set_v_alert/isd17xx_get_v_alert test */
789 isd17xx_interface_debug_print("isd17xx: isd17xx_set_v_alert/isd17xx_get_v_alert test.\n");
790
791 /* set v alert */
792 res = isd17xx_set_v_alert(&gs_handle, ISD17XX_BOOL_TRUE);
793 if (res != 0)
794 {
795 isd17xx_interface_debug_print("isd17xx: set v alert failed.\n");
796 (void)isd17xx_deinit(&gs_handle);
797
798 return 1;
799 }
800
801 /* enable v alert */
802 isd17xx_interface_debug_print("isd17xx: enable v alert.\n");
803
804 /* get v alert */
805 res = isd17xx_get_v_alert(&gs_handle, &enable);
806 if (res != 0)
807 {
808 isd17xx_interface_debug_print("isd17xx: get v alert failed.\n");
809 (void)isd17xx_deinit(&gs_handle);
810
811 return 1;
812 }
813 isd17xx_interface_debug_print("isd17xx: check v alert %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
814
815 /* set v alert */
816 res = isd17xx_set_v_alert(&gs_handle, ISD17XX_BOOL_FALSE);
817 if (res != 0)
818 {
819 isd17xx_interface_debug_print("isd17xx: set v alert failed.\n");
820 (void)isd17xx_deinit(&gs_handle);
821
822 return 1;
823 }
824
825 /* disable v alert */
826 isd17xx_interface_debug_print("isd17xx: disable v alert.\n");
827
828 /* get v alert */
829 res = isd17xx_get_v_alert(&gs_handle, &enable);
830 if (res != 0)
831 {
832 isd17xx_interface_debug_print("isd17xx: get v alert failed.\n");
833 (void)isd17xx_deinit(&gs_handle);
834
835 return 1;
836 }
837 isd17xx_interface_debug_print("isd17xx: check v alert %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
838
839 /* isd17xx_set_eom/isd17xx_get_eom test */
840 isd17xx_interface_debug_print("isd17xx: isd17xx_set_eom/isd17xx_get_eom test.\n");
841
842 /* set eom */
843 res = isd17xx_set_eom(&gs_handle, ISD17XX_BOOL_TRUE);
844 if (res != 0)
845 {
846 isd17xx_interface_debug_print("isd17xx: set eom failed.\n");
847 (void)isd17xx_deinit(&gs_handle);
848
849 return 1;
850 }
851
852 /* enable eom */
853 isd17xx_interface_debug_print("isd17xx: enable eom.\n");
854
855 /* get eom */
856 res = isd17xx_get_eom(&gs_handle, &enable);
857 if (res != 0)
858 {
859 isd17xx_interface_debug_print("isd17xx: get eom failed.\n");
860 (void)isd17xx_deinit(&gs_handle);
861
862 return 1;
863 }
864 isd17xx_interface_debug_print("isd17xx: check eom %s.\n", (enable == ISD17XX_BOOL_TRUE) ? "ok" : "error");
865
866 /* set eom */
867 res = isd17xx_set_eom(&gs_handle, ISD17XX_BOOL_FALSE);
868 if (res != 0)
869 {
870 isd17xx_interface_debug_print("isd17xx: set eom failed.\n");
871 (void)isd17xx_deinit(&gs_handle);
872
873 return 1;
874 }
875
876 /* disable eom */
877 isd17xx_interface_debug_print("isd17xx: disable eom.\n");
878
879 /* get eom */
880 res = isd17xx_get_eom(&gs_handle, &enable);
881 if (res != 0)
882 {
883 isd17xx_interface_debug_print("isd17xx: get eom failed.\n");
884 (void)isd17xx_deinit(&gs_handle);
885
886 return 1;
887 }
888 isd17xx_interface_debug_print("isd17xx: check eom %s.\n", (enable == ISD17XX_BOOL_FALSE) ? "ok" : "error");
889
890 /* isd17xx_load_from_nv test */
891 isd17xx_interface_debug_print("isd17xx: isd17xx_load_from_nv test.\n");
892
893 /* load from nv */
894 res = isd17xx_load_from_nv(&gs_handle);
895 if (res != 0)
896 {
897 isd17xx_interface_debug_print("isd17xx: load from nv failed.\n");
898 (void)isd17xx_deinit(&gs_handle);
899
900 return 1;
901 }
902
903 /* load from nv */
904 isd17xx_interface_debug_print("isd17xx: load from nv.\n");
905 isd17xx_interface_debug_print("isd17xx: check load from nv %s.\n", (res == 0) ? "ok" : "error");
906
907 /* isd17xx_get_device_id test */
908 isd17xx_interface_debug_print("isd17xx: isd17xx_get_device_id test.\n");
909
910 /* get_device_id */
911 res = isd17xx_get_device_id(&gs_handle, &id);
912 if (res != 0)
913 {
914 isd17xx_interface_debug_print("isd17xx: get device id failed.\n");
915 (void)isd17xx_deinit(&gs_handle);
916
917 return 1;
918 }
919 isd17xx_interface_debug_print("isd17xx: device id is 0x%02X.\n", id);
920
921 /* isd17xx_read_play_point/isd17xx_read_record_point test */
922 isd17xx_interface_debug_print("isd17xx: isd17xx_read_play_point/isd17xx_read_record_point test.\n");
923
924 /* read play point test */
925 res = isd17xx_read_play_point(&gs_handle, &point);
926 if (res != 0)
927 {
928 isd17xx_interface_debug_print("isd17xx: read play point failed.\n");
929 (void)isd17xx_deinit(&gs_handle);
930
931 return 1;
932 }
933
934 /* output */
935 isd17xx_interface_debug_print("isd17xx: play point is 0x%04X.\n", point);
936
937 /* read record point test */
938 res = isd17xx_read_record_point(&gs_handle, &point);
939 if (res != 0)
940 {
941 isd17xx_interface_debug_print("isd17xx: read record point failed.\n");
942 (void)isd17xx_deinit(&gs_handle);
943
944 return 1;
945 }
946
947 /* output */
948 isd17xx_interface_debug_print("isd17xx: record point is 0x%04X.\n", point);
949
950 /* isd17xx_get_status test */
951 isd17xx_interface_debug_print("isd17xx: isd17xx_get_status test.\n");
952
953 /* get status */
954 res = isd17xx_get_status(&gs_handle, &status1, &status2);
955 if (res != 0)
956 {
957 isd17xx_interface_debug_print("isd17xx: get status failed.\n");
958 (void)isd17xx_deinit(&gs_handle);
959
960 return 1;
961 }
962
963 /* output */
964 isd17xx_interface_debug_print("isd17xx: status1 is 0x%04X.\n", status1);
965
966 /* output */
967 isd17xx_interface_debug_print("isd17xx: status2 is 0x%02X.\n", status2);
968
969 /* isd17xx_clear_interrupt test */
970 isd17xx_interface_debug_print("isd17xx: isd17xx_clear_interrupt test.\n");
971
972 /* clear interrupt test */
973 res = isd17xx_clear_interrupt(&gs_handle);
974 if (res != 0)
975 {
976 isd17xx_interface_debug_print("isd17xx: clear interrupt failed.\n");
977 (void)isd17xx_deinit(&gs_handle);
978
979 return 1;
980 }
981 isd17xx_interface_debug_print("isd17xx: check clear interrupt %s.\n", (res == 0) ? "ok" : "error");
982
983 /* isd17xx_toggle_extern_clock test */
984 isd17xx_interface_debug_print("isd17xx: isd17xx_toggle_extern_clock test.\n");
985
986 /* toggle extern clock */
987 res = isd17xx_toggle_extern_clock(&gs_handle);
988 if (res != 0)
989 {
990 isd17xx_interface_debug_print("isd17xx: toggle extern clock failed.\n");
991 (void)isd17xx_deinit(&gs_handle);
992
993 return 1;
994 }
995
996 /* check toggle extern clock */
997 isd17xx_interface_debug_print("isd17xx: check toggle extern clock %s.\n", (res == 0) ? "ok" : "error");
998
999 /* delay 100ms */
1001
1002 /* toggle extern clock */
1003 res = isd17xx_toggle_extern_clock(&gs_handle);
1004 if (res != 0)
1005 {
1006 isd17xx_interface_debug_print("isd17xx: toggle extern clock failed.\n");
1007 (void)isd17xx_deinit(&gs_handle);
1008
1009 return 1;
1010 }
1011
1012 /* check toggle extern clock */
1013 isd17xx_interface_debug_print("isd17xx: check toggle extern clock %s.\n", (res == 0) ? "ok" : "error");
1014
1015 /* delay 100ms */
1017
1018 /* isd17xx_reset test */
1019 isd17xx_interface_debug_print("isd17xx: isd17xx_reset test.\n");
1020
1021 /* reset */
1022 res = isd17xx_reset(&gs_handle);
1023 if (res != 0)
1024 {
1025 isd17xx_interface_debug_print("isd17xx: reset failed.\n");
1026 (void)isd17xx_deinit(&gs_handle);
1027
1028 return 1;
1029 }
1030 /* check reset */
1031 isd17xx_interface_debug_print("isd17xx: check reset %s.\n", (res == 0) ? "ok" : "error");
1032
1033 /* power down */
1034 res = isd17xx_power_down(&gs_handle);
1035 if (res != 0)
1036 {
1037 isd17xx_interface_debug_print("isd17xx: power down failed.\n");
1038 (void)isd17xx_deinit(&gs_handle);
1039
1040 return 1;
1041 }
1042
1043 /* finish register test */
1044 isd17xx_interface_debug_print("isd17xx: finish register test.\n");
1045 (void)isd17xx_deinit(&gs_handle);
1046
1047 return 0;
1048}
driver isd17xx register test header file
uint8_t isd17xx_reset(isd17xx_handle_t *handle)
reset
uint8_t isd17xx_info(isd17xx_info_t *info)
get chip's information
isd17xx_bool_t
isd17xx bool enumeration definition
uint8_t isd17xx_toggle_extern_clock(isd17xx_handle_t *handle)
toggle the enable and disable of the external clock
uint8_t isd17xx_set_mix_input(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable the mix input
uint8_t isd17xx_set_spi_ft(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable spi ft
uint8_t isd17xx_power_up(isd17xx_handle_t *handle)
power up
uint8_t isd17xx_read_play_point(isd17xx_handle_t *handle, uint16_t *point)
read the play point
uint8_t isd17xx_get_sound_effect_editing(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the sound effect editing status
uint8_t isd17xx_set_volume(isd17xx_handle_t *handle, uint8_t vol)
set the volume
uint8_t isd17xx_get_volume(isd17xx_handle_t *handle, uint8_t *vol)
get the volume
uint8_t isd17xx_set_type(isd17xx_handle_t *handle, isd17xx_type_t type)
set the chip type
uint8_t isd17xx_get_mix_input(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the mix input status
uint8_t isd17xx_get_power_up_analog_output(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the power up analog output status
uint8_t isd17xx_get_spi_ft(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the spi ft status
uint8_t isd17xx_set_sound_effect_editing(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable sound effect editing
uint8_t isd17xx_get_status(isd17xx_handle_t *handle, uint16_t *status1, uint8_t *status2)
get the status
uint8_t isd17xx_get_v_alert(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the v alert status
uint8_t isd17xx_get_type(isd17xx_handle_t *handle, isd17xx_type_t *type)
get the chip type
uint8_t isd17xx_clear_interrupt(isd17xx_handle_t *handle)
clear interrupt
uint8_t isd17xx_power_down(isd17xx_handle_t *handle)
power down
isd17xx_vol_control_t
isd17xx vol control enumeration definition
uint8_t isd17xx_set_power_up_analog_output(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable power up analog output
uint8_t isd17xx_get_analog_output(isd17xx_handle_t *handle, isd17xx_analog_output_t *output)
get the analog output type
uint8_t isd17xx_get_device_id(isd17xx_handle_t *handle, uint8_t *id)
get the device id
uint8_t isd17xx_init(isd17xx_handle_t *handle)
initialize the chip
uint8_t isd17xx_read_record_point(isd17xx_handle_t *handle, uint16_t *point)
read the record point
uint8_t isd17xx_set_analog_output(isd17xx_handle_t *handle, isd17xx_analog_output_t output)
set the analog output type
struct isd17xx_info_s isd17xx_info_t
isd17xx information structure definition
uint8_t isd17xx_set_v_alert(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable v alert
uint8_t isd17xx_set_monitor_input(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable the monitor input
uint8_t isd17xx_get_pwm_speaker(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the pwm speaker status
uint8_t isd17xx_load_from_nv(isd17xx_handle_t *handle)
load config from non volatile memory
uint8_t isd17xx_get_eom(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the eom status
uint8_t isd17xx_set_pwm_speaker(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable pwm speaker
uint8_t isd17xx_get_volume_control(isd17xx_handle_t *handle, isd17xx_vol_control_t *control)
get the volume control type
struct isd17xx_handle_s isd17xx_handle_t
isd17xx handle structure definition
uint8_t isd17xx_set_eom(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable eom stop playing
uint8_t isd17xx_set_volume_control(isd17xx_handle_t *handle, isd17xx_vol_control_t control)
set the volume control type
isd17xx_type_t
isd17xx type enumeration definition
uint8_t isd17xx_get_monitor_input(isd17xx_handle_t *handle, isd17xx_bool_t *enable)
get the monitor input status
isd17xx_analog_output_t
isd17xx analog output enumeration definition
uint8_t isd17xx_deinit(isd17xx_handle_t *handle)
close the chip
@ ISD17XX_BOOL_TRUE
@ ISD17XX_BOOL_FALSE
@ ISD17XX_VOL_CONTROL_REG
@ ISD17XX_VOL_CONTROL_BUTTON
@ ISD17240
@ ISD1730
@ ISD17210
@ ISD1790
@ ISD1760
@ ISD1750
@ ISD17150
@ ISD17120
@ ISD17180
@ ISD1740
@ ISD17XX_ANALOG_OUTPUT_AUX
@ ISD17XX_ANALOG_OUTPUT_AUD
void isd17xx_interface_debug_print(const char *const fmt,...)
interface print format data
void isd17xx_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t isd17xx_interface_gpio_reset_deinit(void)
interface gpio reset deinit
uint8_t isd17xx_interface_gpio_reset_write(uint8_t value)
interface gpio reset write
uint8_t isd17xx_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
interface spi bus transmit
uint8_t isd17xx_interface_gpio_reset_init(void)
interface gpio reset init
uint8_t isd17xx_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t isd17xx_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t isd17xx_interface_spi_deinit(void)
interface spi bus deinit
uint8_t isd17xx_interface_spi_init(void)
interface spi bus init
uint8_t isd17xx_register_test(isd17xx_type_t type)
register test
uint32_t driver_version
char manufacturer_name[32]