LibDriver WM8978
Loading...
Searching...
No Matches
driver_wm8978.c
Go to the documentation of this file.
1
36
37#include "driver_wm8978.h"
38
42#define CHIP_NAME "Cirrus Logic WM8978"
43#define MANUFACTURER_NAME "Cirrus Logic"
44#define SUPPLY_VOLTAGE_MIN 2.5f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 18.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 100.0f
49#define DRIVER_VERSION 1000
50
54#define WM8978_ADDRESS (0x1A << 1)
55
59#define WM8978_REG_SOFTWARE_RESET 0x00
60#define WM8978_REG_POWER_MANAGE_1 0x01
61#define WM8978_REG_POWER_MANAGE_2 0x02
62#define WM8978_REG_POWER_MANAGE_3 0x03
63#define WM8978_REG_AUDIO_INTERFACE 0x04
64#define WM8978_REG_COMPANDING_CTRL 0x05
65#define WM8978_REG_CLOCK_GEN_CTRL 0x06
66#define WM8978_REG_ADDITIONAL_CTRL 0x07
67#define WM8978_REG_GPIO 0x08
68#define WM8978_REG_JACK_DETECT_CONTROL 0x09
69#define WM8978_REG_DAC_CONTROL 0x0A
70#define WM8978_REG_LEFT_DAC_DIGITAL_VOL 0x0B
71#define WM8978_REG_RIGHT_DAC_DIGITAL_VOL 0x0C
72#define WM8978_REG_JACK_DETECT_CONTROL2 0x0D
73#define WM8978_REG_ADC_CONTROL 0x0E
74#define WM8978_REG_LEFT_ADC_DIGITAL_VOL 0x0F
75#define WM8978_REG_RIGHT_ADC_DIGITAL_VOL 0x10
76#define WM8978_REG_EQ1 0x12
77#define WM8978_REG_EQ2 0x13
78#define WM8978_REG_EQ3 0x14
79#define WM8978_REG_EQ4 0x15
80#define WM8978_REG_EQ5 0x16
81#define WM8978_REG_DAC_LIMITER_1 0x18
82#define WM8978_REG_DAC_LIMITER_2 0x19
83#define WM8978_REG_NOTCH_FILTER_1 0x1B
84#define WM8978_REG_NOTCH_FILTER_2 0x1C
85#define WM8978_REG_NOTCH_FILTER_3 0x1D
86#define WM8978_REG_NOTCH_FILTER_4 0x1E
87#define WM8978_REG_ALC_CONTROL_1 0x20
88#define WM8978_REG_ALC_CONTROL_2 0x21
89#define WM8978_REG_ALC_CONTROL_3 0x22
90#define WM8978_REG_NOISE_GATE 0x23
91#define WM8978_REG_PLL_N 0x24
92#define WM8978_REG_PLL_K1 0x25
93#define WM8978_REG_PLL_K2 0x26
94#define WM8978_REG_PLL_K3 0x27
95#define WM8978_REG_3D_CONTROL 0x29
96#define WM8978_REG_BEEP_CONTROL 0x2B
97#define WM8978_REG_INPUT_CTRL 0x2C
98#define WM8978_REG_LEFT_INP_PGA_CTRL 0x2D
99#define WM8978_REG_RIGHT_INP_PGA_CTRL 0x2E
100#define WM8978_REG_LEFT_ADC_BOOST_CTRL 0x2F
101#define WM8978_REG_RIGHT_ADC_BOOST_CTRL 0x30
102#define WM8978_REG_OUTPUT_CTRL 0x31
103#define WM8978_REG_LEFT_MIXER_CTRL 0x32
104#define WM8978_REG_RIGHT_MIXER_CTRL 0x33
105#define WM8978_REG_LOUT1_CTRL 0x34
106#define WM8978_REG_ROUT1_CTRL 0x35
107#define WM8978_REG_LOUT2_CTRL 0x36
108#define WM8978_REG_ROUT2_CTRL 0x37
109#define WM8978_REG_OUT3_MIXER_CTRL 0x38
110#define WM8978_REG_OUT4_MIXER_CTRL 0x39
111
115static const uint16_t gsc_wm8978_init_reg[58] =
116{
117 0X0000, 0X0000, 0X0000, 0X0000, 0X0050, 0X0000, 0X0140, 0X0000,
118 0X0000, 0X0000, 0X0000, 0X00FF, 0X00FF, 0X0000, 0X0100, 0X00FF,
119 0X00FF, 0X0000, 0X012C, 0X002C, 0X002C, 0X002C, 0X002C, 0X0000,
120 0X0032, 0X0000, 0X0000, 0X0000, 0X0000, 0X0000, 0X0000, 0X0000,
121 0X0038, 0X000B, 0X0032, 0X0000, 0X0008, 0X000C, 0X0093, 0X00E9,
122 0X0000, 0X0000, 0X0000, 0X0000, 0X0003, 0X0010, 0X0010, 0X0100,
123 0X0100, 0X0002, 0X0001, 0X0001, 0X0039, 0X0039, 0X0039, 0X0039,
124 0X0001, 0X0001
125};
126
137static uint8_t a_wm8978_iic_read(wm8978_handle_t *handle, uint8_t reg, uint16_t *config)
138{
139 if (reg > 57) /* check range 57 */
140 {
141 *config = 0x0000; /* init 0 */
142
143 return 1; /* return error */
144 }
145 else
146 {
147 *config = handle->reg[reg]; /* get register config */
148
149 return 0; /* success return 0 */
150 }
151}
152
163static uint8_t a_wm8978_iic_write(wm8978_handle_t *handle, uint8_t reg, uint16_t config)
164{
165 uint8_t buf[1];
166
167 buf[0] = config & 0xFF; /* set LSB */
168 if (handle->iic_write(WM8978_ADDRESS,
169 (reg << 1) | ((config >> 8) & 0x01), (uint8_t *)buf, 1) != 0) /* write data */
170 {
171 return 1; /* return error */
172 }
173 handle->reg[reg] = config; /* save the config */
174
175 return 0; /* success return 0 */
176}
177
189{
190 uint8_t res;
191 uint16_t conf;
192
193 if (handle == NULL) /* check handle */
194 {
195 return 2; /* return error */
196 }
197 if (handle->inited != 1) /* check handle initialization */
198 {
199 return 3; /* return error */
200 }
201
202 conf = 0x0000; /* set any value */
203 res = a_wm8978_iic_write(handle, WM8978_REG_SOFTWARE_RESET, conf); /* write config */
204 if (res != 0) /* check error */
205 {
206 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
207
208 return 1; /* return error */
209 }
210 handle->delay_ms(100); /* delay 100ms */
211
212 return 0; /* success return 0 */
213}
214
227{
228 uint8_t res;
229 uint16_t conf;
230
231 if (handle == NULL) /* check handle */
232 {
233 return 2; /* return error */
234 }
235 if (handle->inited != 1) /* check handle initialization */
236 {
237 return 3; /* return error */
238 }
239
240 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
241 if (res != 0) /* check error */
242 {
243 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
244
245 return 1; /* return error */
246 }
247 conf &= ~(1 << 8); /* clear config */
248 conf |= enable << 8; /* set bool */
249 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
250 if (res != 0) /* check error */
251 {
252 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
253
254 return 1; /* return error */
255 }
256
257 return 0; /* success return 0 */
258}
259
272{
273 uint8_t res;
274 uint16_t conf;
275
276 if (handle == NULL) /* check handle */
277 {
278 return 2; /* return error */
279 }
280 if (handle->inited != 1) /* check handle initialization */
281 {
282 return 3; /* return error */
283 }
284
285 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
286 if (res != 0) /* check error */
287 {
288 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
289
290 return 1; /* return error */
291 }
292 conf &= ~(1 << 7); /* clear config */
293 conf |= enable << 7; /* set bool */
294 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
295 if (res != 0) /* check error */
296 {
297 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
298
299 return 1; /* return error */
300 }
301
302 return 0; /* success return 0 */
303}
304
317{
318 uint8_t res;
319 uint16_t conf;
320
321 if (handle == NULL) /* check handle */
322 {
323 return 2; /* return error */
324 }
325 if (handle->inited != 1) /* check handle initialization */
326 {
327 return 3; /* return error */
328 }
329
330 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
331 if (res != 0) /* check error */
332 {
333 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
334
335 return 1; /* return error */
336 }
337 conf &= ~(1 << 6); /* clear config */
338 conf |= enable << 6; /* set bool */
339 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
340 if (res != 0) /* check error */
341 {
342 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
343
344 return 1; /* return error */
345 }
346
347 return 0; /* success return 0 */
348}
349
362{
363 uint8_t res;
364 uint16_t conf;
365
366 if (handle == NULL) /* check handle */
367 {
368 return 2; /* return error */
369 }
370 if (handle->inited != 1) /* check handle initialization */
371 {
372 return 3; /* return error */
373 }
374
375 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
376 if (res != 0) /* check error */
377 {
378 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
379
380 return 1; /* return error */
381 }
382 conf &= ~(1 << 5); /* clear config */
383 conf |= enable << 5; /* set bool */
384 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
385 if (res != 0) /* check error */
386 {
387 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
388
389 return 1; /* return error */
390 }
391
392 return 0; /* success return 0 */
393}
394
407{
408 uint8_t res;
409 uint16_t conf;
410
411 if (handle == NULL) /* check handle */
412 {
413 return 2; /* return error */
414 }
415 if (handle->inited != 1) /* check handle initialization */
416 {
417 return 3; /* return error */
418 }
419
420 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
421 if (res != 0) /* check error */
422 {
423 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
424
425 return 1; /* return error */
426 }
427 conf &= ~(1 << 4); /* clear config */
428 conf |= enable << 4; /* set bool */
429 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
430 if (res != 0) /* check error */
431 {
432 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
433
434 return 1; /* return error */
435 }
436
437 return 0; /* success return 0 */
438}
439
452{
453 uint8_t res;
454 uint16_t conf;
455
456 if (handle == NULL) /* check handle */
457 {
458 return 2; /* return error */
459 }
460 if (handle->inited != 1) /* check handle initialization */
461 {
462 return 3; /* return error */
463 }
464
465 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
466 if (res != 0) /* check error */
467 {
468 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
469
470 return 1; /* return error */
471 }
472 conf &= ~(1 << 3); /* clear config */
473 conf |= enable << 3; /* set bool */
474 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
475 if (res != 0) /* check error */
476 {
477 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
478
479 return 1; /* return error */
480 }
481
482 return 0; /* success return 0 */
483}
484
497{
498 uint8_t res;
499 uint16_t conf;
500
501 if (handle == NULL) /* check handle */
502 {
503 return 2; /* return error */
504 }
505 if (handle->inited != 1) /* check handle initialization */
506 {
507 return 3; /* return error */
508 }
509
510 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
511 if (res != 0) /* check error */
512 {
513 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
514
515 return 1; /* return error */
516 }
517 conf &= ~(1 << 2); /* clear config */
518 conf |= enable << 2; /* set bool */
519 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
520 if (res != 0) /* check error */
521 {
522 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
523
524 return 1; /* return error */
525 }
526
527 return 0; /* success return 0 */
528}
529
542{
543 uint8_t res;
544 uint16_t conf;
545
546 if (handle == NULL) /* check handle */
547 {
548 return 2; /* return error */
549 }
550 if (handle->inited != 1) /* check handle initialization */
551 {
552 return 3; /* return error */
553 }
554
555 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_1, &conf); /* read config */
556 if (res != 0) /* check error */
557 {
558 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
559
560 return 1; /* return error */
561 }
562 conf &= ~(3 << 0); /* clear config */
563 conf |= impedance << 0; /* set impedance */
564 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_1, conf); /* write config */
565 if (res != 0) /* check error */
566 {
567 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
568
569 return 1; /* return error */
570 }
571
572 return 0; /* success return 0 */
573}
574
587{
588 uint8_t res;
589 uint16_t conf;
590
591 if (handle == NULL) /* check handle */
592 {
593 return 2; /* return error */
594 }
595 if (handle->inited != 1) /* check handle initialization */
596 {
597 return 3; /* return error */
598 }
599
600 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
601 if (res != 0) /* check error */
602 {
603 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
604
605 return 1; /* return error */
606 }
607 conf &= ~(1 << 8); /* clear config */
608 conf |= enable << 8; /* set bool */
609 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
610 if (res != 0) /* check error */
611 {
612 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
613
614 return 1; /* return error */
615 }
616
617 return 0; /* success return 0 */
618}
619
632{
633 uint8_t res;
634 uint16_t conf;
635
636 if (handle == NULL) /* check handle */
637 {
638 return 2; /* return error */
639 }
640 if (handle->inited != 1) /* check handle initialization */
641 {
642 return 3; /* return error */
643 }
644
645 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
646 if (res != 0) /* check error */
647 {
648 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
649
650 return 1; /* return error */
651 }
652 conf &= ~(1 << 7); /* clear config */
653 conf |= enable << 7; /* set bool */
654 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
655 if (res != 0) /* check error */
656 {
657 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
658
659 return 1; /* return error */
660 }
661
662 return 0; /* success return 0 */
663}
664
677{
678 uint8_t res;
679 uint16_t conf;
680
681 if (handle == NULL) /* check handle */
682 {
683 return 2; /* return error */
684 }
685 if (handle->inited != 1) /* check handle initialization */
686 {
687 return 3; /* return error */
688 }
689
690 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
691 if (res != 0) /* check error */
692 {
693 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
694
695 return 1; /* return error */
696 }
697 conf &= ~(1 << 6); /* clear config */
698 conf |= enable << 6; /* set bool */
699 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
700 if (res != 0) /* check error */
701 {
702 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
703
704 return 1; /* return error */
705 }
706
707 return 0; /* success return 0 */
708}
709
722{
723 uint8_t res;
724 uint16_t conf;
725
726 if (handle == NULL) /* check handle */
727 {
728 return 2; /* return error */
729 }
730 if (handle->inited != 1) /* check handle initialization */
731 {
732 return 3; /* return error */
733 }
734
735 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
736 if (res != 0) /* check error */
737 {
738 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
739
740 return 1; /* return error */
741 }
742 conf &= ~(1 << 5); /* clear config */
743 conf |= enable << 5; /* set bool */
744 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
745 if (res != 0) /* check error */
746 {
747 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
748
749 return 1; /* return error */
750 }
751
752 return 0; /* success return 0 */
753}
754
767{
768 uint8_t res;
769 uint16_t conf;
770
771 if (handle == NULL) /* check handle */
772 {
773 return 2; /* return error */
774 }
775 if (handle->inited != 1) /* check handle initialization */
776 {
777 return 3; /* return error */
778 }
779
780 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
781 if (res != 0) /* check error */
782 {
783 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
784
785 return 1; /* return error */
786 }
787 conf &= ~(1 << 4); /* clear config */
788 conf |= enable << 4; /* set bool */
789 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
790 if (res != 0) /* check error */
791 {
792 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
793
794 return 1; /* return error */
795 }
796
797 return 0; /* success return 0 */
798}
799
812{
813 uint8_t res;
814 uint16_t conf;
815
816 if (handle == NULL) /* check handle */
817 {
818 return 2; /* return error */
819 }
820 if (handle->inited != 1) /* check handle initialization */
821 {
822 return 3; /* return error */
823 }
824
825 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
826 if (res != 0) /* check error */
827 {
828 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
829
830 return 1; /* return error */
831 }
832 conf &= ~(1 << 3); /* clear config */
833 conf |= enable << 3; /* set bool */
834 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
835 if (res != 0) /* check error */
836 {
837 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
838
839 return 1; /* return error */
840 }
841
842 return 0; /* success return 0 */
843}
844
857{
858 uint8_t res;
859 uint16_t conf;
860
861 if (handle == NULL) /* check handle */
862 {
863 return 2; /* return error */
864 }
865 if (handle->inited != 1) /* check handle initialization */
866 {
867 return 3; /* return error */
868 }
869
870 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
871 if (res != 0) /* check error */
872 {
873 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
874
875 return 1; /* return error */
876 }
877 conf &= ~(1 << 2); /* clear config */
878 conf |= enable << 2; /* set bool */
879 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
880 if (res != 0) /* check error */
881 {
882 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
883
884 return 1; /* return error */
885 }
886
887 return 0; /* success return 0 */
888}
889
902{
903 uint8_t res;
904 uint16_t conf;
905
906 if (handle == NULL) /* check handle */
907 {
908 return 2; /* return error */
909 }
910 if (handle->inited != 1) /* check handle initialization */
911 {
912 return 3; /* return error */
913 }
914
915 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
916 if (res != 0) /* check error */
917 {
918 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
919
920 return 1; /* return error */
921 }
922 conf &= ~(1 << 1); /* clear config */
923 conf |= enable << 1; /* set bool */
924 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
925 if (res != 0) /* check error */
926 {
927 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
928
929 return 1; /* return error */
930 }
931
932 return 0; /* success return 0 */
933}
934
947{
948 uint8_t res;
949 uint16_t conf;
950
951 if (handle == NULL) /* check handle */
952 {
953 return 2; /* return error */
954 }
955 if (handle->inited != 1) /* check handle initialization */
956 {
957 return 3; /* return error */
958 }
959
960 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
961 if (res != 0) /* check error */
962 {
963 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
964
965 return 1; /* return error */
966 }
967 conf &= ~(1 << 0); /* clear config */
968 conf |= enable << 0; /* set bool */
969 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
970 if (res != 0) /* check error */
971 {
972 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
973
974 return 1; /* return error */
975 }
976
977 return 0; /* success return 0 */
978}
979
992{
993 uint8_t res;
994 uint16_t conf;
995
996 if (handle == NULL) /* check handle */
997 {
998 return 2; /* return error */
999 }
1000 if (handle->inited != 1) /* check handle initialization */
1001 {
1002 return 3; /* return error */
1003 }
1004
1005 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1006 if (res != 0) /* check error */
1007 {
1008 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1009
1010 return 1; /* return error */
1011 }
1012 conf &= ~(1 << 8); /* clear config */
1013 conf |= enable << 8; /* set bool */
1014 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1015 if (res != 0) /* check error */
1016 {
1017 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1018
1019 return 1; /* return error */
1020 }
1021
1022 return 0; /* success return 0 */
1023}
1024
1037{
1038 uint8_t res;
1039 uint16_t conf;
1040
1041 if (handle == NULL) /* check handle */
1042 {
1043 return 2; /* return error */
1044 }
1045 if (handle->inited != 1) /* check handle initialization */
1046 {
1047 return 3; /* return error */
1048 }
1049
1050 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1051 if (res != 0) /* check error */
1052 {
1053 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1054
1055 return 1; /* return error */
1056 }
1057 conf &= ~(1 << 7); /* clear config */
1058 conf |= enable << 7; /* set bool */
1059 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1060 if (res != 0) /* check error */
1061 {
1062 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1063
1064 return 1; /* return error */
1065 }
1066
1067 return 0; /* success return 0 */
1068}
1069
1082{
1083 uint8_t res;
1084 uint16_t conf;
1085
1086 if (handle == NULL) /* check handle */
1087 {
1088 return 2; /* return error */
1089 }
1090 if (handle->inited != 1) /* check handle initialization */
1091 {
1092 return 3; /* return error */
1093 }
1094
1095 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1096 if (res != 0) /* check error */
1097 {
1098 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1099
1100 return 1; /* return error */
1101 }
1102 conf &= ~(1 << 6); /* clear config */
1103 conf |= enable << 6; /* set bool */
1104 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1105 if (res != 0) /* check error */
1106 {
1107 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1108
1109 return 1; /* return error */
1110 }
1111
1112 return 0; /* success return 0 */
1113}
1114
1127{
1128 uint8_t res;
1129 uint16_t conf;
1130
1131 if (handle == NULL) /* check handle */
1132 {
1133 return 2; /* return error */
1134 }
1135 if (handle->inited != 1) /* check handle initialization */
1136 {
1137 return 3; /* return error */
1138 }
1139
1140 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1141 if (res != 0) /* check error */
1142 {
1143 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1144
1145 return 1; /* return error */
1146 }
1147 conf &= ~(1 << 5); /* clear config */
1148 conf |= enable << 5; /* set bool */
1149 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1150 if (res != 0) /* check error */
1151 {
1152 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1153
1154 return 1; /* return error */
1155 }
1156
1157 return 0; /* success return 0 */
1158}
1159
1172{
1173 uint8_t res;
1174 uint16_t conf;
1175
1176 if (handle == NULL) /* check handle */
1177 {
1178 return 2; /* return error */
1179 }
1180 if (handle->inited != 1) /* check handle initialization */
1181 {
1182 return 3; /* return error */
1183 }
1184
1185 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1186 if (res != 0) /* check error */
1187 {
1188 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1189
1190 return 1; /* return error */
1191 }
1192 conf &= ~(1 << 3); /* clear config */
1193 conf |= enable << 3; /* set bool */
1194 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1195 if (res != 0) /* check error */
1196 {
1197 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1198
1199 return 1; /* return error */
1200 }
1201
1202 return 0; /* success return 0 */
1203}
1204
1217{
1218 uint8_t res;
1219 uint16_t conf;
1220
1221 if (handle == NULL) /* check handle */
1222 {
1223 return 2; /* return error */
1224 }
1225 if (handle->inited != 1) /* check handle initialization */
1226 {
1227 return 3; /* return error */
1228 }
1229
1230 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1231 if (res != 0) /* check error */
1232 {
1233 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1234
1235 return 1; /* return error */
1236 }
1237 conf &= ~(1 << 2); /* clear config */
1238 conf |= enable << 2; /* set bool */
1239 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1240 if (res != 0) /* check error */
1241 {
1242 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1243
1244 return 1; /* return error */
1245 }
1246
1247 return 0; /* success return 0 */
1248}
1249
1262{
1263 uint8_t res;
1264 uint16_t conf;
1265
1266 if (handle == NULL) /* check handle */
1267 {
1268 return 2; /* return error */
1269 }
1270 if (handle->inited != 1) /* check handle initialization */
1271 {
1272 return 3; /* return error */
1273 }
1274
1275 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1276 if (res != 0) /* check error */
1277 {
1278 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1279
1280 return 1; /* return error */
1281 }
1282 conf &= ~(1 << 1); /* clear config */
1283 conf |= enable << 1; /* set bool */
1284 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1285 if (res != 0) /* check error */
1286 {
1287 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1288
1289 return 1; /* return error */
1290 }
1291
1292 return 0; /* success return 0 */
1293}
1294
1307{
1308 uint8_t res;
1309 uint16_t conf;
1310
1311 if (handle == NULL) /* check handle */
1312 {
1313 return 2; /* return error */
1314 }
1315 if (handle->inited != 1) /* check handle initialization */
1316 {
1317 return 3; /* return error */
1318 }
1319
1320 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_3, &conf); /* read config */
1321 if (res != 0) /* check error */
1322 {
1323 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1324
1325 return 1; /* return error */
1326 }
1327 conf &= ~(1 << 0); /* clear config */
1328 conf |= enable << 0; /* set bool */
1329 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_3, conf); /* write config */
1330 if (res != 0) /* check error */
1331 {
1332 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1333
1334 return 1; /* return error */
1335 }
1336
1337 return 0; /* success return 0 */
1338}
1339
1352{
1353 uint8_t res;
1354 uint16_t conf;
1355
1356 if (handle == NULL) /* check handle */
1357 {
1358 return 2; /* return error */
1359 }
1360 if (handle->inited != 1) /* check handle initialization */
1361 {
1362 return 3; /* return error */
1363 }
1364
1365 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1366 if (res != 0) /* check error */
1367 {
1368 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1369
1370 return 1; /* return error */
1371 }
1372 conf &= ~(1 << 8); /* clear config */
1373 conf |= polarity << 8; /* set polarity */
1374 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1375 if (res != 0) /* check error */
1376 {
1377 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1378
1379 return 1; /* return error */
1380 }
1381
1382 return 0; /* success return 0 */
1383}
1384
1397{
1398 uint8_t res;
1399 uint16_t conf;
1400
1401 if (handle == NULL) /* check handle */
1402 {
1403 return 2; /* return error */
1404 }
1405 if (handle->inited != 1) /* check handle initialization */
1406 {
1407 return 3; /* return error */
1408 }
1409
1410 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1411 if (res != 0) /* check error */
1412 {
1413 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1414
1415 return 1; /* return error */
1416 }
1417 conf &= ~(1 << 7); /* clear config */
1418 conf |= polarity << 7; /* set polarity */
1419 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1420 if (res != 0) /* check error */
1421 {
1422 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1423
1424 return 1; /* return error */
1425 }
1426
1427 return 0; /* success return 0 */
1428}
1429
1442{
1443 uint8_t res;
1444 uint16_t conf;
1445
1446 if (handle == NULL) /* check handle */
1447 {
1448 return 2; /* return error */
1449 }
1450 if (handle->inited != 1) /* check handle initialization */
1451 {
1452 return 3; /* return error */
1453 }
1454
1455 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1456 if (res != 0) /* check error */
1457 {
1458 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1459
1460 return 1; /* return error */
1461 }
1462 conf &= ~(3 << 5); /* clear config */
1463 conf |= word_length << 5; /* set word length */
1464 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1465 if (res != 0) /* check error */
1466 {
1467 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1468
1469 return 1; /* return error */
1470 }
1471
1472 return 0; /* success return 0 */
1473}
1474
1487{
1488 uint8_t res;
1489 uint16_t conf;
1490
1491 if (handle == NULL) /* check handle */
1492 {
1493 return 2; /* return error */
1494 }
1495 if (handle->inited != 1) /* check handle initialization */
1496 {
1497 return 3; /* return error */
1498 }
1499
1500 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1501 if (res != 0) /* check error */
1502 {
1503 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1504
1505 return 1; /* return error */
1506 }
1507 conf &= ~(3 << 3); /* clear config */
1508 conf |= format << 3; /* set format */
1509 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1510 if (res != 0) /* check error */
1511 {
1512 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1513
1514 return 1; /* return error */
1515 }
1516
1517 return 0; /* success return 0 */
1518}
1519
1532{
1533 uint8_t res;
1534 uint16_t conf;
1535
1536 if (handle == NULL) /* check handle */
1537 {
1538 return 2; /* return error */
1539 }
1540 if (handle->inited != 1) /* check handle initialization */
1541 {
1542 return 3; /* return error */
1543 }
1544
1545 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1546 if (res != 0) /* check error */
1547 {
1548 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1549
1550 return 1; /* return error */
1551 }
1552 conf &= ~(1 << 2); /* clear config */
1553 conf |= appear << 2; /* set appear */
1554 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1555 if (res != 0) /* check error */
1556 {
1557 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1558
1559 return 1; /* return error */
1560 }
1561
1562 return 0; /* success return 0 */
1563}
1564
1577{
1578 uint8_t res;
1579 uint16_t conf;
1580
1581 if (handle == NULL) /* check handle */
1582 {
1583 return 2; /* return error */
1584 }
1585 if (handle->inited != 1) /* check handle initialization */
1586 {
1587 return 3; /* return error */
1588 }
1589
1590 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1591 if (res != 0) /* check error */
1592 {
1593 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1594
1595 return 1; /* return error */
1596 }
1597 conf &= ~(1 << 1); /* clear config */
1598 conf |= appear << 1; /* set appear */
1599 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1600 if (res != 0) /* check error */
1601 {
1602 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1603
1604 return 1; /* return error */
1605 }
1606
1607 return 0; /* success return 0 */
1608}
1609
1622{
1623 uint8_t res;
1624 uint16_t conf;
1625
1626 if (handle == NULL) /* check handle */
1627 {
1628 return 2; /* return error */
1629 }
1630 if (handle->inited != 1) /* check handle initialization */
1631 {
1632 return 3; /* return error */
1633 }
1634
1635 res = a_wm8978_iic_read(handle, WM8978_REG_AUDIO_INTERFACE, &conf); /* read config */
1636 if (res != 0) /* check error */
1637 {
1638 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1639
1640 return 1; /* return error */
1641 }
1642 conf &= ~(1 << 0); /* clear config */
1643 conf |= channel << 0; /* set channel */
1644 res = a_wm8978_iic_write(handle, WM8978_REG_AUDIO_INTERFACE, conf); /* write config */
1645 if (res != 0) /* check error */
1646 {
1647 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1648
1649 return 1; /* return error */
1650 }
1651
1652 return 0; /* success return 0 */
1653}
1654
1667{
1668 uint8_t res;
1669 uint16_t conf;
1670
1671 if (handle == NULL) /* check handle */
1672 {
1673 return 2; /* return error */
1674 }
1675 if (handle->inited != 1) /* check handle initialization */
1676 {
1677 return 3; /* return error */
1678 }
1679
1680 res = a_wm8978_iic_read(handle, WM8978_REG_COMPANDING_CTRL, &conf); /* read config */
1681 if (res != 0) /* check error */
1682 {
1683 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1684
1685 return 1; /* return error */
1686 }
1687 conf &= ~(1 << 5); /* clear config */
1688 conf |= enable << 5; /* set channel */
1689 res = a_wm8978_iic_write(handle, WM8978_REG_COMPANDING_CTRL, conf); /* write config */
1690 if (res != 0) /* check error */
1691 {
1692 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1693
1694 return 1; /* return error */
1695 }
1696
1697 return 0; /* success return 0 */
1698}
1699
1712{
1713 uint8_t res;
1714 uint16_t conf;
1715
1716 if (handle == NULL) /* check handle */
1717 {
1718 return 2; /* return error */
1719 }
1720 if (handle->inited != 1) /* check handle initialization */
1721 {
1722 return 3; /* return error */
1723 }
1724
1725 res = a_wm8978_iic_read(handle, WM8978_REG_COMPANDING_CTRL, &conf); /* read config */
1726 if (res != 0) /* check error */
1727 {
1728 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1729
1730 return 1; /* return error */
1731 }
1732 conf &= ~(3 << 3); /* clear config */
1733 conf |= companding << 3; /* set companding */
1734 res = a_wm8978_iic_write(handle, WM8978_REG_COMPANDING_CTRL, conf); /* write config */
1735 if (res != 0) /* check error */
1736 {
1737 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1738
1739 return 1; /* return error */
1740 }
1741
1742 return 0; /* success return 0 */
1743}
1744
1757{
1758 uint8_t res;
1759 uint16_t conf;
1760
1761 if (handle == NULL) /* check handle */
1762 {
1763 return 2; /* return error */
1764 }
1765 if (handle->inited != 1) /* check handle initialization */
1766 {
1767 return 3; /* return error */
1768 }
1769
1770 res = a_wm8978_iic_read(handle, WM8978_REG_COMPANDING_CTRL, &conf); /* read config */
1771 if (res != 0) /* check error */
1772 {
1773 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1774
1775 return 1; /* return error */
1776 }
1777 conf &= ~(3 << 1); /* clear config */
1778 conf |= companding << 1; /* set companding */
1779 res = a_wm8978_iic_write(handle, WM8978_REG_COMPANDING_CTRL, conf); /* write config */
1780 if (res != 0) /* check error */
1781 {
1782 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1783
1784 return 1; /* return error */
1785 }
1786
1787 return 0; /* success return 0 */
1788}
1789
1802{
1803 uint8_t res;
1804 uint16_t conf;
1805
1806 if (handle == NULL) /* check handle */
1807 {
1808 return 2; /* return error */
1809 }
1810 if (handle->inited != 1) /* check handle initialization */
1811 {
1812 return 3; /* return error */
1813 }
1814
1815 res = a_wm8978_iic_read(handle, WM8978_REG_COMPANDING_CTRL, &conf); /* read config */
1816 if (res != 0) /* check error */
1817 {
1818 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1819
1820 return 1; /* return error */
1821 }
1822 conf &= ~(1 << 0); /* clear config */
1823 conf |= enable << 0; /* set channel */
1824 res = a_wm8978_iic_write(handle, WM8978_REG_COMPANDING_CTRL, conf); /* write config */
1825 if (res != 0) /* check error */
1826 {
1827 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1828
1829 return 1; /* return error */
1830 }
1831
1832 return 0; /* success return 0 */
1833}
1834
1847{
1848 uint8_t res;
1849 uint16_t conf;
1850
1851 if (handle == NULL) /* check handle */
1852 {
1853 return 2; /* return error */
1854 }
1855 if (handle->inited != 1) /* check handle initialization */
1856 {
1857 return 3; /* return error */
1858 }
1859
1860 res = a_wm8978_iic_read(handle, WM8978_REG_CLOCK_GEN_CTRL, &conf); /* read config */
1861 if (res != 0) /* check error */
1862 {
1863 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1864
1865 return 1; /* return error */
1866 }
1867 conf &= ~(1 << 8); /* clear config */
1868 conf |= clksel << 8; /* set clk */
1869 res = a_wm8978_iic_write(handle, WM8978_REG_CLOCK_GEN_CTRL, conf); /* write config */
1870 if (res != 0) /* check error */
1871 {
1872 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1873
1874 return 1; /* return error */
1875 }
1876
1877 return 0; /* success return 0 */
1878}
1879
1892{
1893 uint8_t res;
1894 uint16_t conf;
1895
1896 if (handle == NULL) /* check handle */
1897 {
1898 return 2; /* return error */
1899 }
1900 if (handle->inited != 1) /* check handle initialization */
1901 {
1902 return 3; /* return error */
1903 }
1904
1905 res = a_wm8978_iic_read(handle, WM8978_REG_CLOCK_GEN_CTRL, &conf); /* read config */
1906 if (res != 0) /* check error */
1907 {
1908 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1909
1910 return 1; /* return error */
1911 }
1912 conf &= ~(7 << 5); /* clear config */
1913 conf |= d << 5; /* set div */
1914 res = a_wm8978_iic_write(handle, WM8978_REG_CLOCK_GEN_CTRL, conf); /* write config */
1915 if (res != 0) /* check error */
1916 {
1917 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1918
1919 return 1; /* return error */
1920 }
1921
1922 return 0; /* success return 0 */
1923}
1924
1937{
1938 uint8_t res;
1939 uint16_t conf;
1940
1941 if (handle == NULL) /* check handle */
1942 {
1943 return 2; /* return error */
1944 }
1945 if (handle->inited != 1) /* check handle initialization */
1946 {
1947 return 3; /* return error */
1948 }
1949
1950 res = a_wm8978_iic_read(handle, WM8978_REG_CLOCK_GEN_CTRL, &conf); /* read config */
1951 if (res != 0) /* check error */
1952 {
1953 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1954
1955 return 1; /* return error */
1956 }
1957 conf &= ~(7 << 2); /* clear config */
1958 conf |= d << 2; /* set div */
1959 res = a_wm8978_iic_write(handle, WM8978_REG_CLOCK_GEN_CTRL, conf); /* write config */
1960 if (res != 0) /* check error */
1961 {
1962 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
1963
1964 return 1; /* return error */
1965 }
1966
1967 return 0; /* success return 0 */
1968}
1969
1982{
1983 uint8_t res;
1984 uint16_t conf;
1985
1986 if (handle == NULL) /* check handle */
1987 {
1988 return 2; /* return error */
1989 }
1990 if (handle->inited != 1) /* check handle initialization */
1991 {
1992 return 3; /* return error */
1993 }
1994
1995 res = a_wm8978_iic_read(handle, WM8978_REG_CLOCK_GEN_CTRL, &conf); /* read config */
1996 if (res != 0) /* check error */
1997 {
1998 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
1999
2000 return 1; /* return error */
2001 }
2002 conf &= ~(1 << 0); /* clear config */
2003 conf |= mode << 0; /* set mode */
2004 res = a_wm8978_iic_write(handle, WM8978_REG_CLOCK_GEN_CTRL, conf); /* write config */
2005 if (res != 0) /* check error */
2006 {
2007 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2008
2009 return 1; /* return error */
2010 }
2011
2012 return 0; /* success return 0 */
2013}
2014
2027{
2028 uint8_t res;
2029 uint16_t conf;
2030
2031 if (handle == NULL) /* check handle */
2032 {
2033 return 2; /* return error */
2034 }
2035 if (handle->inited != 1) /* check handle initialization */
2036 {
2037 return 3; /* return error */
2038 }
2039
2040 res = a_wm8978_iic_read(handle, WM8978_REG_ADDITIONAL_CTRL, &conf); /* read config */
2041 if (res != 0) /* check error */
2042 {
2043 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2044
2045 return 1; /* return error */
2046 }
2047 conf &= ~(7 << 1); /* clear config */
2048 conf |= sample << 1; /* set sample */
2049 res = a_wm8978_iic_write(handle, WM8978_REG_ADDITIONAL_CTRL, conf); /* write config */
2050 if (res != 0) /* check error */
2051 {
2052 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2053
2054 return 1; /* return error */
2055 }
2056
2057 return 0; /* success return 0 */
2058}
2059
2072{
2073 uint8_t res;
2074 uint16_t conf;
2075
2076 if (handle == NULL) /* check handle */
2077 {
2078 return 2; /* return error */
2079 }
2080 if (handle->inited != 1) /* check handle initialization */
2081 {
2082 return 3; /* return error */
2083 }
2084
2085 res = a_wm8978_iic_read(handle, WM8978_REG_ADDITIONAL_CTRL, &conf); /* read config */
2086 if (res != 0) /* check error */
2087 {
2088 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2089
2090 return 1; /* return error */
2091 }
2092 conf &= ~(1 << 0); /* clear config */
2093 conf |= enable << 0; /* set bool */
2094 res = a_wm8978_iic_write(handle, WM8978_REG_ADDITIONAL_CTRL, conf); /* write config */
2095 if (res != 0) /* check error */
2096 {
2097 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2098
2099 return 1; /* return error */
2100 }
2101
2102 return 0; /* success return 0 */
2103}
2104
2117{
2118 uint8_t res;
2119 uint16_t conf;
2120
2121 if (handle == NULL) /* check handle */
2122 {
2123 return 2; /* return error */
2124 }
2125 if (handle->inited != 1) /* check handle initialization */
2126 {
2127 return 3; /* return error */
2128 }
2129
2130 res = a_wm8978_iic_read(handle, WM8978_REG_GPIO, &conf); /* read config */
2131 if (res != 0) /* check error */
2132 {
2133 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2134
2135 return 1; /* return error */
2136 }
2137 conf &= ~(3 << 4); /* clear config */
2138 conf |= d << 4; /* set div */
2139 res = a_wm8978_iic_write(handle, WM8978_REG_GPIO, conf); /* write config */
2140 if (res != 0) /* check error */
2141 {
2142 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2143
2144 return 1; /* return error */
2145 }
2146
2147 return 0; /* success return 0 */
2148}
2149
2162{
2163 uint8_t res;
2164 uint16_t conf;
2165
2166 if (handle == NULL) /* check handle */
2167 {
2168 return 2; /* return error */
2169 }
2170 if (handle->inited != 1) /* check handle initialization */
2171 {
2172 return 3; /* return error */
2173 }
2174
2175 res = a_wm8978_iic_read(handle, WM8978_REG_GPIO, &conf); /* read config */
2176 if (res != 0) /* check error */
2177 {
2178 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2179
2180 return 1; /* return error */
2181 }
2182 conf &= ~(1 << 3); /* clear config */
2183 conf |= polarity << 3; /* set polarity */
2184 res = a_wm8978_iic_write(handle, WM8978_REG_GPIO, conf); /* write config */
2185 if (res != 0) /* check error */
2186 {
2187 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2188
2189 return 1; /* return error */
2190 }
2191
2192 return 0; /* success return 0 */
2193}
2194
2207{
2208 uint8_t res;
2209 uint16_t conf;
2210
2211 if (handle == NULL) /* check handle */
2212 {
2213 return 2; /* return error */
2214 }
2215 if (handle->inited != 1) /* check handle initialization */
2216 {
2217 return 3; /* return error */
2218 }
2219
2220 res = a_wm8978_iic_read(handle, WM8978_REG_GPIO, &conf); /* read config */
2221 if (res != 0) /* check error */
2222 {
2223 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2224
2225 return 1; /* return error */
2226 }
2227 conf &= ~(7 << 0); /* clear config */
2228 conf |= sel << 0; /* set select */
2229 res = a_wm8978_iic_write(handle, WM8978_REG_GPIO, conf); /* write config */
2230 if (res != 0) /* check error */
2231 {
2232 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2233
2234 return 1; /* return error */
2235 }
2236
2237 return 0; /* success return 0 */
2238}
2239
2252{
2253 uint8_t res;
2254 uint16_t conf;
2255
2256 if (handle == NULL) /* check handle */
2257 {
2258 return 2; /* return error */
2259 }
2260 if (handle->inited != 1) /* check handle initialization */
2261 {
2262 return 3; /* return error */
2263 }
2264
2265 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL, &conf); /* read config */
2266 if (res != 0) /* check error */
2267 {
2268 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2269
2270 return 1; /* return error */
2271 }
2272 conf &= ~(1 << 8); /* clear config */
2273 conf |= enable << 8; /* set bool */
2274 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL, conf); /* write config */
2275 if (res != 0) /* check error */
2276 {
2277 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2278
2279 return 1; /* return error */
2280 }
2281
2282 return 0; /* success return 0 */
2283}
2284
2297{
2298 uint8_t res;
2299 uint16_t conf;
2300
2301 if (handle == NULL) /* check handle */
2302 {
2303 return 2; /* return error */
2304 }
2305 if (handle->inited != 1) /* check handle initialization */
2306 {
2307 return 3; /* return error */
2308 }
2309
2310 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL, &conf); /* read config */
2311 if (res != 0) /* check error */
2312 {
2313 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2314
2315 return 1; /* return error */
2316 }
2317 conf &= ~(1 << 7); /* clear config */
2318 conf |= enable << 7; /* set bool */
2319 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL, conf); /* write config */
2320 if (res != 0) /* check error */
2321 {
2322 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2323
2324 return 1; /* return error */
2325 }
2326
2327 return 0; /* success return 0 */
2328}
2329
2342{
2343 uint8_t res;
2344 uint16_t conf;
2345
2346 if (handle == NULL) /* check handle */
2347 {
2348 return 2; /* return error */
2349 }
2350 if (handle->inited != 1) /* check handle initialization */
2351 {
2352 return 3; /* return error */
2353 }
2354
2355 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL, &conf); /* read config */
2356 if (res != 0) /* check error */
2357 {
2358 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2359
2360 return 1; /* return error */
2361 }
2362 conf &= ~(1 << 6); /* clear config */
2363 conf |= enable << 6; /* set bool */
2364 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL, conf); /* write config */
2365 if (res != 0) /* check error */
2366 {
2367 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2368
2369 return 1; /* return error */
2370 }
2371
2372 return 0; /* success return 0 */
2373}
2374
2387{
2388 uint8_t res;
2389 uint16_t conf;
2390
2391 if (handle == NULL) /* check handle */
2392 {
2393 return 2; /* return error */
2394 }
2395 if (handle->inited != 1) /* check handle initialization */
2396 {
2397 return 3; /* return error */
2398 }
2399
2400 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL, &conf); /* read config */
2401 if (res != 0) /* check error */
2402 {
2403 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2404
2405 return 1; /* return error */
2406 }
2407 conf &= ~(3 << 4); /* clear config */
2408 conf |= sel << 4; /* set sel */
2409 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL, conf); /* write config */
2410 if (res != 0) /* check error */
2411 {
2412 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2413
2414 return 1; /* return error */
2415 }
2416
2417 return 0; /* success return 0 */
2418}
2419
2432{
2433 uint8_t res;
2434 uint16_t conf;
2435
2436 if (handle == NULL) /* check handle */
2437 {
2438 return 2; /* return error */
2439 }
2440 if (handle->inited != 1) /* check handle initialization */
2441 {
2442 return 3; /* return error */
2443 }
2444
2445 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_CONTROL, &conf); /* read config */
2446 if (res != 0) /* check error */
2447 {
2448 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2449
2450 return 1; /* return error */
2451 }
2452 conf &= ~(1 << 6); /* clear config */
2453 conf |= enable << 6; /* set bool */
2454 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_CONTROL, conf); /* write config */
2455 if (res != 0) /* check error */
2456 {
2457 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2458
2459 return 1; /* return error */
2460 }
2461
2462 return 0; /* success return 0 */
2463}
2464
2477{
2478 uint8_t res;
2479 uint16_t conf;
2480
2481 if (handle == NULL) /* check handle */
2482 {
2483 return 2; /* return error */
2484 }
2485 if (handle->inited != 1) /* check handle initialization */
2486 {
2487 return 3; /* return error */
2488 }
2489
2490 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_CONTROL, &conf); /* read config */
2491 if (res != 0) /* check error */
2492 {
2493 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2494
2495 return 1; /* return error */
2496 }
2497 conf &= ~(1 << 3); /* clear config */
2498 conf |= rate << 3; /* set rate */
2499 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_CONTROL, conf); /* write config */
2500 if (res != 0) /* check error */
2501 {
2502 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2503
2504 return 1; /* return error */
2505 }
2506
2507 return 0; /* success return 0 */
2508}
2509
2522{
2523 uint8_t res;
2524 uint16_t conf;
2525
2526 if (handle == NULL) /* check handle */
2527 {
2528 return 2; /* return error */
2529 }
2530 if (handle->inited != 1) /* check handle initialization */
2531 {
2532 return 3; /* return error */
2533 }
2534
2535 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_CONTROL, &conf); /* read config */
2536 if (res != 0) /* check error */
2537 {
2538 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2539
2540 return 1; /* return error */
2541 }
2542 conf &= ~(1 << 2); /* clear config */
2543 conf |= enable << 2; /* set bool */
2544 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_CONTROL, conf); /* write config */
2545 if (res != 0) /* check error */
2546 {
2547 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2548
2549 return 1; /* return error */
2550 }
2551
2552 return 0; /* success return 0 */
2553}
2554
2567{
2568 uint8_t res;
2569 uint16_t conf;
2570
2571 if (handle == NULL) /* check handle */
2572 {
2573 return 2; /* return error */
2574 }
2575 if (handle->inited != 1) /* check handle initialization */
2576 {
2577 return 3; /* return error */
2578 }
2579
2580 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_CONTROL, &conf); /* read config */
2581 if (res != 0) /* check error */
2582 {
2583 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2584
2585 return 1; /* return error */
2586 }
2587 conf &= ~(1 << 1); /* clear config */
2588 conf |= polarity << 1; /* set polarity */
2589 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_CONTROL, conf); /* write config */
2590 if (res != 0) /* check error */
2591 {
2592 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2593
2594 return 1; /* return error */
2595 }
2596
2597 return 0; /* success return 0 */
2598}
2599
2612{
2613 uint8_t res;
2614 uint16_t conf;
2615
2616 if (handle == NULL) /* check handle */
2617 {
2618 return 2; /* return error */
2619 }
2620 if (handle->inited != 1) /* check handle initialization */
2621 {
2622 return 3; /* return error */
2623 }
2624
2625 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_CONTROL, &conf); /* read config */
2626 if (res != 0) /* check error */
2627 {
2628 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2629
2630 return 1; /* return error */
2631 }
2632 conf &= ~(1 << 0); /* clear config */
2633 conf |= polarity << 0; /* set polarity */
2634 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_CONTROL, conf); /* write config */
2635 if (res != 0) /* check error */
2636 {
2637 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2638
2639 return 1; /* return error */
2640 }
2641
2642 return 0; /* success return 0 */
2643}
2644
2657uint8_t wm8978_set_dac_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
2658{
2659 uint8_t res;
2660 uint16_t conf;
2661
2662 if (handle == NULL) /* check handle */
2663 {
2664 return 2; /* return error */
2665 }
2666 if (handle->inited != 1) /* check handle initialization */
2667 {
2668 return 3; /* return error */
2669 }
2670
2671 conf = (enable << 8) | volume; /* set volume */
2672 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_DAC_DIGITAL_VOL, conf); /* write config */
2673 if (res != 0) /* check error */
2674 {
2675 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2676
2677 return 1; /* return error */
2678 }
2679
2680 return 0; /* success return 0 */
2681}
2682
2695uint8_t wm8978_set_dac_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
2696{
2697 uint8_t res;
2698 uint16_t conf;
2699
2700 if (handle == NULL) /* check handle */
2701 {
2702 return 2; /* return error */
2703 }
2704 if (handle->inited != 1) /* check handle initialization */
2705 {
2706 return 3; /* return error */
2707 }
2708
2709 conf = (enable << 8) | volume; /* set volume */
2710 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_DAC_DIGITAL_VOL, conf); /* write config */
2711 if (res != 0) /* check error */
2712 {
2713 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2714
2715 return 1; /* return error */
2716 }
2717
2718 return 0; /* success return 0 */
2719}
2720
2734{
2735 uint8_t res;
2736 uint16_t conf;
2737
2738 if (handle == NULL) /* check handle */
2739 {
2740 return 2; /* return error */
2741 }
2742 if (handle->inited != 1) /* check handle initialization */
2743 {
2744 return 3; /* return error */
2745 }
2746
2747 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL2, &conf); /* read config */
2748 if (res != 0) /* check error */
2749 {
2750 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2751
2752 return 1; /* return error */
2753 }
2754 if (enable != 0) /* if enable */
2755 {
2756 conf |= jack << 4; /* set 1 */
2757 }
2758 else
2759 {
2760 conf &= ~(jack << 4); /* set 0 */
2761 }
2762 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL2, conf); /* write config */
2763 if (res != 0) /* check error */
2764 {
2765 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2766
2767 return 1; /* return error */
2768 }
2769
2770 return 0; /* success return 0 */
2771}
2772
2786{
2787 uint8_t res;
2788 uint16_t conf;
2789
2790 if (handle == NULL) /* check handle */
2791 {
2792 return 2; /* return error */
2793 }
2794 if (handle->inited != 1) /* check handle initialization */
2795 {
2796 return 3; /* return error */
2797 }
2798
2799 res = a_wm8978_iic_read(handle, WM8978_REG_JACK_DETECT_CONTROL2, &conf); /* read config */
2800 if (res != 0) /* check error */
2801 {
2802 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2803
2804 return 1; /* return error */
2805 }
2806 if (enable != 0) /* if enable */
2807 {
2808 conf |= jack << 0; /* set 1 */
2809 }
2810 else
2811 {
2812 conf &= ~(jack << 0); /* set 0 */
2813 }
2814 res = a_wm8978_iic_write(handle, WM8978_REG_JACK_DETECT_CONTROL2, conf); /* write config */
2815 if (res != 0) /* check error */
2816 {
2817 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2818
2819 return 1; /* return error */
2820 }
2821
2822 return 0; /* success return 0 */
2823}
2824
2837{
2838 uint8_t res;
2839 uint16_t conf;
2840
2841 if (handle == NULL) /* check handle */
2842 {
2843 return 2; /* return error */
2844 }
2845 if (handle->inited != 1) /* check handle initialization */
2846 {
2847 return 3; /* return error */
2848 }
2849
2850 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
2851 if (res != 0) /* check error */
2852 {
2853 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2854
2855 return 1; /* return error */
2856 }
2857 conf &= ~(1 << 8); /* clear config */
2858 conf |= enable << 8; /* set enable */
2859 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
2860 if (res != 0) /* check error */
2861 {
2862 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2863
2864 return 1; /* return error */
2865 }
2866
2867 return 0; /* success return 0 */
2868}
2869
2882{
2883 uint8_t res;
2884 uint16_t conf;
2885
2886 if (handle == NULL) /* check handle */
2887 {
2888 return 2; /* return error */
2889 }
2890 if (handle->inited != 1) /* check handle initialization */
2891 {
2892 return 3; /* return error */
2893 }
2894
2895 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
2896 if (res != 0) /* check error */
2897 {
2898 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2899
2900 return 1; /* return error */
2901 }
2902 conf &= ~(1 << 7); /* clear config */
2903 conf |= mode << 7; /* set mode */
2904 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
2905 if (res != 0) /* check error */
2906 {
2907 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2908
2909 return 1; /* return error */
2910 }
2911
2912 return 0; /* success return 0 */
2913}
2914
2927{
2928 uint8_t res;
2929 uint16_t conf;
2930
2931 if (handle == NULL) /* check handle */
2932 {
2933 return 2; /* return error */
2934 }
2935 if (handle->inited != 1) /* check handle initialization */
2936 {
2937 return 3; /* return error */
2938 }
2939
2940 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
2941 if (res != 0) /* check error */
2942 {
2943 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2944
2945 return 1; /* return error */
2946 }
2947 conf &= ~(7 << 4); /* clear config */
2948 conf |= cut << 4; /* set cut off */
2949 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
2950 if (res != 0) /* check error */
2951 {
2952 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2953
2954 return 1; /* return error */
2955 }
2956
2957 return 0; /* success return 0 */
2958}
2959
2972{
2973 uint8_t res;
2974 uint16_t conf;
2975
2976 if (handle == NULL) /* check handle */
2977 {
2978 return 2; /* return error */
2979 }
2980 if (handle->inited != 1) /* check handle initialization */
2981 {
2982 return 3; /* return error */
2983 }
2984
2985 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
2986 if (res != 0) /* check error */
2987 {
2988 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
2989
2990 return 1; /* return error */
2991 }
2992 conf &= ~(1 << 3); /* clear config */
2993 conf |= rate << 3; /* set rate */
2994 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
2995 if (res != 0) /* check error */
2996 {
2997 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
2998
2999 return 1; /* return error */
3000 }
3001
3002 return 0; /* success return 0 */
3003}
3004
3017{
3018 uint8_t res;
3019 uint16_t conf;
3020
3021 if (handle == NULL) /* check handle */
3022 {
3023 return 2; /* return error */
3024 }
3025 if (handle->inited != 1) /* check handle initialization */
3026 {
3027 return 3; /* return error */
3028 }
3029
3030 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
3031 if (res != 0) /* check error */
3032 {
3033 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3034
3035 return 1; /* return error */
3036 }
3037 conf &= ~(1 << 1); /* clear config */
3038 conf |= polarity << 1; /* set polarity */
3039 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
3040 if (res != 0) /* check error */
3041 {
3042 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3043
3044 return 1; /* return error */
3045 }
3046
3047 return 0; /* success return 0 */
3048}
3049
3062{
3063 uint8_t res;
3064 uint16_t conf;
3065
3066 if (handle == NULL) /* check handle */
3067 {
3068 return 2; /* return error */
3069 }
3070 if (handle->inited != 1) /* check handle initialization */
3071 {
3072 return 3; /* return error */
3073 }
3074
3075 res = a_wm8978_iic_read(handle, WM8978_REG_ADC_CONTROL, &conf); /* read config */
3076 if (res != 0) /* check error */
3077 {
3078 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3079
3080 return 1; /* return error */
3081 }
3082 conf &= ~(1 << 0); /* clear config */
3083 conf |= polarity << 0; /* set polarity */
3084 res = a_wm8978_iic_write(handle, WM8978_REG_ADC_CONTROL, conf); /* write config */
3085 if (res != 0) /* check error */
3086 {
3087 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3088
3089 return 1; /* return error */
3090 }
3091
3092 return 0; /* success return 0 */
3093}
3094
3107uint8_t wm8978_set_adc_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
3108{
3109 uint8_t res;
3110 uint16_t conf;
3111
3112 if (handle == NULL) /* check handle */
3113 {
3114 return 2; /* return error */
3115 }
3116 if (handle->inited != 1) /* check handle initialization */
3117 {
3118 return 3; /* return error */
3119 }
3120
3121 conf = (enable << 8) | volume; /* set volume */
3122 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_ADC_DIGITAL_VOL, conf); /* write config */
3123 if (res != 0) /* check error */
3124 {
3125 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3126
3127 return 1; /* return error */
3128 }
3129
3130 return 0; /* success return 0 */
3131}
3132
3145uint8_t wm8978_set_adc_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
3146{
3147 uint8_t res;
3148 uint16_t conf;
3149
3150 if (handle == NULL) /* check handle */
3151 {
3152 return 2; /* return error */
3153 }
3154 if (handle->inited != 1) /* check handle initialization */
3155 {
3156 return 3; /* return error */
3157 }
3158
3159 conf = (enable << 8) | volume; /* set volume */
3160 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_ADC_DIGITAL_VOL, conf); /* write config */
3161 if (res != 0) /* check error */
3162 {
3163 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3164
3165 return 1; /* return error */
3166 }
3167
3168 return 0; /* success return 0 */
3169}
3170
3182uint8_t wm8978_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
3183{
3184 if (handle == NULL) /* check handle */
3185 {
3186 return 2; /* return error */
3187 }
3188 if (handle->inited != 1) /* check handle initialization */
3189 {
3190 return 3; /* return error */
3191 }
3192
3193 *reg = (uint8_t)((uint8_t)(db + 127.0f) * 2 + 1); /* convert */
3194
3195 return 0; /* success return 0 */
3196}
3197
3209uint8_t wm8978_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *db)
3210{
3211 if (handle == NULL) /* check handle */
3212 {
3213 return 2; /* return error */
3214 }
3215 if (handle->inited != 1) /* check handle initialization */
3216 {
3217 return 3; /* return error */
3218 }
3219
3220 *db = -127.0f + (float)(reg - 1) * 0.5f; /* convert */
3221
3222 return 0; /* success return 0 */
3223}
3224
3237{
3238 uint8_t res;
3239 uint16_t conf;
3240
3241 if (handle == NULL) /* check handle */
3242 {
3243 return 2; /* return error */
3244 }
3245 if (handle->inited != 1) /* check handle initialization */
3246 {
3247 return 3; /* return error */
3248 }
3249
3250 res = a_wm8978_iic_read(handle, WM8978_REG_EQ1, &conf); /* read config */
3251 if (res != 0) /* check error */
3252 {
3253 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3254
3255 return 1; /* return error */
3256 }
3257 conf &= ~(1 << 8); /* clear config */
3258 conf |= equaliser << 8; /* set equaliser */
3259 res = a_wm8978_iic_write(handle, WM8978_REG_EQ1, conf); /* write config */
3260 if (res != 0) /* check error */
3261 {
3262 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3263
3264 return 1; /* return error */
3265 }
3266
3267 return 0; /* success return 0 */
3268}
3269
3282{
3283 uint8_t res;
3284 uint16_t conf;
3285
3286 if (handle == NULL) /* check handle */
3287 {
3288 return 2; /* return error */
3289 }
3290 if (handle->inited != 1) /* check handle initialization */
3291 {
3292 return 3; /* return error */
3293 }
3294
3295 res = a_wm8978_iic_read(handle, WM8978_REG_EQ1, &conf); /* read config */
3296 if (res != 0) /* check error */
3297 {
3298 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3299
3300 return 1; /* return error */
3301 }
3302 conf &= ~(3 << 5); /* clear config */
3303 conf |= cut_off << 5; /* set cut off */
3304 res = a_wm8978_iic_write(handle, WM8978_REG_EQ1, conf); /* write config */
3305 if (res != 0) /* check error */
3306 {
3307 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3308
3309 return 1; /* return error */
3310 }
3311
3312 return 0; /* success return 0 */
3313}
3314
3327uint8_t wm8978_set_eq1_gain(wm8978_handle_t *handle, uint8_t gain)
3328{
3329 uint8_t res;
3330 uint16_t conf;
3331
3332 if (handle == NULL) /* check handle */
3333 {
3334 return 2; /* return error */
3335 }
3336 if (handle->inited != 1) /* check handle initialization */
3337 {
3338 return 3; /* return error */
3339 }
3340 if (gain > 0x1F) /* check gain */
3341 {
3342 handle->debug_print("wm8978: gain > 0x1F.\n"); /* gain > 0x1F */
3343
3344 return 4; /* return error */
3345 }
3346
3347 res = a_wm8978_iic_read(handle, WM8978_REG_EQ1, &conf); /* read config */
3348 if (res != 0) /* check error */
3349 {
3350 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3351
3352 return 1; /* return error */
3353 }
3354 conf &= ~(0x1F << 0); /* clear config */
3355 conf |= gain << 0; /* set gain */
3356 res = a_wm8978_iic_write(handle, WM8978_REG_EQ1, conf); /* write config */
3357 if (res != 0) /* check error */
3358 {
3359 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3360
3361 return 1; /* return error */
3362 }
3363
3364 return 0; /* success return 0 */
3365}
3366
3379{
3380 uint8_t res;
3381 uint16_t conf;
3382
3383 if (handle == NULL) /* check handle */
3384 {
3385 return 2; /* return error */
3386 }
3387 if (handle->inited != 1) /* check handle initialization */
3388 {
3389 return 3; /* return error */
3390 }
3391
3392 res = a_wm8978_iic_read(handle, WM8978_REG_EQ2, &conf); /* read config */
3393 if (res != 0) /* check error */
3394 {
3395 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3396
3397 return 1; /* return error */
3398 }
3399 conf &= ~(1 << 8); /* clear config */
3400 conf |= width << 8; /* set width */
3401 res = a_wm8978_iic_write(handle, WM8978_REG_EQ2, conf); /* write config */
3402 if (res != 0) /* check error */
3403 {
3404 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3405
3406 return 1; /* return error */
3407 }
3408
3409 return 0; /* success return 0 */
3410}
3411
3424{
3425 uint8_t res;
3426 uint16_t conf;
3427
3428 if (handle == NULL) /* check handle */
3429 {
3430 return 2; /* return error */
3431 }
3432 if (handle->inited != 1) /* check handle initialization */
3433 {
3434 return 3; /* return error */
3435 }
3436
3437 res = a_wm8978_iic_read(handle, WM8978_REG_EQ2, &conf); /* read config */
3438 if (res != 0) /* check error */
3439 {
3440 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3441
3442 return 1; /* return error */
3443 }
3444 conf &= ~(3 << 5); /* clear config */
3445 conf |= freq << 5; /* set freq */
3446 res = a_wm8978_iic_write(handle, WM8978_REG_EQ2, conf); /* write config */
3447 if (res != 0) /* check error */
3448 {
3449 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3450
3451 return 1; /* return error */
3452 }
3453
3454 return 0; /* success return 0 */
3455}
3456
3469uint8_t wm8978_set_eq2_gain(wm8978_handle_t *handle, uint8_t gain)
3470{
3471 uint8_t res;
3472 uint16_t conf;
3473
3474 if (handle == NULL) /* check handle */
3475 {
3476 return 2; /* return error */
3477 }
3478 if (handle->inited != 1) /* check handle initialization */
3479 {
3480 return 3; /* return error */
3481 }
3482 if (gain > 0x1F) /* check gain */
3483 {
3484 handle->debug_print("wm8978: gain > 0x1F.\n"); /* gain > 0x1F */
3485
3486 return 4; /* return error */
3487 }
3488
3489 res = a_wm8978_iic_read(handle, WM8978_REG_EQ2, &conf); /* read config */
3490 if (res != 0) /* check error */
3491 {
3492 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3493
3494 return 1; /* return error */
3495 }
3496 conf &= ~(0x1F << 0); /* clear config */
3497 conf |= gain << 0; /* set gain */
3498 res = a_wm8978_iic_write(handle, WM8978_REG_EQ2, conf); /* write config */
3499 if (res != 0) /* check error */
3500 {
3501 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3502
3503 return 1; /* return error */
3504 }
3505
3506 return 0; /* success return 0 */
3507}
3508
3521{
3522 uint8_t res;
3523 uint16_t conf;
3524
3525 if (handle == NULL) /* check handle */
3526 {
3527 return 2; /* return error */
3528 }
3529 if (handle->inited != 1) /* check handle initialization */
3530 {
3531 return 3; /* return error */
3532 }
3533
3534 res = a_wm8978_iic_read(handle, WM8978_REG_EQ3, &conf); /* read config */
3535 if (res != 0) /* check error */
3536 {
3537 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3538
3539 return 1; /* return error */
3540 }
3541 conf &= ~(1 << 8); /* clear config */
3542 conf |= width << 8; /* set width */
3543 res = a_wm8978_iic_write(handle, WM8978_REG_EQ3, conf); /* write config */
3544 if (res != 0) /* check error */
3545 {
3546 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3547
3548 return 1; /* return error */
3549 }
3550
3551 return 0; /* success return 0 */
3552}
3553
3566{
3567 uint8_t res;
3568 uint16_t conf;
3569
3570 if (handle == NULL) /* check handle */
3571 {
3572 return 2; /* return error */
3573 }
3574 if (handle->inited != 1) /* check handle initialization */
3575 {
3576 return 3; /* return error */
3577 }
3578
3579 res = a_wm8978_iic_read(handle, WM8978_REG_EQ3, &conf); /* read config */
3580 if (res != 0) /* check error */
3581 {
3582 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3583
3584 return 1; /* return error */
3585 }
3586 conf &= ~(3 << 5); /* clear config */
3587 conf |= freq << 5; /* set freq */
3588 res = a_wm8978_iic_write(handle, WM8978_REG_EQ3, conf); /* write config */
3589 if (res != 0) /* check error */
3590 {
3591 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3592
3593 return 1; /* return error */
3594 }
3595
3596 return 0; /* success return 0 */
3597}
3598
3611uint8_t wm8978_set_eq3_gain(wm8978_handle_t *handle, uint8_t gain)
3612{
3613 uint8_t res;
3614 uint16_t conf;
3615
3616 if (handle == NULL) /* check handle */
3617 {
3618 return 2; /* return error */
3619 }
3620 if (handle->inited != 1) /* check handle initialization */
3621 {
3622 return 3; /* return error */
3623 }
3624 if (gain > 0x1F) /* check gain */
3625 {
3626 handle->debug_print("wm8978: gain > 0x1F.\n"); /* gain > 0x1F */
3627
3628 return 4; /* return error */
3629 }
3630
3631 res = a_wm8978_iic_read(handle, WM8978_REG_EQ3, &conf); /* read config */
3632 if (res != 0) /* check error */
3633 {
3634 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3635
3636 return 1; /* return error */
3637 }
3638 conf &= ~(0x1F << 0); /* clear config */
3639 conf |= gain << 0; /* set gain */
3640 res = a_wm8978_iic_write(handle, WM8978_REG_EQ3, conf); /* write config */
3641 if (res != 0) /* check error */
3642 {
3643 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3644
3645 return 1; /* return error */
3646 }
3647
3648 return 0; /* success return 0 */
3649}
3650
3663{
3664 uint8_t res;
3665 uint16_t conf;
3666
3667 if (handle == NULL) /* check handle */
3668 {
3669 return 2; /* return error */
3670 }
3671 if (handle->inited != 1) /* check handle initialization */
3672 {
3673 return 3; /* return error */
3674 }
3675
3676 res = a_wm8978_iic_read(handle, WM8978_REG_EQ4, &conf); /* read config */
3677 if (res != 0) /* check error */
3678 {
3679 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3680
3681 return 1; /* return error */
3682 }
3683 conf &= ~(1 << 8); /* clear config */
3684 conf |= width << 8; /* set width */
3685 res = a_wm8978_iic_write(handle, WM8978_REG_EQ4, conf); /* write config */
3686 if (res != 0) /* check error */
3687 {
3688 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3689
3690 return 1; /* return error */
3691 }
3692
3693 return 0; /* success return 0 */
3694}
3695
3708{
3709 uint8_t res;
3710 uint16_t conf;
3711
3712 if (handle == NULL) /* check handle */
3713 {
3714 return 2; /* return error */
3715 }
3716 if (handle->inited != 1) /* check handle initialization */
3717 {
3718 return 3; /* return error */
3719 }
3720
3721 res = a_wm8978_iic_read(handle, WM8978_REG_EQ4, &conf); /* read config */
3722 if (res != 0) /* check error */
3723 {
3724 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3725
3726 return 1; /* return error */
3727 }
3728 conf &= ~(3 << 5); /* clear config */
3729 conf |= freq << 5; /* set freq */
3730 res = a_wm8978_iic_write(handle, WM8978_REG_EQ4, conf); /* write config */
3731 if (res != 0) /* check error */
3732 {
3733 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3734
3735 return 1; /* return error */
3736 }
3737
3738 return 0; /* success return 0 */
3739}
3740
3753uint8_t wm8978_set_eq4_gain(wm8978_handle_t *handle, uint8_t gain)
3754{
3755 uint8_t res;
3756 uint16_t conf;
3757
3758 if (handle == NULL) /* check handle */
3759 {
3760 return 2; /* return error */
3761 }
3762 if (handle->inited != 1) /* check handle initialization */
3763 {
3764 return 3; /* return error */
3765 }
3766 if (gain > 0x1F) /* check gain */
3767 {
3768 handle->debug_print("wm8978: gain > 0x1F.\n"); /* gain > 0x1F */
3769
3770 return 4; /* return error */
3771 }
3772
3773 res = a_wm8978_iic_read(handle, WM8978_REG_EQ4, &conf); /* read config */
3774 if (res != 0) /* check error */
3775 {
3776 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3777
3778 return 1; /* return error */
3779 }
3780 conf &= ~(0x1F << 0); /* clear config */
3781 conf |= gain << 0; /* set gain */
3782 res = a_wm8978_iic_write(handle, WM8978_REG_EQ4, conf); /* write config */
3783 if (res != 0) /* check error */
3784 {
3785 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3786
3787 return 1; /* return error */
3788 }
3789
3790 return 0; /* success return 0 */
3791}
3792
3805{
3806 uint8_t res;
3807 uint16_t conf;
3808
3809 if (handle == NULL) /* check handle */
3810 {
3811 return 2; /* return error */
3812 }
3813 if (handle->inited != 1) /* check handle initialization */
3814 {
3815 return 3; /* return error */
3816 }
3817
3818 res = a_wm8978_iic_read(handle, WM8978_REG_EQ5, &conf); /* read config */
3819 if (res != 0) /* check error */
3820 {
3821 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3822
3823 return 1; /* return error */
3824 }
3825 conf &= ~(3 << 5); /* clear config */
3826 conf |= cut_off << 5; /* set cut off */
3827 res = a_wm8978_iic_write(handle, WM8978_REG_EQ5, conf); /* write config */
3828 if (res != 0) /* check error */
3829 {
3830 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3831
3832 return 1; /* return error */
3833 }
3834
3835 return 0; /* success return 0 */
3836}
3837
3850uint8_t wm8978_set_eq5_gain(wm8978_handle_t *handle, uint8_t gain)
3851{
3852 uint8_t res;
3853 uint16_t conf;
3854
3855 if (handle == NULL) /* check handle */
3856 {
3857 return 2; /* return error */
3858 }
3859 if (handle->inited != 1) /* check handle initialization */
3860 {
3861 return 3; /* return error */
3862 }
3863 if (gain > 0x1F) /* check gain */
3864 {
3865 handle->debug_print("wm8978: gain > 0x1F.\n"); /* gain > 0x1F */
3866
3867 return 4; /* return error */
3868 }
3869
3870 res = a_wm8978_iic_read(handle, WM8978_REG_EQ5, &conf); /* read config */
3871 if (res != 0) /* check error */
3872 {
3873 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3874
3875 return 1; /* return error */
3876 }
3877 conf &= ~(0x1F << 0); /* clear config */
3878 conf |= gain << 0; /* set gain */
3879 res = a_wm8978_iic_write(handle, WM8978_REG_EQ5, conf); /* write config */
3880 if (res != 0) /* check error */
3881 {
3882 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3883
3884 return 1; /* return error */
3885 }
3886
3887 return 0; /* success return 0 */
3888}
3889
3901uint8_t wm8978_eq_gain_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
3902{
3903 if (handle == NULL) /* check handle */
3904 {
3905 return 2; /* return error */
3906 }
3907 if (handle->inited != 1) /* check handle initialization */
3908 {
3909 return 3; /* return error */
3910 }
3911
3912 *reg = (uint8_t)(-db + 12); /* convert */
3913
3914 return 0; /* success return 0 */
3915}
3916
3928uint8_t wm8978_eq_gain_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
3929{
3930 if (handle == NULL) /* check handle */
3931 {
3932 return 2; /* return error */
3933 }
3934 if (handle->inited != 1) /* check handle initialization */
3935 {
3936 return 3; /* return error */
3937 }
3938
3939 *db = (int8_t)(12 - reg); /* convert */
3940
3941 return 0; /* success return 0 */
3942}
3943
3956{
3957 uint8_t res;
3958 uint16_t conf;
3959
3960 if (handle == NULL) /* check handle */
3961 {
3962 return 2; /* return error */
3963 }
3964 if (handle->inited != 1) /* check handle initialization */
3965 {
3966 return 3; /* return error */
3967 }
3968
3969 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_LIMITER_1, &conf); /* read config */
3970 if (res != 0) /* check error */
3971 {
3972 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
3973
3974 return 1; /* return error */
3975 }
3976 conf &= ~(1 << 8); /* clear config */
3977 conf |= enable << 8; /* set bool */
3978 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_LIMITER_1, conf); /* write config */
3979 if (res != 0) /* check error */
3980 {
3981 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
3982
3983 return 1; /* return error */
3984 }
3985
3986 return 0; /* success return 0 */
3987}
3988
4001{
4002 uint8_t res;
4003 uint16_t conf;
4004
4005 if (handle == NULL) /* check handle */
4006 {
4007 return 2; /* return error */
4008 }
4009 if (handle->inited != 1) /* check handle initialization */
4010 {
4011 return 3; /* return error */
4012 }
4013
4014 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_LIMITER_1, &conf); /* read config */
4015 if (res != 0) /* check error */
4016 {
4017 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4018
4019 return 1; /* return error */
4020 }
4021 conf &= ~(0xF << 4); /* clear config */
4022 conf |= decay << 4; /* set decay */
4023 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_LIMITER_1, conf); /* write config */
4024 if (res != 0) /* check error */
4025 {
4026 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4027
4028 return 1; /* return error */
4029 }
4030
4031 return 0; /* success return 0 */
4032}
4033
4046{
4047 uint8_t res;
4048 uint16_t conf;
4049
4050 if (handle == NULL) /* check handle */
4051 {
4052 return 2; /* return error */
4053 }
4054 if (handle->inited != 1) /* check handle initialization */
4055 {
4056 return 3; /* return error */
4057 }
4058
4059 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_LIMITER_1, &conf); /* read config */
4060 if (res != 0) /* check error */
4061 {
4062 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4063
4064 return 1; /* return error */
4065 }
4066 conf &= ~(0xF << 0); /* clear config */
4067 conf |= attack << 0; /* set attack */
4068 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_LIMITER_1, conf); /* write config */
4069 if (res != 0) /* check error */
4070 {
4071 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4072
4073 return 1; /* return error */
4074 }
4075
4076 return 0; /* success return 0 */
4077}
4078
4091{
4092 uint8_t res;
4093 uint16_t conf;
4094
4095 if (handle == NULL) /* check handle */
4096 {
4097 return 2; /* return error */
4098 }
4099 if (handle->inited != 1) /* check handle initialization */
4100 {
4101 return 3; /* return error */
4102 }
4103
4104 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_LIMITER_2, &conf); /* read config */
4105 if (res != 0) /* check error */
4106 {
4107 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4108
4109 return 1; /* return error */
4110 }
4111 conf &= ~(7 << 4); /* clear config */
4112 conf |= level << 4; /* set level */
4113 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_LIMITER_2, conf); /* write config */
4114 if (res != 0) /* check error */
4115 {
4116 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4117
4118 return 1; /* return error */
4119 }
4120
4121 return 0; /* success return 0 */
4122}
4123
4137{
4138 uint8_t res;
4139 uint16_t conf;
4140
4141 if (handle == NULL) /* check handle */
4142 {
4143 return 2; /* return error */
4144 }
4145 if (handle->inited != 1) /* check handle initialization */
4146 {
4147 return 3; /* return error */
4148 }
4149 if (db > 12) /* check db */
4150 {
4151 handle->debug_print("wm8978: boost > 12.\n"); /* boost > 12 */
4152
4153 return 4; /* return error */
4154 }
4155
4156 res = a_wm8978_iic_read(handle, WM8978_REG_DAC_LIMITER_2, &conf); /* read config */
4157 if (res != 0) /* check error */
4158 {
4159 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4160
4161 return 1; /* return error */
4162 }
4163 conf &= ~(0xF << 0); /* clear config */
4164 conf |= db << 0; /* set db */
4165 res = a_wm8978_iic_write(handle, WM8978_REG_DAC_LIMITER_2, conf); /* write config */
4166 if (res != 0) /* check error */
4167 {
4168 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4169
4170 return 1; /* return error */
4171 }
4172
4173 return 0; /* success return 0 */
4174}
4175
4188{
4189 uint8_t res;
4190 uint16_t conf;
4191
4192 if (handle == NULL) /* check handle */
4193 {
4194 return 2; /* return error */
4195 }
4196 if (handle->inited != 1) /* check handle initialization */
4197 {
4198 return 3; /* return error */
4199 }
4200
4201 res = a_wm8978_iic_read(handle, WM8978_REG_NOTCH_FILTER_1, &conf); /* read config */
4202 if (res != 0) /* check error */
4203 {
4204 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4205
4206 return 1; /* return error */
4207 }
4208 conf &= ~(1 << 7); /* clear config */
4209 conf |= enable << 7; /* set bool */
4210 res = a_wm8978_iic_write(handle, WM8978_REG_NOTCH_FILTER_1, conf); /* write config */
4211 if (res != 0) /* check error */
4212 {
4213 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4214
4215 return 1; /* return error */
4216 }
4217
4218 return 0; /* success return 0 */
4219}
4220
4235{
4236 uint8_t res;
4237 uint16_t conf;
4238
4239 if (handle == NULL) /* check handle */
4240 {
4241 return 2; /* return error */
4242 }
4243 if (handle->inited != 1) /* check handle initialization */
4244 {
4245 return 3; /* return error */
4246 }
4247 if (coefficient > 0x7F) /* check coefficient */
4248 {
4249 handle->debug_print("wm8978: coefficient > 0x7F.\n"); /* coefficient > 0x7F*/
4250
4251 return 4; /* return error */
4252 }
4253
4254 res = a_wm8978_iic_read(handle, WM8978_REG_NOTCH_FILTER_1, &conf); /* read config */
4255 if (res != 0) /* check error */
4256 {
4257 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4258
4259 return 1; /* return error */
4260 }
4261 conf &= ~(1 << 8); /* clear config */
4262 conf |= update_once << 8; /* set bool */
4263 conf &= ~(0x7F << 0); /* clear config */
4264 conf |= coefficient << 0; /* set coefficient */
4265 res = a_wm8978_iic_write(handle, WM8978_REG_NOTCH_FILTER_1, conf); /* write config */
4266 if (res != 0) /* check error */
4267 {
4268 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4269
4270 return 1; /* return error */
4271 }
4272
4273 return 0; /* success return 0 */
4274}
4275
4289uint8_t wm8978_set_notch_filter_a0_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
4290{
4291 uint8_t res;
4292 uint16_t conf;
4293
4294 if (handle == NULL) /* check handle */
4295 {
4296 return 2; /* return error */
4297 }
4298 if (handle->inited != 1) /* check handle initialization */
4299 {
4300 return 3; /* return error */
4301 }
4302 if (coefficient > 0x7F) /* check coefficient */
4303 {
4304 handle->debug_print("wm8978: coefficient > 0x7F.\n"); /* coefficient > 0x7F*/
4305
4306 return 4; /* return error */
4307 }
4308
4309 res = a_wm8978_iic_read(handle, WM8978_REG_NOTCH_FILTER_2, &conf); /* read config */
4310 if (res != 0) /* check error */
4311 {
4312 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4313
4314 return 1; /* return error */
4315 }
4316 conf &= ~(1 << 8); /* clear config */
4317 conf |= update_once << 8; /* set bool */
4318 conf &= ~(0x7F << 0); /* clear config */
4319 conf |= coefficient << 0; /* set coefficient */
4320 res = a_wm8978_iic_write(handle, WM8978_REG_NOTCH_FILTER_2, conf); /* write config */
4321 if (res != 0) /* check error */
4322 {
4323 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4324
4325 return 1; /* return error */
4326 }
4327
4328 return 0; /* success return 0 */
4329}
4330
4345{
4346 uint8_t res;
4347 uint16_t conf;
4348
4349 if (handle == NULL) /* check handle */
4350 {
4351 return 2; /* return error */
4352 }
4353 if (handle->inited != 1) /* check handle initialization */
4354 {
4355 return 3; /* return error */
4356 }
4357 if (coefficient > 0x7F) /* check coefficient */
4358 {
4359 handle->debug_print("wm8978: coefficient > 0x7F.\n"); /* coefficient > 0x7F*/
4360
4361 return 4; /* return error */
4362 }
4363
4364 res = a_wm8978_iic_read(handle, WM8978_REG_NOTCH_FILTER_3, &conf); /* read config */
4365 if (res != 0) /* check error */
4366 {
4367 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4368
4369 return 1; /* return error */
4370 }
4371 conf &= ~(1 << 8); /* clear config */
4372 conf |= update_once << 8; /* set bool */
4373 conf &= ~(0x7F << 0); /* clear config */
4374 conf |= coefficient << 0; /* set coefficient */
4375 res = a_wm8978_iic_write(handle, WM8978_REG_NOTCH_FILTER_3, conf); /* write config */
4376 if (res != 0) /* check error */
4377 {
4378 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4379
4380 return 1; /* return error */
4381 }
4382
4383 return 0; /* success return 0 */
4384}
4385
4399uint8_t wm8978_set_notch_filter_a1_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
4400{
4401 uint8_t res;
4402 uint16_t conf;
4403
4404 if (handle == NULL) /* check handle */
4405 {
4406 return 2; /* return error */
4407 }
4408 if (handle->inited != 1) /* check handle initialization */
4409 {
4410 return 3; /* return error */
4411 }
4412 if (coefficient > 0x7F) /* check coefficient */
4413 {
4414 handle->debug_print("wm8978: coefficient > 0x7F.\n"); /* coefficient > 0x7F*/
4415
4416 return 4; /* return error */
4417 }
4418
4419 res = a_wm8978_iic_read(handle, WM8978_REG_NOTCH_FILTER_4, &conf); /* read config */
4420 if (res != 0) /* check error */
4421 {
4422 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4423
4424 return 1; /* return error */
4425 }
4426 conf &= ~(1 << 8); /* clear config */
4427 conf |= update_once << 8; /* set bool */
4428 conf &= ~(0x7F << 0); /* clear config */
4429 conf |= coefficient << 0; /* set coefficient */
4430 res = a_wm8978_iic_write(handle, WM8978_REG_NOTCH_FILTER_4, conf); /* write config */
4431 if (res != 0) /* check error */
4432 {
4433 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4434
4435 return 1; /* return error */
4436 }
4437
4438 return 0; /* success return 0 */
4439}
4440
4453{
4454 uint8_t res;
4455 uint16_t conf;
4456
4457 if (handle == NULL) /* check handle */
4458 {
4459 return 2; /* return error */
4460 }
4461 if (handle->inited != 1) /* check handle initialization */
4462 {
4463 return 3; /* return error */
4464 }
4465
4466 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_1, &conf); /* read config */
4467 if (res != 0) /* check error */
4468 {
4469 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4470
4471 return 1; /* return error */
4472 }
4473 conf &= ~(3 << 7); /* clear config */
4474 conf |= alc << 7; /* set alc */
4475 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_1, conf); /* write config */
4476 if (res != 0) /* check error */
4477 {
4478 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4479
4480 return 1; /* return error */
4481 }
4482
4483 return 0; /* success return 0 */
4484}
4485
4498{
4499 uint8_t res;
4500 uint16_t conf;
4501
4502 if (handle == NULL) /* check handle */
4503 {
4504 return 2; /* return error */
4505 }
4506 if (handle->inited != 1) /* check handle initialization */
4507 {
4508 return 3; /* return error */
4509 }
4510
4511 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_1, &conf); /* read config */
4512 if (res != 0) /* check error */
4513 {
4514 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4515
4516 return 1; /* return error */
4517 }
4518 conf &= ~(7 << 3); /* clear config */
4519 conf |= gain << 3; /* set gain */
4520 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_1, conf); /* write config */
4521 if (res != 0) /* check error */
4522 {
4523 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4524
4525 return 1; /* return error */
4526 }
4527
4528 return 0; /* success return 0 */
4529}
4530
4543{
4544 uint8_t res;
4545 uint16_t conf;
4546
4547 if (handle == NULL) /* check handle */
4548 {
4549 return 2; /* return error */
4550 }
4551 if (handle->inited != 1) /* check handle initialization */
4552 {
4553 return 3; /* return error */
4554 }
4555
4556 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_1, &conf); /* read config */
4557 if (res != 0) /* check error */
4558 {
4559 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4560
4561 return 1; /* return error */
4562 }
4563 conf &= ~(7 << 0); /* clear config */
4564 conf |= gain << 0; /* set gain */
4565 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_1, conf); /* write config */
4566 if (res != 0) /* check error */
4567 {
4568 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4569
4570 return 1; /* return error */
4571 }
4572
4573 return 0; /* success return 0 */
4574}
4575
4589{
4590 uint8_t res;
4591 uint16_t conf;
4592
4593 if (handle == NULL) /* check handle */
4594 {
4595 return 2; /* return error */
4596 }
4597 if (handle->inited != 1) /* check handle initialization */
4598 {
4599 return 3; /* return error */
4600 }
4601 if (t > 0xF) /* check t */
4602 {
4603 handle->debug_print("wm8978: t > 0xF.\n"); /* t > 0xF */
4604
4605 return 4; /* return error */
4606 }
4607
4608 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_2, &conf); /* read config */
4609 if (res != 0) /* check error */
4610 {
4611 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4612
4613 return 1; /* return error */
4614 }
4615 conf &= ~(0xF << 4); /* clear config */
4616 conf |= t << 4; /* set time */
4617 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_2, conf); /* write config */
4618 if (res != 0) /* check error */
4619 {
4620 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4621
4622 return 1; /* return error */
4623 }
4624
4625 return 0; /* success return 0 */
4626}
4627
4639uint8_t wm8978_alc_hold_time_convert_to_register(wm8978_handle_t *handle, float ms, uint8_t *reg)
4640{
4641 if (handle == NULL) /* check handle */
4642 {
4643 return 2; /* return error */
4644 }
4645 if (handle->inited != 1) /* check handle initialization */
4646 {
4647 return 3; /* return error */
4648 }
4649
4650 *reg = (uint8_t)(ms / 2.67f); /* convert */
4651
4652 return 0; /* success return 0 */
4653}
4654
4666uint8_t wm8978_alc_hold_time_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *ms)
4667{
4668 if (handle == NULL) /* check handle */
4669 {
4670 return 2; /* return error */
4671 }
4672 if (handle->inited != 1) /* check handle initialization */
4673 {
4674 return 3; /* return error */
4675 }
4676
4677 *ms = (float)(reg * 2.67f); /* convert */
4678
4679 return 0; /* success return 0 */
4680}
4681
4694{
4695 uint8_t res;
4696 uint16_t conf;
4697
4698 if (handle == NULL) /* check handle */
4699 {
4700 return 2; /* return error */
4701 }
4702 if (handle->inited != 1) /* check handle initialization */
4703 {
4704 return 3; /* return error */
4705 }
4706
4707 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_2, &conf); /* read config */
4708 if (res != 0) /* check error */
4709 {
4710 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4711
4712 return 1; /* return error */
4713 }
4714 conf &= ~(0xF << 0); /* clear config */
4715 conf |= level << 0; /* set level */
4716 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_2, conf); /* write config */
4717 if (res != 0) /* check error */
4718 {
4719 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4720
4721 return 1; /* return error */
4722 }
4723
4724 return 0; /* success return 0 */
4725}
4726
4739{
4740 uint8_t res;
4741 uint16_t conf;
4742
4743 if (handle == NULL) /* check handle */
4744 {
4745 return 2; /* return error */
4746 }
4747 if (handle->inited != 1) /* check handle initialization */
4748 {
4749 return 3; /* return error */
4750 }
4751
4752 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_3, &conf); /* read config */
4753 if (res != 0) /* check error */
4754 {
4755 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4756
4757 return 1; /* return error */
4758 }
4759 conf &= ~(1 << 8); /* clear config */
4760 conf |= mode << 8; /* set mode */
4761 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_3, conf); /* write config */
4762 if (res != 0) /* check error */
4763 {
4764 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4765
4766 return 1; /* return error */
4767 }
4768
4769 return 0; /* success return 0 */
4770}
4771
4784uint8_t wm8978_set_alc_decay(wm8978_handle_t *handle, uint8_t decay)
4785{
4786 uint8_t res;
4787 uint16_t conf;
4788
4789 if (handle == NULL) /* check handle */
4790 {
4791 return 2; /* return error */
4792 }
4793 if (handle->inited != 1) /* check handle initialization */
4794 {
4795 return 3; /* return error */
4796 }
4797 if (decay > 0xF) /* check decay */
4798 {
4799 handle->debug_print("wm8978: decay > 0xF.\n"); /* decay > 0xF */
4800
4801 return 4; /* return error */
4802 }
4803
4804 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_3, &conf); /* read config */
4805 if (res != 0) /* check error */
4806 {
4807 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4808
4809 return 1; /* return error */
4810 }
4811 conf &= ~(0xF << 4); /* clear config */
4812 conf |= decay << 4; /* set decay */
4813 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_3, conf); /* write config */
4814 if (res != 0) /* check error */
4815 {
4816 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4817
4818 return 1; /* return error */
4819 }
4820
4821 return 0; /* success return 0 */
4822}
4823
4836uint8_t wm8978_set_alc_attack(wm8978_handle_t *handle, uint8_t attack)
4837{
4838 uint8_t res;
4839 uint16_t conf;
4840
4841 if (handle == NULL) /* check handle */
4842 {
4843 return 2; /* return error */
4844 }
4845 if (handle->inited != 1) /* check handle initialization */
4846 {
4847 return 3; /* return error */
4848 }
4849 if (attack > 0xF) /* check attack */
4850 {
4851 handle->debug_print("wm8978: attack > 0xF.\n"); /* attack > 0xF */
4852
4853 return 4; /* return error */
4854 }
4855
4856 res = a_wm8978_iic_read(handle, WM8978_REG_ALC_CONTROL_3, &conf); /* read config */
4857 if (res != 0) /* check error */
4858 {
4859 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4860
4861 return 1; /* return error */
4862 }
4863 conf &= ~(0xF << 0); /* clear config */
4864 conf |= attack << 0; /* set attack */
4865 res = a_wm8978_iic_write(handle, WM8978_REG_ALC_CONTROL_3, conf); /* write config */
4866 if (res != 0) /* check error */
4867 {
4868 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4869
4870 return 1; /* return error */
4871 }
4872
4873 return 0; /* success return 0 */
4874}
4875
4888{
4889 uint8_t res;
4890 uint16_t conf;
4891
4892 if (handle == NULL) /* check handle */
4893 {
4894 return 2; /* return error */
4895 }
4896 if (handle->inited != 1) /* check handle initialization */
4897 {
4898 return 3; /* return error */
4899 }
4900
4901 res = a_wm8978_iic_read(handle, WM8978_REG_NOISE_GATE, &conf); /* read config */
4902 if (res != 0) /* check error */
4903 {
4904 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4905
4906 return 1; /* return error */
4907 }
4908 conf &= ~(1 << 3); /* clear config */
4909 conf |= enable << 3; /* set bool */
4910 res = a_wm8978_iic_write(handle, WM8978_REG_NOISE_GATE, conf); /* write config */
4911 if (res != 0) /* check error */
4912 {
4913 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4914
4915 return 1; /* return error */
4916 }
4917
4918 return 0; /* success return 0 */
4919}
4920
4933uint8_t wm8978_set_alc_noise_gate_threshold(wm8978_handle_t *handle, uint8_t threshold)
4934{
4935 uint8_t res;
4936 uint16_t conf;
4937
4938 if (handle == NULL) /* check handle */
4939 {
4940 return 2; /* return error */
4941 }
4942 if (handle->inited != 1) /* check handle initialization */
4943 {
4944 return 3; /* return error */
4945 }
4946 if (threshold > 0x7) /* check threshold */
4947 {
4948 handle->debug_print("wm8978: threshold > 0x7.\n"); /* threshold > 0x7 */
4949
4950 return 4; /* return error */
4951 }
4952
4953 res = a_wm8978_iic_read(handle, WM8978_REG_NOISE_GATE, &conf); /* read config */
4954 if (res != 0) /* check error */
4955 {
4956 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
4957
4958 return 1; /* return error */
4959 }
4960 conf &= ~(7 << 0); /* clear config */
4961 conf |= threshold << 0; /* set threshold */
4962 res = a_wm8978_iic_write(handle, WM8978_REG_NOISE_GATE, conf); /* write config */
4963 if (res != 0) /* check error */
4964 {
4965 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
4966
4967 return 1; /* return error */
4968 }
4969
4970 return 0; /* success return 0 */
4971}
4972
4985{
4986 if (handle == NULL) /* check handle */
4987 {
4988 return 2; /* return error */
4989 }
4990 if (handle->inited != 1) /* check handle initialization */
4991 {
4992 return 3; /* return error */
4993 }
4994
4995 *reg = (uint8_t)((db + 39) / (-6)); /* convert */
4996
4997 return 0; /* success return 0 */
4998}
4999
5012{
5013 if (handle == NULL) /* check handle */
5014 {
5015 return 2; /* return error */
5016 }
5017 if (handle->inited != 1) /* check handle initialization */
5018 {
5019 return 3; /* return error */
5020 }
5021
5022 *db = (int8_t)(reg * (-6) - 39); /* convert */
5023
5024 return 0; /* success return 0 */
5025}
5026
5039{
5040 uint8_t res;
5041 uint16_t conf;
5042
5043 if (handle == NULL) /* check handle */
5044 {
5045 return 2; /* return error */
5046 }
5047 if (handle->inited != 1) /* check handle initialization */
5048 {
5049 return 3; /* return error */
5050 }
5051
5052 res = a_wm8978_iic_read(handle, WM8978_REG_PLL_N, &conf); /* read config */
5053 if (res != 0) /* check error */
5054 {
5055 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5056
5057 return 1; /* return error */
5058 }
5059 conf &= ~(1 << 4); /* clear config */
5060 conf |= enable << 4; /* set bool */
5061 res = a_wm8978_iic_write(handle, WM8978_REG_PLL_N, conf); /* write config */
5062 if (res != 0) /* check error */
5063 {
5064 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5065
5066 return 1; /* return error */
5067 }
5068
5069 return 0; /* success return 0 */
5070}
5071
5084uint8_t wm8978_set_plln(wm8978_handle_t *handle, uint8_t n)
5085{
5086 uint8_t res;
5087 uint16_t conf;
5088
5089 if (handle == NULL) /* check handle */
5090 {
5091 return 2; /* return error */
5092 }
5093 if (handle->inited != 1) /* check handle initialization */
5094 {
5095 return 3; /* return error */
5096 }
5097 if (n > 0xF) /* check n */
5098 {
5099 handle->debug_print("wm8978: n > 0xF.\n"); /* n > 0xF */
5100
5101 return 4; /* return error */
5102 }
5103
5104 res = a_wm8978_iic_read(handle, WM8978_REG_PLL_N, &conf); /* read config */
5105 if (res != 0) /* check error */
5106 {
5107 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5108
5109 return 1; /* return error */
5110 }
5111 conf &= ~(0xF << 0); /* clear config */
5112 conf |= n << 0; /* set plln */
5113 res = a_wm8978_iic_write(handle, WM8978_REG_PLL_N, conf); /* write config */
5114 if (res != 0) /* check error */
5115 {
5116 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5117
5118 return 1; /* return error */
5119 }
5120
5121 return 0; /* success return 0 */
5122}
5123
5135uint8_t wm8978_set_pll_freq(wm8978_handle_t *handle, uint32_t freq)
5136{
5137 uint8_t res;
5138 uint16_t conf;
5139
5140 if (handle == NULL) /* check handle */
5141 {
5142 return 2; /* return error */
5143 }
5144 if (handle->inited != 1) /* check handle initialization */
5145 {
5146 return 3; /* return error */
5147 }
5148
5149 conf = (freq >> 0) & 0x1FF; /* set freq */
5150 res = a_wm8978_iic_write(handle, WM8978_REG_PLL_K3, conf); /* write config */
5151 if (res != 0) /* check error */
5152 {
5153 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5154
5155 return 1; /* return error */
5156 }
5157 conf = (freq >> 9) & 0x1FF; /* set freq */
5158 res = a_wm8978_iic_write(handle, WM8978_REG_PLL_K2, conf); /* write config */
5159 if (res != 0) /* check error */
5160 {
5161 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5162
5163 return 1; /* return error */
5164 }
5165 conf = (freq >> 18) & 0x3F; /* set freq */
5166 res = a_wm8978_iic_write(handle, WM8978_REG_PLL_K1, conf); /* write config */
5167 if (res != 0) /* check error */
5168 {
5169 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5170
5171 return 1; /* return error */
5172 }
5173
5174 return 0; /* success return 0 */
5175}
5176
5189uint8_t wm8978_set_depth_3d(wm8978_handle_t *handle, uint8_t depth)
5190{
5191 uint8_t res;
5192 uint16_t conf;
5193
5194 if (handle == NULL) /* check handle */
5195 {
5196 return 2; /* return error */
5197 }
5198 if (handle->inited != 1) /* check handle initialization */
5199 {
5200 return 3; /* return error */
5201 }
5202 if (depth > 0xF) /* check depth */
5203 {
5204 handle->debug_print("wm8978: depth > 0xF.\n"); /* depth > 0xF */
5205
5206 return 4; /* return error */
5207 }
5208
5209 res = a_wm8978_iic_read(handle, WM8978_REG_3D_CONTROL, &conf); /* read config */
5210 if (res != 0) /* check error */
5211 {
5212 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5213
5214 return 1; /* return error */
5215 }
5216 conf &= ~(0xF << 0); /* clear config */
5217 conf |= depth << 0; /* set depth */
5218 res = a_wm8978_iic_write(handle, WM8978_REG_3D_CONTROL, conf); /* write config */
5219 if (res != 0) /* check error */
5220 {
5221 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5222
5223 return 1; /* return error */
5224 }
5225
5226 return 0; /* success return 0 */
5227}
5228
5240uint8_t wm8978_depth_3d_convert_to_register(wm8978_handle_t *handle, float percent, uint8_t *reg)
5241{
5242 if (handle == NULL) /* check handle */
5243 {
5244 return 2; /* return error */
5245 }
5246 if (handle->inited != 1) /* check handle initialization */
5247 {
5248 return 3; /* return error */
5249 }
5250
5251 *reg = (uint8_t)(percent / 6.67f); /* convert */
5252
5253 return 0; /* success return 0 */
5254}
5255
5267uint8_t wm8978_depth_3d_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *percent)
5268{
5269 if (handle == NULL) /* check handle */
5270 {
5271 return 2; /* return error */
5272 }
5273 if (handle->inited != 1) /* check handle initialization */
5274 {
5275 return 3; /* return error */
5276 }
5277
5278 *percent = (float)(reg) * 6.67f; /* convert */
5279
5280 return 0; /* success return 0 */
5281}
5282
5295{
5296 uint8_t res;
5297 uint16_t conf;
5298
5299 if (handle == NULL) /* check handle */
5300 {
5301 return 2; /* return error */
5302 }
5303 if (handle->inited != 1) /* check handle initialization */
5304 {
5305 return 3; /* return error */
5306 }
5307
5308 res = a_wm8978_iic_read(handle, WM8978_REG_BEEP_CONTROL, &conf); /* read config */
5309 if (res != 0) /* check error */
5310 {
5311 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5312
5313 return 1; /* return error */
5314 }
5315 conf &= ~(1 << 5); /* clear config */
5316 conf |= enable << 5; /* set enable */
5317 res = a_wm8978_iic_write(handle, WM8978_REG_BEEP_CONTROL, conf); /* write config */
5318 if (res != 0) /* check error */
5319 {
5320 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5321
5322 return 1; /* return error */
5323 }
5324
5325 return 0; /* success return 0 */
5326}
5327
5340{
5341 uint8_t res;
5342 uint16_t conf;
5343
5344 if (handle == NULL) /* check handle */
5345 {
5346 return 2; /* return error */
5347 }
5348 if (handle->inited != 1) /* check handle initialization */
5349 {
5350 return 3; /* return error */
5351 }
5352
5353 res = a_wm8978_iic_read(handle, WM8978_REG_BEEP_CONTROL, &conf); /* read config */
5354 if (res != 0) /* check error */
5355 {
5356 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5357
5358 return 1; /* return error */
5359 }
5360 conf &= ~(1 << 4); /* clear config */
5361 conf |= enable << 4; /* set enable */
5362 res = a_wm8978_iic_write(handle, WM8978_REG_BEEP_CONTROL, conf); /* write config */
5363 if (res != 0) /* check error */
5364 {
5365 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5366
5367 return 1; /* return error */
5368 }
5369
5370 return 0; /* success return 0 */
5371}
5372
5385uint8_t wm8978_set_beep_volume(wm8978_handle_t *handle, uint8_t vol)
5386{
5387 uint8_t res;
5388 uint16_t conf;
5389
5390 if (handle == NULL) /* check handle */
5391 {
5392 return 2; /* return error */
5393 }
5394 if (handle->inited != 1) /* check handle initialization */
5395 {
5396 return 3; /* return error */
5397 }
5398 if (vol > 0x7) /* check vol */
5399 {
5400 handle->debug_print("wm8978: vol > 0x7.\n"); /* vol > 0x7 */
5401
5402 return 4; /* return error */
5403 }
5404
5405 res = a_wm8978_iic_read(handle, WM8978_REG_BEEP_CONTROL, &conf); /* read config */
5406 if (res != 0) /* check error */
5407 {
5408 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5409
5410 return 1; /* return error */
5411 }
5412 conf &= ~(7 << 1); /* clear config */
5413 conf |= vol << 1; /* set vol */
5414 res = a_wm8978_iic_write(handle, WM8978_REG_BEEP_CONTROL, conf); /* write config */
5415 if (res != 0) /* check error */
5416 {
5417 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5418
5419 return 1; /* return error */
5420 }
5421
5422 return 0; /* success return 0 */
5423}
5424
5436uint8_t wm8978_beep_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
5437{
5438 if (handle == NULL) /* check handle */
5439 {
5440 return 2; /* return error */
5441 }
5442 if (handle->inited != 1) /* check handle initialization */
5443 {
5444 return 3; /* return error */
5445 }
5446
5447 *reg = (uint8_t)(db + 15) / 3; /* convert */
5448
5449 return 0; /* success return 0 */
5450}
5451
5463uint8_t wm8978_beep_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
5464{
5465 if (handle == NULL) /* check handle */
5466 {
5467 return 2; /* return error */
5468 }
5469 if (handle->inited != 1) /* check handle initialization */
5470 {
5471 return 3; /* return error */
5472 }
5473
5474 *db = (int8_t)(reg * 3 - 15); /* convert */
5475
5476 return 0; /* success return 0 */
5477}
5478
5491{
5492 uint8_t res;
5493 uint16_t conf;
5494
5495 if (handle == NULL) /* check handle */
5496 {
5497 return 2; /* return error */
5498 }
5499 if (handle->inited != 1) /* check handle initialization */
5500 {
5501 return 3; /* return error */
5502 }
5503
5504 res = a_wm8978_iic_read(handle, WM8978_REG_BEEP_CONTROL, &conf); /* read config */
5505 if (res != 0) /* check error */
5506 {
5507 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5508
5509 return 1; /* return error */
5510 }
5511 conf &= ~(1 << 0); /* clear config */
5512 conf |= enable << 0; /* set enable */
5513 res = a_wm8978_iic_write(handle, WM8978_REG_BEEP_CONTROL, conf); /* write config */
5514 if (res != 0) /* check error */
5515 {
5516 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5517
5518 return 1; /* return error */
5519 }
5520
5521 return 0; /* success return 0 */
5522}
5523
5536{
5537 uint8_t res;
5538 uint16_t conf;
5539
5540 if (handle == NULL) /* check handle */
5541 {
5542 return 2; /* return error */
5543 }
5544 if (handle->inited != 1) /* check handle initialization */
5545 {
5546 return 3; /* return error */
5547 }
5548
5549 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5550 if (res != 0) /* check error */
5551 {
5552 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5553
5554 return 1; /* return error */
5555 }
5556 conf &= ~(1 << 8); /* clear config */
5557 conf |= avdd << 8; /* set avdd */
5558 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5559 if (res != 0) /* check error */
5560 {
5561 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5562
5563 return 1; /* return error */
5564 }
5565
5566 return 0; /* success return 0 */
5567}
5568
5581{
5582 uint8_t res;
5583 uint16_t conf;
5584
5585 if (handle == NULL) /* check handle */
5586 {
5587 return 2; /* return error */
5588 }
5589 if (handle->inited != 1) /* check handle initialization */
5590 {
5591 return 3; /* return error */
5592 }
5593
5594 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5595 if (res != 0) /* check error */
5596 {
5597 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5598
5599 return 1; /* return error */
5600 }
5601 conf &= ~(1 << 6); /* clear config */
5602 conf |= enable << 6; /* set bool */
5603 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5604 if (res != 0) /* check error */
5605 {
5606 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5607
5608 return 1; /* return error */
5609 }
5610
5611 return 0; /* success return 0 */
5612}
5613
5626{
5627 uint8_t res;
5628 uint16_t conf;
5629
5630 if (handle == NULL) /* check handle */
5631 {
5632 return 2; /* return error */
5633 }
5634 if (handle->inited != 1) /* check handle initialization */
5635 {
5636 return 3; /* return error */
5637 }
5638
5639 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5640 if (res != 0) /* check error */
5641 {
5642 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5643
5644 return 1; /* return error */
5645 }
5646 conf &= ~(1 << 5); /* clear config */
5647 conf |= enable << 5; /* set bool */
5648 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5649 if (res != 0) /* check error */
5650 {
5651 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5652
5653 return 1; /* return error */
5654 }
5655
5656 return 0; /* success return 0 */
5657}
5658
5671{
5672 uint8_t res;
5673 uint16_t conf;
5674
5675 if (handle == NULL) /* check handle */
5676 {
5677 return 2; /* return error */
5678 }
5679 if (handle->inited != 1) /* check handle initialization */
5680 {
5681 return 3; /* return error */
5682 }
5683
5684 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5685 if (res != 0) /* check error */
5686 {
5687 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5688
5689 return 1; /* return error */
5690 }
5691 conf &= ~(1 << 4); /* clear config */
5692 conf |= enable << 4; /* set bool */
5693 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5694 if (res != 0) /* check error */
5695 {
5696 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5697
5698 return 1; /* return error */
5699 }
5700
5701 return 0; /* success return 0 */
5702}
5703
5716{
5717 uint8_t res;
5718 uint16_t conf;
5719
5720 if (handle == NULL) /* check handle */
5721 {
5722 return 2; /* return error */
5723 }
5724 if (handle->inited != 1) /* check handle initialization */
5725 {
5726 return 3; /* return error */
5727 }
5728
5729 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5730 if (res != 0) /* check error */
5731 {
5732 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5733
5734 return 1; /* return error */
5735 }
5736 conf &= ~(1 << 2); /* clear config */
5737 conf |= enable << 2; /* set bool */
5738 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5739 if (res != 0) /* check error */
5740 {
5741 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5742
5743 return 1; /* return error */
5744 }
5745
5746 return 0; /* success return 0 */
5747}
5748
5761{
5762 uint8_t res;
5763 uint16_t conf;
5764
5765 if (handle == NULL) /* check handle */
5766 {
5767 return 2; /* return error */
5768 }
5769 if (handle->inited != 1) /* check handle initialization */
5770 {
5771 return 3; /* return error */
5772 }
5773
5774 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5775 if (res != 0) /* check error */
5776 {
5777 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5778
5779 return 1; /* return error */
5780 }
5781 conf &= ~(1 << 1); /* clear config */
5782 conf |= enable << 1; /* set bool */
5783 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5784 if (res != 0) /* check error */
5785 {
5786 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5787
5788 return 1; /* return error */
5789 }
5790
5791 return 0; /* success return 0 */
5792}
5793
5806{
5807 uint8_t res;
5808 uint16_t conf;
5809
5810 if (handle == NULL) /* check handle */
5811 {
5812 return 2; /* return error */
5813 }
5814 if (handle->inited != 1) /* check handle initialization */
5815 {
5816 return 3; /* return error */
5817 }
5818
5819 res = a_wm8978_iic_read(handle, WM8978_REG_INPUT_CTRL, &conf); /* read config */
5820 if (res != 0) /* check error */
5821 {
5822 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5823
5824 return 1; /* return error */
5825 }
5826 conf &= ~(1 << 0); /* clear config */
5827 conf |= enable << 0; /* set bool */
5828 res = a_wm8978_iic_write(handle, WM8978_REG_INPUT_CTRL, conf); /* write config */
5829 if (res != 0) /* check error */
5830 {
5831 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5832
5833 return 1; /* return error */
5834 }
5835
5836 return 0; /* success return 0 */
5837}
5838
5851{
5852 uint8_t res;
5853 uint16_t conf;
5854
5855 if (handle == NULL) /* check handle */
5856 {
5857 return 2; /* return error */
5858 }
5859 if (handle->inited != 1) /* check handle initialization */
5860 {
5861 return 3; /* return error */
5862 }
5863
5864 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_INP_PGA_CTRL, &conf); /* read config */
5865 if (res != 0) /* check error */
5866 {
5867 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5868
5869 return 1; /* return error */
5870 }
5871 conf &= ~(1 << 8); /* clear config */
5872 conf |= enable << 8; /* set bool */
5873 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_INP_PGA_CTRL, conf); /* write config */
5874 if (res != 0) /* check error */
5875 {
5876 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5877
5878 return 1; /* return error */
5879 }
5880
5881 return 0; /* success return 0 */
5882}
5883
5896{
5897 uint8_t res;
5898 uint16_t conf;
5899
5900 if (handle == NULL) /* check handle */
5901 {
5902 return 2; /* return error */
5903 }
5904 if (handle->inited != 1) /* check handle initialization */
5905 {
5906 return 3; /* return error */
5907 }
5908
5909 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_INP_PGA_CTRL, &conf); /* read config */
5910 if (res != 0) /* check error */
5911 {
5912 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5913
5914 return 1; /* return error */
5915 }
5916 conf &= ~(1 << 7); /* clear config */
5917 conf |= enable << 7; /* set bool */
5918 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_INP_PGA_CTRL, conf); /* write config */
5919 if (res != 0) /* check error */
5920 {
5921 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5922
5923 return 1; /* return error */
5924 }
5925
5926 return 0; /* success return 0 */
5927}
5928
5941{
5942 uint8_t res;
5943 uint16_t conf;
5944
5945 if (handle == NULL) /* check handle */
5946 {
5947 return 2; /* return error */
5948 }
5949 if (handle->inited != 1) /* check handle initialization */
5950 {
5951 return 3; /* return error */
5952 }
5953
5954 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_INP_PGA_CTRL, &conf); /* read config */
5955 if (res != 0) /* check error */
5956 {
5957 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
5958
5959 return 1; /* return error */
5960 }
5961 conf &= ~(1 << 6); /* clear config */
5962 conf |= enable << 6; /* set bool */
5963 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_INP_PGA_CTRL, conf); /* write config */
5964 if (res != 0) /* check error */
5965 {
5966 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
5967
5968 return 1; /* return error */
5969 }
5970
5971 return 0; /* success return 0 */
5972}
5973
5987{
5988 uint8_t res;
5989 uint16_t conf;
5990
5991 if (handle == NULL) /* check handle */
5992 {
5993 return 2; /* return error */
5994 }
5995 if (handle->inited != 1) /* check handle initialization */
5996 {
5997 return 3; /* return error */
5998 }
5999 if (volume > 0x3F) /* check volume */
6000 {
6001 handle->debug_print("wm8978: volume > 0x3F.\n"); /* volume > 0x3F */
6002
6003 return 4; /* return error */
6004 }
6005
6006 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_INP_PGA_CTRL, &conf); /* read config */
6007 if (res != 0) /* check error */
6008 {
6009 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6010
6011 return 1; /* return error */
6012 }
6013 conf &= ~(0x3F << 0); /* clear config */
6014 conf |= volume << 0; /* set volume */
6015 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_INP_PGA_CTRL, conf); /* write config */
6016 if (res != 0) /* check error */
6017 {
6018 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6019
6020 return 1; /* return error */
6021 }
6022
6023 return 0; /* success return 0 */
6024}
6025
6038{
6039 if (handle == NULL) /* check handle */
6040 {
6041 return 2; /* return error */
6042 }
6043 if (handle->inited != 1) /* check handle initialization */
6044 {
6045 return 3; /* return error */
6046 }
6047
6048 *reg = (uint8_t)((db + 12.0f) / 0.75f); /* convert */
6049
6050 return 0; /* success return 0 */
6051}
6052
6065{
6066 if (handle == NULL) /* check handle */
6067 {
6068 return 2; /* return error */
6069 }
6070 if (handle->inited != 1) /* check handle initialization */
6071 {
6072 return 3; /* return error */
6073 }
6074
6075 *db = (float)(reg) * 0.75f - 12.0f; /* convert */
6076
6077 return 0; /* success return 0 */
6078}
6079
6092{
6093 uint8_t res;
6094 uint16_t conf;
6095
6096 if (handle == NULL) /* check handle */
6097 {
6098 return 2; /* return error */
6099 }
6100 if (handle->inited != 1) /* check handle initialization */
6101 {
6102 return 3; /* return error */
6103 }
6104
6105 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, &conf); /* read config */
6106 if (res != 0) /* check error */
6107 {
6108 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6109
6110 return 1; /* return error */
6111 }
6112 conf &= ~(1 << 8); /* clear config */
6113 conf |= enable << 8; /* set bool */
6114 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, conf); /* write config */
6115 if (res != 0) /* check error */
6116 {
6117 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6118
6119 return 1; /* return error */
6120 }
6121
6122 return 0; /* success return 0 */
6123}
6124
6137{
6138 uint8_t res;
6139 uint16_t conf;
6140
6141 if (handle == NULL) /* check handle */
6142 {
6143 return 2; /* return error */
6144 }
6145 if (handle->inited != 1) /* check handle initialization */
6146 {
6147 return 3; /* return error */
6148 }
6149
6150 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, &conf); /* read config */
6151 if (res != 0) /* check error */
6152 {
6153 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6154
6155 return 1; /* return error */
6156 }
6157 conf &= ~(1 << 7); /* clear config */
6158 conf |= enable << 7; /* set bool */
6159 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, conf); /* write config */
6160 if (res != 0) /* check error */
6161 {
6162 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6163
6164 return 1; /* return error */
6165 }
6166
6167 return 0; /* success return 0 */
6168}
6169
6182{
6183 uint8_t res;
6184 uint16_t conf;
6185
6186 if (handle == NULL) /* check handle */
6187 {
6188 return 2; /* return error */
6189 }
6190 if (handle->inited != 1) /* check handle initialization */
6191 {
6192 return 3; /* return error */
6193 }
6194
6195 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, &conf); /* read config */
6196 if (res != 0) /* check error */
6197 {
6198 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6199
6200 return 1; /* return error */
6201 }
6202 conf &= ~(1 << 6); /* clear config */
6203 conf |= enable << 6; /* set bool */
6204 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, conf); /* write config */
6205 if (res != 0) /* check error */
6206 {
6207 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6208
6209 return 1; /* return error */
6210 }
6211
6212 return 0; /* success return 0 */
6213}
6214
6228{
6229 uint8_t res;
6230 uint16_t conf;
6231
6232 if (handle == NULL) /* check handle */
6233 {
6234 return 2; /* return error */
6235 }
6236 if (handle->inited != 1) /* check handle initialization */
6237 {
6238 return 3; /* return error */
6239 }
6240 if (volume > 0x3F) /* check volume */
6241 {
6242 handle->debug_print("wm8978: volume > 0x3F.\n"); /* volume > 0x3F */
6243
6244 return 4; /* return error */
6245 }
6246
6247 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, &conf); /* read config */
6248 if (res != 0) /* check error */
6249 {
6250 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6251
6252 return 1; /* return error */
6253 }
6254 conf &= ~(0x3F << 0); /* clear config */
6255 conf |= volume << 0; /* set volume */
6256 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_INP_PGA_CTRL, conf); /* write config */
6257 if (res != 0) /* check error */
6258 {
6259 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6260
6261 return 1; /* return error */
6262 }
6263
6264 return 0; /* success return 0 */
6265}
6266
6279{
6280 if (handle == NULL) /* check handle */
6281 {
6282 return 2; /* return error */
6283 }
6284 if (handle->inited != 1) /* check handle initialization */
6285 {
6286 return 3; /* return error */
6287 }
6288
6289 *reg = (uint8_t)((db + 12.0f) / 0.75f); /* convert */
6290
6291 return 0; /* success return 0 */
6292}
6293
6306{
6307 if (handle == NULL) /* check handle */
6308 {
6309 return 2; /* return error */
6310 }
6311 if (handle->inited != 1) /* check handle initialization */
6312 {
6313 return 3; /* return error */
6314 }
6315
6316 *db = (float)(reg) * 0.75f - 12.0f; /* convert */
6317
6318 return 0; /* success return 0 */
6319}
6320
6333{
6334 uint8_t res;
6335 uint16_t conf;
6336
6337 if (handle == NULL) /* check handle */
6338 {
6339 return 2; /* return error */
6340 }
6341 if (handle->inited != 1) /* check handle initialization */
6342 {
6343 return 3; /* return error */
6344 }
6345
6346 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, &conf); /* read config */
6347 if (res != 0) /* check error */
6348 {
6349 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6350
6351 return 1; /* return error */
6352 }
6353 conf &= ~(1 << 8); /* clear config */
6354 conf |= enable << 8; /* set bool */
6355 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, conf); /* write config */
6356 if (res != 0) /* check error */
6357 {
6358 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6359
6360 return 1; /* return error */
6361 }
6362
6363 return 0; /* success return 0 */
6364}
6365
6379{
6380 uint8_t res;
6381 uint16_t conf;
6382
6383 if (handle == NULL) /* check handle */
6384 {
6385 return 2; /* return error */
6386 }
6387 if (handle->inited != 1) /* check handle initialization */
6388 {
6389 return 3; /* return error */
6390 }
6391 if (stage > 0x7) /* check stage */
6392 {
6393 handle->debug_print("wm8978: stage > 0x7.\n"); /* stage > 0x7 */
6394
6395 return 4; /* return error */
6396 }
6397
6398 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, &conf); /* read config */
6399 if (res != 0) /* check error */
6400 {
6401 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6402
6403 return 1; /* return error */
6404 }
6405 conf &= ~(0x7 << 4); /* clear config */
6406 conf |= stage << 4; /* set stage */
6407 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, conf); /* write config */
6408 if (res != 0) /* check error */
6409 {
6410 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6411
6412 return 1; /* return error */
6413 }
6414
6415 return 0; /* success return 0 */
6416}
6417
6430{
6431 if (handle == NULL) /* check handle */
6432 {
6433 return 2; /* return error */
6434 }
6435 if (handle->inited != 1) /* check handle initialization */
6436 {
6437 return 3; /* return error */
6438 }
6439
6440 *reg = (uint8_t)(db + 15) / 3; /* convert */
6441
6442 return 0; /* success return 0 */
6443}
6444
6457{
6458 if (handle == NULL) /* check handle */
6459 {
6460 return 2; /* return error */
6461 }
6462 if (handle->inited != 1) /* check handle initialization */
6463 {
6464 return 3; /* return error */
6465 }
6466
6467 *db = (int8_t)(reg * 3 - 15); /* convert */
6468
6469 return 0; /* success return 0 */
6470}
6471
6485{
6486 uint8_t res;
6487 uint16_t conf;
6488
6489 if (handle == NULL) /* check handle */
6490 {
6491 return 2; /* return error */
6492 }
6493 if (handle->inited != 1) /* check handle initialization */
6494 {
6495 return 3; /* return error */
6496 }
6497 if (stage > 0x7) /* check stage */
6498 {
6499 handle->debug_print("wm8978: stage > 0x7.\n"); /* stage > 0x7 */
6500
6501 return 4; /* return error */
6502 }
6503
6504 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, &conf); /* read config */
6505 if (res != 0) /* check error */
6506 {
6507 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6508
6509 return 1; /* return error */
6510 }
6511 conf &= ~(0x7 << 0); /* clear config */
6512 conf |= stage << 0; /* set stage */
6513 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_ADC_BOOST_CTRL, conf); /* write config */
6514 if (res != 0) /* check error */
6515 {
6516 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6517
6518 return 1; /* return error */
6519 }
6520
6521 return 0; /* success return 0 */
6522}
6523
6536{
6537 if (handle == NULL) /* check handle */
6538 {
6539 return 2; /* return error */
6540 }
6541 if (handle->inited != 1) /* check handle initialization */
6542 {
6543 return 3; /* return error */
6544 }
6545
6546 *reg = (uint8_t)(db + 15) / 3; /* convert */
6547
6548 return 0; /* success return 0 */
6549}
6550
6563{
6564 if (handle == NULL) /* check handle */
6565 {
6566 return 2; /* return error */
6567 }
6568 if (handle->inited != 1) /* check handle initialization */
6569 {
6570 return 3; /* return error */
6571 }
6572
6573 *db = (int8_t)(reg * 3 - 15); /* convert */
6574
6575 return 0; /* success return 0 */
6576}
6577
6590{
6591 uint8_t res;
6592 uint16_t conf;
6593
6594 if (handle == NULL) /* check handle */
6595 {
6596 return 2; /* return error */
6597 }
6598 if (handle->inited != 1) /* check handle initialization */
6599 {
6600 return 3; /* return error */
6601 }
6602
6603 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, &conf); /* read config */
6604 if (res != 0) /* check error */
6605 {
6606 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6607
6608 return 1; /* return error */
6609 }
6610 conf &= ~(1 << 8); /* clear config */
6611 conf |= enable << 8; /* set bool */
6612 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, conf); /* write config */
6613 if (res != 0) /* check error */
6614 {
6615 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6616
6617 return 1; /* return error */
6618 }
6619
6620 return 0; /* success return 0 */
6621}
6622
6636{
6637 uint8_t res;
6638 uint16_t conf;
6639
6640 if (handle == NULL) /* check handle */
6641 {
6642 return 2; /* return error */
6643 }
6644 if (handle->inited != 1) /* check handle initialization */
6645 {
6646 return 3; /* return error */
6647 }
6648 if (stage > 0x7) /* check stage */
6649 {
6650 handle->debug_print("wm8978: stage > 0x7.\n"); /* stage > 0x7 */
6651
6652 return 4; /* return error */
6653 }
6654
6655 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, &conf); /* read config */
6656 if (res != 0) /* check error */
6657 {
6658 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6659
6660 return 1; /* return error */
6661 }
6662 conf &= ~(0x7 << 4); /* clear config */
6663 conf |= stage << 4; /* set stage */
6664 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, conf); /* write config */
6665 if (res != 0) /* check error */
6666 {
6667 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6668
6669 return 1; /* return error */
6670 }
6671
6672 return 0; /* success return 0 */
6673}
6674
6687{
6688 if (handle == NULL) /* check handle */
6689 {
6690 return 2; /* return error */
6691 }
6692 if (handle->inited != 1) /* check handle initialization */
6693 {
6694 return 3; /* return error */
6695 }
6696
6697 *reg = (uint8_t)(db + 15) / 3; /* convert */
6698
6699 return 0; /* success return 0 */
6700}
6701
6714{
6715 if (handle == NULL) /* check handle */
6716 {
6717 return 2; /* return error */
6718 }
6719 if (handle->inited != 1) /* check handle initialization */
6720 {
6721 return 3; /* return error */
6722 }
6723
6724 *db = (int8_t)(reg * 3 - 15); /* convert */
6725
6726 return 0; /* success return 0 */
6727}
6728
6742{
6743 uint8_t res;
6744 uint16_t conf;
6745
6746 if (handle == NULL) /* check handle */
6747 {
6748 return 2; /* return error */
6749 }
6750 if (handle->inited != 1) /* check handle initialization */
6751 {
6752 return 3; /* return error */
6753 }
6754 if (stage > 0x7) /* check stage */
6755 {
6756 handle->debug_print("wm8978: stage > 0x7.\n"); /* stage > 0x7 */
6757
6758 return 4; /* return error */
6759 }
6760
6761 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, &conf); /* read config */
6762 if (res != 0) /* check error */
6763 {
6764 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6765
6766 return 1; /* return error */
6767 }
6768 conf &= ~(0x7 << 0); /* clear config */
6769 conf |= stage << 0; /* set stage */
6770 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_ADC_BOOST_CTRL, conf); /* write config */
6771 if (res != 0) /* check error */
6772 {
6773 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6774
6775 return 1; /* return error */
6776 }
6777
6778 return 0; /* success return 0 */
6779}
6780
6793{
6794 if (handle == NULL) /* check handle */
6795 {
6796 return 2; /* return error */
6797 }
6798 if (handle->inited != 1) /* check handle initialization */
6799 {
6800 return 3; /* return error */
6801 }
6802
6803 *reg = (uint8_t)(db + 15) / 3; /* convert */
6804
6805 return 0; /* success return 0 */
6806}
6807
6820{
6821 if (handle == NULL) /* check handle */
6822 {
6823 return 2; /* return error */
6824 }
6825 if (handle->inited != 1) /* check handle initialization */
6826 {
6827 return 3; /* return error */
6828 }
6829
6830 *db = (int8_t)(reg * 3 - 15); /* convert */
6831
6832 return 0; /* success return 0 */
6833}
6834
6847{
6848 uint8_t res;
6849 uint16_t conf;
6850
6851 if (handle == NULL) /* check handle */
6852 {
6853 return 2; /* return error */
6854 }
6855 if (handle->inited != 1) /* check handle initialization */
6856 {
6857 return 3; /* return error */
6858 }
6859
6860 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
6861 if (res != 0) /* check error */
6862 {
6863 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6864
6865 return 1; /* return error */
6866 }
6867 conf &= ~(1 << 6); /* clear config */
6868 conf |= enable << 6; /* set bool */
6869 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
6870 if (res != 0) /* check error */
6871 {
6872 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6873
6874 return 1; /* return error */
6875 }
6876
6877 return 0; /* success return 0 */
6878}
6879
6892{
6893 uint8_t res;
6894 uint16_t conf;
6895
6896 if (handle == NULL) /* check handle */
6897 {
6898 return 2; /* return error */
6899 }
6900 if (handle->inited != 1) /* check handle initialization */
6901 {
6902 return 3; /* return error */
6903 }
6904
6905 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
6906 if (res != 0) /* check error */
6907 {
6908 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6909
6910 return 1; /* return error */
6911 }
6912 conf &= ~(1 << 5); /* clear config */
6913 conf |= enable << 5; /* set bool */
6914 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
6915 if (res != 0) /* check error */
6916 {
6917 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6918
6919 return 1; /* return error */
6920 }
6921
6922 return 0; /* success return 0 */
6923}
6924
6937{
6938 uint8_t res;
6939 uint16_t conf;
6940
6941 if (handle == NULL) /* check handle */
6942 {
6943 return 2; /* return error */
6944 }
6945 if (handle->inited != 1) /* check handle initialization */
6946 {
6947 return 3; /* return error */
6948 }
6949
6950 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
6951 if (res != 0) /* check error */
6952 {
6953 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6954
6955 return 1; /* return error */
6956 }
6957 conf &= ~(1 << 4); /* clear config */
6958 conf |= enable << 4; /* set bool */
6959 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
6960 if (res != 0) /* check error */
6961 {
6962 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
6963
6964 return 1; /* return error */
6965 }
6966
6967 return 0; /* success return 0 */
6968}
6969
6982{
6983 uint8_t res;
6984 uint16_t conf;
6985
6986 if (handle == NULL) /* check handle */
6987 {
6988 return 2; /* return error */
6989 }
6990 if (handle->inited != 1) /* check handle initialization */
6991 {
6992 return 3; /* return error */
6993 }
6994
6995 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
6996 if (res != 0) /* check error */
6997 {
6998 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
6999
7000 return 1; /* return error */
7001 }
7002 conf &= ~(1 << 3); /* clear config */
7003 conf |= enable << 3; /* set bool */
7004 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
7005 if (res != 0) /* check error */
7006 {
7007 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7008
7009 return 1; /* return error */
7010 }
7011
7012 return 0; /* success return 0 */
7013}
7014
7027{
7028 uint8_t res;
7029 uint16_t conf;
7030
7031 if (handle == NULL) /* check handle */
7032 {
7033 return 2; /* return error */
7034 }
7035 if (handle->inited != 1) /* check handle initialization */
7036 {
7037 return 3; /* return error */
7038 }
7039
7040 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
7041 if (res != 0) /* check error */
7042 {
7043 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7044
7045 return 1; /* return error */
7046 }
7047 conf &= ~(1 << 2); /* clear config */
7048 conf |= enable << 2; /* set bool */
7049 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
7050 if (res != 0) /* check error */
7051 {
7052 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7053
7054 return 1; /* return error */
7055 }
7056
7057 return 0; /* success return 0 */
7058}
7059
7072{
7073 uint8_t res;
7074 uint16_t conf;
7075
7076 if (handle == NULL) /* check handle */
7077 {
7078 return 2; /* return error */
7079 }
7080 if (handle->inited != 1) /* check handle initialization */
7081 {
7082 return 3; /* return error */
7083 }
7084
7085 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
7086 if (res != 0) /* check error */
7087 {
7088 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7089
7090 return 1; /* return error */
7091 }
7092 conf &= ~(1 << 1); /* clear config */
7093 conf |= enable << 1; /* set bool */
7094 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
7095 if (res != 0) /* check error */
7096 {
7097 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7098
7099 return 1; /* return error */
7100 }
7101
7102 return 0; /* success return 0 */
7103}
7104
7117{
7118 uint8_t res;
7119 uint16_t conf;
7120
7121 if (handle == NULL) /* check handle */
7122 {
7123 return 2; /* return error */
7124 }
7125 if (handle->inited != 1) /* check handle initialization */
7126 {
7127 return 3; /* return error */
7128 }
7129
7130 res = a_wm8978_iic_read(handle, WM8978_REG_OUTPUT_CTRL, &conf); /* read config */
7131 if (res != 0) /* check error */
7132 {
7133 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7134
7135 return 1; /* return error */
7136 }
7137 conf &= ~(1 << 0); /* clear config */
7138 conf |= vref << 0; /* set vref */
7139 res = a_wm8978_iic_write(handle, WM8978_REG_OUTPUT_CTRL, conf); /* write config */
7140 if (res != 0) /* check error */
7141 {
7142 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7143
7144 return 1; /* return error */
7145 }
7146
7147 return 0; /* success return 0 */
7148}
7149
7163{
7164 uint8_t res;
7165 uint16_t conf;
7166
7167 if (handle == NULL) /* check handle */
7168 {
7169 return 2; /* return error */
7170 }
7171 if (handle->inited != 1) /* check handle initialization */
7172 {
7173 return 3; /* return error */
7174 }
7175 if (vol > 0x7) /* check vol */
7176 {
7177 handle->debug_print("wm8978: vol > 0x7.\n"); /* vol > 0x7 */
7178
7179 return 4; /* return error */
7180 }
7181
7182 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_MIXER_CTRL, &conf); /* read config */
7183 if (res != 0) /* check error */
7184 {
7185 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7186
7187 return 1; /* return error */
7188 }
7189 conf &= ~(7 << 6); /* clear config */
7190 conf |= vol << 6; /* set vol */
7191 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_MIXER_CTRL, conf); /* write config */
7192 if (res != 0) /* check error */
7193 {
7194 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7195
7196 return 1; /* return error */
7197 }
7198
7199 return 0; /* success return 0 */
7200}
7201
7214{
7215 if (handle == NULL) /* check handle */
7216 {
7217 return 2; /* return error */
7218 }
7219 if (handle->inited != 1) /* check handle initialization */
7220 {
7221 return 3; /* return error */
7222 }
7223
7224 *reg = (uint8_t)(db + 15) / 3; /* convert */
7225
7226 return 0; /* success return 0 */
7227}
7228
7241{
7242 if (handle == NULL) /* check handle */
7243 {
7244 return 2; /* return error */
7245 }
7246 if (handle->inited != 1) /* check handle initialization */
7247 {
7248 return 3; /* return error */
7249 }
7250
7251 *db = (int8_t)(reg * 3 - 15); /* convert */
7252
7253 return 0; /* success return 0 */
7254}
7255
7268{
7269 uint8_t res;
7270 uint16_t conf;
7271
7272 if (handle == NULL) /* check handle */
7273 {
7274 return 2; /* return error */
7275 }
7276 if (handle->inited != 1) /* check handle initialization */
7277 {
7278 return 3; /* return error */
7279 }
7280
7281 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_MIXER_CTRL, &conf); /* read config */
7282 if (res != 0) /* check error */
7283 {
7284 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7285
7286 return 1; /* return error */
7287 }
7288 conf &= ~(1 << 5); /* clear config */
7289 conf |= enable << 5; /* set bool */
7290 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_MIXER_CTRL, conf); /* write config */
7291 if (res != 0) /* check error */
7292 {
7293 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7294
7295 return 1; /* return error */
7296 }
7297
7298 return 0; /* success return 0 */
7299}
7300
7314{
7315 uint8_t res;
7316 uint16_t conf;
7317
7318 if (handle == NULL) /* check handle */
7319 {
7320 return 2; /* return error */
7321 }
7322 if (handle->inited != 1) /* check handle initialization */
7323 {
7324 return 3; /* return error */
7325 }
7326 if (vol > 0x7) /* check vol */
7327 {
7328 handle->debug_print("wm8978: vol > 0x7.\n"); /* vol > 0x7 */
7329
7330 return 4; /* return error */
7331 }
7332
7333 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_MIXER_CTRL, &conf); /* read config */
7334 if (res != 0) /* check error */
7335 {
7336 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7337
7338 return 1; /* return error */
7339 }
7340 conf &= ~(7 << 2); /* clear config */
7341 conf |= vol << 2; /* set vol */
7342 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_MIXER_CTRL, conf); /* write config */
7343 if (res != 0) /* check error */
7344 {
7345 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7346
7347 return 1; /* return error */
7348 }
7349
7350 return 0; /* success return 0 */
7351}
7352
7365{
7366 if (handle == NULL) /* check handle */
7367 {
7368 return 2; /* return error */
7369 }
7370 if (handle->inited != 1) /* check handle initialization */
7371 {
7372 return 3; /* return error */
7373 }
7374
7375 *reg = (uint8_t)(db + 15) / 3; /* convert */
7376
7377 return 0; /* success return 0 */
7378}
7379
7392{
7393 if (handle == NULL) /* check handle */
7394 {
7395 return 2; /* return error */
7396 }
7397 if (handle->inited != 1) /* check handle initialization */
7398 {
7399 return 3; /* return error */
7400 }
7401
7402 *db = (int8_t)(reg * 3 - 15); /* convert */
7403
7404 return 0; /* success return 0 */
7405}
7406
7419{
7420 uint8_t res;
7421 uint16_t conf;
7422
7423 if (handle == NULL) /* check handle */
7424 {
7425 return 2; /* return error */
7426 }
7427 if (handle->inited != 1) /* check handle initialization */
7428 {
7429 return 3; /* return error */
7430 }
7431
7432 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_MIXER_CTRL, &conf); /* read config */
7433 if (res != 0) /* check error */
7434 {
7435 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7436
7437 return 1; /* return error */
7438 }
7439 conf &= ~(1 << 1); /* clear config */
7440 conf |= enable << 1; /* set bool */
7441 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_MIXER_CTRL, conf); /* write config */
7442 if (res != 0) /* check error */
7443 {
7444 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7445
7446 return 1; /* return error */
7447 }
7448
7449 return 0; /* success return 0 */
7450}
7451
7464{
7465 uint8_t res;
7466 uint16_t conf;
7467
7468 if (handle == NULL) /* check handle */
7469 {
7470 return 2; /* return error */
7471 }
7472 if (handle->inited != 1) /* check handle initialization */
7473 {
7474 return 3; /* return error */
7475 }
7476
7477 res = a_wm8978_iic_read(handle, WM8978_REG_LEFT_MIXER_CTRL, &conf); /* read config */
7478 if (res != 0) /* check error */
7479 {
7480 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7481
7482 return 1; /* return error */
7483 }
7484 conf &= ~(1 << 0); /* clear config */
7485 conf |= enable << 0; /* set bool */
7486 res = a_wm8978_iic_write(handle, WM8978_REG_LEFT_MIXER_CTRL, conf); /* write config */
7487 if (res != 0) /* check error */
7488 {
7489 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7490
7491 return 1; /* return error */
7492 }
7493
7494 return 0; /* success return 0 */
7495}
7496
7510{
7511 uint8_t res;
7512 uint16_t conf;
7513
7514 if (handle == NULL) /* check handle */
7515 {
7516 return 2; /* return error */
7517 }
7518 if (handle->inited != 1) /* check handle initialization */
7519 {
7520 return 3; /* return error */
7521 }
7522 if (vol > 0x7) /* check vol */
7523 {
7524 handle->debug_print("wm8978: vol > 0x7.\n"); /* vol > 0x7 */
7525
7526 return 4; /* return error */
7527 }
7528
7529 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_MIXER_CTRL, &conf); /* read config */
7530 if (res != 0) /* check error */
7531 {
7532 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7533
7534 return 1; /* return error */
7535 }
7536 conf &= ~(7 << 6); /* clear config */
7537 conf |= vol << 6; /* set vol */
7538 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_MIXER_CTRL, conf); /* write config */
7539 if (res != 0) /* check error */
7540 {
7541 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7542
7543 return 1; /* return error */
7544 }
7545
7546 return 0; /* success return 0 */
7547}
7548
7561{
7562 if (handle == NULL) /* check handle */
7563 {
7564 return 2; /* return error */
7565 }
7566 if (handle->inited != 1) /* check handle initialization */
7567 {
7568 return 3; /* return error */
7569 }
7570
7571 *reg = (uint8_t)(db + 15) / 3; /* convert */
7572
7573 return 0; /* success return 0 */
7574}
7575
7588{
7589 if (handle == NULL) /* check handle */
7590 {
7591 return 2; /* return error */
7592 }
7593 if (handle->inited != 1) /* check handle initialization */
7594 {
7595 return 3; /* return error */
7596 }
7597
7598 *db = (int8_t)(reg * 3 - 15); /* convert */
7599
7600 return 0; /* success return 0 */
7601}
7602
7615{
7616 uint8_t res;
7617 uint16_t conf;
7618
7619 if (handle == NULL) /* check handle */
7620 {
7621 return 2; /* return error */
7622 }
7623 if (handle->inited != 1) /* check handle initialization */
7624 {
7625 return 3; /* return error */
7626 }
7627
7628 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_MIXER_CTRL, &conf); /* read config */
7629 if (res != 0) /* check error */
7630 {
7631 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7632
7633 return 1; /* return error */
7634 }
7635 conf &= ~(1 << 5); /* clear config */
7636 conf |= enable << 5; /* set bool */
7637 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_MIXER_CTRL, conf); /* write config */
7638 if (res != 0) /* check error */
7639 {
7640 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7641
7642 return 1; /* return error */
7643 }
7644
7645 return 0; /* success return 0 */
7646}
7647
7661{
7662 uint8_t res;
7663 uint16_t conf;
7664
7665 if (handle == NULL) /* check handle */
7666 {
7667 return 2; /* return error */
7668 }
7669 if (handle->inited != 1) /* check handle initialization */
7670 {
7671 return 3; /* return error */
7672 }
7673 if (vol > 0x7) /* check vol */
7674 {
7675 handle->debug_print("wm8978: vol > 0x7.\n"); /* vol > 0x7 */
7676
7677 return 4; /* return error */
7678 }
7679
7680 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_MIXER_CTRL, &conf); /* read config */
7681 if (res != 0) /* check error */
7682 {
7683 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7684
7685 return 1; /* return error */
7686 }
7687 conf &= ~(7 << 2); /* clear config */
7688 conf |= vol << 2; /* set vol */
7689 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_MIXER_CTRL, conf); /* write config */
7690 if (res != 0) /* check error */
7691 {
7692 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7693
7694 return 1; /* return error */
7695 }
7696
7697 return 0; /* success return 0 */
7698}
7699
7712{
7713 if (handle == NULL) /* check handle */
7714 {
7715 return 2; /* return error */
7716 }
7717 if (handle->inited != 1) /* check handle initialization */
7718 {
7719 return 3; /* return error */
7720 }
7721
7722 *reg = (uint8_t)(db + 15) / 3; /* convert */
7723
7724 return 0; /* success return 0 */
7725}
7726
7739{
7740 if (handle == NULL) /* check handle */
7741 {
7742 return 2; /* return error */
7743 }
7744 if (handle->inited != 1) /* check handle initialization */
7745 {
7746 return 3; /* return error */
7747 }
7748
7749 *db = (int8_t)(reg * 3 - 15); /* convert */
7750
7751 return 0; /* success return 0 */
7752}
7753
7766{
7767 uint8_t res;
7768 uint16_t conf;
7769
7770 if (handle == NULL) /* check handle */
7771 {
7772 return 2; /* return error */
7773 }
7774 if (handle->inited != 1) /* check handle initialization */
7775 {
7776 return 3; /* return error */
7777 }
7778
7779 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_MIXER_CTRL, &conf); /* read config */
7780 if (res != 0) /* check error */
7781 {
7782 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7783
7784 return 1; /* return error */
7785 }
7786 conf &= ~(1 << 1); /* clear config */
7787 conf |= enable << 1; /* set bool */
7788 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_MIXER_CTRL, conf); /* write config */
7789 if (res != 0) /* check error */
7790 {
7791 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7792
7793 return 1; /* return error */
7794 }
7795
7796 return 0; /* success return 0 */
7797}
7798
7811{
7812 uint8_t res;
7813 uint16_t conf;
7814
7815 if (handle == NULL) /* check handle */
7816 {
7817 return 2; /* return error */
7818 }
7819 if (handle->inited != 1) /* check handle initialization */
7820 {
7821 return 3; /* return error */
7822 }
7823
7824 res = a_wm8978_iic_read(handle, WM8978_REG_RIGHT_MIXER_CTRL, &conf); /* read config */
7825 if (res != 0) /* check error */
7826 {
7827 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7828
7829 return 1; /* return error */
7830 }
7831 conf &= ~(1 << 0); /* clear config */
7832 conf |= enable << 0; /* set bool */
7833 res = a_wm8978_iic_write(handle, WM8978_REG_RIGHT_MIXER_CTRL, conf); /* write config */
7834 if (res != 0) /* check error */
7835 {
7836 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7837
7838 return 1; /* return error */
7839 }
7840
7841 return 0; /* success return 0 */
7842}
7843
7856{
7857 uint8_t res;
7858 uint16_t conf;
7859
7860 if (handle == NULL) /* check handle */
7861 {
7862 return 2; /* return error */
7863 }
7864 if (handle->inited != 1) /* check handle initialization */
7865 {
7866 return 3; /* return error */
7867 }
7868
7869 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT1_CTRL, &conf); /* read config */
7870 if (res != 0) /* check error */
7871 {
7872 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7873
7874 return 1; /* return error */
7875 }
7876 conf &= ~(1 << 8); /* clear config */
7877 conf |= enable << 8; /* set bool */
7878 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT1_CTRL, conf); /* write config */
7879 if (res != 0) /* check error */
7880 {
7881 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7882
7883 return 1; /* return error */
7884 }
7885
7886 return 0; /* success return 0 */
7887}
7888
7901{
7902 uint8_t res;
7903 uint16_t conf;
7904
7905 if (handle == NULL) /* check handle */
7906 {
7907 return 2; /* return error */
7908 }
7909 if (handle->inited != 1) /* check handle initialization */
7910 {
7911 return 3; /* return error */
7912 }
7913
7914 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT1_CTRL, &conf); /* read config */
7915 if (res != 0) /* check error */
7916 {
7917 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7918
7919 return 1; /* return error */
7920 }
7921 conf &= ~(1 << 7); /* clear config */
7922 conf |= enable << 7; /* set bool */
7923 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT1_CTRL, conf); /* write config */
7924 if (res != 0) /* check error */
7925 {
7926 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7927
7928 return 1; /* return error */
7929 }
7930
7931 return 0; /* success return 0 */
7932}
7933
7946{
7947 uint8_t res;
7948 uint16_t conf;
7949
7950 if (handle == NULL) /* check handle */
7951 {
7952 return 2; /* return error */
7953 }
7954 if (handle->inited != 1) /* check handle initialization */
7955 {
7956 return 3; /* return error */
7957 }
7958
7959 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT1_CTRL, &conf); /* read config */
7960 if (res != 0) /* check error */
7961 {
7962 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
7963
7964 return 1; /* return error */
7965 }
7966 conf &= ~(1 << 6); /* clear config */
7967 conf |= enable << 6; /* set bool */
7968 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT1_CTRL, conf); /* write config */
7969 if (res != 0) /* check error */
7970 {
7971 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
7972
7973 return 1; /* return error */
7974 }
7975
7976 return 0; /* success return 0 */
7977}
7978
7992{
7993 uint8_t res;
7994 uint16_t conf;
7995
7996 if (handle == NULL) /* check handle */
7997 {
7998 return 2; /* return error */
7999 }
8000 if (handle->inited != 1) /* check handle initialization */
8001 {
8002 return 3; /* return error */
8003 }
8004 if (vol > 0x3F) /* check vol */
8005 {
8006 handle->debug_print("wm8978: vol > 0x3F.\n"); /* vol > 0x3F */
8007
8008 return 4; /* return error */
8009 }
8010
8011 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT1_CTRL, &conf); /* read config */
8012 if (res != 0) /* check error */
8013 {
8014 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8015
8016 return 1; /* return error */
8017 }
8018 conf &= ~(0x3F << 0); /* clear config */
8019 conf |= vol << 0; /* set vol */
8020 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT1_CTRL, conf); /* write config */
8021 if (res != 0) /* check error */
8022 {
8023 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8024
8025 return 1; /* return error */
8026 }
8027
8028 return 0; /* success return 0 */
8029}
8030
8043{
8044 if (handle == NULL) /* check handle */
8045 {
8046 return 2; /* return error */
8047 }
8048 if (handle->inited != 1) /* check handle initialization */
8049 {
8050 return 3; /* return error */
8051 }
8052
8053 *reg = (uint8_t)(db + 57); /* convert */
8054
8055 return 0; /* success return 0 */
8056}
8057
8070{
8071 if (handle == NULL) /* check handle */
8072 {
8073 return 2; /* return error */
8074 }
8075 if (handle->inited != 1) /* check handle initialization */
8076 {
8077 return 3; /* return error */
8078 }
8079
8080 *db = (int8_t)(reg - 57); /* convert */
8081
8082 return 0; /* success return 0 */
8083}
8084
8097{
8098 uint8_t res;
8099 uint16_t conf;
8100
8101 if (handle == NULL) /* check handle */
8102 {
8103 return 2; /* return error */
8104 }
8105 if (handle->inited != 1) /* check handle initialization */
8106 {
8107 return 3; /* return error */
8108 }
8109
8110 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT1_CTRL, &conf); /* read config */
8111 if (res != 0) /* check error */
8112 {
8113 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8114
8115 return 1; /* return error */
8116 }
8117 conf &= ~(1 << 8); /* clear config */
8118 conf |= enable << 8; /* set bool */
8119 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT1_CTRL, conf); /* write config */
8120 if (res != 0) /* check error */
8121 {
8122 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8123
8124 return 1; /* return error */
8125 }
8126
8127 return 0; /* success return 0 */
8128}
8129
8142{
8143 uint8_t res;
8144 uint16_t conf;
8145
8146 if (handle == NULL) /* check handle */
8147 {
8148 return 2; /* return error */
8149 }
8150 if (handle->inited != 1) /* check handle initialization */
8151 {
8152 return 3; /* return error */
8153 }
8154
8155 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT1_CTRL, &conf); /* read config */
8156 if (res != 0) /* check error */
8157 {
8158 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8159
8160 return 1; /* return error */
8161 }
8162 conf &= ~(1 << 7); /* clear config */
8163 conf |= enable << 7; /* set bool */
8164 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT1_CTRL, conf); /* write config */
8165 if (res != 0) /* check error */
8166 {
8167 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8168
8169 return 1; /* return error */
8170 }
8171
8172 return 0; /* success return 0 */
8173}
8174
8187{
8188 uint8_t res;
8189 uint16_t conf;
8190
8191 if (handle == NULL) /* check handle */
8192 {
8193 return 2; /* return error */
8194 }
8195 if (handle->inited != 1) /* check handle initialization */
8196 {
8197 return 3; /* return error */
8198 }
8199
8200 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT1_CTRL, &conf); /* read config */
8201 if (res != 0) /* check error */
8202 {
8203 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8204
8205 return 1; /* return error */
8206 }
8207 conf &= ~(1 << 6); /* clear config */
8208 conf |= enable << 6; /* set bool */
8209 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT1_CTRL, conf); /* write config */
8210 if (res != 0) /* check error */
8211 {
8212 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8213
8214 return 1; /* return error */
8215 }
8216
8217 return 0; /* success return 0 */
8218}
8219
8233{
8234 uint8_t res;
8235 uint16_t conf;
8236
8237 if (handle == NULL) /* check handle */
8238 {
8239 return 2; /* return error */
8240 }
8241 if (handle->inited != 1) /* check handle initialization */
8242 {
8243 return 3; /* return error */
8244 }
8245 if (vol > 0x3F) /* check vol */
8246 {
8247 handle->debug_print("wm8978: vol > 0x3F.\n"); /* vol > 0x3F */
8248
8249 return 4; /* return error */
8250 }
8251
8252 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT1_CTRL, &conf); /* read config */
8253 if (res != 0) /* check error */
8254 {
8255 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8256
8257 return 1; /* return error */
8258 }
8259 conf &= ~(0x3F << 0); /* clear config */
8260 conf |= vol << 0; /* set vol */
8261 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT1_CTRL, conf); /* write config */
8262 if (res != 0) /* check error */
8263 {
8264 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8265
8266 return 1; /* return error */
8267 }
8268
8269 return 0; /* success return 0 */
8270}
8271
8284{
8285 if (handle == NULL) /* check handle */
8286 {
8287 return 2; /* return error */
8288 }
8289 if (handle->inited != 1) /* check handle initialization */
8290 {
8291 return 3; /* return error */
8292 }
8293
8294 *reg = (uint8_t)(db + 57); /* convert */
8295
8296 return 0; /* success return 0 */
8297}
8298
8311{
8312 if (handle == NULL) /* check handle */
8313 {
8314 return 2; /* return error */
8315 }
8316 if (handle->inited != 1) /* check handle initialization */
8317 {
8318 return 3; /* return error */
8319 }
8320
8321 *db = (int8_t)(reg - 57); /* convert */
8322
8323 return 0; /* success return 0 */
8324}
8325
8338{
8339 uint8_t res;
8340 uint16_t conf;
8341
8342 if (handle == NULL) /* check handle */
8343 {
8344 return 2; /* return error */
8345 }
8346 if (handle->inited != 1) /* check handle initialization */
8347 {
8348 return 3; /* return error */
8349 }
8350
8351 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT2_CTRL, &conf); /* read config */
8352 if (res != 0) /* check error */
8353 {
8354 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8355
8356 return 1; /* return error */
8357 }
8358 conf &= ~(1 << 8); /* clear config */
8359 conf |= enable << 8; /* set bool */
8360 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT2_CTRL, conf); /* write config */
8361 if (res != 0) /* check error */
8362 {
8363 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8364
8365 return 1; /* return error */
8366 }
8367
8368 return 0; /* success return 0 */
8369}
8370
8383{
8384 uint8_t res;
8385 uint16_t conf;
8386
8387 if (handle == NULL) /* check handle */
8388 {
8389 return 2; /* return error */
8390 }
8391 if (handle->inited != 1) /* check handle initialization */
8392 {
8393 return 3; /* return error */
8394 }
8395
8396 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT2_CTRL, &conf); /* read config */
8397 if (res != 0) /* check error */
8398 {
8399 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8400
8401 return 1; /* return error */
8402 }
8403 conf &= ~(1 << 7); /* clear config */
8404 conf |= enable << 7; /* set bool */
8405 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT2_CTRL, conf); /* write config */
8406 if (res != 0) /* check error */
8407 {
8408 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8409
8410 return 1; /* return error */
8411 }
8412
8413 return 0; /* success return 0 */
8414}
8415
8428{
8429 uint8_t res;
8430 uint16_t conf;
8431
8432 if (handle == NULL) /* check handle */
8433 {
8434 return 2; /* return error */
8435 }
8436 if (handle->inited != 1) /* check handle initialization */
8437 {
8438 return 3; /* return error */
8439 }
8440
8441 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT2_CTRL, &conf); /* read config */
8442 if (res != 0) /* check error */
8443 {
8444 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8445
8446 return 1; /* return error */
8447 }
8448 conf &= ~(1 << 6); /* clear config */
8449 conf |= enable << 6; /* set bool */
8450 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT2_CTRL, conf); /* write config */
8451 if (res != 0) /* check error */
8452 {
8453 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8454
8455 return 1; /* return error */
8456 }
8457
8458 return 0; /* success return 0 */
8459}
8460
8474{
8475 uint8_t res;
8476 uint16_t conf;
8477
8478 if (handle == NULL) /* check handle */
8479 {
8480 return 2; /* return error */
8481 }
8482 if (handle->inited != 1) /* check handle initialization */
8483 {
8484 return 3; /* return error */
8485 }
8486 if (vol > 0x3F) /* check vol */
8487 {
8488 handle->debug_print("wm8978: vol > 0x3F.\n"); /* vol > 0x3F */
8489
8490 return 4; /* return error */
8491 }
8492
8493 res = a_wm8978_iic_read(handle, WM8978_REG_LOUT2_CTRL, &conf); /* read config */
8494 if (res != 0) /* check error */
8495 {
8496 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8497
8498 return 1; /* return error */
8499 }
8500 conf &= ~(0x3F << 0); /* clear config */
8501 conf |= vol << 0; /* set vol */
8502 res = a_wm8978_iic_write(handle, WM8978_REG_LOUT2_CTRL, conf); /* write config */
8503 if (res != 0) /* check error */
8504 {
8505 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8506
8507 return 1; /* return error */
8508 }
8509
8510 return 0; /* success return 0 */
8511}
8512
8525{
8526 if (handle == NULL) /* check handle */
8527 {
8528 return 2; /* return error */
8529 }
8530 if (handle->inited != 1) /* check handle initialization */
8531 {
8532 return 3; /* return error */
8533 }
8534
8535 *reg = (uint8_t)(db + 57); /* convert */
8536
8537 return 0; /* success return 0 */
8538}
8539
8552{
8553 if (handle == NULL) /* check handle */
8554 {
8555 return 2; /* return error */
8556 }
8557 if (handle->inited != 1) /* check handle initialization */
8558 {
8559 return 3; /* return error */
8560 }
8561
8562 *db = (int8_t)(reg - 57); /* convert */
8563
8564 return 0; /* success return 0 */
8565}
8566
8579{
8580 uint8_t res;
8581 uint16_t conf;
8582
8583 if (handle == NULL) /* check handle */
8584 {
8585 return 2; /* return error */
8586 }
8587 if (handle->inited != 1) /* check handle initialization */
8588 {
8589 return 3; /* return error */
8590 }
8591
8592 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT2_CTRL, &conf); /* read config */
8593 if (res != 0) /* check error */
8594 {
8595 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8596
8597 return 1; /* return error */
8598 }
8599 conf &= ~(1 << 8); /* clear config */
8600 conf |= enable << 8; /* set bool */
8601 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT2_CTRL, conf); /* write config */
8602 if (res != 0) /* check error */
8603 {
8604 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8605
8606 return 1; /* return error */
8607 }
8608
8609 return 0; /* success return 0 */
8610}
8611
8624{
8625 uint8_t res;
8626 uint16_t conf;
8627
8628 if (handle == NULL) /* check handle */
8629 {
8630 return 2; /* return error */
8631 }
8632 if (handle->inited != 1) /* check handle initialization */
8633 {
8634 return 3; /* return error */
8635 }
8636
8637 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT2_CTRL, &conf); /* read config */
8638 if (res != 0) /* check error */
8639 {
8640 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8641
8642 return 1; /* return error */
8643 }
8644 conf &= ~(1 << 7); /* clear config */
8645 conf |= enable << 7; /* set bool */
8646 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT2_CTRL, conf); /* write config */
8647 if (res != 0) /* check error */
8648 {
8649 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8650
8651 return 1; /* return error */
8652 }
8653
8654 return 0; /* success return 0 */
8655}
8656
8669{
8670 uint8_t res;
8671 uint16_t conf;
8672
8673 if (handle == NULL) /* check handle */
8674 {
8675 return 2; /* return error */
8676 }
8677 if (handle->inited != 1) /* check handle initialization */
8678 {
8679 return 3; /* return error */
8680 }
8681
8682 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT2_CTRL, &conf); /* read config */
8683 if (res != 0) /* check error */
8684 {
8685 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8686
8687 return 1; /* return error */
8688 }
8689 conf &= ~(1 << 6); /* clear config */
8690 conf |= enable << 6; /* set bool */
8691 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT2_CTRL, conf); /* write config */
8692 if (res != 0) /* check error */
8693 {
8694 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8695
8696 return 1; /* return error */
8697 }
8698
8699 return 0; /* success return 0 */
8700}
8701
8715{
8716 uint8_t res;
8717 uint16_t conf;
8718
8719 if (handle == NULL) /* check handle */
8720 {
8721 return 2; /* return error */
8722 }
8723 if (handle->inited != 1) /* check handle initialization */
8724 {
8725 return 3; /* return error */
8726 }
8727 if (vol > 0x3F) /* check vol */
8728 {
8729 handle->debug_print("wm8978: vol > 0x3F.\n"); /* vol > 0x3F */
8730
8731 return 4; /* return error */
8732 }
8733
8734 res = a_wm8978_iic_read(handle, WM8978_REG_ROUT2_CTRL, &conf); /* read config */
8735 if (res != 0) /* check error */
8736 {
8737 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8738
8739 return 1; /* return error */
8740 }
8741 conf &= ~(0x3F << 0); /* clear config */
8742 conf |= vol << 0; /* set vol */
8743 res = a_wm8978_iic_write(handle, WM8978_REG_ROUT2_CTRL, conf); /* write config */
8744 if (res != 0) /* check error */
8745 {
8746 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8747
8748 return 1; /* return error */
8749 }
8750
8751 return 0; /* success return 0 */
8752}
8753
8766{
8767 if (handle == NULL) /* check handle */
8768 {
8769 return 2; /* return error */
8770 }
8771 if (handle->inited != 1) /* check handle initialization */
8772 {
8773 return 3; /* return error */
8774 }
8775
8776 *reg = (uint8_t)(db + 57); /* convert */
8777
8778 return 0; /* success return 0 */
8779}
8780
8793{
8794 if (handle == NULL) /* check handle */
8795 {
8796 return 2; /* return error */
8797 }
8798 if (handle->inited != 1) /* check handle initialization */
8799 {
8800 return 3; /* return error */
8801 }
8802
8803 *db = (int8_t)(reg - 57); /* convert */
8804
8805 return 0; /* success return 0 */
8806}
8807
8820{
8821 uint8_t res;
8822 uint16_t conf;
8823
8824 if (handle == NULL) /* check handle */
8825 {
8826 return 2; /* return error */
8827 }
8828 if (handle->inited != 1) /* check handle initialization */
8829 {
8830 return 3; /* return error */
8831 }
8832
8833 res = a_wm8978_iic_read(handle, WM8978_REG_OUT3_MIXER_CTRL, &conf); /* read config */
8834 if (res != 0) /* check error */
8835 {
8836 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8837
8838 return 1; /* return error */
8839 }
8840 conf &= ~(1 << 6); /* clear config */
8841 conf |= enable << 6; /* set bool */
8842 res = a_wm8978_iic_write(handle, WM8978_REG_OUT3_MIXER_CTRL, conf); /* write config */
8843 if (res != 0) /* check error */
8844 {
8845 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8846
8847 return 1; /* return error */
8848 }
8849
8850 return 0; /* success return 0 */
8851}
8852
8865{
8866 uint8_t res;
8867 uint16_t conf;
8868
8869 if (handle == NULL) /* check handle */
8870 {
8871 return 2; /* return error */
8872 }
8873 if (handle->inited != 1) /* check handle initialization */
8874 {
8875 return 3; /* return error */
8876 }
8877
8878 res = a_wm8978_iic_read(handle, WM8978_REG_OUT3_MIXER_CTRL, &conf); /* read config */
8879 if (res != 0) /* check error */
8880 {
8881 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8882
8883 return 1; /* return error */
8884 }
8885 conf &= ~(1 << 3); /* clear config */
8886 conf |= enable << 3; /* set bool */
8887 res = a_wm8978_iic_write(handle, WM8978_REG_OUT3_MIXER_CTRL, conf); /* write config */
8888 if (res != 0) /* check error */
8889 {
8890 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8891
8892 return 1; /* return error */
8893 }
8894
8895 return 0; /* success return 0 */
8896}
8897
8910{
8911 uint8_t res;
8912 uint16_t conf;
8913
8914 if (handle == NULL) /* check handle */
8915 {
8916 return 2; /* return error */
8917 }
8918 if (handle->inited != 1) /* check handle initialization */
8919 {
8920 return 3; /* return error */
8921 }
8922
8923 res = a_wm8978_iic_read(handle, WM8978_REG_OUT3_MIXER_CTRL, &conf); /* read config */
8924 if (res != 0) /* check error */
8925 {
8926 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8927
8928 return 1; /* return error */
8929 }
8930 conf &= ~(1 << 2); /* clear config */
8931 conf |= enable << 2; /* set bool */
8932 res = a_wm8978_iic_write(handle, WM8978_REG_OUT3_MIXER_CTRL, conf); /* write config */
8933 if (res != 0) /* check error */
8934 {
8935 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8936
8937 return 1; /* return error */
8938 }
8939
8940 return 0; /* success return 0 */
8941}
8942
8955{
8956 uint8_t res;
8957 uint16_t conf;
8958
8959 if (handle == NULL) /* check handle */
8960 {
8961 return 2; /* return error */
8962 }
8963 if (handle->inited != 1) /* check handle initialization */
8964 {
8965 return 3; /* return error */
8966 }
8967
8968 res = a_wm8978_iic_read(handle, WM8978_REG_OUT3_MIXER_CTRL, &conf); /* read config */
8969 if (res != 0) /* check error */
8970 {
8971 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
8972
8973 return 1; /* return error */
8974 }
8975 conf &= ~(1 << 1); /* clear config */
8976 conf |= enable << 1; /* set bool */
8977 res = a_wm8978_iic_write(handle, WM8978_REG_OUT3_MIXER_CTRL, conf); /* write config */
8978 if (res != 0) /* check error */
8979 {
8980 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
8981
8982 return 1; /* return error */
8983 }
8984
8985 return 0; /* success return 0 */
8986}
8987
9000{
9001 uint8_t res;
9002 uint16_t conf;
9003
9004 if (handle == NULL) /* check handle */
9005 {
9006 return 2; /* return error */
9007 }
9008 if (handle->inited != 1) /* check handle initialization */
9009 {
9010 return 3; /* return error */
9011 }
9012
9013 res = a_wm8978_iic_read(handle, WM8978_REG_OUT3_MIXER_CTRL, &conf); /* read config */
9014 if (res != 0) /* check error */
9015 {
9016 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9017
9018 return 1; /* return error */
9019 }
9020 conf &= ~(1 << 0); /* clear config */
9021 conf |= enable << 0; /* set bool */
9022 res = a_wm8978_iic_write(handle, WM8978_REG_OUT3_MIXER_CTRL, conf); /* write config */
9023 if (res != 0) /* check error */
9024 {
9025 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9026
9027 return 1; /* return error */
9028 }
9029
9030 return 0; /* success return 0 */
9031}
9032
9045{
9046 uint8_t res;
9047 uint16_t conf;
9048
9049 if (handle == NULL) /* check handle */
9050 {
9051 return 2; /* return error */
9052 }
9053 if (handle->inited != 1) /* check handle initialization */
9054 {
9055 return 3; /* return error */
9056 }
9057
9058 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9059 if (res != 0) /* check error */
9060 {
9061 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9062
9063 return 1; /* return error */
9064 }
9065 conf &= ~(1 << 6); /* clear config */
9066 conf |= enable << 6; /* set bool */
9067 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9068 if (res != 0) /* check error */
9069 {
9070 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9071
9072 return 1; /* return error */
9073 }
9074
9075 return 0; /* success return 0 */
9076}
9077
9090{
9091 uint8_t res;
9092 uint16_t conf;
9093
9094 if (handle == NULL) /* check handle */
9095 {
9096 return 2; /* return error */
9097 }
9098 if (handle->inited != 1) /* check handle initialization */
9099 {
9100 return 3; /* return error */
9101 }
9102
9103 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9104 if (res != 0) /* check error */
9105 {
9106 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9107
9108 return 1; /* return error */
9109 }
9110 conf &= ~(1 << 5); /* clear config */
9111 conf |= enable << 5; /* set bool */
9112 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9113 if (res != 0) /* check error */
9114 {
9115 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9116
9117 return 1; /* return error */
9118 }
9119
9120 return 0; /* success return 0 */
9121}
9122
9135{
9136 uint8_t res;
9137 uint16_t conf;
9138
9139 if (handle == NULL) /* check handle */
9140 {
9141 return 2; /* return error */
9142 }
9143 if (handle->inited != 1) /* check handle initialization */
9144 {
9145 return 3; /* return error */
9146 }
9147
9148 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9149 if (res != 0) /* check error */
9150 {
9151 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9152
9153 return 1; /* return error */
9154 }
9155 conf &= ~(1 << 4); /* clear config */
9156 conf |= enable << 4; /* set bool */
9157 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9158 if (res != 0) /* check error */
9159 {
9160 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9161
9162 return 1; /* return error */
9163 }
9164
9165 return 0; /* success return 0 */
9166}
9167
9180{
9181 uint8_t res;
9182 uint16_t conf;
9183
9184 if (handle == NULL) /* check handle */
9185 {
9186 return 2; /* return error */
9187 }
9188 if (handle->inited != 1) /* check handle initialization */
9189 {
9190 return 3; /* return error */
9191 }
9192
9193 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9194 if (res != 0) /* check error */
9195 {
9196 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9197
9198 return 1; /* return error */
9199 }
9200 conf &= ~(1 << 3); /* clear config */
9201 conf |= enable << 3; /* set bool */
9202 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9203 if (res != 0) /* check error */
9204 {
9205 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9206
9207 return 1; /* return error */
9208 }
9209
9210 return 0; /* success return 0 */
9211}
9212
9225{
9226 uint8_t res;
9227 uint16_t conf;
9228
9229 if (handle == NULL) /* check handle */
9230 {
9231 return 2; /* return error */
9232 }
9233 if (handle->inited != 1) /* check handle initialization */
9234 {
9235 return 3; /* return error */
9236 }
9237
9238 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9239 if (res != 0) /* check error */
9240 {
9241 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9242
9243 return 1; /* return error */
9244 }
9245 conf &= ~(1 << 2); /* clear config */
9246 conf |= enable << 2; /* set bool */
9247 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9248 if (res != 0) /* check error */
9249 {
9250 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9251
9252 return 1; /* return error */
9253 }
9254
9255 return 0; /* success return 0 */
9256}
9257
9270{
9271 uint8_t res;
9272 uint16_t conf;
9273
9274 if (handle == NULL) /* check handle */
9275 {
9276 return 2; /* return error */
9277 }
9278 if (handle->inited != 1) /* check handle initialization */
9279 {
9280 return 3; /* return error */
9281 }
9282
9283 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9284 if (res != 0) /* check error */
9285 {
9286 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9287
9288 return 1; /* return error */
9289 }
9290 conf &= ~(1 << 1); /* clear config */
9291 conf |= enable << 1; /* set bool */
9292 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9293 if (res != 0) /* check error */
9294 {
9295 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9296
9297 return 1; /* return error */
9298 }
9299
9300 return 0; /* success return 0 */
9301}
9302
9315{
9316 uint8_t res;
9317 uint16_t conf;
9318
9319 if (handle == NULL) /* check handle */
9320 {
9321 return 2; /* return error */
9322 }
9323 if (handle->inited != 1) /* check handle initialization */
9324 {
9325 return 3; /* return error */
9326 }
9327
9328 res = a_wm8978_iic_read(handle, WM8978_REG_OUT4_MIXER_CTRL, &conf); /* read config */
9329 if (res != 0) /* check error */
9330 {
9331 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9332
9333 return 1; /* return error */
9334 }
9335 conf &= ~(1 << 0); /* clear config */
9336 conf |= enable << 0; /* set bool */
9337 res = a_wm8978_iic_write(handle, WM8978_REG_OUT4_MIXER_CTRL, conf); /* write config */
9338 if (res != 0) /* check error */
9339 {
9340 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9341
9342 return 1; /* return error */
9343 }
9344
9345 return 0; /* success return 0 */
9346}
9347
9360{
9361 uint8_t res;
9362 uint8_t i;
9363 uint16_t conf;
9364
9365 if (handle == NULL) /* check handle */
9366 {
9367 return 2; /* return error */
9368 }
9369 if (handle->debug_print == NULL) /* check debug_print */
9370 {
9371 return 3; /* return error */
9372 }
9373 if (handle->iic_init == NULL) /* check iic_init */
9374 {
9375 handle->debug_print("wm8978: iic_init is null.\n"); /* iic_init is null */
9376
9377 return 3; /* return error */
9378 }
9379 if (handle->iic_deinit == NULL) /* check iic_deinit */
9380 {
9381 handle->debug_print("wm8978: iic_deinit is null.\n"); /* iic_deinit is null */
9382
9383 return 3; /* return error */
9384 }
9385 if (handle->iic_write == NULL) /* check iic_write */
9386 {
9387 handle->debug_print("wm8978: iic_write is null.\n"); /* iic_write is null */
9388
9389 return 3; /* return error */
9390 }
9391 if (handle->delay_ms == NULL) /* check delay_ms */
9392 {
9393 handle->debug_print("wm8978: delay_ms is null.\n"); /* delay_ms is null */
9394
9395 return 3; /* return error */
9396 }
9397
9398 if (handle->iic_init() != 0) /* iic init */
9399 {
9400 handle->debug_print("wm8978: iic init failed.\n"); /* iic init failed */
9401
9402 return 1; /* return error */
9403 }
9404 conf = 0x0000; /* set any value */
9405 res = a_wm8978_iic_write(handle, WM8978_REG_SOFTWARE_RESET, conf); /* write config */
9406 if (res != 0) /* check error */
9407 {
9408 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9409 (void)handle->iic_deinit(); /* iic deinit */
9410
9411 return 4; /* return error */
9412 }
9413 handle->delay_ms(100); /* delay 100ms */
9414 for (i = 0; i < 58; i++) /* set all */
9415 {
9416 handle->reg[i] = gsc_wm8978_init_reg[i]; /* save regs */
9417 }
9418 handle->inited = 1; /* flag inited */
9419
9420 return 0; /* success return 0 */
9421}
9422
9435{
9436 uint8_t res;
9437 uint16_t conf;
9438
9439 if (handle == NULL) /* check handle */
9440 {
9441 return 2; /* return error */
9442 }
9443 if (handle->inited != 1) /* check handle initialization */
9444 {
9445 return 3; /* return error */
9446 }
9447
9448 res = a_wm8978_iic_read(handle, WM8978_REG_POWER_MANAGE_2, &conf); /* read config */
9449 if (res != 0) /* check error */
9450 {
9451 handle->debug_print("wm8978: read config failed.\n"); /* read config failed */
9452
9453 return 4; /* return error */
9454 }
9455 conf &= ~(1 << 6); /* clear config */
9456 conf |= 1 << 6; /* set bool */
9457 res = a_wm8978_iic_write(handle, WM8978_REG_POWER_MANAGE_2, conf); /* write config */
9458 if (res != 0) /* check error */
9459 {
9460 handle->debug_print("wm8978: write config failed.\n"); /* write config failed */
9461
9462 return 4; /* return error */
9463 }
9464 res = handle->iic_deinit(); /* close iic */
9465 if (res != 0) /* check the result */
9466 {
9467 handle->debug_print("wm8978: iic deinit failed.\n"); /* iic deinit failed */
9468
9469 return 1; /* return error */
9470 }
9471 handle->inited = 0; /* flag close */
9472
9473 return 0; /* success return 0 */
9474}
9475
9488uint8_t wm8978_set_reg(wm8978_handle_t *handle, uint8_t reg, uint16_t value)
9489{
9490 if (handle == NULL) /* check handle */
9491 {
9492 return 2; /* return error */
9493 }
9494 if (handle->inited != 1) /* check handle initialization */
9495 {
9496 return 3; /* return error */
9497 }
9498
9499 return a_wm8978_iic_write(handle, reg, value); /* write reg */
9500}
9501
9511{
9512 if (info == NULL) /* check handle */
9513 {
9514 return 2; /* return error */
9515 }
9516
9517 memset(info, 0, sizeof(wm8978_info_t)); /* initialize wm8978 info structure */
9518 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
9519 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
9520 strncpy(info->interface, "IIC IIS", 8); /* copy interface name */
9521 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
9522 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
9523 info->max_current_ma = MAX_CURRENT; /* set maximum current */
9524 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
9525 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
9526 info->driver_version = DRIVER_VERSION; /* set driver version */
9527
9528 return 0; /* success return 0 */
9529}
#define WM8978_REG_POWER_MANAGE_1
#define WM8978_REG_EQ2
#define WM8978_REG_OUT3_MIXER_CTRL
#define WM8978_REG_RIGHT_MIXER_CTRL
#define WM8978_REG_PLL_K2
#define WM8978_REG_AUDIO_INTERFACE
#define WM8978_REG_LEFT_DAC_DIGITAL_VOL
#define WM8978_REG_LOUT2_CTRL
#define MAX_CURRENT
#define WM8978_REG_EQ1
#define WM8978_REG_LEFT_INP_PGA_CTRL
#define WM8978_REG_3D_CONTROL
#define WM8978_REG_LEFT_ADC_BOOST_CTRL
#define WM8978_REG_EQ4
#define WM8978_REG_POWER_MANAGE_3
#define WM8978_REG_RIGHT_ADC_DIGITAL_VOL
#define WM8978_REG_PLL_K3
#define WM8978_REG_NOTCH_FILTER_2
#define WM8978_REG_DAC_CONTROL
#define WM8978_REG_LEFT_ADC_DIGITAL_VOL
#define WM8978_REG_EQ5
#define WM8978_REG_DAC_LIMITER_2
#define WM8978_REG_ALC_CONTROL_3
#define WM8978_REG_POWER_MANAGE_2
#define SUPPLY_VOLTAGE_MAX
#define WM8978_REG_BEEP_CONTROL
#define WM8978_REG_NOISE_GATE
#define WM8978_REG_JACK_DETECT_CONTROL2
#define WM8978_REG_GPIO
#define WM8978_REG_DAC_LIMITER_1
#define WM8978_REG_NOTCH_FILTER_3
#define WM8978_REG_ALC_CONTROL_2
#define WM8978_REG_COMPANDING_CTRL
#define TEMPERATURE_MAX
#define WM8978_REG_ADDITIONAL_CTRL
#define WM8978_ADDRESS
chip address definition
#define WM8978_REG_ROUT2_CTRL
#define WM8978_REG_RIGHT_INP_PGA_CTRL
#define WM8978_REG_NOTCH_FILTER_4
#define WM8978_REG_ADC_CONTROL
#define WM8978_REG_RIGHT_ADC_BOOST_CTRL
#define WM8978_REG_OUT4_MIXER_CTRL
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define WM8978_REG_CLOCK_GEN_CTRL
#define WM8978_REG_JACK_DETECT_CONTROL
#define WM8978_REG_PLL_N
#define WM8978_REG_SOFTWARE_RESET
chip register definition
#define WM8978_REG_EQ3
#define WM8978_REG_ROUT1_CTRL
#define WM8978_REG_NOTCH_FILTER_1
#define WM8978_REG_LOUT1_CTRL
#define CHIP_NAME
chip information definition
#define DRIVER_VERSION
#define WM8978_REG_ALC_CONTROL_1
#define WM8978_REG_OUTPUT_CTRL
#define WM8978_REG_INPUT_CTRL
#define WM8978_REG_LEFT_MIXER_CTRL
#define WM8978_REG_RIGHT_DAC_DIGITAL_VOL
#define WM8978_REG_PLL_K1
driver wm8978 header file
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_soft_reset(wm8978_handle_t *handle)
soft reset
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
wm8978_eq3_band_centre_freq_t
wm8978 eq3 band centre freq enumeration definition
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_auxiliary_amplifier_right_channel_input_boost_stage_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the auxiliary amplifier right channel input boost stage register raw data to the real 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_rout1_right_headphone_output_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the rout1 right headphone output volume raw data to the real 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
wm8978_mode_t
wm8978 mode enumeration definition
uint8_t wm8978_alc_noise_gate_threshold_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the alc noise gate threshold register raw data to the real data
uint8_t wm8978_rout2_right_speaker_output_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the rout2 right speaker output volume raw data to the real data
wm8978_high_pass_filter_cut_off_t
wm8978 high pass filter cut off enumeration definition
uint8_t wm8978_set_channel(wm8978_handle_t *handle, wm8978_channel_t channel)
set channel
uint8_t wm8978_right_channel_input_boost_stage_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the right channel input boost stage register raw data to the real data
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_auxiliary_amplifier_left_channel_input_boost_stage_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the auxiliary amplifier left channel input boost stage register raw data to the real data
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
wm8978_eq4_band_centre_freq_t
wm8978 eq4 band centre freq enumeration definition
wm8978_data_format_t
wm8978 data format enumeration definition
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
wm8978_impedance_t
wm8978 impedance enumeration definition
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
wm8978_dac_limiter_attack_t
wm8978 dac limiter attack enumeration definition
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
wm8978_vref_t
wm8978 vref enumeration definition
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_aux_right_channel_input_to_right_mixer_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the aux right channel input to right mixer volume raw data to the real data
wm8978_clock_mode_t
wm8978 clock mode enumeration definition
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_right_channel_input_pga_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *db)
convert the right channel input pga volume register raw data to the real 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
wm8978_adc_oversample_rate_t
wm8978 adc oversample rate enumeration definition
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_data(wm8978_handle_t *handle, uint8_t reg, float *db)
convert the left channel input pga volume register raw data to the real data
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
wm8978_companding_t
wm8978 companding enumeration definition
uint8_t wm8978_aux_left_channel_input_to_left_mixer_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the aux left channel input to left mixer volume register raw data to the real 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_lout2_left_speaker_output_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the lout2 left speaker output volume raw data to the real data
wm8978_word_length_t
wm8978 word length enumeration definition
uint8_t wm8978_set_out4_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mixer
wm8978_channel_t
wm8978 channel enumeration definition
wm8978_dac_limiter_level_t
wm8978 dac limiter level enumeration definition
uint8_t wm8978_left_channel_input_boost_stage_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the left channel input boost stage register raw data to the real data
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
wm8978_approximate_sample_t
wm8978 approximate sample enumeration definition
wm8978_pll_div_t
wm8978 pll div enumeration definition
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_alc_hold_time_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *ms)
convert the alc hold time register raw data to the real data
uint8_t wm8978_set_vref_to_analogue_output_resistance(wm8978_handle_t *handle, wm8978_vref_t vref)
set vref to analogue output resistance
wm8978_avdd_t
wm8978 avdd enumeration definition
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
wm8978_jack_t
wm8978 jack enumeration definition
wm8978_polarity_t
wm8978 polarity enumeration definition
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
wm8978_eq5_band_cut_off_t
wm8978 eq5 band cut off enumeration definition
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_lout1_left_headphone_output_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the lout1 left headphone output volume raw data to the real data
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
wm8978_gpio1_sel_t
wm8978 gpio1 sel enumeration 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_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *db)
convert the volume register raw data to the real data
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_eq_gain_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the eq gain register raw data to the real data
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
wm8978_clksel_t
wm8978 clksel enumeration definition
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
wm8978_equaliser_t
wm8978 equaliser enumeration definition
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_beep_volume_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the beep volume register raw data to the real data
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
wm8978_bclk_div_t
wm8978 bclk div enumeration definition
uint8_t wm8978_set_out3_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 mute
wm8978_dac_oversample_rate_t
wm8978 dac oversample rate enumeration definition
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
wm8978_min_gain_t
wm8978 min gain enumeration definition
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
wm8978_max_gain_t
wm8978 max gain enumeration definition
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
wm8978_bool_t
wm8978 bool enumeration definition
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_right_bypass_volume_control_to_output_channel_mixer_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the right bypass volume control to output channel mixer raw data to the real data
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
wm8978_alc_t
wm8978 alc enumeration definition
uint8_t wm8978_set_left_channel_input_pga(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga
wm8978_jack_sel_t
wm8978 jack sel enumeration definition
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
wm8978_alc_level_t
wm8978 alc level enumeration definition
uint8_t wm8978_set_high_pass_filter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable high pass filter
uint8_t wm8978_left_bypass_volume_control_to_output_channel_mixer_convert_to_data(wm8978_handle_t *handle, uint8_t reg, int8_t *db)
convert the left bypass volume control to output channel mixer register raw data to the real data
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
wm8978_eq1_band_cut_off_t
wm8978 eq1 band cut off enumeration definition
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
wm8978_alc_mode_t
wm8978 alc mode enumeration definition
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
wm8978_dac_limiter_decay_t
wm8978 dac limiter decay enumeration definition
uint8_t wm8978_depth_3d_convert_to_data(wm8978_handle_t *handle, uint8_t reg, float *percent)
convert the depth 3d register raw data to the real data
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
wm8978_appear_t
wm8978 appear enumeration definition
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
wm8978_eq_bandwidth_t
wm8978 eq bandwidth enumeration definition
wm8978_mclk_div_t
wm8978 mclk div enumeration definition
uint8_t wm8978_set_right_channel_dac(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel dac
wm8978_eq2_band_centre_freq_t
wm8978 eq2 band centre freq enumeration definition
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
uint8_t wm8978_set_reg(wm8978_handle_t *handle, uint8_t reg, uint16_t value)
set the chip register
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint16_t reg[58]
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]