LibDriver WM8978
Loading...
Searching...
No Matches
driver_wm8978_record_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static wav_handle_t gs_wav_handle;
41static wm8978_handle_t gs_handle;
42
50static uint8_t a_wm8978_config(void)
51{
52 uint8_t res;
53 uint8_t reg;
54
55 /* disable dc buffer */
56 res = wm8978_set_dc_buffer(&gs_handle, WM8978_BOOL_FALSE);
57 if (res != 0)
58 {
59 return 1;
60 }
61
62 /* disable out4 mixer */
64 if (res != 0)
65 {
66 return 1;
67 }
68
69 /* disable out3 mixer */
71 if (res != 0)
72 {
73 return 1;
74 }
75
76 /* disable pll */
77 res = wm8978_set_pll(&gs_handle, WM8978_BOOL_FALSE);
78 if (res != 0)
79 {
80 return 1;
81 }
82
83 /* enable microphone bias */
85 if (res != 0)
86 {
87 return 1;
88 }
89
90 /* enable analogue amplifier bias */
92 if (res != 0)
93 {
94 return 1;
95 }
96
97 /* disable unused input output tie off buffer */
99 if (res != 0)
100 {
101 return 1;
102 }
103
104 /* set reference impedance 5k */
106 if (res != 0)
107 {
108 return 1;
109 }
110
111 /* enable right out1 */
112 res = wm8978_set_right_out1(&gs_handle, WM8978_BOOL_TRUE);
113 if (res != 0)
114 {
115 return 1;
116 }
117
118 /* enable left out1 */
119 res = wm8978_set_left_out1(&gs_handle, WM8978_BOOL_TRUE);
120 if (res != 0)
121 {
122 return 1;
123 }
124
125 /* disable sleep */
126 res = wm8978_set_sleep(&gs_handle, WM8978_BOOL_FALSE);
127 if (res != 0)
128 {
129 return 1;
130 }
131
132 /* enable right channel input boost */
134 if (res != 0)
135 {
136 return 1;
137 }
138
139 /* enable left channel input boost */
141 if (res != 0)
142 {
143 return 1;
144 }
145
146 /* enable right channel input pga */
148 if (res != 0)
149 {
150 return 1;
151 }
152
153 /* enable left channel input pga */
155 if (res != 0)
156 {
157 return 1;
158 }
159
160 /* enable right channel adc */
162 if (res != 0)
163 {
164 return 1;
165 }
166
167 /* enable left channel adc */
169 if (res != 0)
170 {
171 return 1;
172 }
173
174 /* disable out4 */
175 res = wm8978_set_out4(&gs_handle, WM8978_BOOL_FALSE);
176 if (res != 0)
177 {
178 return 1;
179 }
180
181 /* disable out3 */
182 res = wm8978_set_out3(&gs_handle, WM8978_BOOL_FALSE);
183 if (res != 0)
184 {
185 return 1;
186 }
187
188 /* enable left out2 */
189 res = wm8978_set_left_out2(&gs_handle, WM8978_BOOL_TRUE);
190 if (res != 0)
191 {
192 return 1;
193 }
194
195 /* enable right out2 */
196 res = wm8978_set_right_out2(&gs_handle, WM8978_BOOL_TRUE);
197 if (res != 0)
198 {
199 return 1;
200 }
201
202 /* enable right output channel mixer */
204 if (res != 0)
205 {
206 return 1;
207 }
208
209 /* enable left output channel mixer */
211 if (res != 0)
212 {
213 return 1;
214 }
215
216 /* disable right channel dac */
218 if (res != 0)
219 {
220 return 1;
221 }
222
223 /* disable left channel dac */
225 if (res != 0)
226 {
227 return 1;
228 }
229
230 /* bclk polarity normal */
232 if (res != 0)
233 {
234 return 1;
235 }
236
237 /* lrclk polarity normal */
239 if (res != 0)
240 {
241 return 1;
242 }
243
244 /* iis data format */
246 if (res != 0)
247 {
248 return 1;
249 }
250
251 /* set dac appear left */
252 res = wm8978_set_dac_appear(&gs_handle, WM8978_APPEAR_LEFT);
253 if (res != 0)
254 {
255 return 1;
256 }
257
258 /* set adc appear left */
260 if (res != 0)
261 {
262 return 1;
263 }
264
265 /* disable companding 8bit mode */
267 if (res != 0)
268 {
269 return 1;
270 }
271
272 /* set dac companding linear */
274 if (res != 0)
275 {
276 wm8978_interface_debug_print("wm8978: set dac companding failed.\n");
277
278 return 1;
279 }
280
281 /* set adc companding linear */
283 if (res != 0)
284 {
285 return 1;
286 }
287
288 /* disable loopback */
289 res = wm8978_set_loopback(&gs_handle, WM8978_BOOL_FALSE);
290 if (res != 0)
291 {
292 return 1;
293 }
294
295 /* set mclk */
296 res = wm8978_set_clksel(&gs_handle, WM8978_CLKSEL_MCLK);
297 if (res != 0)
298 {
299 return 1;
300 }
301
302 /* mclk div by 1 */
303 res = wm8978_set_mclk_div(&gs_handle, WM8978_MCLK_DIV_BY_1);
304 if (res != 0)
305 {
306 return 1;
307 }
308
309 /* bclk div by 1 */
310 res = wm8978_set_bclk_div(&gs_handle, WM8978_BCLK_DIV_BY_1);
311 if (res != 0)
312 {
313 return 1;
314 }
315
316 /* input clock mode */
318 if (res != 0)
319 {
320 return 1;
321 }
322
323 /* set approximate sample rate 48khz */
325 if (res != 0)
326 {
327 return 1;
328 }
329
330 /* disable slow clock */
331 res = wm8978_set_slow_clock(&gs_handle, WM8978_BOOL_FALSE);
332 if (res != 0)
333 {
334 return 1;
335 }
336
337 /* pll div 1 */
338 res = wm8978_set_pll_div(&gs_handle, WM8978_PLL_DIV_BY_1);
339 if (res != 0)
340 {
341 return 1;
342 }
343
344 /* gpio1 polarity normal */
346 if (res != 0)
347 {
348 return 1;
349 }
350
351 /* set logic 0 */
353 if (res != 0)
354 {
355 return 1;
356 }
357
358 /* enable vmid 1 */
359 res = wm8978_set_vmid_1(&gs_handle, WM8978_BOOL_TRUE);
360 if (res != 0)
361 {
362 return 1;
363 }
364
365 /* enable vmid 0 */
366 res = wm8978_set_vmid_0(&gs_handle, WM8978_BOOL_TRUE);
367 if (res != 0)
368 {
369 return 1;
370 }
371
372 /* disable jack detection */
374 if (res != 0)
375 {
376 return 1;
377 }
378
379 /* jack use gpio2 */
381 if (res != 0)
382 {
383 return 1;
384 }
385
386 /* disable soft mute */
387 res = wm8978_set_soft_mute(&gs_handle, WM8978_BOOL_FALSE);
388 if (res != 0)
389 {
390 return 1;
391 }
392
393 /* dac oversample rate 128x */
395 if (res != 0)
396 {
397 return 1;
398 }
399
400 /* disable amute */
401 res = wm8978_set_amute(&gs_handle, WM8978_BOOL_FALSE);
402 if (res != 0)
403 {
404 return 1;
405 }
406
407 /* set right dac output polarity normal */
409 if (res != 0)
410 {
411 return 1;
412 }
413
414 /* set left dac output polarity normal */
416 if (res != 0)
417 {
418 return 1;
419 }
420
421 /* -10db */
422 res = wm8978_volume_convert_to_register(&gs_handle, -10, &reg);
423 if (res != 0)
424 {
425 return 1;
426 }
427
428 /* set dac left volume */
429 res = wm8978_set_dac_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
430 if (res != 0)
431 {
432 return 1;
433 }
434
435 /* set dac right volume */
436 res = wm8978_set_dac_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
437 if (res != 0)
438 {
439 return 1;
440 }
441
442 /* out1 logic0 disable */
444 if (res != 0)
445 {
446 return 1;
447 }
448
449 /* out1 logic0 enable */
451 if (res != 0)
452 {
453 return 1;
454 }
455
456 /* out2 logic0 enable */
458 if (res != 0)
459 {
460 return 1;
461 }
462
463 /* out2 logic1 disable */
465 if (res != 0)
466 {
467 return 1;
468 }
469
470 /* out3 logic0 disable */
472 if (res != 0)
473 {
474 return 1;
475 }
476
477 /* out4 logic0 disable */
479 if (res != 0)
480 {
481 return 1;
482 }
483
484 /* out3 logic1 disable */
486 if (res != 0)
487 {
488 return 1;
489 }
490
491 /* out4 logic1 disable */
493 if (res != 0)
494 {
495 return 1;
496 }
497
498 /* disable high pass filter */
500 if (res != 0)
501 {
502 return 1;
503 }
504
505 /* set audio mode */
506 res = wm8978_set_mode(&gs_handle, WM8978_MODE_AUDIO);
507 if (res != 0)
508 {
509 return 1;
510 }
511
512 /* set high pass filter cut off 0 */
514 if (res != 0)
515 {
516 return 1;
517 }
518
519 /* set adc oversample rate 128x */
521 if (res != 0)
522 {
523 return 1;
524 }
525
526 /* set adc right channel polarity */
528 if (res != 0)
529 {
530 return 1;
531 }
532
533 /* set adc left channel polarity */
535 if (res != 0)
536 {
537 return 1;
538 }
539
540 /* -10db */
541 res = wm8978_volume_convert_to_register(&gs_handle, -10.0f, &reg);
542 if (res != 0)
543 {
544 return 1;
545 }
546
547 /* set adc left volume */
548 res = wm8978_set_adc_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
549 if (res != 0)
550 {
551 return 1;
552 }
553
554 /* set adc right volume */
555 res = wm8978_set_adc_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
556 if (res != 0)
557 {
558 return 1;
559 }
560
561 /* apply to dac */
563 if (res != 0)
564 {
565 return 1;
566 }
567
568 /* eq1 cut off 80hz */
570 if (res != 0)
571 {
572 return 1;
573 }
574
575 /* 0db */
576 res = wm8978_eq_gain_convert_to_register(&gs_handle, 0, &reg);
577 if (res != 0)
578 {
579 return 1;
580 }
581
582 /* set eq1 gain */
583 res = wm8978_set_eq1_gain(&gs_handle, reg);
584 if (res != 0)
585 {
586 return 1;
587 }
588
589 /* set eq2 bandwidth wide */
591 if (res != 0)
592 {
593 return 1;
594 }
595
596 /* set eq2 centre freq 385hz */
598 if (res != 0)
599 {
600 return 1;
601 }
602
603 /* 0db */
604 res = wm8978_eq_gain_convert_to_register(&gs_handle, 0, &reg);
605 if (res != 0)
606 {
607 return 1;
608 }
609
610 /* set eq2 gain */
611 res = wm8978_set_eq2_gain(&gs_handle, reg);
612 if (res != 0)
613 {
614 return 1;
615 }
616
617 /* set eq3 bandwidth wide */
619 if (res != 0)
620 {
621 return 1;
622 }
623
624 /* set eq3 centre freq 1100hz */
626 if (res != 0)
627 {
628 return 1;
629 }
630
631 /* 0db */
632 res = wm8978_eq_gain_convert_to_register(&gs_handle, 0, &reg);
633 if (res != 0)
634 {
635 return 1;
636 }
637
638 /* set eq3 gain */
639 res = wm8978_set_eq3_gain(&gs_handle, reg);
640 if (res != 0)
641 {
642 return 1;
643 }
644
645 /* set eq4 bandwidth wide */
647 if (res != 0)
648 {
649 return 1;
650 }
651
652 /* set eq4 centre freq 3200hz */
654 if (res != 0)
655 {
656 return 1;
657 }
658
659 /* 0db */
660 res = wm8978_eq_gain_convert_to_register(&gs_handle, 0, &reg);
661 if (res != 0)
662 {
663 return 1;
664 }
665
666 /* set eq4 gain */
667 res = wm8978_set_eq4_gain(&gs_handle, reg);
668 if (res != 0)
669 {
670 return 1;
671 }
672
673 /* set eq5 cut off 11700hz */
675 if (res != 0)
676 {
677 return 1;
678 }
679
680 /* 0db */
681 res = wm8978_eq_gain_convert_to_register(&gs_handle, 0, &reg);
682 if (res != 0)
683 {
684 return 1;
685 }
686
687 /* set eq5 gain */
688 res = wm8978_set_eq5_gain(&gs_handle, reg);
689 if (res != 0)
690 {
691 return 1;
692 }
693
694 /* enable dac digital limiter */
696 if (res != 0)
697 {
698 return 1;
699 }
700
701 /* set dac limiter decay 192ms */
703 if (res != 0)
704 {
705 return 1;
706 }
707
708 /* set dac limiter attack 12ms */
710 if (res != 0)
711 {
712 return 1;
713 }
714
715 /* set dac limiter level -1db */
717 if (res != 0)
718 {
719 return 1;
720 }
721
722 /* 12db */
723 res = wm8978_set_dac_limiter_volume_boost(&gs_handle, 12);
724 if (res != 0)
725 {
726 return 1;
727 }
728
729 /* disable notch filter */
731 if (res != 0)
732 {
733 return 1;
734 }
735
736 /* 0x00 */
738 if (res != 0)
739 {
740 return 1;
741 }
742
743 /* 0x00 */
745 if (res != 0)
746 {
747 return 1;
748 }
749
750 /* 0x00 */
752 if (res != 0)
753 {
754 return 1;
755 }
756
757 /* 0x00 */
759 if (res != 0)
760 {
761 return 1;
762 }
763
764 /* both alc */
765 res = wm8978_set_alc(&gs_handle, WM8978_ALC_BOTH);
766 if (res != 0)
767 {
768 return 1;
769 }
770
771 /* alc max gain 35.25db */
773 if (res != 0)
774 {
775 return 1;
776 }
777
778 /* alc min gain -12.0db */
780 if (res != 0)
781 {
782 return 1;
783 }
784
785 /* 12ms */
786 res = wm8978_alc_hold_time_convert_to_register(&gs_handle, 12.0f, &reg);
787 if (res != 0)
788 {
789 return 1;
790 }
791
792 /* set alc hold time */
793 res = wm8978_set_alc_hold_time(&gs_handle, reg);
794 if (res != 0)
795 {
796 return 1;
797 }
798
799 /* set alc level -3 */
801 if (res != 0)
802 {
803 return 1;
804 }
805
806 /* alc mode */
807 res = wm8978_set_alc_mode(&gs_handle, WM8978_ALC_MODE_ALC);
808 if (res != 0)
809 {
810 return 1;
811 }
812
813 /* 0x00 */
814 res = wm8978_set_alc_decay(&gs_handle, 0x00);
815 if (res != 0)
816 {
817 return 1;
818 }
819
820 /* 0x00 */
821 res = wm8978_set_alc_attack(&gs_handle, 0x00);
822 if (res != 0)
823 {
824 return 1;
825 }
826
827 /* enable alc noise gate */
829 if (res != 0)
830 {
831 return 1;
832 }
833
834 /* -39db */
835 res = wm8978_alc_noise_gate_threshold_convert_to_register(&gs_handle, -39, &reg);
836 if (res != 0)
837 {
838 return 1;
839 }
840
841 /* set alc noise gate threshold */
842 res = wm8978_set_alc_noise_gate_threshold(&gs_handle, reg);
843 if (res != 0)
844 {
845 return 1;
846 }
847
848 /* disable mclk divide by 2 */
850 if (res != 0)
851 {
852 return 1;
853 }
854
855 /* 0x00 */
856 res = wm8978_set_plln(&gs_handle, 0x00);
857 if (res != 0)
858 {
859 return 1;
860 }
861
862 /* 0x00000000 */
863 res = wm8978_set_pll_freq(&gs_handle, 0x00000000);
864 if (res != 0)
865 {
866 return 1;
867 }
868
869 /* 0.00% */
870 res = wm8978_depth_3d_convert_to_register(&gs_handle, 0.00f, &reg);
871 if (res != 0)
872 {
873 return 1;
874 }
875
876 /* set depth 3d */
877 res = wm8978_set_depth_3d(&gs_handle, reg);
878 if (res != 0)
879 {
880 return 1;
881 }
882
883 /* disable mute input to inv rout2 mixer */
885 if (res != 0)
886 {
887 return 1;
888 }
889
890 /* enable inv rout2 mixer */
892 if (res != 0)
893 {
894 return 1;
895 }
896
897 /* -15db */
898 res = wm8978_beep_volume_convert_to_register(&gs_handle, -15, &reg);
899 if (res != 0)
900 {
901 return 1;
902 }
903
904 /* set beep volume */
905 res = wm8978_set_beep_volume(&gs_handle, reg);
906 if (res != 0)
907 {
908 return 1;
909 }
910
911 /* disable sleep */
912 res = wm8978_set_beep(&gs_handle, WM8978_BOOL_FALSE);
913 if (res != 0)
914 {
915 return 1;
916 }
917
918 /* set microphone bias voltage 0.9 avdd */
920 if (res != 0)
921 {
922 return 1;
923 }
924
925 /* disable right channel input pga positive */
927 if (res != 0)
928 {
929 return 1;
930 }
931
932 /* enable right channel input pga negative */
934 if (res != 0)
935 {
936 return 1;
937 }
938
939 /* enable right channel input pga amplifier positive */
941 if (res != 0)
942 {
943 return 1;
944 }
945
946 /* disable left channel input pga positive */
948 if (res != 0)
949 {
950 return 1;
951 }
952
953 /* enable left channel input pga negative */
955 if (res != 0)
956 {
957 return 1;
958 }
959
960 /* enable left channel input pga amplifier positive */
962 if (res != 0)
963 {
964 return 1;
965 }
966
967 /* enable left input pga update */
969 if (res != 0)
970 {
971 return 1;
972 }
973
974 /* disable left channel input pga zero cross */
976 if (res != 0)
977 {
978 return 1;
979 }
980
981 /* disable left channel input pga mute */
983 if (res != 0)
984 {
985 return 1;
986 }
987
988 /* 22.5db */
990 if (res != 0)
991 {
992 return 1;
993 }
994
995 /* set left channel input pga volume */
996 res = wm8978_set_left_channel_input_pga_volume(&gs_handle, reg);
997 if (res != 0)
998 {
999 return 1;
1000 }
1001
1002 /* enable right input pga update */
1004 if (res != 0)
1005 {
1006 return 1;
1007 }
1008
1009 /* disable right channel input pga zero cross */
1011 if (res != 0)
1012 {
1013 return 1;
1014 }
1015
1016 /* disable right channel input pga mute */
1018 if (res != 0)
1019 {
1020 return 1;
1021 }
1022
1023 /* 22.5db */
1024 res = wm8978_right_channel_input_pga_volume_convert_to_register(&gs_handle, 22.5f, &reg);
1025 if (res != 0)
1026 {
1027 return 1;
1028 }
1029
1030 /* set right channel input pga volume */
1031 res = wm8978_set_right_channel_input_pga_volume(&gs_handle, reg);
1032 if (res != 0)
1033 {
1034 return 1;
1035 }
1036
1037 /* enable left channel input pga boost */
1039 if (res != 0)
1040 {
1041 return 1;
1042 }
1043
1044 /* 0db */
1046 if (res != 0)
1047 {
1048 return 1;
1049 }
1050
1051 /* set left channel input boost stage */
1052 res = wm8978_set_left_channel_input_boost_stage(&gs_handle, reg);
1053 if (res != 0)
1054 {
1055 return 1;
1056 }
1057
1058 /* -15db */
1060 if (res != 0)
1061 {
1062 return 1;
1063 }
1064
1065 /* set auxiliary amplifier left channel input boost stage */
1067 if (res != 0)
1068 {
1069 return 1;
1070 }
1071
1072 /* enable right channel input pga boost */
1074 if (res != 0)
1075 {
1076 return 1;
1077 }
1078
1079 /* 0db */
1081 if (res != 0)
1082 {
1083 return 1;
1084 }
1085
1086 /* set right channel input boost stage */
1087 res = wm8978_set_right_channel_input_boost_stage(&gs_handle, reg);
1088 if (res != 0)
1089 {
1090 return 1;
1091 }
1092
1093 /* -15db */
1095 if (res != 0)
1096 {
1097 return 1;
1098 }
1099
1100 /* set auxiliary amplifier right channel input boost stage */
1102 if (res != 0)
1103 {
1104 return 1;
1105 }
1106
1107 /* disable left dac output to right output mixer */
1109 if (res != 0)
1110 {
1111 return 1;
1112 }
1113
1114 /* disable right dac output to left output mixer */
1116 if (res != 0)
1117 {
1118 return 1;
1119 }
1120
1121 /* disable out4 boost */
1122 res = wm8978_set_out4_boost(&gs_handle, WM8978_BOOL_FALSE);
1123 if (res != 0)
1124 {
1125 return 1;
1126 }
1127
1128 /* disable out3 boost */
1129 res = wm8978_set_out3_boost(&gs_handle, WM8978_BOOL_FALSE);
1130 if (res != 0)
1131 {
1132 return 1;
1133 }
1134
1135 /* enable speaker boost */
1136 res = wm8978_set_speaker_boost(&gs_handle, WM8978_BOOL_TRUE);
1137 if (res != 0)
1138 {
1139 return 1;
1140 }
1141
1142 /* enable thermal shutdown */
1144 if (res != 0)
1145 {
1146 return 1;
1147 }
1148
1149 /* set vref to analogue output resistance 1K */
1151 if (res != 0)
1152 {
1153 return 1;
1154 }
1155
1156 /* -15db */
1158 if (res != 0)
1159 {
1160 return 1;
1161 }
1162
1163 /* set aux left channel input to left mixer volume */
1165 if (res != 0)
1166 {
1167 return 1;
1168 }
1169
1170 /* disable left auxiliary input to left channel output mixer */
1172 if (res != 0)
1173 {
1174 return 1;
1175 }
1176
1177 /* 0db */
1179 if (res != 0)
1180 {
1181 return 1;
1182 }
1183
1184 /* set left bypass volume control to output channel mixer */
1186 if (res != 0)
1187 {
1188 return 1;
1189 }
1190
1191 /* enable left bypass path to left output mixer */
1193 if (res != 0)
1194 {
1195 return 1;
1196 }
1197
1198 /* disable left dac output to left output mixer */
1200 if (res != 0)
1201 {
1202 return 1;
1203 }
1204
1205 /* -15db */
1207 if (res != 0)
1208 {
1209 return 1;
1210 }
1211
1212 /* set aux right channel input to right mixer volume */
1214 if (res != 0)
1215 {
1216 return 1;
1217 }
1218
1219 /* disable right auxiliary input to right channel output mixer */
1221 if (res != 0)
1222 {
1223 return 1;
1224 }
1225
1226 /* 0db */
1228 if (res != 0)
1229 {
1230 return 1;
1231 }
1232
1233 /* set right bypass volume control to output channel mixer */
1235 if (res != 0)
1236 {
1237 return 1;
1238 }
1239
1240 /* enable right bypass path to right output mixer */
1242 if (res != 0)
1243 {
1244 return 1;
1245 }
1246
1247 /* disable right dac output to right output mixer */
1249 if (res != 0)
1250 {
1251 return 1;
1252 }
1253
1254 /* enable lout1 update */
1255 res = wm8978_set_lout1_update(&gs_handle, WM8978_BOOL_TRUE);
1256 if (res != 0)
1257 {
1258 return 1;
1259 }
1260
1261 /* disable lout1 headphone volume zero cross */
1263 if (res != 0)
1264 {
1265 return 1;
1266 }
1267
1268 /* disable lout1 left headphone output mute */
1270 if (res != 0)
1271 {
1272 return 1;
1273 }
1274
1275 /* 0db */
1277 if (res != 0)
1278 {
1279 return 1;
1280 }
1281
1282 /* set lout1 left headphone output volume */
1283 res = wm8978_set_lout1_left_headphone_output_volume(&gs_handle, reg);
1284 if (res != 0)
1285 {
1286 return 1;
1287 }
1288
1289 /* enable rout1 update */
1290 res = wm8978_set_rout1_update(&gs_handle, WM8978_BOOL_TRUE);
1291 if (res != 0)
1292 {
1293 return 1;
1294 }
1295
1296 /* disable rout1 headphone volume zero cross */
1298 if (res != 0)
1299 {
1300 return 1;
1301 }
1302
1303 /* disable rout1 right headphone output mute */
1305 if (res != 0)
1306 {
1307 return 1;
1308 }
1309
1310 /* 0db */
1312 if (res != 0)
1313 {
1314 return 1;
1315 }
1316
1317 /* set rout1 right headphone output volume */
1319 if (res != 0)
1320 {
1321 return 1;
1322 }
1323
1324 /* enable lout2 update */
1325 res = wm8978_set_lout2_update(&gs_handle, WM8978_BOOL_TRUE);
1326 if (res != 0)
1327 {
1328 return 1;
1329 }
1330
1331 /* disable lout2 speaker volume zero cross */
1333 if (res != 0)
1334 {
1335 return 1;
1336 }
1337
1338 /* disable lout2 left speaker output mute */
1340 if (res != 0)
1341 {
1342 return 1;
1343 }
1344
1345 /* -57db */
1347 if (res != 0)
1348 {
1349 return 1;
1350 }
1351
1352 /* set lout2 left speaker output volume */
1353 res = wm8978_set_lout2_left_speaker_output_volume(&gs_handle, reg);
1354 if (res != 0)
1355 {
1356 return 1;
1357 }
1358
1359 /* enable rout2 update */
1360 res = wm8978_set_rout2_update(&gs_handle, WM8978_BOOL_TRUE);
1361 if (res != 0)
1362 {
1363 return 1;
1364 }
1365
1366 /* disable rout2 speaker volume zero cross */
1368 if (res != 0)
1369 {
1370 return 1;
1371 }
1372
1373 /* disable rout2 right speaker output mute */
1375 if (res != 0)
1376 {
1377 return 1;
1378 }
1379
1380 /* -57db */
1382 if (res != 0)
1383 {
1384 return 1;
1385 }
1386
1387 /* set rout2 right speaker output volume */
1388 res = wm8978_set_rout2_right_speaker_output_volume(&gs_handle, reg);
1389 if (res != 0)
1390 {
1391 return 1;
1392 }
1393
1394 /* enable out3 mute */
1395 res = wm8978_set_out3_mute(&gs_handle, WM8978_BOOL_TRUE);
1396 if (res != 0)
1397 {
1398 return 1;
1399 }
1400
1401 /* disable out4 mixer output to out3 */
1403 if (res != 0)
1404 {
1405 return 1;
1406 }
1407
1408 /* disable left adc input to out3 */
1410 if (res != 0)
1411 {
1412 return 1;
1413 }
1414
1415 /* disable left dac mixer to out3 */
1417 if (res != 0)
1418 {
1419 return 1;
1420 }
1421
1422 /* disable left dac output to out3 */
1424 if (res != 0)
1425 {
1426 return 1;
1427 }
1428
1429 /* enable out4 mute */
1430 res = wm8978_set_out4_mute(&gs_handle, WM8978_BOOL_TRUE);
1431 if (res != 0)
1432 {
1433 return 1;
1434 }
1435
1436 /* disable out4 attenuated by 6db */
1438 if (res != 0)
1439 {
1440 return 1;
1441 }
1442
1443 /* disable left dac mixer to out4 */
1445 if (res != 0)
1446 {
1447 return 1;
1448 }
1449
1450 /* disable left dac to out4 */
1452 if (res != 0)
1453 {
1454 return 1;
1455 }
1456
1457 /* disable right adc input to out4 */
1459 if (res != 0)
1460 {
1461 return 1;
1462 }
1463
1464 /* disable right dac mixer to out4 */
1466 if (res != 0)
1467 {
1468 return 1;
1469 }
1470
1471 /* disable right dac output to out4 */
1473 if (res != 0)
1474 {
1475 return 1;
1476 }
1477
1478 return 0;
1479}
1480
1487{
1488 return &gs_wav_handle;
1489}
1490
1499uint8_t wm8978_record_file_fill(uint8_t index)
1500{
1501 if (wav_record_file_fill(&gs_wav_handle, index) != 0)
1502 {
1503 return 1;
1504 }
1505
1506 return 0;
1507}
1508
1518uint8_t wm8978_record_test(char *path, uint32_t second)
1519{
1520 uint8_t res;
1521 uint32_t timeout;
1522 wm8978_info_t info;
1523
1524 /* link interface function */
1525 WAV_LINK_INIT(&gs_wav_handle, wav_handle_t);
1526 WAV_LINK_AUDIO_INIT(&gs_wav_handle, wav_audio_init);
1527 WAV_LINK_AUDIO_DEINIT(&gs_wav_handle, wav_audio_deinit);
1528 WAV_LINK_AUDIO_READ(&gs_wav_handle, wav_audio_read);
1529 WAV_LINK_AUDIO_WRITE(&gs_wav_handle, wav_audio_write);
1530 WAV_LINK_IIS_INIT(&gs_wav_handle, wav_iis_init);
1531 WAV_LINK_IIS_DEINIT(&gs_wav_handle, wav_iis_deinit);
1532 WAV_LINK_IIS_STOP(&gs_wav_handle, wav_iis_stop);
1533 WAV_LINK_IIS_PAUSE(&gs_wav_handle, wav_iis_pause);
1534 WAV_LINK_IIS_RESUME(&gs_wav_handle, wav_iis_resume);
1535 WAV_LINK_IIS_SET_FREQ(&gs_wav_handle, wav_iis_set_freq);
1536 WAV_LINK_IIS_WRITE(&gs_wav_handle, wav_iis_write);
1537 WAV_LINK_IIS_READ(&gs_wav_handle, wav_iis_read);
1538 WAV_LINK_DELAY_MS(&gs_wav_handle, wav_delay_ms);
1539 WAV_LINK_DEBUG_PRINT(&gs_wav_handle, wav_debug_print);
1540
1541 /* link interface function */
1548
1549 /* get information */
1550 res = wm8978_info(&info);
1551 if (res != 0)
1552 {
1553 wm8978_interface_debug_print("wm8978: get info failed.\n");
1554
1555 return 1;
1556 }
1557 else
1558 {
1559 /* print chip info */
1560 wm8978_interface_debug_print("wm8978: chip is %s.\n", info.chip_name);
1561 wm8978_interface_debug_print("wm8978: manufacturer is %s.\n", info.manufacturer_name);
1562 wm8978_interface_debug_print("wm8978: interface is %s.\n", info.interface);
1563 wm8978_interface_debug_print("wm8978: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
1564 wm8978_interface_debug_print("wm8978: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
1565 wm8978_interface_debug_print("wm8978: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
1566 wm8978_interface_debug_print("wm8978: max current is %0.2fmA.\n", info.max_current_ma);
1567 wm8978_interface_debug_print("wm8978: max temperature is %0.1fC.\n", info.temperature_max);
1568 wm8978_interface_debug_print("wm8978: min temperature is %0.1fC.\n", info.temperature_min);
1569 }
1570
1571 /* start record test */
1572 wm8978_interface_debug_print("wm8978: start record test.\n");
1573
1574 /* wm8978 init */
1575 res = wm8978_init(&gs_handle);
1576 if (res != 0)
1577 {
1578 wm8978_interface_debug_print("wm8978: init failed.\n");
1579
1580 return 1;
1581 }
1582
1583 /* config */
1584 res = a_wm8978_config();
1585 if (res != 0)
1586 {
1587 wm8978_interface_debug_print("wm8978: config failed.\n");
1588 (void)wm8978_deinit(&gs_handle);
1589
1590 return 1;
1591 }
1592
1593 /* wav init */
1594 res = wav_init(&gs_wav_handle);
1595 if (res != 0)
1596 {
1597 wm8978_interface_debug_print("wm8978: wav init failed.\n");
1598 (void)wm8978_deinit(&gs_handle);
1599
1600 return 1;
1601 }
1602
1603 /* 2 channels */
1604 res = wm8978_set_channel(&gs_handle, WM8978_CHANNEL_STEREO);
1605 if (res != 0)
1606 {
1607 wm8978_interface_debug_print("wm8978: set channel failed.\n");
1608 (void)wav_deinit(&gs_wav_handle);
1609 (void)wm8978_deinit(&gs_handle);
1610
1611 return 1;
1612 }
1613
1614 /* set 16bits */
1616 if (res != 0)
1617 {
1618 wm8978_interface_debug_print("wm8978: set word length failed.\n");
1619 (void)wav_deinit(&gs_wav_handle);
1620 (void)wm8978_deinit(&gs_handle);
1621
1622 return 1;
1623 }
1624
1625 /* wav player config */
1626 res = wav_player_config(&gs_wav_handle, I2S_STANDARD_PHILIPS,
1627 I2S_MODE_MASTER_TX, I2S_CPOL_LOW,
1628 I2S_DATAFORMAT_16B, I2S_MCLKOUTPUT_ENABLE, 22050);
1629 if (res != 0)
1630 {
1631 wm8978_interface_debug_print("wm8978: wav record config failed.\n");
1632 (void)wav_deinit(&gs_wav_handle);
1633 (void)wm8978_deinit(&gs_handle);
1634
1635 return 1;
1636 }
1637
1638 /* record start */
1639 res = wav_record_start(&gs_wav_handle, 22050, path);
1640 if (res != 0)
1641 {
1642 wm8978_interface_debug_print("wm8978: wav record start failed.\n");
1643 (void)wav_deinit(&gs_wav_handle);
1644 (void)wm8978_deinit(&gs_handle);
1645
1646 return 1;
1647 }
1648
1649 /* set timeout */
1650 timeout = second;
1651
1652 /* loop */
1653 while (timeout != 0)
1654 {
1655 wav_delay_ms(1000);
1656 timeout--;
1657 wav_debug_print("wav: record %d bytes time %d/%ds.\n", gs_wav_handle.pos, second - timeout, second);
1658 }
1659
1660 /* record stop */
1661 res = wav_record_stop(&gs_wav_handle);
1662 if (res != 0)
1663 {
1664 wm8978_interface_debug_print("wm8978: wav record stop failed.\n");
1665 (void)wav_deinit(&gs_wav_handle);
1666 (void)wm8978_deinit(&gs_handle);
1667
1668 return 1;
1669 }
1670
1671 /* finish record */
1672 wm8978_interface_debug_print("wm8978: finish record test.\n");
1673 (void)wav_deinit(&gs_wav_handle);
1674 (void)wm8978_deinit(&gs_handle);
1675
1676 return 0;
1677}
driver wm8978 record test header file
struct wav_handle_s wav_handle_t
wav handle structure definition
uint8_t wav_record_stop(wav_handle_t *handle)
wav record stop
Definition wav_player.c:611
uint8_t wav_player_config(wav_handle_t *handle, uint32_t standard, uint32_t mode, uint32_t polarity, uint32_t format, uint32_t enable, uint32_t freq)
wav player config
Definition wav_player.c:391
#define WAV_LINK_INIT(HANDLE, STRUCTURE)
initialize wav_handle_t structure
Definition wav_player.h:125
#define WAV_LINK_IIS_INIT(HANDLE, FUC)
link iis_init function
Definition wav_player.h:165
#define WAV_LINK_AUDIO_DEINIT(HANDLE, FUC)
link audio_deinit function
Definition wav_player.h:141
#define WAV_LINK_AUDIO_INIT(HANDLE, FUC)
link audio_init function
Definition wav_player.h:133
uint8_t wav_record_file_fill(wav_handle_t *handle, uint8_t index)
wav record file fill
Definition wav_player.c:558
#define WAV_LINK_IIS_STOP(HANDLE, FUC)
link iis_stop function
Definition wav_player.h:181
#define WAV_LINK_IIS_PAUSE(HANDLE, FUC)
link iis_pause function
Definition wav_player.h:189
#define WAV_LINK_DEBUG_PRINT(HANDLE, FUC)
link debug_print function
Definition wav_player.h:237
#define WAV_LINK_DELAY_MS(HANDLE, FUC)
link delay_ms function
Definition wav_player.h:229
uint8_t wav_record_start(wav_handle_t *handle, uint32_t sample_rate, char *path)
wav record start
Definition wav_player.c:479
#define WAV_LINK_IIS_RESUME(HANDLE, FUC)
link iis_resume function
Definition wav_player.h:197
#define WAV_LINK_IIS_WRITE(HANDLE, FUC)
link iis_write function
Definition wav_player.h:213
#define WAV_LINK_AUDIO_WRITE(HANDLE, FUC)
link audio_write function
Definition wav_player.h:157
#define WAV_LINK_AUDIO_READ(HANDLE, FUC)
link audio_read function
Definition wav_player.h:149
uint8_t wav_init(wav_handle_t *handle)
initialize the wav
Definition wav_player.c:117
#define WAV_LINK_IIS_DEINIT(HANDLE, FUC)
link iis_deinit function
Definition wav_player.h:173
#define WAV_LINK_IIS_READ(HANDLE, FUC)
link iis_read function
Definition wav_player.h:221
#define WAV_LINK_IIS_SET_FREQ(HANDLE, FUC)
link iis_set_freq function
Definition wav_player.h:205
uint8_t wav_deinit(wav_handle_t *handle)
wav deinit
Definition wav_player.c:221
uint8_t wm8978_set_lout2_left_speaker_output_volume(wm8978_handle_t *handle, uint8_t vol)
set lout2 left speaker output volume
uint8_t wm8978_set_right_out2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right out2
uint8_t wm8978_set_microphone_bias(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable microphone bias
uint8_t wm8978_set_right_channel_adc(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel adc
uint8_t wm8978_left_bypass_volume_control_to_output_channel_mixer_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the left bypass volume control to output channel mixer to the register raw data
uint8_t wm8978_set_right_channel_input_pga_negative(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga negative
uint8_t wm8978_set_auxiliary_amplifier_left_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set auxiliary amplifier left channel input boost stage
uint8_t wm8978_set_microphone_bias_voltage(wm8978_handle_t *handle, wm8978_avdd_t avdd)
set microphone bias voltage
uint8_t wm8978_set_eq1_gain(wm8978_handle_t *handle, uint8_t gain)
set eq1 gain
uint8_t wm8978_lout1_left_headphone_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the lout1 left headphone output volume to the register raw data
uint8_t wm8978_set_equaliser_apply(wm8978_handle_t *handle, wm8978_equaliser_t equaliser)
set equaliser apply
uint8_t wm8978_set_notch_filter_a0_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a0 coefficient bit6 - bit0
uint8_t wm8978_set_mute_input_to_inv_rout2_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable mute input to inv rout2 mixer
uint8_t wm8978_set_eq4_gain(wm8978_handle_t *handle, uint8_t gain)
set eq4 gain
uint8_t wm8978_set_channel(wm8978_handle_t *handle, wm8978_channel_t channel)
set channel
uint8_t wm8978_set_lout1_headphone_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 headphone volume zero cross
uint8_t wm8978_set_adc_right_channel_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set adc right channel polarity
uint8_t wm8978_set_plln(wm8978_handle_t *handle, uint8_t n)
set plln
uint8_t wm8978_set_rout1_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 update
uint8_t wm8978_set_left_channel_input_pga_volume(wm8978_handle_t *handle, uint8_t volume)
set left channel input pga volume
uint8_t wm8978_set_word_length(wm8978_handle_t *handle, wm8978_word_length_t word_length)
set word length
uint8_t wm8978_set_right_dac_output_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set right dac output polarity
uint8_t wm8978_set_pll(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable pll
uint8_t wm8978_set_left_dac_output_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to right output mixer
uint8_t wm8978_set_vmid_0(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable vmid 0
uint8_t wm8978_set_alc(wm8978_handle_t *handle, wm8978_alc_t alc)
set alc
uint8_t wm8978_set_rout2_speaker_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 speaker volume zero cross
uint8_t wm8978_aux_right_channel_input_to_right_mixer_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the aux right channel input to right mixer volume to the register raw data
uint8_t wm8978_set_adc_appear(wm8978_handle_t *handle, wm8978_appear_t appear)
set adc appear
uint8_t wm8978_set_rout1_right_headphone_output_volume(wm8978_handle_t *handle, uint8_t vol)
set rout1 right headphone output volume
uint8_t wm8978_init(wm8978_handle_t *handle)
initialize the chip
uint8_t wm8978_set_right_channel_input_pga_volume(wm8978_handle_t *handle, uint8_t volume)
set right channel input pga volume
uint8_t wm8978_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the volume data to the register raw data
uint8_t wm8978_set_gpio1_select(wm8978_handle_t *handle, wm8978_gpio1_sel_t sel)
set gpio1 select
uint8_t wm8978_set_right_dac_output_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to out4
uint8_t wm8978_set_left_channel_input_pga_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga boost
uint8_t wm8978_set_right_auxiliary_input_to_right_channel_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right auxiliary input to right channel output mixer
uint8_t wm8978_info(wm8978_info_t *info)
get chip's information
uint8_t wm8978_set_left_input_pga_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left input pga update
uint8_t wm8978_set_left_dac_mixer_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac mixer to out3
uint8_t wm8978_set_dac_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set dac left volume
uint8_t wm8978_set_eq4_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq4 bandwidth
uint8_t wm8978_set_adc_companding(wm8978_handle_t *handle, wm8978_companding_t companding)
set adc companding
uint8_t wm8978_auxiliary_amplifier_left_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the auxiliary amplifier left channel input boost stage to the register raw data
uint8_t wm8978_set_alc_level(wm8978_handle_t *handle, wm8978_alc_level_t level)
set alc level
uint8_t wm8978_set_right_bypass_path_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right bypass path to right output mixer
uint8_t wm8978_set_left_dac_output_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set left dac output polarity
uint8_t wm8978_set_right_channel_input_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input boost
uint8_t wm8978_set_right_output_channel_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right output channel mixer
uint8_t wm8978_auxiliary_amplifier_right_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the auxiliary amplifier right channel input boost stage to the register raw data
uint8_t wm8978_set_pll_div(wm8978_handle_t *handle, wm8978_pll_div_t d)
set pll div
uint8_t wm8978_eq_gain_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the eq gain to the register raw data
uint8_t wm8978_set_left_channel_input_pga_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga zero cross
uint8_t wm8978_set_eq5_gain(wm8978_handle_t *handle, uint8_t gain)
set eq5 gain
uint8_t wm8978_set_loopback(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable loopback
uint8_t wm8978_set_pll_freq(wm8978_handle_t *handle, uint32_t freq)
set pll freq
uint8_t wm8978_set_left_dac_mixer_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac mixer to out4
uint8_t wm8978_set_lrclk_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set lrclk polarity
uint8_t wm8978_set_dac_limiter_level(wm8978_handle_t *handle, wm8978_dac_limiter_level_t level)
set dac limiter level
uint8_t wm8978_alc_hold_time_convert_to_register(wm8978_handle_t *handle, float ms, uint8_t *reg)
convert the alc hold time to the register raw data
uint8_t wm8978_set_slow_clock(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable slow clock
uint8_t wm8978_set_approximate_sample_rate(wm8978_handle_t *handle, wm8978_approximate_sample_t sample)
set approximate sample rate
uint8_t wm8978_set_left_dac_output_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to left output mixer
uint8_t wm8978_set_eq5_cut_off(wm8978_handle_t *handle, wm8978_eq5_band_cut_off_t cut_off)
set eq5 cut off
uint8_t wm8978_set_lout2_speaker_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 speaker volume zero cross
uint8_t wm8978_set_eq2_gain(wm8978_handle_t *handle, uint8_t gain)
set eq2 gain
uint8_t wm8978_alc_noise_gate_threshold_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the alc noise gate threshold to the register raw data
uint8_t wm8978_set_amute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable amute
uint8_t wm8978_set_unused_input_output_tie_off_buffer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable unused input output tie off buffer
uint8_t wm8978_left_channel_input_pga_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the left channel input pga volume to the register raw data
uint8_t wm8978_set_out3_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 boost
uint8_t wm8978_set_rout2_right_speaker_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 right speaker output mute
uint8_t wm8978_set_left_channel_input_pga_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga mute
uint8_t wm8978_set_left_out1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left out1
uint8_t wm8978_left_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the left channel input boost stage to the register raw data
uint8_t wm8978_set_alc_noise_gate(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable alc noise gate
uint8_t wm8978_set_out4_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mixer
uint8_t wm8978_set_lout2_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 update
uint8_t wm8978_set_right_bypass_volume_control_to_output_channel_mixer(wm8978_handle_t *handle, uint8_t vol)
set right bypass volume control to output channel mixer
uint8_t wm8978_depth_3d_convert_to_register(wm8978_handle_t *handle, float percent, uint8_t *reg)
convert the depth 3d to the register raw data
uint8_t wm8978_set_left_channel_input_pga_negative(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga negative
uint8_t wm8978_set_clock_mode(wm8978_handle_t *handle, wm8978_clock_mode_t mode)
set clock mode
uint8_t wm8978_set_vref_to_analogue_output_resistance(wm8978_handle_t *handle, wm8978_vref_t vref)
set vref to analogue output resistance
uint8_t wm8978_set_bclk_div(wm8978_handle_t *handle, wm8978_bclk_div_t d)
set bclk div
uint8_t wm8978_set_gpio1_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set gpio1 polarity
uint8_t wm8978_set_right_dac_output_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to left output mixer
uint8_t wm8978_set_right_dac_mixer_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac mixer to out4
uint8_t wm8978_set_adc_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set adc left volume
uint8_t wm8978_aux_left_channel_input_to_left_mixer_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the aux left channel input to left mixer volume to the register raw data
uint8_t wm8978_set_left_bypass_volume_control_to_output_channel_mixer(wm8978_handle_t *handle, uint8_t vol)
set left bypass volume control to output channel mixer
uint8_t wm8978_set_left_channel_input_pga_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga positive
uint8_t wm8978_set_adc_left_channel_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set adc left channel polarity
uint8_t wm8978_set_speaker_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable speaker boost
uint8_t wm8978_set_eq3_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq3 bandwidth
uint8_t wm8978_rout1_right_headphone_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the rout1 right headphone output volume to the register raw data
uint8_t wm8978_set_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4
uint8_t wm8978_set_adc_oversample_rate(wm8978_handle_t *handle, wm8978_adc_oversample_rate_t rate)
set adc oversample rate
uint8_t wm8978_set_depth_3d(wm8978_handle_t *handle, uint8_t depth)
set depth 3d
uint8_t wm8978_set_clksel(wm8978_handle_t *handle, wm8978_clksel_t clksel)
set clksel
uint8_t wm8978_set_dac_oversample_rate(wm8978_handle_t *handle, wm8978_dac_oversample_rate_t rate)
set dac oversample rate
uint8_t wm8978_set_out4_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mute
uint8_t wm8978_set_left_out2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left out2
uint8_t wm8978_set_adc_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set adc right volume
uint8_t wm8978_set_thermal_shutdown(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable thermal shutdown
uint8_t wm8978_set_reference_impedance(wm8978_handle_t *handle, wm8978_impedance_t impedance)
set reference impedance
uint8_t wm8978_right_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the right channel input boost stage to the register raw data
uint8_t wm8978_set_eq2_centre_freq(wm8978_handle_t *handle, wm8978_eq2_band_centre_freq_t freq)
set eq2 centre freq
uint8_t wm8978_set_left_channel_dac(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel dac
uint8_t wm8978_set_rout2_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 update
struct wm8978_handle_s wm8978_handle_t
wm8978 handle structure definition
uint8_t wm8978_set_dac_limiter_decay(wm8978_handle_t *handle, wm8978_dac_limiter_decay_t decay)
set dac limiter decay
uint8_t wm8978_lout2_left_speaker_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the lout2 left speaker output volume to the register raw data
uint8_t wm8978_set_right_channel_input_pga_amplifier_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga amplifier positive
uint8_t wm8978_set_alc_noise_gate_threshold(wm8978_handle_t *handle, uint8_t threshold)
set alc noise gate threshold
uint8_t wm8978_set_dac_companding(wm8978_handle_t *handle, wm8978_companding_t companding)
set dac companding
uint8_t wm8978_set_inv_rout2_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable inv rout2 mixer
uint8_t wm8978_set_out4_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 boost
uint8_t wm8978_set_right_input_pga_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right input pga update
uint8_t wm8978_set_out3_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 mixer
uint8_t wm8978_set_rout2_right_speaker_output_volume(wm8978_handle_t *handle, uint8_t vol)
set rout2 right speaker output volume
uint8_t wm8978_set_left_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set left channel input boost stage
uint8_t wm8978_set_right_adc_input_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right adc input to out4
uint8_t wm8978_set_left_auxiliary_input_to_left_channel_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left auxiliary input to left channel output mixer
uint8_t wm8978_set_left_dac_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac to out4
uint8_t wm8978_set_left_output_channel_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left output channel mixer
uint8_t wm8978_set_alc_hold_time(wm8978_handle_t *handle, uint8_t t)
set alc hold time
uint8_t wm8978_set_eq1_cut_off(wm8978_handle_t *handle, wm8978_eq1_band_cut_off_t cut_off)
set eq1 cut off
uint8_t wm8978_set_left_bypass_path_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left bypass path to left output mixer
uint8_t wm8978_set_eq4_centre_freq(wm8978_handle_t *handle, wm8978_eq4_band_centre_freq_t freq)
set eq4 centre freq
uint8_t wm8978_rout2_right_speaker_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the rout2 right speaker output volume to the register raw data
uint8_t wm8978_set_alc_max_gain(wm8978_handle_t *handle, wm8978_max_gain_t gain)
set alc max gain
uint8_t wm8978_set_mclk_div(wm8978_handle_t *handle, wm8978_mclk_div_t d)
set mclk div
uint8_t wm8978_set_lout2_left_speaker_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 left speaker output mute
uint8_t wm8978_set_lout1_left_headphone_output_volume(wm8978_handle_t *handle, uint8_t vol)
set lout1 left headphone output volume
uint8_t wm8978_set_sleep(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable sleep
uint8_t wm8978_set_notch_filter_a1_coefficient_bit_13_7(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a1 coefficient bit13 - bit7
uint8_t wm8978_set_alc_attack(wm8978_handle_t *handle, uint8_t attack)
set alc attack
uint8_t wm8978_set_out4_attenuated_by_6db(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 attenuated by 6db
uint8_t wm8978_set_aux_right_channel_input_to_right_mixer_volume(wm8978_handle_t *handle, uint8_t vol)
set aux right channel input to right mixer volume
uint8_t wm8978_set_notch_filter_a0_coefficient_bit_13_7(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a0 coefficient bit13 - bit7
uint8_t wm8978_right_channel_input_pga_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the right channel input pga volume to the register raw data
uint8_t wm8978_set_out3_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 mute
uint8_t wm8978_set_eq2_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq2 bandwidth
uint8_t wm8978_set_right_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set right channel input boost stage
uint8_t wm8978_set_dac_appear(wm8978_handle_t *handle, wm8978_appear_t appear)
set dac appear
uint8_t wm8978_set_right_channel_input_pga_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga boost
uint8_t wm8978_set_companding_8bit_mode(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable companding 8bit mode
uint8_t wm8978_set_left_adc_input_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left adc input to out3
uint8_t wm8978_set_beep_volume(wm8978_handle_t *handle, uint8_t vol)
set beep volume
uint8_t wm8978_set_dac_digital_limiter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable dac digital limiter
uint8_t wm8978_set_right_channel_input_pga_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga zero cross
uint8_t wm8978_set_beep(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable beep
uint8_t wm8978_set_eq3_gain(wm8978_handle_t *handle, uint8_t gain)
set eq3 gain
uint8_t wm8978_set_dc_buffer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable dc buffer
uint8_t wm8978_deinit(wm8978_handle_t *handle)
close the chip
uint8_t wm8978_set_rout1_right_headphone_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 right headphone output mute
uint8_t wm8978_set_vmid_1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable vmid 1
uint8_t wm8978_set_right_out1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right out1
uint8_t wm8978_set_dac_limiter_volume_boost(wm8978_handle_t *handle, uint8_t db)
set dac limiter volume boost
uint8_t wm8978_set_out4_mixer_output_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mixer output to out3
uint8_t wm8978_set_bclk_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set bclk polarity
uint8_t wm8978_set_alc_min_gain(wm8978_handle_t *handle, wm8978_min_gain_t gain)
set alc min gain
uint8_t wm8978_set_jack_logic_1(wm8978_handle_t *handle, wm8978_jack_t jack, wm8978_bool_t enable)
set jack logic 1
uint8_t wm8978_set_analogue_amplifier_bias(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable analogue amplifier bias
uint8_t wm8978_set_rout1_headphone_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 headphone volume zero cross
uint8_t wm8978_set_left_channel_input_pga_amplifier_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga amplifier positive
uint8_t wm8978_set_mode(wm8978_handle_t *handle, wm8978_mode_t mode)
set chip mode
uint8_t wm8978_set_high_pass_filter_cut_off(wm8978_handle_t *handle, wm8978_high_pass_filter_cut_off_t cut)
set high pass filter cut off
uint8_t wm8978_set_left_channel_input_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input boost
uint8_t wm8978_set_jack_detection(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable jack detection
uint8_t wm8978_set_left_channel_input_pga(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga
uint8_t wm8978_set_alc_mode(wm8978_handle_t *handle, wm8978_alc_mode_t mode)
set alc mode
uint8_t wm8978_set_right_channel_input_pga(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga
uint8_t wm8978_set_auxiliary_amplifier_right_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set auxiliary amplifier right channel input boost stage
uint8_t wm8978_set_lout1_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 update
uint8_t wm8978_set_high_pass_filter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable high pass filter
uint8_t wm8978_set_right_channel_input_pga_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga mute
uint8_t wm8978_set_dac_limiter_attack(wm8978_handle_t *handle, wm8978_dac_limiter_attack_t attack)
set dac limiter attack
uint8_t wm8978_set_data_format(wm8978_handle_t *handle, wm8978_data_format_t format)
set data format
uint8_t wm8978_beep_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the beep volume to the register raw data
uint8_t wm8978_set_soft_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable soft mute
uint8_t wm8978_set_right_channel_input_pga_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga positive
uint8_t wm8978_set_mclk_divide_by_2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable mclk divide by 2
uint8_t wm8978_set_left_channel_adc(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel adc
uint8_t wm8978_set_aux_left_channel_input_to_left_mixer_volume(wm8978_handle_t *handle, uint8_t vol)
set aux left channel input to left mixer volume
uint8_t wm8978_set_left_dac_output_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to out3
uint8_t wm8978_set_dac_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set dac right volume
uint8_t wm8978_set_notch_filter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable notch filter
uint8_t wm8978_set_jack_logic_0(wm8978_handle_t *handle, wm8978_jack_t jack, wm8978_bool_t enable)
set jack logic 0
uint8_t wm8978_right_bypass_volume_control_to_output_channel_mixer_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the right bypass volume control to output channel mixer to the register raw data
uint8_t wm8978_set_eq3_centre_freq(wm8978_handle_t *handle, wm8978_eq3_band_centre_freq_t freq)
set eq3 centre freq
uint8_t wm8978_set_lout1_left_headphone_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 left headphone output mute
uint8_t wm8978_set_jack_gpio(wm8978_handle_t *handle, wm8978_jack_sel_t sel)
set jack gpio
uint8_t wm8978_set_right_dac_output_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to right output mixer
uint8_t wm8978_set_right_channel_dac(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel dac
uint8_t wm8978_set_alc_decay(wm8978_handle_t *handle, uint8_t decay)
set alc decay
uint8_t wm8978_set_notch_filter_a1_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a1 coefficient bit6 - bit0
struct wm8978_info_s wm8978_info_t
wm8978 information structure definition
uint8_t wm8978_set_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3
@ WM8978_EQ3_BAND_CENTRE_FREQ_1100HZ
@ WM8978_MODE_AUDIO
@ WM8978_HIGH_PASS_FILTER_CUT_OFF_0
@ WM8978_EQ4_BAND_CENTRE_FREQ_3200HZ
@ WM8978_DATA_FORMAT_IIS
@ WM8978_IMPEDANCE_5K
@ WM8978_DAC_LIMITER_ATTACK_12MS
@ WM8978_VREF_1K
@ WM8978_CLOCK_MODE_INPUT
@ WM8978_ADC_OVERSAMPLE_RATE_128X
@ WM8978_COMPANDING_LINEAR
@ WM8978_WORD_LENGTH_16_BITS
@ WM8978_CHANNEL_STEREO
@ WM8978_DAC_LIMITER_LEVEL_NEGATIVE_1DB
@ WM8978_APPROXIMATE_SAMPLE_48_KHZ
@ WM8978_PLL_DIV_BY_1
@ WM8978_AVDD_0P9
@ WM8978_JACK_OUT1
@ WM8978_JACK_OUT4
@ WM8978_JACK_OUT3
@ WM8978_JACK_OUT2
@ WM8978_POLARITY_NORMAL
@ WM8978_EQ5_BAND_CUT_OFF_11700HZ
@ WM8978_GPIO1_SEL_LOGIC_0
@ WM8978_CLKSEL_MCLK
@ WM8978_EQUALISER_APPLIED_TO_DAC
@ WM8978_BCLK_DIV_BY_1
@ WM8978_DAC_OVERSAMPLE_RATE_128X
@ WM8978_MIN_GAIN_NEGATIVE_12_DB
@ WM8978_MAX_GAIN_35P25_DB
@ WM8978_BOOL_FALSE
@ WM8978_BOOL_TRUE
@ WM8978_ALC_BOTH
@ WM8978_JACK_SEL_GPIO2
@ WM8978_ALC_LEVEL_NEGATIVE_3
@ WM8978_EQ1_BAND_CUT_OFF_80HZ
@ WM8978_ALC_MODE_ALC
@ WM8978_DAC_LIMITER_DECAY_192MS
@ WM8978_APPEAR_LEFT
@ WM8978_EQ_BANDWIDTH_WIDE
@ WM8978_MCLK_DIV_BY_1
@ WM8978_EQ2_BAND_CENTRE_FREQ_385HZ
void wm8978_interface_debug_print(const char *const fmt,...)
interface print format data
void wm8978_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t wm8978_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t wm8978_interface_iic_init(void)
interface iic bus init
uint8_t wm8978_interface_iic_deinit(void)
interface iic bus deinit
wav_handle_t * wm8978_record_get_handle(void)
record get handle
uint8_t wm8978_record_test(char *path, uint32_t second)
record test
uint8_t wm8978_record_file_fill(uint8_t index)
record file fill
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]