arduino-audio-driver
Loading...
Searching...
No Matches
AudioDriver.h
Go to the documentation of this file.
1#pragma once
2#include "Codecs/AllCodecs.h"
3#include "ConfigAudioDriver.h"
4#include "DriverCommon.h"
5#include "DriverDeviceInfo.h"
8
9namespace audio_driver {
10
11const int rate_num[14] = {8000, 11025, 16000, 22050, 24000, 32000, 44100,
12 48000, 64000, 88200, 96000, 128000, 176400, 192000};
16
25 public:
34 // codec is slave - microcontroller is master
36 }
37
40 return (input_device == alt.input_device &&
41 output_device == alt.output_device && i2s.bits == alt.i2s.bits &&
42 i2s.channels == alt.i2s.channels && i2s.fmt == alt.i2s.fmt &&
43 i2s.mode == alt.i2s.mode);
44 }
45
48 switch (i2s.bits) {
50 return 16;
52 return 24;
54 return 32;
55 default:
56 return 0;
57 }
58 return 0;
59 }
60
62 bool setBitsNumeric(int bits) {
63 switch (bits) {
64 case 16:
66 return true;
67 case 18:
69 return true;
70 case 20:
72 return true;
73 case 24:
75 return true;
76 case 32:
78 return true;
79 }
80 AD_LOGE("bits not supported: %d", bits);
81 return false;
82 }
83
86 for (int j = 0; j < 14; j++) {
87 if (rate_code[j] == i2s.rate) {
88 AD_LOGD("-> %d", rate_num[j]);
89 return rate_num[j];
90 }
91 }
92 return 0;
93 }
94
97
99 bool setChannelsNumeric(int channels) {
100 switch (channels) {
101 case CHANNELS2:
102 i2s.channels = (channels_t)channels;
103 return true;
104 case CHANNELS4:
105 i2s.channels = (channels_t)channels;
106 return true;
107 case CHANNELS8:
108 i2s.channels = (channels_t)channels;
109 return true;
110 case CHANNELS16:
111 i2s.channels = (channels_t)channels;
112 return true;
113 default:
114 AD_LOGE("Channels not supported: %d - using %d", channels, 2);
116 return false;
117 }
118 }
119
121 int setRateNumeric(int requestedRate) {
122 int diff = 99999;
123 int result = 0;
124 for (int j = 0; j < 14; j++) {
125 if (rate_num[j] == requestedRate) {
126 AD_LOGD("-> %d", rate_num[j]);
127 i2s.rate = rate_code[j];
128 return requestedRate;
129 } else {
130 int new_diff = abs(rate_num[j] - requestedRate);
131 if (new_diff < diff) {
132 result = j;
133 diff = new_diff;
134 }
135 }
136 }
137 AD_LOGE("Sample Rate not supported: %d - using %d", requestedRate,
138 rate_num[result]);
139 i2s.rate = rate_code[result];
140 return rate_num[result];
141 }
142
145 // codec_mode_t mode;
146 bool is_input = false;
147 bool is_output = false;
148
149 if (input_device != ADC_INPUT_NONE) is_input = true;
150
151 if (output_device != DAC_OUTPUT_NONE) is_output = true;
152
153 if (is_input && is_output) {
154 AD_LOGD("mode->CODEC_MODE_BOTH");
155 return CODEC_MODE_BOTH;
156 }
157
158 if (is_output) {
159 AD_LOGD("mode->CODEC_MODE_DECODE");
160 return CODEC_MODE_DECODE;
161 }
162
163 if (is_input) {
164 AD_LOGD("mode->CODEC_MODE_ENCODE");
165 return CODEC_MODE_ENCODE;
166 }
167
168 AD_LOGD("mode->CODEC_MODE_NONE");
169 return CODEC_MODE_NONE;
170 }
171 // if sd active we setup SPI for the SD
172 bool sd_active = false;
173 bool sdmmc_active = false;
174};
175
183 public:
185 virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) {
186 AD_LOGI("AudioDriver::begin");
187 p_pins = &pins;
188
189 // Store default i2c address to pins
191
192 AD_LOGI("sd_active: %d", codecCfg.sd_active);
194 AD_LOGI("sdmmc_active: %d", codecCfg.sdmmc_active);
196 if (!p_pins->begin()) {
197 AD_LOGE("AudioBoard::pins::begin failed");
198 return false;
199 }
200
201 if (!setConfig(codecCfg)) {
202 AD_LOGE("setConfig has failed");
203 return false;
204 }
205 setPAPower(true);
206 // setup default volume
208 return true;
209 }
210
212 virtual bool setConfig(CodecConfig codecCfg) {
213 AD_LOGI("AudioDriver::setConfig");
214 codec_cfg = codecCfg;
215 if (!init(codec_cfg)) {
216 AD_LOGE("AudioDriver init failed");
217 return false;
218 }
219 codec_mode_t codec_mode = codec_cfg.get_mode();
220 if (!controlState(codec_mode)) {
221 AD_LOGE("AudioDriver controlState failed");
222 return false;
223 }
224 bool result = configInterface(codec_mode, codec_cfg.i2s);
225 if (!result) {
226 AD_LOGE("AudioDriver configInterface failed");
227 return false;
228 }
229 return result;
230 }
232 virtual bool end(void) { return deinit(); }
234 virtual bool setMute(bool enable) = 0;
236 virtual bool setMute(bool mute, int line) {
237 AD_LOGE("setMute not supported on line level");
238 return false;
239 }
240
242 virtual bool setVolume(int volume) = 0;
244 virtual int getVolume() = 0;
246 virtual bool setInputVolume(int volume) { return false; }
248 virtual bool isVolumeSupported() { return true; }
250 virtual bool isInputVolumeSupported() { return false; }
252 virtual DriverDeviceInfo& pins() { return *p_pins; }
253
255
257 bool setPAPower(bool enable) {
258 if (p_pins == nullptr) {
259 AD_LOGI("pins are null");
260 return false;
261 }
263 if (pin == GPIO_UNDEFINED) {
264 AD_LOGI("PinFunction::PA not defined");
265 return false;
266 }
267 AD_LOGI("setPAPower pin %d -> %d", pin, enable);
268
270 uint8_t enable_value = pin_logic == PinLogic::Output ? HIGH : LOW;
271
272 getGPIO().digitalWrite(pin, enable ? enable_value : !enable_value);
273 return true;
274 }
275
276 operator bool() { return p_pins != nullptr; }
277
279 virtual bool setI2CAddress(uint16_t adr) {
281 if (p_pins == nullptr) return true;
282 // look it up from the pin definition
283 auto i2c = pins().getI2CPins(PinFunction::CODEC);
284 if (i2c) {
285 AD_LOGI("==> Updating address: 0x%x", adr);
286 InfoI2C val = i2c.value();
287 val.address = adr;
288 pins().setI2C(val);
289 return true;
290 } else {
291 // we should have a codec defined!
292 AD_LOGW("No I2C Pins defined");
293 }
294 return false;
295 }
296
298 virtual int getI2CAddress() {
299 if (p_pins == nullptr) return i2c_default_address;
300 // look it up from the pin definition
301 auto i2c = pins().getI2CPins(PinFunction::CODEC);
302 if (i2c) {
303 auto value = i2c.value();
304 auto addr = value.address;
305 if (addr > -1) return addr;
306 }
307 return i2c_default_address;
308 }
309
312 AD_LOGI("setupI2CAddress: 0x%x", i2c_default_address);
313 int adr = getI2CAddress();
314 if (adr == -1) {
315 AD_LOGW("No i2c address defined - ignoring");
316 return;
317 }
318 setI2CAddress(adr);
319 }
320
322 assert(p_pins != nullptr);
323 return p_pins->getGPIO();
324 }
325
326 protected:
330
331 int mapVolume(int x, int in_min, int in_max, int out_min, int out_max) {
332 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
333 }
334
337 if (p_pins == nullptr) return DEFAULT_WIRE;
338 auto i2c = pins().getI2CPins(PinFunction::CODEC);
339 if (!i2c) {
340 return DEFAULT_WIRE;
341 }
342 i2c_bus_handle_t result = (i2c_bus_handle_t)i2c.value().p_wire;
343 return result;
344 }
345
346 virtual bool init(codec_config_t codec_cfg) { return false; }
347 virtual bool deinit() { return false; }
348 virtual bool controlState(codec_mode_t mode) { return false; };
349 virtual bool configInterface(codec_mode_t mode, I2SDefinition iface) {
350 return false;
351 };
352
356 int limitValue(int volume, int min = 0, int max = 100) {
357 if (volume > max) volume = max;
358 if (volume < min) volume = min;
359 return volume;
360 }
361};
362
370 public:
371 virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) {
372 // codec_cfg = codecCfg;
373 // p_pins = &pins;
374 return true;
375 }
376 virtual bool end(void) { return true; }
377 virtual bool setMute(bool enable) { return false; }
378 virtual bool setVolume(int volume) { return false; }
379 virtual int getVolume() { return 100; }
380 virtual bool setInputVolume(int volume) { return false; }
381 virtual bool isVolumeSupported() { return false;}
382 virtual bool isInputVolumeSupported() { return false; }
383};
384
391 public:
392 AudioDriverAC101Class(uint16_t deviceAddr = 0x1A) {
393 i2c_default_address = deviceAddr;
394 }
395 bool setMute(bool mute) { return ac101.setVoiceMute(mute) == RESULT_OK; }
396 bool setVolume(int volume) {
397 return ac101.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
398 };
399 int getVolume() {
400 int vol;
401 ac101.getVoiceVolume(&vol);
402 return vol;
403 };
404
406 AC101& driver() { return ac101; }
407
408 protected:
410
416 bool deinit() { return ac101.deinit() == RESULT_OK; }
418 return ac101.ctrlStateActive(mode, true) == RESULT_OK;
419 }
421 return ac101.configI2S(mode, &iface) == RESULT_OK;
422 }
423};
424
431 public:
432 AudioDriverCS43l22Class(uint16_t deviceAddr = 0x4A) {
433 i2c_default_address = deviceAddr;
434 }
435
436 virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) {
437 AD_LOGD("AudioDriverCS43l22Class::begin");
438 p_pins = &pins;
439 codec_cfg = codecCfg;
440 // setup gpio pin modes and the i2c bus (Wire.begin): must run before we
441 // can drive the reset pin or talk to the codec over i2c
443 if (!p_pins->begin()) {
444 AD_LOGE("AudioBoard::pins::begin failed");
445 return false;
446 }
447 // manage reset pin -> acive high
448 setPAPower(true);
449 // Setup enable pin for codec
450 delayMs(100);
453 // 0xE0-0xE7 confirms the chip is actually responding on i2c; 0x00 means
454 // the read failed (wrong address/pins/reset) even if writes look ok
455 AD_LOGI("CS43L22 chip id: 0x%x", cs43l22.readID());
456 uint32_t freq = getFrequency(codec_cfg.i2s.rate);
457 uint16_t outputDevice = getOutput(codec_cfg.output_device);
458 AD_LOGD("cs43l22.init");
459 bool result = cs43l22.init(outputDevice, volume, freq) == 0;
460 if (!result) {
461 AD_LOGE("error: cs43l22.init");
462 }
463 cs43l22.play(nullptr, 0);
464 return result;
465 }
466
467 virtual bool setConfig(CodecConfig codecCfg) {
468 codec_cfg = codecCfg;
469 uint32_t freq = getFrequency(codec_cfg.i2s.rate);
470 uint16_t outputDevice = getOutput(codecCfg.output_device);
471 return cs43l22.init(outputDevice, this->volume, freq) == 0;
472 }
473
474 bool setMute(bool mute) {
475 uint32_t rc = mute ? cs43l22.pause() : cs43l22.resume();
476 return rc == 0;
477 }
478
479 bool setVolume(int volume) {
480 this->volume = volume;
481 return cs43l22.setVolume(volume) == 0;
482 }
483 int getVolume() { return volume; }
484
486 CS43L22& driver() { return cs43l22; }
487
488 protected:
490 int volume = 100;
491
492 bool deinit() {
494 cnt += cs43l22.reset();
495 setPAPower(false);
496 return cnt == 0;
497 }
498
499 uint32_t getFrequency(samplerate_t rateNum) {
500 switch (rateNum) {
501 case RATE_8K:
502 return 8000;
503 case RATE_11K:
504 return 11024;
505 case RATE_16K:
506 return 16000;
507 case RATE_22K:
508 return 22050;
509 case RATE_24K:
510 return 24000;
511 case RATE_32K:
512 return 32000;
513 case RATE_44K:
514 return 44100;
515 case RATE_48K:
516 return 48000;
517 default:
518 break;
519 }
520 return 44100;
521 }
522
523 uint16_t getOutput(output_device_t output_device) {
524 switch (output_device) {
525 case DAC_OUTPUT_NONE:
526 return 0;
527 case DAC_OUTPUT_LINE1:
529 case DAC_OUTPUT_LINE2:
531 case DAC_OUTPUT_ALL:
533 default:
534 break;
535 }
537 }
538};
539
546 public:
547 AudioDriverCS42L51Class(uint16_t deviceAddr = 0x4A) {
548 i2c_default_address = deviceAddr;
549 }
550
551 virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) {
552 AD_LOGD("AudioDriverCS42L51Class::begin");
553 p_pins = &pins;
554 codec_cfg = codecCfg;
556 if (!p_pins->begin()) {
557 AD_LOGE("AudioBoard::pins::begin failed");
558 return false;
559 }
560 // manage reset pin -> acive high
561 setPAPower(true);
562 // Setup enable pin for codec
563 delayMs(100);
566 uint32_t freq = getFrequency(codec_cfg.i2s.rate);
567 uint32_t inputDevice = getInput(codec_cfg.input_device);
568 uint32_t outputDevice = getOutput(codec_cfg.output_device);
569 AD_LOGD("cs42l51.init");
570 bool result = cs42l51.init(inputDevice, outputDevice, volume, freq) == 0;
571 if (!result) {
572 AD_LOGE("error: cs42l51.init");
573 }
574 cs42l51.play();
575 return result;
576 }
577
578 virtual bool setConfig(CodecConfig codecCfg) {
579 codec_cfg = codecCfg;
580 uint32_t freq = getFrequency(codec_cfg.i2s.rate);
581 uint32_t inputDevice = getInput(codecCfg.input_device);
582 uint32_t outputDevice = getOutput(codecCfg.output_device);
583 return cs42l51.init(inputDevice, outputDevice, volume, freq) == 0;
584 }
585
586 bool setMute(bool mute) {
587 uint32_t rc = mute ? cs42l51.pause() : cs42l51.resume();
588 return rc == 0;
589 }
590
591 bool setVolume(int volume) {
592 this->volume = volume;
593 return cs42l51.setVolume(volume) == 0;
594 }
595 int getVolume() { return volume; }
596
598 CS42L51& driver() { return cs42l51; }
599
600 protected:
602 int volume = 100;
603
604 bool deinit() {
605 int cnt = cs42l51.stop(CS42L51_PDWN_SW);
606 cnt += cs42l51.reset();
607 setPAPower(false);
608 return cnt == 0;
609 }
610
611 uint32_t getFrequency(samplerate_t rateNum) {
612 switch (rateNum) {
613 case RATE_8K:
614 return CS42L51_FREQUENCY_8K;
615 case RATE_11K:
616 return CS42L51_FREQUENCY_11K;
617 case RATE_16K:
618 return CS42L51_FREQUENCY_16K;
619 case RATE_22K:
620 return CS42L51_FREQUENCY_22K;
621 case RATE_32K:
622 return CS42L51_FREQUENCY_32K;
623 case RATE_44K:
624 return CS42L51_FREQUENCY_44K;
625 case RATE_48K:
626 return CS42L51_FREQUENCY_48K;
627 default:
628 break;
629 }
631 }
632
633 uint32_t getInput(input_device_t input_device) {
634 switch (input_device) {
635 case ADC_INPUT_NONE:
636 return CS42L51_IN_NONE;
637 case ADC_INPUT_LINE1:
638 return CS42L51_IN_LINE1;
639 case ADC_INPUT_LINE2:
640 return CS42L51_IN_LINE2;
641 case ADC_INPUT_LINE3:
642 return CS42L51_IN_LINE3;
643 case ADC_INPUT_ALL:
647 default:
648 break;
649 }
650 return CS42L51_IN_NONE;
651 }
652
653 uint32_t getOutput(output_device_t output_device) {
654 if (output_device == DAC_OUTPUT_NONE) return CS42L51_OUT_NONE;
656 }
657};
658
665 public:
666 AudioDriverCS42448Class(uint16_t deviceAddr = 0x48) {
667 i2c_default_address = deviceAddr;
668 }
669 bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) override {
670 p_pins = &pins;
671 cfg = codecCfg;
673 if (!p_pins->begin()) {
674 AD_LOGE("AudioBoard::pins::begin failed");
675 return false;
676 }
677 // setup cs42448
679 cs42448.setMute(false);
680 return true;
681 }
682 virtual bool setConfig(CodecConfig codecCfg) {
683 bool result = true;
684 if (codecCfg.equalsExRate(cfg)) {
685 // just update the rate
686 if (cfg.i2s.rate != codecCfg.getRateNumeric()) {
687 cs42448.setMute(true);
689 cs42448.setMute(false);
690 }
691 } else {
692 assert(p_pins != nullptr);
693 result = begin(codecCfg, *p_pins);
694 }
695 return result;
696 }
697 bool end(void) override { return cs42448.end(); }
698 bool setMute(bool enable) override { return cs42448.setMute(enable); }
699 bool setMute(bool enable, int line) {
700 return cs42448.setMuteDAC(line, enable);
701 }
703 bool setVolume(int volume) override {
704 this->volume = volume;
705 return cs42448.setVolumeDAC(2.55f * volume);
706 }
707 bool setVolume(int dac, int volume) {
708 return cs42448.setVolumeDAC(dac, 2.55f * volume);
709 }
710
711 int getVolume() override { return volume; }
712 bool setInputVolume(int volume) override {
713 int vol = mapVolume(volume, 0, 100, -128, 127);
714 return cs42448.setVolumeADC(vol);
715 }
716 bool isVolumeSupported() override { return true; }
717 bool isInputVolumeSupported() override { return true; }
718
720 CS42448& driver() { return cs42448; }
721
722 protected:
724 int volume = 100;
726};
727
734 public:
735 AudioDriverES7210Class(uint16_t deviceAddr = ES7210_AD1_AD0_00 >> 1) {
736 i2c_default_address = deviceAddr;
737 }
738 bool setMute(bool mute) { return es7210.setMute(mute) == RESULT_OK; }
739 bool setVolume(int volume) {
740 this->volume = volume;
741 return es7210.setVolume(limitValue(volume, 0, 100)) == RESULT_OK;
742 }
743 int getVolume() { return volume; }
744 bool setInputVolume(int volume) { return setVolume(volume); }
745 bool isInputVolumeSupported() { return true; }
746 ES7210& driver() { return es7210; }
747
748 protected:
751
757 bool deinit() { return es7210.deinit() == RESULT_OK; }
758
760 return es7210.ctrlStateActive(mode, true) == RESULT_OK;
761 }
763 return es7210.configI2S(mode, &iface) == RESULT_OK;
764 }
765};
766
773 public:
774 AudioDriverES7243Class(uint16_t deviceAddr = 0x13) {
775 i2c_default_address = deviceAddr;
776 }
777 bool setMute(bool mute) {
778 return es7243.setVoiceMute(mute) == RESULT_OK;
779 }
780 bool setVolume(int volume) {
781 return es7243.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
782 }
783 int getVolume() {
784 int vol;
786 return vol;
787 }
788 ES7243& driver() { return es7243; }
789
790 protected:
792
798 bool deinit() { return es7243.deinit() == RESULT_OK; }
799
801 return es7243.ctrlStateActive(mode, true) == RESULT_OK;
802 }
804 return es7243.configI2S(mode, &iface) == RESULT_OK;
805 }
806};
807
815 public:
816 AudioDriverES7243eClass(uint16_t deviceAddr = 0x10) {
817 i2c_default_address = deviceAddr;
818 }
819 bool setMute(bool mute) {
820 return mute ? setVolume(0) == RESULT_OK : setVolume(volume) == RESULT_OK;
821 }
822 bool setVolume(int volume) {
823 this->volume = volume;
824 return es7243e.setVoiceVolume(limitValue(volume, 0, 100)) ==
825 RESULT_OK;
826 }
827 int getVolume() {
828 int vol = 0;
830 return vol;
831 }
832 ES7243E& driver() { return es7243e; }
833
834 protected:
836 int volume = 0;
837
843 bool deinit() { return es7243e.deinit() == RESULT_OK; }
844
846 return es7243e.ctrlStateActive(mode, true) == RESULT_OK;
847 }
849 return es7243e.configI2S(mode, &iface) == RESULT_OK;
850 }
851};
852
859 public:
861 i2c_default_address = deviceAddr;
862 }
863 bool setMute(bool mute) {
864 return es8156.setVoiceMute(mute) == RESULT_OK;
865 }
866 bool setVolume(int volume) {
867 AD_LOGD("volume %d", volume);
868 return es8156.setVoiceVolume(limitValue(volume, 0, 100)) ==
869 RESULT_OK;
870 }
871 int getVolume() {
872 int vol;
874 return vol;
875 }
876 ES8156& driver() { return es8156; }
877
878 protected:
880
886 bool deinit() { return es8156.deinit() == RESULT_OK; }
887
889 return es8156.ctrlStateActive(mode, true) == RESULT_OK;
890 }
892 return es8156.configI2S(mode, &iface) == RESULT_OK;
893 }
894};
895
902 public:
903 AudioDriverWM8731Class(uint16_t deviceAddr = WM8731_ADDR) {
904 i2c_default_address = deviceAddr;
905 }
906 bool setMute(bool mute) { return wm8731.setVoiceMute(mute) == RESULT_OK; }
907 bool setVolume(int volume) {
908 AD_LOGD("volume %d", volume);
909 return wm8731.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
910 }
911 int getVolume() {
912 int vol;
914 return vol;
915 }
916 WM8731& driver() { return wm8731; }
917
918 protected:
920
926 bool deinit() { return wm8731.deinit() == RESULT_OK; }
927
929 return wm8731.ctrlStateActive(mode, true) == RESULT_OK;
930 }
932 return wm8731.configI2S(mode, &iface) == RESULT_OK;
933 }
934};
935
942 public:
944 i2c_default_address = deviceAddr;
945 }
946 bool setMute(bool mute) { return sgtl5000.setVoiceMute(mute) == RESULT_OK; }
947 bool setVolume(int volume) {
948 AD_LOGD("volume %d", volume);
949 return sgtl5000.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
950 }
951 int getVolume() {
952 int vol;
954 return vol;
955 }
956 SGTL5000& driver() { return sgtl5000; }
957
958 protected:
960
966 bool deinit() { return sgtl5000.deinit() == RESULT_OK; }
967
969 return sgtl5000.ctrlStateActive(mode, true) == RESULT_OK;
970 }
972 return sgtl5000.configI2S(mode, &iface) == RESULT_OK;
973 }
974};
975
982 public:
984 i2c_default_address = deviceAddr;
985 }
986 bool setMute(bool mute) { return es8311.setVoiceMute(mute) == RESULT_OK; }
987 bool setVolume(int volume) {
988 return es8311.setVoiceVolume(limitValue(volume, 0, 100)) ==
989 RESULT_OK;
990 }
991 int getVolume() {
992 int vol;
994 return vol;
995 }
996
997 bool setInputVolume(int volume) override {
998 // map volume from 0 - 100 to the 8 mic gain steps (0, 6, 12, ... 42 dB)
999 es8311_mic_gain_t gains[] = {
1003 int vol = limitValue(volume, 0, 100);
1004 int idx = mapVolume(vol, 0, 100, 0, 7);
1005 es8311_mic_gain_t gain = gains[idx];
1006 AD_LOGD("input volume: %d -> gain idx %d", volume, idx);
1007 return es8311.setMicGain(gain) == RESULT_OK;
1008 }
1009
1010 bool isInputVolumeSupported() { return true; }
1011
1013 void setMasterClockSource(int source) { master_clock_source = source; }
1014
1015 ES8311& driver() { return es8311; }
1016
1017 protected:
1020
1022 int mclk_src = master_clock_source;
1023 if (mclk_src == -1) {
1024 mclk_src = 0; // = FROM_MCLK_PIN;
1025 }
1026 AD_LOGI("MCLK_SOURCE: %d", mclk_src);
1027
1028 assert(getI2C() != nullptr);
1031 es8311.setMclkSrc(mclk_src);
1032 return es8311.init(&codec_cfg) == RESULT_OK;
1033 }
1034 bool deinit() { return es8311.deinit() == RESULT_OK; }
1035
1037 return es8311.ctrlStateActive(mode, true) == RESULT_OK;
1038 }
1040 return es8311.configI2S(mode, &iface) == RESULT_OK;
1041 }
1042};
1043
1050 public:
1052 i2c_default_address = deviceAddr;
1053 }
1054 bool setMute(bool mute) { return es8374.setVoiceMute(mute) == RESULT_OK; }
1055 bool setVolume(int volume) {
1056 AD_LOGD("volume %d", volume);
1057 return es8374.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
1058 }
1060 int vol;
1061 es8374.getVoiceVolume(&vol);
1062 return vol;
1063 }
1064
1066 ES8374& driver() { return es8374; }
1067
1068 protected:
1070
1072 auto codec_mode = this->codec_cfg.get_mode();
1075 return es8374.init(&codec_cfg, codec_mode) == RESULT_OK;
1076 }
1077 bool deinit() { return es8374.deinit() == RESULT_OK; }
1078
1080 return es8374.ctrlStateActive(mode, true) == RESULT_OK;
1081 }
1083 return es8374.configI2S(mode, &iface) == RESULT_OK;
1084 }
1085};
1086
1093 public:
1095 int volumeHack = AI_THINKER_ES8388_VOLUME_HACK) {
1096 i2c_default_address = deviceAddr;
1097 volume_hack = volumeHack;
1098 }
1099 bool setMute(bool mute) {
1100 line_active[0] = !mute;
1101 line_active[1] = !mute;
1102 return es8388.setVoiceMute(mute) == RESULT_OK;
1103 }
1104 // mute individual line: lines start at 0 (valid range 0:1)
1105 bool setMute(bool mute, int line) {
1106 if (line > 1) {
1107 AD_LOGD("invalid line %d", line);
1108 return false;
1109 }
1110 // mute is managed on line level, so deactivate global mute
1111 line_active[line] = !mute;
1112 if (line_active[0] && line_active[1]) {
1114 } else if (!line_active[0] && !line_active[1]) {
1116 } else if (line_active[0]) {
1118 } else if (line_active[1]) {
1120 }
1121 return false;
1122 }
1123 bool setVolume(int volume) {
1124 AD_LOGD("volume %d", volume);
1125 return es8388.setVoiceVolume(limitValue(volume, 0, 100)) == RESULT_OK;
1126 }
1128 int vol;
1129 es8388.getVoiceVolume(&vol);
1130 return vol;
1131 }
1132
1134 ES8388& driver() { return es8388; }
1135
1136 bool setInputVolume(int volume) {
1137 // mapVolume values from 0 - 100 to 0 to 8
1138
1139 // es_mic_gain_t: MIC_GAIN_MIN = -1, 0,3,6,9,12,15,18,21,24 MIC_GAIN_MAX =
1140 // 25
1141
1142 // Vol: 0, 12.5, 25, 37.5, 50, 62.5, 75, 87.5, 100
1143 // idx: 0, 1, 2, 3, 4, 5, 6, 7, 8
1144 // dB/gain: 0, 3, 6, 9, 12, 15, 18, 21, 24
1145 // factor: 1, 2, 4, 8, 16, 32, 63, 126, 252
1146
1147 // es8388 Register 9 – ADC Control 1
1148 // dB MicL MicR
1149 // 0 0000 0000
1150 // 3 0001 0001
1151 // 6 0010 0010
1152 // 9 0011 0011
1153 // 12 0100 0100
1154 // 15 0101 0101
1155 // 18 0110 0110
1156 // 21 0111 0111
1157 // 24 1000 1000
1158
1162
1163 int vol = limitValue(volume, 0, 100);
1164 int idx = mapVolume(vol, 0, 100, 0, 8);
1165
1166 es_mic_gain_t gain = gains[idx];
1167 AD_LOGD("input volume: %d -> gain %d [dB] (idx: %d of 0..8)", volume, gain,
1168 idx);
1169 return setMicrophoneGain(gain);
1170 }
1171
1173 return es8388.setMicGain(gain) == RESULT_OK;
1174 }
1175
1176 bool isInputVolumeSupported() { return true; }
1177
1179 this->volume_hack = volume_hack;
1181 }
1182 int getVolumeHack() { return volume_hack; }
1183
1184 protected:
1186 bool line_active[2] = {true, true};
1188
1194 bool deinit() { return es8388.deinit() == RESULT_OK; }
1195
1197 return es8388.ctrlStateActive(mode, true) == RESULT_OK;
1198 }
1200 return es8388.configI2S(mode, &iface) == RESULT_OK;
1201 }
1202};
1203
1210 public:
1212 i2c_default_address = deviceAddr;
1213 }
1214 bool setMute(bool mute) { return tas5805m.setMute(mute) == RESULT_OK; }
1215 bool setVolume(int volume) {
1216 AD_LOGD("volume %d", volume);
1217 return tas5805m.setVolume(limitValue(volume, 0, 100)) == RESULT_OK;
1218 }
1220 int vol;
1221 tas5805m.getVolume(&vol);
1222 return vol;
1223 }
1224
1226 TAS5805M& driver() { return tas5805m; }
1227
1228 protected:
1230
1236 bool deinit() { return tas5805m.deinit() == RESULT_OK; }
1237};
1238
1245 public:
1247 i2c_default_address = deviceAddr;
1248 }
1249
1251 WM8960& driver() { return wm8960; }
1252
1254 p_pins = &pins;
1255 codec_cfg = codecCfg;
1257 if (!p_pins->begin()) {
1258 AD_LOGE("AudioBoard::pins::begin failed");
1259 return false;
1260 }
1261
1262 // define wire object
1266
1267 // setup wm8960
1268 int features = getFeatures(codecCfg);
1269 if (!wm8960.init(features)) {
1270 AD_LOGE("wm8960.init");
1271 return false;
1272 }
1274 if (!wm8960.activate()) {
1275 AD_LOGE("wm8960.activate");
1276 return false;
1277 }
1278 if (!configure_clocking()) {
1279 AD_LOGE("configure_clocking");
1280 return false;
1281 }
1282 return true;
1283 }
1284 bool end(void) {
1286 wm8960.deinit();
1287 return true;
1288 }
1289 virtual bool setConfig(CodecConfig codecCfg) {
1290 codec_cfg = codecCfg;
1291 return configure_clocking();
1292 }
1293
1294 bool setMute(bool enable) { return setVolume(enable ? 0 : volume_out); }
1295
1297 bool setVolume(int volume) {
1298 volume_out = limitValue(volume, 0, 100);
1299 int vol_int =
1300 volume_out == 0.0 ? 0 : mapVolume(volume_out, 0, 100, 30, 0x7F);
1301 return wm8960.setOutputVolume(vol_int);
1302 }
1303
1304 int getVolume() { return volume_out; }
1305
1306 bool setInputVolume(int volume) {
1307 volume_in = limitValue(volume, 0, 100);
1308 int vol_int = mapVolume(volume_in, 0, 100, 0, 30);
1309 return wm8960.adjustInputVolume(vol_int);
1310 }
1311 bool isVolumeSupported() { return true; }
1312
1313 bool isInputVolumeSupported() { return true; }
1314
1316 void setI2CRetryCount(int cnt) { i2c_retry_count = cnt; }
1317
1319 void setEnablePLL(bool active) { vs1053_enable_pll = active; }
1320
1322 void setMclkHz(uint32_t hz) { vs1053_mclk_hz = hz; }
1323
1325
1326 protected:
1328 int volume_in = 100;
1329 int volume_out = 100;
1331 uint32_t vs1053_mclk_hz = 0;
1333
1335 int features = 0;
1336 switch (cfg.output_device) {
1337 case DAC_OUTPUT_LINE1:
1338 features = features | WM8960_FEATURE_SPEAKER;
1339 break;
1340 case DAC_OUTPUT_LINE2:
1341 features = features | WM8960_FEATURE_HEADPHONE;
1342 break;
1343 case DAC_OUTPUT_ALL:
1344 features = features | WM8960_FEATURE_SPEAKER | WM8960_FEATURE_HEADPHONE;
1345 break;
1346 default:
1347 break;
1348 }
1349 switch (cfg.input_device) {
1350 case ADC_INPUT_LINE1:
1351 features = features | WM8960_FEATURE_MICROPHONE1;
1352 break;
1353 case ADC_INPUT_LINE2:
1354 features = features | WM8960_FEATURE_MICROPHONE2;
1355 break;
1356 case ADC_INPUT_ALL:
1357 features = features | WM8960_FEATURE_MICROPHONE1 |
1359 break;
1360 default:
1361 break;
1362 }
1363 AD_LOGI("features: %d", features);
1364 return features;
1365 }
1366
1368 if (vs1053_mclk_hz == 0) {
1369 // just pick a multiple of the sample rate
1371 }
1377 AD_LOGE("wm8960.configureClocking");
1378 return false;
1379 }
1380 return true;
1381 }
1382
1384 switch (rate) {
1385 case 48000:
1387 case 44100:
1389 case 32000:
1391 case 24000:
1393 case 22050:
1395 case 16000:
1397 case 12000:
1399 case 11025:
1401 case 8018:
1403 case 8000:
1405 default:
1406 AD_LOGE("Unsupported rate: %d", rate);
1408 }
1409 }
1410
1412 switch (bits) {
1413 case 16:
1414 return WM8960_WL_16BITS;
1415 case 20:
1416 return WM8960_WL_20BITS;
1417 case 24:
1418 return WM8960_WL_24BITS;
1419 case 32:
1420 return WM8960_WL_32BITS;
1421 default:
1422 AD_LOGE("Unsupported bits: %d", bits);
1423 return WM8960_WL_16BITS;
1424 }
1425 }
1426
1429 return is_master ? WM8960_MODE_MASTER : WM8960_MODE_SLAVE;
1430 }
1431};
1432
1439 public:
1441 i2c_default_address = deviceAddr;
1442 }
1443
1444 bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) override {
1445 p_pins = &pins;
1447 if (!p_pins->begin()) {
1448 AD_LOGE("AudioBoard::pins::begin failed");
1449 return false;
1450 }
1451 bool rc = true;
1452 rc = wm8078.begin(getI2C(), getI2CAddress());
1453 setConfig(codecCfg);
1454
1455 // setup initial default volume
1457
1458 return rc;
1459 }
1460
1461 bool setConfig(CodecConfig codecCfg) override {
1462 codec_cfg = codecCfg;
1463 bool is_dac = codec_cfg.output_device != DAC_OUTPUT_NONE;
1464 bool is_adc = codec_cfg.input_device != ADC_INPUT_NONE;
1465 wm8078.cfgADDA(is_dac, is_adc);
1466
1467 bool is_mic = codec_cfg.input_device == ADC_INPUT_LINE1 ||
1469 bool is_linein = codec_cfg.input_device == ADC_INPUT_LINE2 ||
1471 bool is_auxin = codec_cfg.input_device == ADC_INPUT_LINE3 ||
1473 wm8078.cfgInput(is_mic, is_linein, is_auxin);
1474 wm8078.cfgOutput(is_dac, false);
1475
1476 int bits = toBits(codecCfg.i2s.bits);
1477 if (bits < 0) return false;
1478 int i2s = toI2S(codecCfg.i2s.fmt);
1479 if (i2s < 0) return false;
1480 wm8078.cfgI2S(i2s, bits);
1481 return true;
1482 }
1483
1484 bool end() override {
1485 setVolume(0);
1486 wm8078.cfgADDA(false, false);
1487 return true;
1488 }
1489
1491 bool setMute(bool mute, int line) override {
1492 int scaled = mute ? 0 : mapVolume(volume, 0, 100, 0, 63);
1493 switch (line) {
1494 case 0:
1495 wm8078.setSPKvol(scaled);
1496 return true;
1497 case 1:
1498 wm8078.setHPvol(scaled, scaled);
1499 return true;
1500 default:
1501 return false;
1502 }
1503 return false;
1504 }
1505
1506 bool setMute(bool mute) override {
1507 if (mute) {
1508 // set volume to 0
1509 wm8078.setSPKvol(0);
1510 wm8078.setHPvol(0, 0);
1511 } else {
1512 // restore volume
1514 }
1515 return true;
1516 }
1517
1518 bool setVolume(int volume) override {
1519 this->volume = volume;
1520 int scaled = mapVolume(volume, 0, 100, 0, 63);
1521 wm8078.setSPKvol(scaled);
1522 wm8078.setHPvol(scaled, scaled);
1523 return true;
1524 }
1525
1526 int getVolume() override { return volume; }
1527
1528 bool setInputVolume(int volume) override {
1529 int scaled = mapVolume(volume, 0, 100, 0, 63);
1530 wm8078.setMICgain(scaled);
1531 wm8078.setAUXgain(scaled);
1532 wm8078.setLINEINgain(scaled);
1533 return true;
1534 }
1535
1536 bool isVolumeSupported() override { return true; }
1537
1538 bool isInputVolumeSupported() override { return true; }
1539
1540 WM8978& driver() { return wm8078; }
1541
1542 protected:
1544 int volume = 0;
1545
1549 switch (fmt) {
1550 case I2S_NORMAL:
1551 return 2;
1552 case I2S_LEFT:
1553 return 1;
1554 case I2S_RIGHT:
1555 return 0;
1556 case I2S_DSP:
1557 return 3;
1558 default:
1559 break;
1560 }
1561 return -1;
1562 }
1563
1564 // len: 0, 16 digits; 1, 20 digits; 2, 24 digits; 3, 32 digits;
1566 switch (bits) {
1567 case BIT_LENGTH_16BITS:
1568 return 0;
1569 case BIT_LENGTH_20BITS:
1570 return 1;
1571 case BIT_LENGTH_24BITS:
1572 return 2;
1573 case BIT_LENGTH_32BITS:
1574 return 3;
1575 default:
1576 break;
1577 }
1578 return -1;
1579 }
1580};
1581
1588 public:
1590 this->i2c_default_address = deviceAddr;
1591 }
1592
1594 WM8994& driver() { return wm8994; }
1595
1596 virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) {
1597 codec_cfg = codecCfg;
1598 p_pins = &pins;
1600 if (!p_pins->begin()) {
1601 AD_LOGE("AudioBoard::pins::begin failed");
1602 return false;
1603 }
1604 // manage reset pin -> active high
1605 setPAPower(true);
1606 delayMs(10);
1608 uint32_t freq = codecCfg.getRateNumeric();
1609 uint16_t outputDevice = getOutput(codec_cfg.output_device);
1610
1613 // Don't treat a non-zero init() counter as fatal: writeReg16Verified()
1614 // now actually detects registers that fail to retain a write (logged
1615 // via AD_LOGE at the point of failure), where the older writeReg16()
1616 // silently always reported success. Aborting begin() here would regress
1617 // from "plays with some registers imperfectly configured" (the previous
1618 // behavior) to "doesn't play at all" for a problem that was already
1619 // there, just previously invisible - keep going best-effort instead.
1620 wm8994.init(outputDevice, vol, freq);
1621 // AudioBoard::begin() unconditionally calls setVolume(DRIVER_DEFAULT_VOLUME)
1622 // right after this returns - init() above already wrote the volume
1623 // registers once; skip that redundant second round-trip to the exact
1624 // same registers (0x1C/0x1D/0x420/0x422) once, here.
1625 volume_set_in_begin = true;
1626 return true;
1627 }
1628
1629 bool setMute(bool mute) {
1630 uint32_t rc = mute ? wm8994.pause() : wm8994.resume();
1631 return rc == 0;
1632 }
1633
1634 bool setVolume(int volume) {
1635 if (volume_set_in_begin) {
1636 volume_set_in_begin = false;
1637 this->volume = volume;
1638 return true;
1639 }
1640 this->volume = volume;
1642 return wm8994.setVolume(vol) == 0;
1643 }
1644 int getVolume() { return volume; }
1645
1646 protected:
1650
1651 bool deinit() {
1653 cnt += wm8994.reset();
1654 setPAPower(false);
1655 return cnt == 0;
1656 }
1657
1658 uint16_t getOutput(output_device_t output_device) {
1659 switch (output_device) {
1660 case DAC_OUTPUT_NONE:
1661 return 0;
1662 case DAC_OUTPUT_LINE1:
1664 case DAC_OUTPUT_LINE2:
1666 case DAC_OUTPUT_ALL:
1668 }
1670 }
1671};
1672
1679 public:
1680 AudioDriverPCM3168Class(uint16_t deviceAddr = 0x44) {
1681 i2c_default_address = deviceAddr;
1682 }
1683
1684 bool setMute(bool mute) { return driver.setMute(mute); }
1685
1686 bool setMute(bool mute, int line) { return driver.setMute(line, mute); }
1687
1688 bool setVolume(int vol) {
1689 volume = vol;
1690 return driver.setVolume(100.0 * vol);
1691 }
1692 int getVolume() { return volume; }
1693
1694 protected:
1697
1701 return true;
1702 }
1703 bool deinit() { return driver.end(); }
1704 bool controlState(codec_mode_t mode) { return true; }
1706 if (iface.mode == MODE_MASTER) {
1707 AD_LOGE("Only slave is supported: MCU must be master");
1708 return false;
1709 }
1711 switch (iface.bits) {
1712 case BIT_LENGTH_16BITS:
1713 if (iface.fmt != I2S_RIGHT) {
1714 AD_LOGW("Only I2S_RIGHT is supported for 16 bits");
1715 }
1717 break;
1718 case BIT_LENGTH_32BITS:
1719 case BIT_LENGTH_24BITS:
1720 if (iface.signal_type == SIGNAL_TDM) {
1721 switch (iface.fmt) {
1722 case I2S_NORMAL:
1724 break;
1725 case I2S_LEFT:
1727 break;
1728 default:
1729 AD_LOGE("Unsupported fmt for tdm");
1730 return false;
1731 }
1732 } else {
1733 switch (iface.fmt) {
1734 case I2S_NORMAL:
1736 break;
1737 case I2S_LEFT:
1739 break;
1740 case I2S_RIGHT:
1742 break;
1743 case I2S_DSP:
1745 break;
1746 default:
1747 AD_LOGE("Unsupported fmt");
1748 return false;
1749 }
1750 }
1751 break;
1752 default:
1753 AD_LOGE("Unsupported bits");
1754 return false;
1755 }
1756
1757 return driver.begin(fmt);
1758 }
1759};
1760
1767 public:
1769 AD_LOGI("AudioDriverLyratMiniClass::begin");
1770 p_pins = &pins;
1771 codec_cfg = codecCfg;
1772
1773 // setup SPI for SD
1774 // pins.setSPIActiveForSD(codecCfg.sd_active);
1775
1776 // Start ES8311
1777 AD_LOGI("starting ES8311");
1778 if (!p_pins->begin()) {
1779 AD_LOGE("AudioBoard::pins::begin failed");
1780 return false;
1781 }
1782 dac.setPins(this->pins());
1783 if (!dac.setConfig(codecCfg)) {
1784 AD_LOGE("setConfig failed");
1785 return false;
1786 }
1787 setPAPower(true);
1789
1790 // Start ES7243
1791 if (codecCfg.input_device != ADC_INPUT_NONE) {
1792 AD_LOGI("starting ES7243");
1793 adc.setPins(this->pins());
1794 if (!adc.setConfig(codecCfg)) {
1795 AD_LOGE("adc.begin failed");
1796 return false;
1797 }
1798 }
1799
1800 return true;
1801 }
1802 bool end(void) {
1803 int rc = 0;
1804 rc += dac.end();
1805 rc += adc.end();
1806 return rc == 2;
1807 }
1808 bool setMute(bool enable) override { return dac.setMute(enable); }
1809 bool setVolume(int volume) override { return dac.setVolume(volume); }
1810 int getVolume() override { return dac.getVolume(); }
1811 bool setInputVolume(int volume) override { return adc.setVolume(volume); }
1812 int getInputVolume() { return adc.getVolume(); }
1813 bool isInputVolumeSupported() override { return true; }
1814
1815 protected:
1818};
1819
1826 public:
1827 AudioDriverCombined(AudioDriver& dac, AudioDriver& adc, bool sdActive = true)
1828 : p_dac(&dac), p_adc(&adc) {}
1829
1831 AD_LOGI("AudioDriverCombined::begin");
1832 p_pins = &pins;
1833 codec_cfg = codecCfg;
1834
1835 assert(p_dac != nullptr);
1836 assert(p_adc != nullptr);
1837
1838 AD_LOGI("sd_active: %d", codecCfg.sd_active);
1840 AD_LOGI("sdmmc_active: %d", codecCfg.sdmmc_active);
1842
1843 // Start
1844 AD_LOGI("starting DAC");
1845 if (!p_pins->begin()) {
1846 AD_LOGE("AudioBoard::pins::begin failed");
1847 return false;
1848 }
1849 p_dac->setPins(this->pins());
1850 if (!p_dac->setConfig(codecCfg)) {
1851 AD_LOGE("setConfig failed");
1852 return false;
1853 }
1854 setPAPower(true);
1856
1857 // Start ADC
1858 if (codecCfg.input_device != ADC_INPUT_NONE) {
1859 AD_LOGI("starting ADC");
1860 p_adc->setPins(this->pins());
1861 if (!p_adc->setConfig(codecCfg)) {
1862 AD_LOGE("adc.begin failed");
1863 return false;
1864 }
1865 }
1866 return true;
1867 }
1868 bool end(void) {
1869 int rc = 0;
1870 rc += p_dac->end();
1871 rc += p_adc->end();
1872 return rc == 2;
1873 }
1874 bool setMute(bool enable) override { return p_dac->setMute(enable); }
1875 bool setVolume(int volume) override { return p_dac->setVolume(volume); }
1876 int getVolume() override { return p_dac->getVolume(); }
1877 bool setInputVolume(int volume) override { return p_adc->setVolume(volume); }
1878 int getInputVolume() { return p_adc->getVolume(); }
1879 bool isInputVolumeSupported() override { return true; }
1880
1881 protected:
1882 AudioDriver* p_dac = nullptr;
1883 AudioDriver* p_adc = nullptr;
1884};
1885
1904template <class T, uint8_t DefaultI2CAddress = 0>
1906 public:
1907 AudioDriverZephyrT(uint8_t i2cAddress = DefaultI2CAddress) {
1908 if (i2cAddress != 0) i2c_default_address = i2cAddress;
1909 }
1910
1912 T& driver() { return zephyr_driver; }
1913
1914 bool setMute(bool enable) override { return zephyr_driver.setMute(enable); }
1915
1916 bool setVolume(int volume) override {
1917 volume_value = limitValue(volume, 0, 100);
1918 return zephyr_driver.setVolume(volume_value);
1919 }
1920
1921 int getVolume() override { return volume_value; }
1922
1923 bool setInputVolume(int volume) override {
1924 return zephyr_driver.setInputVolume(limitValue(volume, 0, 100));
1925 }
1926
1927 int getInputVolume() { return zephyr_driver.getInputVolume(); }
1928
1929 bool isInputVolumeSupported() override {
1930 return zephyr_driver.isInputVolumeSupported();
1931 }
1932
1933 protected:
1935 int volume_value = 100;
1936
1937 bool init(codec_config_t codecCfg) override {
1938 zephyr_driver.setWire(getI2C());
1939 zephyr_driver.setAddress((uint8_t)getI2CAddress());
1940 return zephyr_driver.setDevices(codecCfg.input_device, codecCfg.output_device);
1941 }
1943 bool deinit() override { return zephyr_driver.setMute(true); }
1944 bool controlState(codec_mode_t mode) override { return true; }
1946 bool configInterface(codec_mode_t mode, I2SDefinition iface) override {
1947 CodecConfig cfg;
1948 cfg.i2s = iface;
1949 return zephyr_driver.begin((uint32_t)cfg.getRateNumeric(),
1950 (uint8_t)cfg.getBitsNumeric());
1951 }
1952};
1953
1954/* -- NAU8325 Driver Class--- */
1956 public:
1958 i2c_default_address = deviceAddr;
1959 }
1960
1961 NAU8325* nau8325 = nullptr; // pointer to construct later
1962
1964 if (nau8325) delete nau8325;
1965 }
1966
1968 AD_LOGI("AudioDriverNAU8325Class::begin");
1969
1970 this->p_pins = &pins;
1972 if (!p_pins->begin()) {
1973 AD_LOGE("AudioBoard::pins::begin failed");
1974 return false;
1975 }
1976
1977 // Get I2C config
1978 auto i2c_opt = pins.getI2CPins(PinFunction::CODEC);
1979 if (!i2c_opt) {
1980 AD_LOGE("No I2C pins defined for codec");
1981 return false;
1982 }
1983 InfoI2C val = i2c_opt.value();
1984
1985 // Create instance with required params (only TwoWire&)
1986 nau8325 = new NAU8325(val.p_wire);
1987
1988 // Set MCLK if available
1990 if (mclk != GPIO_UNDEFINED) {
1991 getGPIO().pinMode(mclk, OUTPUT);
1992 getGPIO().digitalWrite(mclk, HIGH);
1993 delayMs(10); // optional small delay to stabilize
1994 }
1995
1996 // Begin your driver using known public methods
1997 int fs = cfg.getRateNumeric();
1998 int bits = cfg.getBitsNumeric();
1999
2000 AD_LOGI("Calling nau8325->begin(fs=%d, bits=%d)", fs, bits);
2001 if (!nau8325->begin(fs, bits)) {
2002 AD_LOGE("NAU8325 begin failed");
2003 return false;
2004 }
2005
2006 return true;
2007 }
2008
2009 bool end() override {
2010 if (nau8325) {
2011 nau8325->powerOff();
2012 }
2013 return true;
2014 }
2015
2016 bool setMute(bool enable) override {
2017 if (!nau8325) return false;
2018 nau8325->softMute(enable);
2019 return true;
2020 }
2021
2022 bool setVolume(int volume) override {
2023 if (!nau8325) return false;
2024 // Mapping volume (0–100) to 0–255 (NAU range)
2025 uint8_t val = mapVolume(volume, 0, 100, 0, 255);
2026 nau8325->setVolume(val, val); // assuming stereo
2027 return true;
2028 }
2029
2030 int getVolume() override {
2031 // NAU8325 doesn't have a getVolume, so return last set or dummy
2032 return 100;
2033 }
2034};
2035
2036#ifdef ARDUINO
2037// currently only supported in Arduino because we do not have a platform
2038// independent SPI API
2044class AudioDriverAD1938Class : public AudioDriver {
2045 public:
2046 bool begin(CodecConfig codecCfg, DriverDeviceInfo& pins) override {
2047 p_pins = &pins;
2048 int clatch = pins.getPinID(PinFunction::LATCH);
2049 if (clatch < 0) return false;
2050 int reset = pins.getPinID(PinFunction::RESET);
2051 if (reset < 0) return false;
2052 auto spi_opt = pins.getSPIPins(PinFunction::CODEC);
2053 SPIClass* p_spi = nullptr;
2054 if (spi_opt) {
2055 p_spi = (SPIClass*)spi_opt.value().p_spi;
2056 } else {
2057 p_spi = &SPI;
2058 p_spi->begin();
2059 }
2060 setupI2CAddress();
2061 // setup pins
2062 if (!p_pins->begin()) {
2063 AD_LOGE("AudioBoard::pins::begin failed");
2064 return false;
2065 }
2066 // setup ad1938
2067 ad1938.begin(getGPIO(), codecCfg, clatch, reset, *p_spi);
2068 ad1938.enable();
2069 ad1938.setMute(false);
2070 return true;
2071 }
2072 virtual bool setConfig(CodecConfig codecCfg) {
2073 assert(p_pins != nullptr);
2074 bool result = begin(codecCfg, *p_pins);
2075 return result;
2076 }
2077 bool end(void) override { return ad1938.end(); }
2078 bool setMute(bool mute) override { return ad1938.setMute(mute); }
2079 // mutes an individual DAC: valid range (0:7)
2080 bool setMute(bool mute, int line) {
2081 if (line < 0 || line > 7) return false;
2082 return ad1938.setVolume(
2083 line, mute ? 0.0f : (static_cast<float>(volumes[line]) / 100.0f));
2084 }
2085
2087 bool setVolume(int volume) override {
2088 this->volume = volume;
2089 for (int j = 0; j < 8; j++) {
2090 volumes[j] = volume;
2091 }
2092 return ad1938.setVolume(static_cast<float>(volume) / 100.0f);
2093 }
2096 bool setVolume(int volume, int line) {
2097 if (line < 0 || line > 7) return false;
2098 volumes[line] = volume;
2099 return ad1938.setVolume(line, static_cast<float>(volume) / 100.0f);
2100 }
2101
2102 int getVolume() override { return volume; }
2103 bool setInputVolume(int volume) override { return false; }
2104 bool isVolumeSupported() override { return true; }
2105 bool isInputVolumeSupported() override { return false; }
2106
2107 DriverDeviceInfo& pins() { return *p_pins; }
2108 AD1938& driver() { return ad1938; }
2109
2110 protected:
2111 AD1938 ad1938;
2112 int volume = 100;
2113 int volumes[8] = {100, 100, 100, 100, 100, 100, 100, 100};
2114};
2115
2116#endif
2117
2124class AudioDriverTLV320AIC3104Class : public AudioDriverZephyrT<TLV320AIC3104, 0x18> {
2125public:
2126 // Set to 0 (default) to use BCLK instead of MCLK. BCLK is calculated by sample rate, bits, and channels.
2127 bool setMclk(uint32_t _mclk) {
2128 mclk = _mclk;
2129 return true;
2130 }
2131
2132protected:
2133 uint32_t mclk = 0; // Defaults to using BCLK.
2134 bool configInterface(codec_mode_t mode, I2SDefinition iface) override {
2135 (void)mode;
2136 AD_LOGI("configInterface()");
2137
2138 uint32_t sample_rate = (uint32_t)codec_cfg.getRateNumeric();
2139 uint8_t bits = (uint8_t)codec_cfg.getBitsNumeric();
2140 uint8_t channels = (uint8_t)codec_cfg.getChannelsNumeric();
2141 return zephyr_driver.begin(sample_rate, bits, channels, iface.mode == MODE_MASTER, mclk);
2142 }
2143};
2144
2145
2146// -- Drivers
2199
2202
2203// -- Zephyr ported Drivers
2227
2228#ifdef ARDUINO
2230static AudioDriverAD1938Class AudioDriverAD1938;
2231#endif
2232
2233} // namespace audio_driver
#define DRIVER_DEFAULT_VOLUME
Definition ConfigAudioDriver.h:5
#define AI_THINKER_ES8388_VOLUME_HACK
Definition ConfigAudioDriver.h:20
#define RESULT_OK
Definition DriverCommon.h:74
#define GPIO_UNDEFINED
Definition DriverCommon.h:131
#define HIGH
Definition DriverCommon.h:35
#define OUTPUT
Definition DriverCommon.h:44
#define DEFAULT_WIRE
Definition DriverCommon.h:32
#define LOW
Definition DriverCommon.h:38
#define AD_LOGD(...)
Definition Logger.h:12
#define AD_LOGI(...)
Definition Logger.h:13
#define AD_LOGE(...)
Definition Logger.h:15
#define AD_LOGW(...)
Definition Logger.h:14
Header-only driver class for the AC101 codec chip.
Definition AC101.h:108
error_t deinit()
Definition AC101.h:229
void setAddress(int addr)
Defines the I2C device address.
Definition AC101.h:177
error_t ctrlStateActive(codec_mode_t mode, bool ctrlStateActive)
Definition AC101.h:233
error_t setVoiceMute(bool enable)
Definition AC101.h:421
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Definition AC101.h:263
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition AC101.h:174
error_t setVoiceVolume(int volume)
Definition AC101.h:431
error_t getVoiceVolume(int *volume)
Definition AC101.h:438
error_t init(codec_config_t *codec_cfg)
Definition AC101.h:181
Definition API_GPIO.h:8
virtual bool digitalWrite(GpioPin pin, bool value)=0
virtual void pinMode(GpioPin pin, int mode)=0
Driver API for AC101 codec chip.
Definition AudioDriver.h:390
AC101 & driver()
Provides access to the wrapped AC101 driver instance.
Definition AudioDriver.h:406
bool deinit()
Definition AudioDriver.h:416
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:411
AudioDriverAC101Class(uint16_t deviceAddr=0x1A)
Definition AudioDriver.h:392
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:395
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:399
AC101 ac101
Definition AudioDriver.h:409
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:396
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:420
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:417
Driver API for CS42448 TDS DAC/ADC.
Definition AudioDriver.h:664
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:711
bool isInputVolumeSupported() override
Determines if setInputVolume() is supported.
Definition AudioDriver.h:717
CS42448 & driver()
Definition AudioDriver.h:720
bool isVolumeSupported() override
Determines if setVolume() is suppored.
Definition AudioDriver.h:716
CS42448 cs42448
Definition AudioDriver.h:723
bool setMute(bool enable) override
Mutes all output lines.
Definition AudioDriver.h:698
virtual bool setConfig(CodecConfig codecCfg)
changes the configuration
Definition AudioDriver.h:682
bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins) override
Starts the processing.
Definition AudioDriver.h:669
bool setVolume(int dac, int volume)
Definition AudioDriver.h:707
DriverDeviceInfo & pins()
Provides the pin information.
Definition AudioDriver.h:719
AudioDriverCS42448Class(uint16_t deviceAddr=0x48)
Definition AudioDriver.h:666
bool end(void) override
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:697
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:712
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:703
CodecConfig cfg
Definition AudioDriver.h:725
bool setMute(bool enable, int line)
Mute individual lines: only supported for some rare DACs.
Definition AudioDriver.h:699
int volume
Definition AudioDriver.h:724
Driver API for CS42L51 codec chip.
Definition AudioDriver.h:545
AudioDriverCS42L51Class(uint16_t deviceAddr=0x4A)
Definition AudioDriver.h:547
uint32_t getOutput(output_device_t output_device)
Definition AudioDriver.h:653
bool deinit()
Definition AudioDriver.h:604
uint32_t getInput(input_device_t input_device)
Definition AudioDriver.h:633
virtual bool setConfig(CodecConfig codecCfg)
changes the configuration
Definition AudioDriver.h:578
CS42L51 cs42l51
Definition AudioDriver.h:601
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:586
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:595
uint32_t getFrequency(samplerate_t rateNum)
Definition AudioDriver.h:611
virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:551
CS42L51 & driver()
Provides access to the wrapped CS42L51 driver instance.
Definition AudioDriver.h:598
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:591
int volume
Definition AudioDriver.h:602
Driver API for the CS43l22 codec chip on 0x94 (0x4A<<1)
Definition AudioDriver.h:430
CS43L22 & driver()
Provides access to the wrapped CS43L22 driver instance.
Definition AudioDriver.h:486
bool deinit()
Definition AudioDriver.h:492
virtual bool setConfig(CodecConfig codecCfg)
changes the configuration
Definition AudioDriver.h:467
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:474
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:483
uint32_t getFrequency(samplerate_t rateNum)
Definition AudioDriver.h:499
virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:436
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:479
CS43L22 cs43l22
Definition AudioDriver.h:489
int volume
Definition AudioDriver.h:490
uint16_t getOutput(output_device_t output_device)
Definition AudioDriver.h:523
AudioDriverCS43l22Class(uint16_t deviceAddr=0x4A)
Definition AudioDriver.h:432
Generic Driver API for boards with a different DAC and ADC codec chip.
Definition AudioDriver.h:1825
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1876
bool end(void)
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:1868
bool isInputVolumeSupported() override
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1879
bool setMute(bool enable) override
Mutes all output lines.
Definition AudioDriver.h:1874
AudioDriverCombined(AudioDriver &dac, AudioDriver &adc, bool sdActive=true)
Definition AudioDriver.h:1827
AudioDriver * p_dac
Definition AudioDriver.h:1882
AudioDriver * p_adc
Definition AudioDriver.h:1883
bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:1830
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1877
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1875
int getInputVolume()
Definition AudioDriver.h:1878
Driver API for ES7210 codec chip. This chip supports only input!
Definition AudioDriver.h:733
ES7210 & driver()
Definition AudioDriver.h:746
bool deinit()
Definition AudioDriver.h:757
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:752
AudioDriverES7210Class(uint16_t deviceAddr=ES7210_AD1_AD0_00 > > 1)
Definition AudioDriver.h:735
ES7210 es7210
Definition AudioDriver.h:749
bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:745
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:738
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:743
bool setInputVolume(int volume)
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:744
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:739
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:762
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:759
int volume
Definition AudioDriver.h:750
Driver API for Lyrat ES7243 codec chip.
Definition AudioDriver.h:772
AudioDriverES7243Class(uint16_t deviceAddr=0x13)
Definition AudioDriver.h:774
bool deinit()
Definition AudioDriver.h:798
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:793
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:777
ES7243 & driver()
Definition AudioDriver.h:788
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:783
ES7243 es7243
Definition AudioDriver.h:791
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:780
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:803
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:800
Driver API for ES7243e codec chip.
Definition AudioDriver.h:814
AudioDriverES7243eClass(uint16_t deviceAddr=0x10)
Definition AudioDriver.h:816
bool deinit()
Definition AudioDriver.h:843
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:838
ES7243E & driver()
Definition AudioDriver.h:832
ES7243E es7243e
Definition AudioDriver.h:835
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:819
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:827
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:822
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:848
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:845
int volume
Definition AudioDriver.h:836
Driver API for ES8156 codec chip.
Definition AudioDriver.h:858
AudioDriverES8156Class(uint16_t deviceAddr=ES8156::ES8156_ADDR)
Definition AudioDriver.h:860
ES8156 & driver()
Definition AudioDriver.h:876
bool deinit()
Definition AudioDriver.h:886
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:881
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:863
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:871
ES8156 es8156
Definition AudioDriver.h:879
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:866
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:891
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:888
Driver API for Lyrat ES8311 codec chip.
Definition AudioDriver.h:981
int master_clock_source
Definition AudioDriver.h:1019
bool deinit()
Definition AudioDriver.h:1034
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:1021
ES8311 es8311
Definition AudioDriver.h:1018
ES8311 & driver()
Definition AudioDriver.h:1015
void setMasterClockSource(int source)
Definition AudioDriver.h:1013
bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1010
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:986
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:991
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:997
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:987
AudioDriverES8311Class(uint16_t deviceAddr=ES8311::ES8311_ADDR)
Definition AudioDriver.h:983
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:1039
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:1036
Driver API for ES8374 codec chip.
Definition AudioDriver.h:1049
ES8374 & driver()
Provides access to the ES8374 driver.
Definition AudioDriver.h:1066
AudioDriverES8374Class(uint16_t deviceAddr=ES8374::ES8374_ADDR)
Definition AudioDriver.h:1051
bool deinit()
Definition AudioDriver.h:1077
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:1071
ES8374 es8374
Definition AudioDriver.h:1069
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:1054
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1059
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1055
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:1082
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:1079
Driver API for ES8388 codec chip.
Definition AudioDriver.h:1092
int getVolumeHack()
Definition AudioDriver.h:1182
ES8388 & driver()
Provides access to the ES8388 driver.
Definition AudioDriver.h:1134
bool deinit()
Definition AudioDriver.h:1194
int volume_hack
Definition AudioDriver.h:1187
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:1189
bool setMute(bool mute, int line)
Mute individual lines: only supported for some rare DACs.
Definition AudioDriver.h:1105
bool line_active[2]
Definition AudioDriver.h:1186
ES8388 es8388
Definition AudioDriver.h:1185
bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1176
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:1099
void setVolumeHack(int volume_hack)
Definition AudioDriver.h:1178
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1127
bool setMicrophoneGain(es_mic_gain_t gain)
Definition AudioDriver.h:1172
AudioDriverES8388Class(uint16_t deviceAddr=ES8388::ES8388_ADDR, int volumeHack=1)
Definition AudioDriver.h:1094
bool setInputVolume(int volume)
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1136
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1123
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:1199
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:1196
Abstract Driver API for codec chips.
Definition AudioDriver.h:182
virtual bool setMute(bool enable)=0
Mutes all output lines.
virtual bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:250
virtual bool end(void)
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:232
int i2c_default_address
Definition AudioDriver.h:329
void setPins(DriverDeviceInfo &pins)
Definition AudioDriver.h:254
virtual bool setInputVolume(int volume)
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:246
bool setPAPower(bool enable)
Sets the PA Power pin to active or inactive.
Definition AudioDriver.h:257
virtual bool isVolumeSupported()
Determines if setVolume() is suppored.
Definition AudioDriver.h:248
API_GPIO & getGPIO()
Definition AudioDriver.h:321
CodecConfig codec_cfg
Definition AudioDriver.h:327
virtual bool setVolume(int volume)=0
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
void setupI2CAddress()
If no address is defined in the pins we provide it here.
Definition AudioDriver.h:311
virtual bool setI2CAddress(uint16_t adr)
Defines the i2c address.
Definition AudioDriver.h:279
virtual bool setMute(bool mute, int line)
Mute individual lines: only supported for some rare DACs.
Definition AudioDriver.h:236
virtual int getI2CAddress()
Provides the i2c address.
Definition AudioDriver.h:298
virtual i2c_bus_handle_t getI2C()
Determine the TwoWire object from the I2C config or use Wire.
Definition AudioDriver.h:336
int mapVolume(int x, int in_min, int in_max, int out_min, int out_max)
Definition AudioDriver.h:331
virtual bool deinit()
Definition AudioDriver.h:347
virtual bool setConfig(CodecConfig codecCfg)
changes the configuration
Definition AudioDriver.h:212
virtual DriverDeviceInfo & pins()
Provides the pin information.
Definition AudioDriver.h:252
int limitValue(int volume, int min=0, int max=100)
Definition AudioDriver.h:356
virtual bool controlState(codec_mode_t mode)
Definition AudioDriver.h:348
virtual int getVolume()=0
Determines the actual volume (range: 0-100)
virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:185
DriverDeviceInfo * p_pins
Definition AudioDriver.h:328
virtual bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:346
virtual bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:349
Driver API for Lyrat Mini with a ES8311 and a ES7243 codec chip.
Definition AudioDriver.h:1766
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1810
bool end(void)
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:1802
bool isInputVolumeSupported() override
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1813
AudioDriverES7243Class adc
Definition AudioDriver.h:1817
AudioDriverES8311Class dac
Definition AudioDriver.h:1816
bool setMute(bool enable) override
Mutes all output lines.
Definition AudioDriver.h:1808
bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:1768
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1811
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1809
int getInputVolume()
Definition AudioDriver.h:1812
Definition AudioDriver.h:1955
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:2030
~AudioDriverNAU8325Class()
Definition AudioDriver.h:1963
bool setMute(bool enable) override
Mutes all output lines.
Definition AudioDriver.h:2016
NAU8325 * nau8325
Definition AudioDriver.h:1961
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:2022
bool begin(CodecConfig cfg, DriverDeviceInfo &pins) override
Starts the processing.
Definition AudioDriver.h:1967
bool end() override
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:2009
AudioDriverNAU8325Class(uint16_t deviceAddr=NAU8325::NAU8325_I2C_ADDR)
Definition AudioDriver.h:1957
Driver API for the CS43l22 codec chip on 0x94 (0x4A<<1)
Definition AudioDriver.h:1678
PCM3168 driver
Definition AudioDriver.h:1696
bool deinit()
Definition AudioDriver.h:1703
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:1698
bool setMute(bool mute, int line)
Mute individual lines: only supported for some rare DACs.
Definition AudioDriver.h:1686
bool setVolume(int vol)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1688
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:1684
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1692
AudioDriverPCM3168Class(uint16_t deviceAddr=0x44)
Definition AudioDriver.h:1680
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:1705
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:1704
int volume
Definition AudioDriver.h:1695
Driver API for SGTL5000 codec chip.
Definition AudioDriver.h:941
SGTL5000 sgtl5000
Definition AudioDriver.h:959
bool deinit()
Definition AudioDriver.h:966
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:961
SGTL5000 & driver()
Definition AudioDriver.h:956
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:946
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:951
AudioDriverSGTL5000Class(uint16_t deviceAddr=SGTL5000_ADDR)
Definition AudioDriver.h:943
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:947
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:971
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:968
Driver API for TAS5805M codec chip.
Definition AudioDriver.h:1209
TAS5805M tas5805m
Definition AudioDriver.h:1229
AudioDriverTAS5805MClass(uint16_t deviceAddr=TAS5805M::TAS5805M_ADDR)
Definition AudioDriver.h:1211
bool deinit()
Definition AudioDriver.h:1236
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:1231
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:1214
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1219
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1215
TAS5805M & driver()
Provides access to the TAS5805M driver.
Definition AudioDriver.h:1226
Driver for the TI TLV320AIC3104. It might also work on other AIC310x chips.
Definition AudioDriver.h:2124
uint32_t mclk
Definition AudioDriver.h:2133
bool setMclk(uint32_t _mclk)
Definition AudioDriver.h:2127
bool configInterface(codec_mode_t mode, I2SDefinition iface) override
Definition AudioDriver.h:2134
Driver API for WM8731 codec chip.
Definition AudioDriver.h:901
AudioDriverWM8731Class(uint16_t deviceAddr=WM8731_ADDR)
Definition AudioDriver.h:903
bool deinit()
Definition AudioDriver.h:926
bool init(codec_config_t codec_cfg)
Definition AudioDriver.h:921
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:906
WM8731 wm8731
Definition AudioDriver.h:919
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:911
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:907
bool configInterface(codec_mode_t mode, I2SDefinition iface)
Definition AudioDriver.h:931
bool controlState(codec_mode_t mode)
Definition AudioDriver.h:928
WM8731 & driver()
Definition AudioDriver.h:916
Driver API for WM8990 codec chip.
Definition AudioDriver.h:1244
int volume_in
Definition AudioDriver.h:1328
wm8960_word_length_t wordLength(int bits)
Definition AudioDriver.h:1411
bool end(void)
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:1284
void setI2CRetryCount(int cnt)
Configuration: define retry count (default : 0)
Definition AudioDriver.h:1316
void setMclkHz(uint32_t hz)
Configuration: define master clock frequency (default: 0)
Definition AudioDriver.h:1322
bool isVolumeSupported()
Determines if setVolume() is suppored.
Definition AudioDriver.h:1311
bool vs1053_enable_pll
Definition AudioDriver.h:1332
WM8960 & driver()
Provides access to the WM8960 driver.
Definition AudioDriver.h:1251
int i2c_retry_count
Definition AudioDriver.h:1330
virtual bool setConfig(CodecConfig codecCfg)
changes the configuration
Definition AudioDriver.h:1289
bool setMute(bool enable)
Mutes all output lines.
Definition AudioDriver.h:1294
void setEnablePLL(bool active)
Configuration: enable/disable PLL (active by default)
Definition AudioDriver.h:1319
wm8960_mode_t modeMasterSlave(bool is_master)
if microcontroller is master then module is slave
Definition AudioDriver.h:1428
bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1313
int getFeatures(CodecConfig cfg)
Definition AudioDriver.h:1334
void dumpRegisters()
Definition AudioDriver.h:1324
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1304
int volume_out
Definition AudioDriver.h:1329
AudioDriverWM8960Class(uint16_t deviceAddr=WM8960_I2C_ADDRESS)
Definition AudioDriver.h:1246
bool configure_clocking()
Definition AudioDriver.h:1367
bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:1253
bool setInputVolume(int volume)
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1306
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1297
uint32_t vs1053_mclk_hz
Definition AudioDriver.h:1331
wm8960_adc_dac_sample_rate_t sampleRate(int rate)
Definition AudioDriver.h:1383
WM8960 wm8960
Definition AudioDriver.h:1327
Driver API for the wm8978 codec chip.
Definition AudioDriver.h:1438
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1526
bool isInputVolumeSupported() override
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1538
bool setMute(bool mute, int line) override
Mute line 0 = speaker, line 1 = headphones.
Definition AudioDriver.h:1491
bool setMute(bool mute) override
Mutes all output lines.
Definition AudioDriver.h:1506
bool isVolumeSupported() override
Determines if setVolume() is suppored.
Definition AudioDriver.h:1536
int toI2S(i2s_format_t fmt)
Definition AudioDriver.h:1548
bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins) override
Starts the processing.
Definition AudioDriver.h:1444
WM8978 & driver()
Definition AudioDriver.h:1540
WM8978 wm8078
Definition AudioDriver.h:1543
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1528
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1518
AudioDriverWM8978Class(uint16_t deviceAddr=WM8978::WM8978_ADDR)
Definition AudioDriver.h:1440
bool end() override
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:1484
int volume
Definition AudioDriver.h:1544
bool setConfig(CodecConfig codecCfg) override
changes the configuration
Definition AudioDriver.h:1461
int toBits(sample_bits_t bits)
Definition AudioDriver.h:1565
Driver API for the wm8994 codec chip.
Definition AudioDriver.h:1587
WM8994 wm8994
Definition AudioDriver.h:1649
bool deinit()
Definition AudioDriver.h:1651
bool setMute(bool mute)
Mutes all output lines.
Definition AudioDriver.h:1629
int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1644
AudioDriverWM8994Class(uint16_t deviceAddr=WM8994::WM8994_ADDR)
Definition AudioDriver.h:1589
virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:1596
WM8994 & driver()
Provides access to the WM8994 driver.
Definition AudioDriver.h:1594
bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1634
bool volume_set_in_begin
Definition AudioDriver.h:1648
int volume
Definition AudioDriver.h:1647
uint16_t getOutput(output_device_t output_device)
Definition AudioDriver.h:1658
Generic Driver API that wraps a codec driver class which has been ported from the Zephyr RTOS (see Co...
Definition AudioDriver.h:1905
int getVolume() override
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:1921
bool isInputVolumeSupported() override
Determines if setInputVolume() is supported.
Definition AudioDriver.h:1929
bool init(codec_config_t codecCfg) override
Definition AudioDriver.h:1937
bool setMute(bool enable) override
Mutes all output lines.
Definition AudioDriver.h:1914
bool deinit() override
Stops the input and output and (if supported) shuts down the codec.
Definition AudioDriver.h:1943
AudioDriverZephyrT(uint8_t i2cAddress=DefaultI2CAddress)
Definition AudioDriver.h:1907
int volume_value
Definition AudioDriver.h:1935
bool controlState(codec_mode_t mode) override
Definition AudioDriver.h:1944
bool configInterface(codec_mode_t mode, I2SDefinition iface) override
Configures the codec (sample rate, bits per sample) for the given I2S setup.
Definition AudioDriver.h:1946
bool setInputVolume(int volume) override
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:1923
bool setVolume(int volume) override
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:1916
int getInputVolume()
Definition AudioDriver.h:1927
T zephyr_driver
Definition AudioDriver.h:1934
T & driver()
Provides access to the wrapped Zephyr driver instance.
Definition AudioDriver.h:1912
The CS42448 CODEC from Cirrus Logic provides six multi-bit ana- log-to-digital and eight multi-bit di...
Definition CS42448.h:38
bool begin(codec_config_t codecCfg, i2c_bus_handle_t handle, int i2cAddress=-1)
Definition CS42448.h:143
bool setVolumeDAC(uint8_t vol)
Definition CS42448.h:257
bool setMuteDAC(uint8_t line, bool mute)
Definition CS42448.h:230
bool setMute(bool mute)
Definition CS42448.h:255
bool setVolumeADC(int8_t volume)
Set volume in 0.5 dB increments. -128 .. 127 is -64dB .. 24dB; 0 = 0dB.
Definition CS42448.h:282
bool end()
Mute ADC and DAC and then power down.
Definition CS42448.h:174
bool setSampleRate(int rate)
Single-Speed Mode (SSM) supports input sample rates up to 50 kHz and uses a 128x oversampling ratio....
Definition CS42448.h:189
Header-only driver class for the CS42L51 codec chip.
Definition CS42L51.h:149
uint32_t stop(uint32_t cmd)
Definition CS42L51.h:387
uint32_t play()
Start the audio Codec play feature.
Definition CS42L51.h:304
uint32_t init(uint32_t inputDevice, uint32_t outputDevice, uint8_t volume, uint32_t audioFreq)
Definition CS42L51.h:166
uint32_t resume()
Resumes playing on the audio codec.
Definition CS42L51.h:382
uint32_t setVolume(uint8_t volume)
Definition CS42L51.h:422
uint32_t pause()
Pauses playing on the audio codec.
Definition CS42L51.h:379
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition CS42L51.h:154
uint32_t reset()
Resets cs42l51 registers.
Definition CS42L51.h:471
void setAddress(uint16_t addr)
Defines the I2C device address.
Definition CS42L51.h:157
Header-only driver class for the CS43L22 codec chip.
Definition CS43L22.h:55
uint32_t stop(uint32_t cmd)
Definition CS43L22.h:277
uint32_t init(uint16_t outputDevice, uint8_t volume, uint32_t audioFreq)
Definition CS43L22.h:138
uint32_t readID()
Get the CS43L22 ID.
Definition CS43L22.h:216
uint32_t resume()
Resumes playing on the audio codec.
Definition CS43L22.h:259
static constexpr uint8_t OUTPUT_DEVICE_BOTH
Definition CS43L22.h:70
uint32_t setVolume(uint8_t volume)
Definition CS43L22.h:296
uint32_t pause()
Pauses playing on the audio codec.
Definition CS43L22.h:245
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition CS43L22.h:129
static constexpr uint8_t OUTPUT_DEVICE_SPEAKER
Definition CS43L22.h:68
static constexpr int AUDIO_MUTE_ON
Definition CS43L22.h:79
uint32_t reset()
Resets cs43l22 registers.
Definition CS43L22.h:378
uint32_t play(uint16_t *pBuffer, uint16_t size)
Definition CS43L22.h:225
static constexpr uint8_t OUTPUT_DEVICE_HEADPHONE
Definition CS43L22.h:69
void setAddress(uint16_t addr)
Defines the I2C device address.
Definition CS43L22.h:132
I2S configuration and definition of input and output with default values.
Definition AudioDriver.h:24
CodecConfig()
setup default values
Definition AudioDriver.h:27
bool setBitsNumeric(int bits)
Sets the bits per sample with a numeric value.
Definition AudioDriver.h:62
bool sdmmc_active
Definition AudioDriver.h:173
bool setChannelsNumeric(int channels)
Defines the number of channels.
Definition AudioDriver.h:99
int getRateNumeric()
Get the sample rate as number.
Definition AudioDriver.h:85
codec_mode_t get_mode()
Determines the codec_mode_t dynamically based on the input and output.
Definition AudioDriver.h:144
int getChannelsNumeric()
Returns the number of channels as number.
Definition AudioDriver.h:96
bool sd_active
Definition AudioDriver.h:172
bool equalsExRate(CodecConfig alt)
Compare all attributes but ignore sample rate.
Definition AudioDriver.h:39
int setRateNumeric(int requestedRate)
Sets the sample rate as number: returns the effectively set rate.
Definition AudioDriver.h:121
int getBitsNumeric()
Returns bits per sample as number.
Definition AudioDriver.h:47
All pins for i2s, spi, i2c and other pins.
Definition DriverDeviceInfo.h:20
GpioPin getPinID(PinFunction function, int pos=0)
Definition DriverDeviceInfo.h:149
API_GPIO & getGPIO()
Definition DriverDeviceInfo.h:264
PinLogic getPinLogic(PinFunction function, int pos=0)
Definition DriverDeviceInfo.h:155
bool setI2C(InfoI2C pin)
Updates the I2C pin information using the function as key.
Definition DriverDeviceInfo.h:84
virtual bool begin()
Sets up all pins e.g. by calling pinMode()
Definition DriverDeviceInfo.h:193
audio_driver_local::Optional< InfoI2C > getI2CPins(PinFunction function) override
Finds the I2C pin info with the help of the function.
Definition DriverDeviceInfo.h:162
void setSDMMCActive(bool active)
Defines if SPI for SD should be started (by default true)
Definition DriverDeviceInfo.h:243
void setSPIActiveForSD(bool active)
Defines if SPI for SD should be started (by default true)
Definition DriverDeviceInfo.h:235
Header-only driver class for the ES7210 ADC chip.
Definition ES7210.h:157
error_t deinit()
Deinitialize ES7210 ADC chip.
Definition ES7210.h:273
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES7210 ADC chip.
Definition ES7210.h:285
void setAddress(int addr)
Defines the I2C device address.
Definition ES7210.h:204
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES7210 ADC mode and I2S interface.
Definition ES7210.h:276
error_t setMute(bool enable)
Set ES7210 ADC mute status.
Definition ES7210.h:403
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES7210.h:201
error_t setVolume(int volume)
Set volume.
Definition ES7210.h:396
error_t init(codec_config_t *codec_cfg)
Initialize ES7210 ADC chip.
Definition ES7210.h:207
Header-only driver class for the ES7243E ADC chip.
Definition ES7243E.h:43
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES7243E adc chip.
Definition ES7243E.h:107
void setAddress(int addr)
Defines the I2C device address.
Definition ES7243E.h:51
error_t deinit(void)
Deinitialize ES7243E adc chip.
Definition ES7243E.h:104
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES7243E adc mode and I2S interface.
Definition ES7243E.h:139
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES7243E.h:48
error_t setVoiceVolume(int volume)
Set adc gain (value of gain 0~100)
Definition ES7243E.h:144
error_t getVoiceVolume(int *volume)
Get adc gain (value of gain 0~100)
Definition ES7243E.h:147
error_t init(codec_config_t *codec_cfg)
Initialize ES7243E adc chip.
Definition ES7243E.h:54
Header-only driver class for the ES7243 ADC chip.
Definition ES7243.h:46
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES7243 adc chip.
Definition ES7243.h:81
void setAddress(int addr)
Defines the I2C device address.
Definition ES7243.h:55
error_t deinit(void)
Deinitialize ES7243 adc chip.
Definition ES7243.h:78
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES7243 adc mode and I2S interface.
Definition ES7243.h:86
error_t setVoiceMute(bool mute)
Set mute.
Definition ES7243.h:129
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES7243.h:52
error_t setVoiceVolume(int volume)
Set adc gain (value of gain 0~100)
Definition ES7243.h:141
error_t getVoiceVolume(int *volume)
Get adc gain (value of gain 0~100)
Definition ES7243.h:183
error_t init(codec_config_t *codec_cfg)
Initialize ES7243 adc chip.
Definition ES7243.h:61
Header-only driver class for the ES8156 DAC chip.
Definition ES8156.h:43
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES8156 codec chip.
Definition ES8156.h:129
void setAddress(int addr)
Defines the I2C device address.
Definition ES8156.h:87
error_t init(codec_config_t *cfg)
Initialize ES8156 codec chip.
Definition ES8156.h:90
error_t deinit(void)
Deinitialize ES8156 codec chip.
Definition ES8156.h:122
error_t setVoiceMute(bool enable)
Configure ES8156 DAC mute or not.
Definition ES8156.h:146
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES8156 codec mode and I2S interface.
Definition ES8156.h:141
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES8156.h:84
static constexpr int ES8156_ADDR
Definition ES8156.h:45
error_t setVoiceVolume(int volume)
Set voice volume.
Definition ES8156.h:163
error_t getVoiceVolume(int *volume)
Get voice volume (0~100)
Definition ES8156.h:176
Header-only driver class for the ES8311 codec chip.
Definition ES8311.h:247
error_t deinit()
Deinitialize ES8311 codec chip.
Definition ES8311.h:508
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES8311 codec chip.
Definition ES8311.h:519
void setAddress(int addr)
Defines the I2C device address.
Definition ES8311.h:304
error_t setMicGain(es8311_mic_gain_t gain_db)
Set ES8311 mic gain.
Definition ES8311.h:618
static constexpr int ES8311_ADDR
Definition ES8311.h:249
error_t setVoiceMute(bool enable)
Configure ES8311 DAC mute or not.
Definition ES8311.h:597
void setMclkSrc(int8_t src)
Defines the source of the master clock (FROM_MCLK_PIN or FROM_SCLK_PIN)
Definition ES8311.h:309
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES8311 codec mode and I2S interface.
Definition ES8311.h:511
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES8311.h:301
error_t setVoiceVolume(int volume)
Set voice volume (0~100)
Definition ES8311.h:553
error_t getVoiceVolume(int *volume)
Get voice volume (0~100)
Definition ES8311.h:574
error_t init(codec_config_t *codec_cfg)
Initialize ES8311 codec chip.
Definition ES8311.h:313
Header-only driver class for the ES8374 codec chip.
Definition ES8374.h:51
static constexpr int ES8374_ADDR
Definition ES8374.h:53
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES8374 codec chip.
Definition ES8374.h:149
error_t init(codec_config_t *cfg, codec_mode_t codec_mode)
Initialize ES8374 codec chip.
Definition ES8374.h:117
void setAddress(int addr)
Defines the I2C device address.
Definition ES8374.h:60
error_t deinit(void)
Deinitialize ES8374 codec chip.
Definition ES8374.h:143
error_t setVoiceMute(bool enable)
Mute or unmute ES8374 DAC.
Definition ES8374.h:74
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES8374 codec mode and I2S interface.
Definition ES8374.h:101
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES8374.h:57
error_t setVoiceVolume(int volume)
Set voice volume (0~100)
Definition ES8374.h:180
error_t getVoiceVolume(int *volume)
Get voice volume (0~100)
Definition ES8374.h:197
Header-only driver class for the ES8388 codec chip.
Definition ES8388.h:64
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES8388 codec chip.
Definition ES8388.h:460
void setAddress(int addr)
Defines the I2C device address.
Definition ES8388.h:126
error_t deinit(void)
Deinitialize ES8388 codec chip.
Definition ES8388.h:448
error_t setVoiceMute(bool enable)
Configure ES8388 DAC mute or not.
Definition ES8388.h:147
static constexpr int ES8388_ADDR
Definition ES8388.h:66
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES8388 codec mode and I2S interface.
Definition ES8388.h:328
void setVolumeHack(int volumeHack)
Defines the volume hack to use (see AI_THINKER_ES8388_VOLUME_HACK)
Definition ES8388.h:131
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES8388.h:123
error_t configOutputDevice(output_device_t output_device)
Set ES8388 dac output mode.
Definition ES8388.h:225
error_t init(codec_config_t *cfg, int volumeHack)
Initialize ES8388 codec chip.
Definition ES8388.h:345
error_t setVoiceVolume(int volume)
Set voice volume.
Definition ES8388.h:184
error_t setMicGain(es_mic_gain_t gain)
Set ES8388 mic gain.
Definition ES8388.h:171
error_t getVoiceVolume(int *volume)
Get voice volume (0~100)
Definition ES8388.h:198
Header-only driver for the Nuvoton NAU8325 Class-D amplifier with DAC.
Definition NAU8325.h:63
void powerOff()
Powers off the analog and DAC blocks after soft-muting the output.
Definition NAU8325.h:544
static constexpr uint16_t NAU8325_I2C_ADDR
Definition NAU8325.h:65
void setVolume(uint8_t left, uint8_t right)
Sets the DAC digital volume for left and right channels (0x00–0xFE, 0xFF = mute)
Definition NAU8325.h:571
void softMute(bool enable)
Enables or disables soft mute on the DAC output.
Definition NAU8325.h:518
bool begin(uint32_t fs, uint8_t bits_per_sample, uint16_t ratio)
Initializes the codec with explicit sample rate, bit depth, and MCLK/FS ratio.
Definition NAU8325.h:446
Dummy Driver which does nothing.
Definition AudioDriver.h:369
virtual bool isInputVolumeSupported()
Determines if setInputVolume() is supported.
Definition AudioDriver.h:382
virtual bool end(void)
Ends the processing: shut down dac and adc.
Definition AudioDriver.h:376
virtual bool setInputVolume(int volume)
Defines the input volume (range: 0-100) if supported.
Definition AudioDriver.h:380
virtual bool isVolumeSupported()
Determines if setVolume() is suppored.
Definition AudioDriver.h:381
virtual int getVolume()
Determines the actual volume (range: 0-100)
Definition AudioDriver.h:379
virtual bool begin(CodecConfig codecCfg, DriverDeviceInfo &pins)
Starts the processing.
Definition AudioDriver.h:371
virtual bool setMute(bool enable)
Mutes all output lines.
Definition AudioDriver.h:377
virtual bool setVolume(int volume)
Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
Definition AudioDriver.h:378
Definition PCM3168.h:41
bool end(void)
Definition PCM3168.h:90
bool setMute(int channel, bool mute)
Definition PCM3168.h:95
bool begin(FMT fmt=I2SHighSpeedTDM24bit)
Definition PCM3168.h:84
void setWire(i2c_bus_handle_t w)
Definition PCM3168.h:82
void setAddress(uint8_t addr)
Definition PCM3168.h:80
bool setVolume(float level)
Definition PCM3168.h:110
FMT
Definition PCM3168.h:65
@ I2SHighSpeedTDM24bit
Definition PCM3168.h:74
@ LeftTDM24bit
Definition PCM3168.h:73
@ LeftDSP24bit
Definition PCM3168.h:71
@ I2S24bit
Definition PCM3168.h:66
@ I2STDM24bit
Definition PCM3168.h:72
@ Right24bit
Definition PCM3168.h:68
@ Right16bit
Definition PCM3168.h:69
@ Left24bit
Definition PCM3168.h:67
Header-only driver class for the SGTL5000 codec chip.
Definition SGTL5000.h:28
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Activate or mute the codec.
Definition SGTL5000.h:140
void setAddress(int addr)
Defines the I2C device address.
Definition SGTL5000.h:80
error_t init(codec_config_t *cfg)
Initialize the SGTL5000 codec chip.
Definition SGTL5000.h:83
error_t deinit(void)
Deinitialize the SGTL5000 codec chip.
Definition SGTL5000.h:130
error_t setVoiceMute(bool enable)
Mute / unmute the headphone and line outputs.
Definition SGTL5000.h:190
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure the digital audio interface format and sample rate.
Definition SGTL5000.h:145
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition SGTL5000.h:77
error_t setVoiceVolume(int volume)
Set the headphone / line output volume.
Definition SGTL5000.h:203
error_t getVoiceVolume(int *volume)
Get the headphone / line output volume (0~100)
Definition SGTL5000.h:220
Header-only driver class for the TAS5805M amplifier chip.
Definition TAS5805M.h:44
void setAddress(int addr)
Defines the I2C device address.
Definition TAS5805M.h:77
error_t deinit(void)
Deinitialize TAS5805 codec chip.
Definition TAS5805M.h:104
static constexpr int TAS5805M_ADDR
Definition TAS5805M.h:68
error_t setMute(bool enable)
Set TAS5805 mute or not Continuously call should have an interval time determined by setMuteFade()
Definition TAS5805M.h:152
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition TAS5805M.h:74
error_t getVolume(int *value)
Get voice volume (0~100)
Definition TAS5805M.h:132
error_t setVolume(int vol)
Set voice volume (0~100)
Definition TAS5805M.h:110
error_t init(codec_config_t *codec_cfg)
Initialize TAS5805 codec chip.
Definition TAS5805M.h:85
bool begin(uint32_t sample_rate, uint8_t bits, codec_mode_t mode, i2s_format_t fmt, bool is_master, uint8_t channels) override
Initializes the codec for I2S with the given sample rate and bits per sample.
Definition TLV320AIC3104.h:334
Header-only driver class for the WM8731 codec chip.
Definition WM8731.h:25
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Activate or standby the codec.
Definition WM8731.h:182
void setAddress(int addr)
Defines the I2C device address.
Definition WM8731.h:128
error_t init(codec_config_t *cfg)
Initialize the WM8731 codec chip.
Definition WM8731.h:131
error_t deinit(void)
Deinitialize the WM8731 codec chip.
Definition WM8731.h:173
error_t setVoiceMute(bool enable)
Mute / unmute the DAC output.
Definition WM8731.h:231
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure the digital audio interface format and sample rate.
Definition WM8731.h:187
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition WM8731.h:125
error_t setVoiceVolume(int volume)
Set the headphone / line output volume.
Definition WM8731.h:244
error_t getVoiceVolume(int *volume)
Get the headphone / line output volume (0~100)
Definition WM8731.h:259
Header-only driver class for the WM8960 audio codec chip.
Definition WM8960.h:342
void setAddress(int addr)
Defines the I2C device address.
Definition WM8960.h:350
bool deactivate(void)
This function powers down the modules the required for the features enabled using init.
Definition WM8960.h:666
bool setOutputVolume(uint8_t volume)
This function updates the volume of both the left and right channels of the speaker and headphones.
Definition WM8960.h:582
bool adjustInputVolume(uint8_t volume)
This function updates the volume of both the left and right channels of the microphone input.
Definition WM8960.h:519
void setWriteRetryCount(uint32_t count)
Defines the number of times we retry to update a register value via I2C. This might help if you have ...
Definition WM8960.h:362
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition WM8960.h:347
void deinit()
Frees up any resources allocated by the driver as part of init().
Definition WM8960.h:421
bool activate(void)
This function powers up the modules the required for the features enabled using init....
Definition WM8960.h:603
bool init(uint8_t features)
Initialize the I2C communication with the audio codec, reset the codec and apply default configuratio...
Definition WM8960.h:401
bool dump()
This function dumps the actual register values.
Definition WM8960.h:811
bool configureClocking(uint32_t mclk_hz, bool enable_pll, wm8960_adc_dac_sample_rate_t sample_rate, wm8960_word_length_t word_length, wm8960_mode_t mode)
This function configures the master clock and the digital interface for the audio codec.
Definition WM8960.h:732
Definition WM8978.h:24
void setAUXgain(uint8_t gain)
Definition WM8978.h:220
void cfgADDA(uint8_t dacen, uint8_t adcen)
Definition WM8978.h:130
void cfgOutput(uint8_t dacen, uint8_t bpsen)
Definition WM8978.h:184
void cfgI2S(uint8_t fmt, uint8_t len)
Definition WM8978.h:235
void setMICgain(uint8_t gain)
Definition WM8978.h:197
void setSPKvol(uint8_t volx)
Definition WM8978.h:256
static constexpr int WM8978_ADDR
Definition WM8978.h:26
bool begin(i2c_bus_handle_t p_wire, int address)
Definition WM8978.h:413
void setLINEINgain(uint8_t gain)
Definition WM8978.h:206
void cfgInput(uint8_t micen, uint8_t lineinen, uint8_t auxen)
Definition WM8978.h:152
void setHPvol(uint8_t voll, uint8_t volr)
Definition WM8978.h:244
Header-only driver class for the WM8994 audio codec chip.
Definition WM8994.h:61
static constexpr uint16_t OUTPUT_DEVICE_HEADPHONE
Definition WM8994.h:75
uint32_t init(uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq)
Initializes the audio codec and the control interface.
Definition WM8994.h:115
void setAddress(int addr)
Defines the I2C device address.
Definition WM8994.h:101
static constexpr uint16_t OUTPUT_DEVICE_BOTH
Definition WM8994.h:76
uint32_t resume()
Resumes playing on the audio codec.
Definition WM8994.h:605
static constexpr uint8_t DEFAULT_VOLMIN
Definition WM8994.h:82
uint32_t setVolume(uint8_t Volume)
Sets higher or lower the codec volume level.
Definition WM8994.h:668
uint32_t pause()
Pauses playing on the audio codec.
Definition WM8994.h:591
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition WM8994.h:98
static constexpr uint16_t OUTPUT_DEVICE_SPEAKER
Definition WM8994.h:74
static constexpr int AUDIO_MUTE_ON
Definition WM8994.h:89
uint32_t reset()
Resets wm8994 registers.
Definition WM8994.h:901
static constexpr int WM8994_ADDR
Definition WM8994.h:93
static constexpr uint8_t DEFAULT_VOLMAX
Definition WM8994.h:83
uint32_t stop(uint32_t CodecPdwnMode)
Stops audio Codec playing. It powers down the codec.
Definition WM8994.h:627
static AudioDriverES8388Class AudioDriverES8388H0
Definition AudioDriver.h:2168
static AudioDriverES8311Class AudioDriverES8311
Definition AudioDriver.h:2162
static AudioDriverWM8994Class AudioDriverWM8994
Definition AudioDriver.h:2180
static AudioDriverZephyrT< AW88298, 0x36 > AudioDriverAW88298
Definition AudioDriver.h:2211
static AudioDriverZephyrT< PCM1681, 0x4C > AudioDriverPCM1681
Definition AudioDriver.h:2213
static AudioDriverZephyrT< MAX98091, 0x10 > AudioDriverMAX98091
Definition AudioDriver.h:2209
static AudioDriverES8388Class AudioDriverES8388H2
Definition AudioDriver.h:2172
static AudioDriverNAU8325Class AudioDriverNAU8325
Definition AudioDriver.h:2190
static AudioDriverPCM3168Class AudioDriverPCM3168
Definition AudioDriver.h:2188
static AudioDriverLyratMiniClass AudioDriverLyratMini
Definition AudioDriver.h:2182
static NoDriverClass NoDriver
Definition AudioDriver.h:2184
static AudioDriverES7210Class AudioDriverES7210
Definition AudioDriver.h:2154
static AudioDriverZephyrT< TAS2563, 0x4C > AudioDriverTAS2563
Definition AudioDriver.h:2215
static AudioDriverCS42L51Class AudioDriverCS42L51
Definition AudioDriver.h:2152
static AudioDriverES8156Class AudioDriverES8156
Definition AudioDriver.h:2160
static AudioDriverZephyrT< TAS6422DAC, 0x6C > AudioDriverTAS6422DAC
Definition AudioDriver.h:2217
static AudioDriverES7243Class AudioDriverES7243
Definition AudioDriver.h:2156
static AudioDriverCombined AudioDriverES8311_ES7243(AudioDriverES8311, AudioDriverES7243)
static AudioDriverAC101Class AudioDriverAC101
Definition AudioDriver.h:2148
static AudioDriverZephyrT< DA7212, 0x1A > AudioDriverDA7212
Definition AudioDriver.h:2224
static AudioDriverZephyrT< TLV320DAC310x, 0x18 > AudioDriverTLV320DAC310x
Definition AudioDriver.h:2219
static AudioDriverSGTL5000Class AudioDriverSGTL5000
Definition AudioDriver.h:2201
static AudioDriverZephyrT< WM8962, 0x1A > AudioDriverWM8962
Definition AudioDriver.h:2207
static AudioDriverCS42448Class AudioDriverCS42448
Definition AudioDriver.h:2186
static AudioDriverES7243eClass AudioDriverES7243e
Definition AudioDriver.h:2158
static AudioDriverES8388Class AudioDriverES8388H1
Definition AudioDriver.h:2170
static AudioDriverCS43l22Class AudioDriverCS43l22
Definition AudioDriver.h:2150
static AudioDriverTLV320AIC3104Class AudioDriverTLV320AIC3104
Definition AudioDriver.h:2192
static AudioDriverZephyrT< WM8904, 0x1A > AudioDriverWM8904
Definition AudioDriver.h:2205
static AudioDriverWM8960Class AudioDriverWM8960
Definition AudioDriver.h:2176
static AudioDriverCombined AudioDriverES8311_ES7210(AudioDriverES8311, AudioDriverES7210)
static AudioDriverZephyrT< TLV320AIC3110, 0x18 > AudioDriverTLV320AIC3110
Definition AudioDriver.h:2226
static AudioDriverES8388Class AudioDriverES8388
Definition AudioDriver.h:2166
static AudioDriverWM8978Class AudioDriverWM8978
Definition AudioDriver.h:2178
static AudioDriverES8374Class AudioDriverES8374
Definition AudioDriver.h:2164
static AudioDriverES8388Class AudioDriverES8388H3
Definition AudioDriver.h:2174
static AudioDriverZephyrT< TLV320DAC3100, 0x18 > AudioDriverTLV320DAC3100
Definition AudioDriver.h:2222
Namespace for audio driver components.
Definition AudioBoard.h:5
wm8960_word_length_t
Definition WM8960.h:308
@ WM8960_WL_32BITS
Definition WM8960.h:312
@ WM8960_WL_24BITS
Definition WM8960.h:311
@ WM8960_WL_16BITS
Definition WM8960.h:309
@ WM8960_WL_20BITS
Definition WM8960.h:310
constexpr int WM8731_ADDR
7-bit I2C address (CSB pin low). If CSB is pulled high use 0x1B.
Definition WM8731.h:18
@ CS42L51_FREQUENCY_8K
Definition CS42L51.h:104
@ CS42L51_FREQUENCY_22K
Definition CS42L51.h:101
@ CS42L51_FREQUENCY_16K
Definition CS42L51.h:102
@ CS42L51_FREQUENCY_44K
Definition CS42L51.h:99
@ CS42L51_FREQUENCY_32K
Definition CS42L51.h:100
@ CS42L51_FREQUENCY_48K
Definition CS42L51.h:98
@ CS42L51_FREQUENCY_11K
Definition CS42L51.h:103
struct audio_driver::SPIClass SPI
wm8960_adc_dac_sample_rate_t
Definition WM8960.h:291
@ WM8960_ADC_DAC_SAMPLE_RATE_11_025_KHZ
Definition WM8960.h:299
@ WM8960_ADC_DAC_SAMPLE_RATE_8_KHZ
Definition WM8960.h:301
@ WM8960_ADC_DAC_SAMPLE_RATE_16_KHZ
Definition WM8960.h:297
@ WM8960_ADC_DAC_SAMPLE_RATE_32_KHZ
Definition WM8960.h:294
@ WM8960_ADC_DAC_SAMPLE_RATE_8_018_KHZ
Definition WM8960.h:300
@ WM8960_ADC_DAC_SAMPLE_RATE_24_KHZ
Definition WM8960.h:295
@ WM8960_ADC_DAC_SAMPLE_RATE_48_KHZ
Definition WM8960.h:292
@ WM8960_ADC_DAC_SAMPLE_RATE_22_05_KHZ
Definition WM8960.h:296
@ WM8960_ADC_DAC_SAMPLE_RATE_12_KHZ
Definition WM8960.h:298
@ WM8960_ADC_DAC_SAMPLE_RATE_44_1_KHZ
Definition WM8960.h:293
@ ES7210_AD1_AD0_00
Definition ES7210.h:40
int16_t GpioPin
Definition DriverCommon.h:153
PinLogic
Definition DriverCommon.h:328
input_device_t
Definition DriverCommon.h:170
@ ADC_INPUT_ALL
Definition DriverCommon.h:175
@ ADC_INPUT_NONE
Definition DriverCommon.h:171
@ ADC_INPUT_LINE1
Definition DriverCommon.h:172
@ ADC_INPUT_LINE3
Definition DriverCommon.h:174
@ ADC_INPUT_LINE2
Definition DriverCommon.h:173
@ ADC_INPUT_DIFFERENCE
Definition DriverCommon.h:176
const samplerate_t rate_code[14]
Definition AudioDriver.h:13
static constexpr int WM8960_I2C_ADDRESS
Definition WM8960.h:49
void delayMs(unsigned long ms)
Definition API_Delay.h:19
sample_bits_t
Definition DriverCommon.h:235
@ BIT_LENGTH_24BITS
Definition DriverCommon.h:240
@ BIT_LENGTH_18BITS
Definition DriverCommon.h:238
@ BIT_LENGTH_20BITS
Definition DriverCommon.h:239
@ BIT_LENGTH_32BITS
Definition DriverCommon.h:241
@ BIT_LENGTH_16BITS
Definition DriverCommon.h:237
constexpr int SGTL5000_ADDR
7-bit I2C address with CTRL_ADR0_CS pin low (normal configuration)
Definition SGTL5000.h:19
codec_mode_t
Definition DriverCommon.h:290
@ CODEC_MODE_ENCODE
Definition DriverCommon.h:293
@ CODEC_MODE_NONE
Definition DriverCommon.h:292
@ CODEC_MODE_BOTH
Definition DriverCommon.h:295
@ CODEC_MODE_DECODE
Definition DriverCommon.h:294
es8311_mic_gain_t
Definition ES8311.h:39
@ ES8311MIC_GAIN_42DB
Definition ES8311.h:48
@ ES8311MIC_GAIN_12DB
Definition ES8311.h:43
@ ES8311MIC_GAIN_18DB
Definition ES8311.h:44
@ ES8311MIC_GAIN_24DB
Definition ES8311.h:45
@ ES8311MIC_GAIN_30DB
Definition ES8311.h:46
@ ES8311MIC_GAIN_36DB
Definition ES8311.h:47
@ ES8311MIC_GAIN_6DB
Definition ES8311.h:42
@ ES8311MIC_GAIN_0DB
Definition ES8311.h:41
wm8960_mode_t
Definition WM8960.h:318
@ WM8960_MODE_MASTER
Definition WM8960.h:319
@ WM8960_MODE_SLAVE
Definition WM8960.h:320
@ CS42L51_IN_NONE
Definition CS42L51.h:78
@ CS42L51_IN_MIC2
Definition CS42L51.h:80
@ CS42L51_IN_MIC1
Definition CS42L51.h:79
@ CS42L51_IN_LINE1
Definition CS42L51.h:81
@ CS42L51_IN_LINE3
Definition CS42L51.h:83
@ CS42L51_IN_LINE2
Definition CS42L51.h:82
output_device_t
Definition DriverCommon.h:186
@ DAC_OUTPUT_LINE1
Definition DriverCommon.h:188
@ DAC_OUTPUT_ALL
Definition DriverCommon.h:190
@ DAC_OUTPUT_NONE
Definition DriverCommon.h:187
@ DAC_OUTPUT_LINE2
Definition DriverCommon.h:189
samplerate_t
Definition DriverCommon.h:213
@ RATE_44K
Definition DriverCommon.h:220
@ RATE_24K
Definition DriverCommon.h:218
@ RATE_22K
Definition DriverCommon.h:217
@ RATE_128K
Definition DriverCommon.h:225
@ RATE_8K
Definition DriverCommon.h:214
@ RATE_88K
Definition DriverCommon.h:223
@ RATE_176K
Definition DriverCommon.h:226
@ RATE_32K
Definition DriverCommon.h:219
@ RATE_96K
Definition DriverCommon.h:224
@ RATE_11K
Definition DriverCommon.h:215
@ RATE_64K
Definition DriverCommon.h:222
@ RATE_16K
Definition DriverCommon.h:216
@ RATE_48K
Definition DriverCommon.h:221
@ RATE_192K
Definition DriverCommon.h:227
channels_t
Definition DriverCommon.h:274
@ CHANNELS2
Definition DriverCommon.h:275
@ CHANNELS16
Definition DriverCommon.h:278
@ CHANNELS8
Definition DriverCommon.h:277
@ CHANNELS4
Definition DriverCommon.h:276
es_mic_gain_t
Definition DriverCommon.h:305
@ MIC_GAIN_15DB
Definition DriverCommon.h:312
@ MIC_GAIN_6DB
Definition DriverCommon.h:309
@ MIC_GAIN_9DB
Definition DriverCommon.h:310
@ MIC_GAIN_24DB
Definition DriverCommon.h:315
@ MIC_GAIN_0DB
Definition DriverCommon.h:307
@ MIC_GAIN_12DB
Definition DriverCommon.h:311
@ MIC_GAIN_18DB
Definition DriverCommon.h:313
@ MIC_GAIN_21DB
Definition DriverCommon.h:314
@ MIC_GAIN_3DB
Definition DriverCommon.h:308
@ WM8960_FEATURE_HEADPHONE
Definition WM8960.h:280
@ WM8960_FEATURE_MICROPHONE1
Definition WM8960.h:277
@ WM8960_FEATURE_SPEAKER
Definition WM8960.h:281
@ WM8960_FEATURE_MICROPHONE2
Definition WM8960.h:278
@ WM8960_FEATURE_MICROPHONE3
Definition WM8960.h:279
@ CS42L51_OUT_HEADPHONE
Definition CS42L51.h:89
@ CS42L51_OUT_NONE
Definition CS42L51.h:88
i2s_format_t
Definition DriverCommon.h:250
@ I2S_RIGHT
Definition DriverCommon.h:253
@ I2S_DSP
Definition DriverCommon.h:254
@ I2S_LEFT
Definition DriverCommon.h:252
@ I2S_NORMAL
Definition DriverCommon.h:251
@ MODE_MASTER
Definition DriverCommon.h:205
@ MODE_SLAVE
Definition DriverCommon.h:204
@ CS42L51_PDWN_SW
Definition CS42L51.h:118
@ SIGNAL_TDM
Definition DriverCommon.h:266
const int rate_num[14]
Definition AudioDriver.h:11
void * i2c_bus_handle_t
Definition DriverCommon.h:155
int address
Definition API_I2C.h:27
i2c_bus_handle_t p_wire
Definition API_I2C.h:24
I2S interface parameters for the audio codec.
Definition DriverCommon.h:384
i2s_format_t fmt
Definition DriverCommon.h:386
samplerate_t rate
Definition DriverCommon.h:387
i2s_master_slave_t mode
Definition DriverCommon.h:385
channels_t channels
Definition DriverCommon.h:389
signal_t signal_type
Definition DriverCommon.h:390
sample_bits_t bits
Definition DriverCommon.h:388
I2C pins.
Definition IDriverDeviceInfo.h:127
Top-level codec configuration passed to the audio driver at init.
Definition DriverCommon.h:397
output_device_t output_device
Definition DriverCommon.h:399
I2SDefinition i2s
Definition DriverCommon.h:400
input_device_t input_device
Definition DriverCommon.h:398