arduino-audio-driver
Loading...
Searching...
No Matches
DA7212.h
Go to the documentation of this file.
1
12#pragma once
13
15
16namespace audio_driver {
17
19enum class DA7212Protocol {
20 I2S = 0x00,
21 LeftJustified = 0x01,
22 RightJustified = 0x02,
23 DSPMode = 0x03,
24};
25
27enum class DA7212SampleRate {
28 Rate8kHz = (1U << 0),
29 Rate11025Hz = (2U << 0),
30 Rate12kHz = (3U << 0),
31 Rate16kHz = (5U << 0),
32 Rate22050Hz = (6U << 0),
33 Rate24kHz = (7U << 0),
34 Rate32kHz = (9U << 0),
35 Rate44100Hz = (10U << 0),
36 Rate48kHz = (11U << 0),
37 Rate88200Hz = (14U << 0),
38 Rate96kHz = (15U << 0),
39};
40
42enum class DA7212Channel {
47 All,
48};
49
57class DA7212 : public ZephyrDriverCommon {
58 public:
59 // ---- Register addresses ----
108
109 // ---- Bit masks ----
110 static constexpr uint8_t CIF_CTRL_SOFT_RESET = (1U << 7);
111
112 static constexpr uint8_t DAI_CLK_EN_MASK = (1U << 7);
113 static constexpr uint8_t DAI_BCLKS_PER_WCLK_MASK = 0x03;
114 static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK32 = 0;
115 static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK64 = 1;
116 static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK128 = 2;
117 static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK256 = 3;
118
119 static constexpr uint8_t DAI_EN_MASK = (1U << 7);
120 static constexpr uint8_t DAI_OE_MASK = (1U << 6);
121 static constexpr uint8_t DAI_FORMAT_MASK = 0x03;
122 static constexpr uint8_t DAI_WORD_LENGTH_MASK = 0x0C;
123 static constexpr uint8_t DAI_WORD_LENGTH_16B = (0U << 2);
124 static constexpr uint8_t DAI_WORD_LENGTH_20B = (1U << 2);
125 static constexpr uint8_t DAI_WORD_LENGTH_24B = (2U << 2);
126 static constexpr uint8_t DAI_WORD_LENGTH_32B = (3U << 2);
127
128 // REG_DIG_ROUTING_DAI
129 static constexpr uint8_t DIG_ROUTING_DAI_R_SRC_ADC_RIGHT = (1U << 4);
130 static constexpr uint8_t DIG_ROUTING_DAI_L_SRC_ADC_LEFT = (0U << 0);
131
132 // REG_DIG_ROUTING_DAC
133 static constexpr uint8_t DIG_ROUTING_DAC_R_RSC_DAC_R = (3U << 4);
134 static constexpr uint8_t DIG_ROUTING_DAC_L_RSC_DAC_L = (2U << 0);
135 static constexpr uint8_t DIG_ROUTING_DAC_R_RSC_ADC_R_OUTPUT = (1U << 4);
136 static constexpr uint8_t DIG_ROUTING_DAC_L_RSC_ADC_L_OUTPUT = (0U << 0);
137
138 static constexpr uint8_t REFERENCES_BIAS_EN_MASK = (1U << 3);
139 static constexpr uint8_t PLL_FBDIV_INTEGER_RESET_VALUE = 0x20;
140
141 // REG_HP_x_GAIN / REG_ADC_x_GAIN
142 static constexpr uint8_t HP_GAIN_MASK = 0x3F;
143 static constexpr uint8_t ADC_GAIN_MASK = 0x7F;
144 static constexpr uint8_t HP_DEFAULT_GAIN = 0x2F;
145 static constexpr uint8_t DAC_DEFAULT_GAIN = 0x67;
146
147 // REG_HP_x_CTRL / REG_ADC_x_CTRL / REG_LINE_CTRL: mute/unmute
148 static constexpr uint8_t MUTE_MASK = (3U << 6);
149 static constexpr uint8_t UNMUTE_MASK = (1U << 7);
150
151 // REG_ADC_x_CTRL / REG_DAC_x_CTRL
152 static constexpr uint8_t EN_MASK = (1U << 7);
153 static constexpr uint8_t RAMP_EN_MASK = (1U << 5);
154
155 // REG_HP_x_CTRL
156 static constexpr uint8_t AMP_EN_MASK = (1U << 7);
157 static constexpr uint8_t AMP_RAMP_EN_MASK = (1U << 5);
158 static constexpr uint8_t AMP_ZC_EN_MASK = (1U << 4);
159 static constexpr uint8_t AMP_OE_MASK = (1U << 3);
160
161 // REG_MIXOUT_x_CTRL
162 static constexpr uint8_t MIXOUT_AMP_EN_MASK = (1U << 7);
163 static constexpr uint8_t MIXOUT_AMP_SOFT_MIX_EN_MASK = (1U << 4);
164 static constexpr uint8_t MIXOUT_AMP_MIX_EN_MASK = (1U << 3);
165
166 // REG_MIXOUT_x_SELECT
167 static constexpr uint8_t MIXOUT_L_SELECT_DAC_L_MASK = (1U << 3);
168 static constexpr uint8_t MIXOUT_R_SELECT_DAC_R_MASK = (1U << 3);
169
170 // REG_MIXIN_x_SELECT
171 static constexpr uint8_t MIXIN_L_SELECT_AUX_L_SEL_MASK = (1U << 0);
172 static constexpr uint8_t MIXIN_R_SELECT_AUX_R_SEL_MASK = (1U << 0);
173
174 // REG_MIXIN_x_CTRL
175 static constexpr uint8_t MIXIN_AMP_EN_MASK = (1U << 7);
176 static constexpr uint8_t MIXIN_AMP_MIX_EN_MASK = (1U << 3);
177
178 // REG_AUX_x_CTRL
179 static constexpr uint8_t AUX_AMP_EN_MASK = (1U << 7);
180 static constexpr uint8_t AUX_AMP_RAMP_EN_MASK = (1U << 5);
181 static constexpr uint8_t AUX_AMP_ZC_EN_MASK = (1U << 4);
182 static constexpr uint8_t AUX_L_CTRL_AMP_ZC_SEL_INPUT_AUX_L_IF = (1U << 2);
183
184 // REG_MIC_x_CTRL
185 static constexpr uint8_t MIC_CTRL_AMP_IN_SEL_MIC_P = (1U << 2);
186
187 // REG_CP_CTRL
188 static constexpr uint8_t CP_CTRL_EN_MASK = (1U << 7);
189 static constexpr uint8_t CP_CTRL_SMALL_SWITCH_FREQ_EN_MASK = (1U << 6);
190 static constexpr uint8_t CP_CTRL_MCHANGE_OUTPUT = (3U << 4);
191 static constexpr uint8_t CP_CTRL_MOD_CPVDD_1 = (3U << 2);
192 static constexpr uint8_t CP_CTRL_ANALOG_VLL_LV_BOOSTS_CP = (1U << 0);
193
194 // REG_GAIN_RAMP_CTRL
195 static constexpr uint8_t GAIN_RAMP_CTRL_RATE_NR_MUL_16 = (2U << 0);
196
197 // REG_PC_COUNT
198 static constexpr uint8_t PC_COUNT_RESYNC_MASK = (1U << 1);
199
200 // REG_CP_DELAY
201 static constexpr uint8_t CP_DELAY_ON_OFF_LIMITER_AUT = (2U << 6);
202 static constexpr uint8_t CP_DELAY_TAU_DELAY_4MS = (2U << 3);
203 static constexpr uint8_t CP_DELAY_FCONTROL_0HZ_OR_1MHZ = (5U << 0);
204
205 DA7212() { i2c_addr = 0x1A; }
206
221 bool begin(uint32_t sample_rate, uint8_t bits) {
222 return begin(DA7212Protocol::I2S, sample_rate, bits);
223 }
224
229 bool begin(uint32_t sample_rate, uint8_t bits, codec_mode_t mode,
230 i2s_format_t fmt, bool is_master, uint8_t channels) override {
231 (void)channels;
233 switch (fmt) {
234 case I2S_LEFT:
236 break;
237 case I2S_RIGHT:
239 break;
240 case I2S_DSP:
241 protocol = DA7212Protocol::DSPMode;
242 break;
243 default:
244 protocol = DA7212Protocol::I2S;
245 break;
246 }
247 return begin(protocol, sample_rate, bits, is_master,
248 mode & CODEC_MODE_DECODE, mode & CODEC_MODE_ENCODE);
249 }
250
252 uint32_t sample_rate = 44100, uint8_t word_size = 16,
253 bool master = false, bool playback = true,
254 bool capture = true) {
255 bool rc = true;
256
257 rc &= softReset();
258
259 /* DAI right/left output stream comes from ADC right/left */
263
264 /* Default sample rate 16kHz, overwritten below */
266
267 /* Enable voltage reference and bias */
269
270 /* Keep PLL disabled, use MCLK as system clock */
271 rc &= writeReg(REG_PLL_FRAC_TOP, 0);
272 rc &= writeReg(REG_PLL_FRAC_BOT, 0);
274 rc &= writeReg(REG_PLL_CTRL, 0x00);
275
276 /* Default clock mode: BCLK number per WCLK = 64 */
278
279 /* Enable DAI, default word length 16 bits, I2S format, output enabled */
282 (uint8_t)DA7212Protocol::I2S);
283
284 /* Route DAC to MixOut by default */
287
288 rc &= setClockMode(master, word_size);
289 rc &= routeDacInput(playback);
290 rc &= setProtocol(protocol);
291 rc &= setAudioFormat(sample_rate, word_size);
292
293 if (playback) rc &= configureOutput();
294 if (capture) rc &= configureInput();
295
296 return rc;
297 }
298
301
307 bool setClockMode(bool master, uint8_t word_size) {
308 if (!master) {
310 }
311
312 uint8_t val;
313 switch (word_size) {
314 case 16:
316 break;
317 case 32:
319 break;
320 case 64:
322 break;
323 case 128:
325 break;
326 default:
328 break;
329 }
332 return rc;
333 }
334
344
347 return updateReg(REG_DAI_CTRL, DAI_FORMAT_MASK, (uint8_t)protocol);
348 }
349
351 bool setAudioFormat(uint32_t sample_rate, uint8_t word_size = 16) {
352 bool rc = true;
354
355 switch (sample_rate) {
356 case 8000:
358 break;
359 case 11025:
361 break;
362 case 12000:
364 break;
365 case 16000:
367 break;
368 case 22050:
370 break;
371 case 24000:
373 break;
374 case 32000:
376 break;
377 case 44100:
379 break;
380 case 48000:
382 break;
383 case 88200:
385 break;
386 case 96000:
388 break;
389 default:
390 return false;
391 }
392 rc &= writeReg(REG_SR, (uint8_t)sr);
393
394 uint8_t wl;
395 switch (word_size) {
396 case 16:
398 break;
399 case 20:
401 break;
402 case 24:
404 break;
405 case 32:
407 break;
408 default:
409 return false;
410 }
412 return rc;
413 }
414
416 bool setOutputVolume(uint8_t volume, DA7212Channel channel = DA7212Channel::All) {
417 if (volume > HP_GAIN_MASK) volume = HP_GAIN_MASK;
418 return updateOutGain(channel, volume);
419 }
420
422 bool setOutputMute(bool mute, DA7212Channel channel = DA7212Channel::All) {
423 uint8_t val = mute ? MUTE_MASK : UNMUTE_MASK;
424 switch (channel) {
427 return updateReg(REG_HP_L_CTRL, MUTE_MASK, val);
430 return updateReg(REG_HP_R_CTRL, MUTE_MASK, val);
431 case DA7212Channel::All: {
432 bool rc = true;
433 rc &= updateReg(REG_HP_L_CTRL, MUTE_MASK, val);
434 rc &= updateReg(REG_HP_R_CTRL, MUTE_MASK, val);
435 rc &= updateReg(REG_LINE_CTRL, MUTE_MASK, val);
436 return rc;
437 }
438 default:
439 return false;
440 }
441 }
442
444 bool setVolume(int volume) override {
445 volume_percent = volume < 0 ? 0 : (volume > 100 ? 100 : volume);
446 uint8_t vol = (uint8_t)((volume_percent * HP_GAIN_MASK) / 100);
448 }
449
451 bool setMute(bool mute) override { return setOutputMute(mute, DA7212Channel::All); }
452
455 (void)input_device;
456 this->output_device = output_device;
457 return true;
458 }
459
462 bool setActive(codec_mode_t mode) override {
465 return rc;
466 }
467
469 bool setInputVolume(uint8_t volume, DA7212Channel channel = DA7212Channel::All) {
470 if (volume > ADC_GAIN_MASK) volume = ADC_GAIN_MASK;
471 switch (channel) {
473 return writeReg(REG_ADC_L_GAIN, volume);
475 return writeReg(REG_ADC_R_GAIN, volume);
476 case DA7212Channel::All: {
477 bool rc = true;
478 rc &= writeReg(REG_ADC_L_GAIN, volume);
479 rc &= writeReg(REG_ADC_R_GAIN, volume);
480 return rc;
481 }
482 default:
483 return false;
484 }
485 }
486
488 bool setInputVolume(int volume) override {
489 input_volume_percent = volume < 0 ? 0 : (volume > 100 ? 100 : volume);
490 uint8_t vol = (uint8_t)((input_volume_percent * ADC_GAIN_MASK) / 100);
492 }
493
494
496 bool isInputVolumeSupported() override { return true; }
497
499 bool setInputMute(bool mute, DA7212Channel channel = DA7212Channel::All) {
500 uint8_t val = mute ? MUTE_MASK : UNMUTE_MASK;
501 if (channel == DA7212Channel::FrontRight) {
502 return updateReg(REG_ADC_R_CTRL, MUTE_MASK, val);
503 }
504 if (channel == DA7212Channel::All) {
505 bool rc = true;
508 return rc;
509 }
510 return updateReg(REG_ADC_L_CTRL, MUTE_MASK, val);
511 }
512
515 bool rc = true;
516 if (channel == DA7212Channel::FrontLeft || channel == DA7212Channel::All)
518 if (channel == DA7212Channel::FrontRight || channel == DA7212Channel::All)
520 return rc;
521 }
522
524 bool routeOutput() {
525 bool rc = true;
528 return rc;
529 }
530
537 bool rc = true;
538
540 /* keep DACs/headphone amps disabled and muted */
542 return rc;
543 }
544
545 /* Power charge pump: 0xFD */
551
552 rc &= routeOutput();
553
554 /* Enable DACs with ramp */
557
558 /* Enable HP amps, ZC and OE */
563
564 /* Enable MixOut amplifiers and mixing into HP */
571
572 /* DAC gain */
575
576 /* Default HP volume and unmute */
578 rc &= setOutputMute(false, DA7212Channel::All);
579
580 return rc;
581 }
582
589 bool rc = true;
590
592
593 /* Charge pump control: 0xFD */
599
600 /* AUX_L_CTRL: 0xB4 */
604
605 /* AUX_R_CTRL: 0xB0 */
608
609 /* MIC_x_CTRL: 0x04 */
612
613 /* MIXIN_L/R_CTRL: 0x88 */
616
617 /* ADC_L/R_CTRL: 0xA0 */
620
621 /* GAIN_RAMP_CTRL: 0x02 */
623
624 /* PC_COUNT: 0x02 */
626
627 /* CP_DELAY: 0x95 */
631
632 /* Default ADC volume and unmute */
634 rc &= setInputMute(false, DA7212Channel::All);
635
636 return rc;
637 }
638
639 protected:
642
643 bool updateOutGain(DA7212Channel channel, uint8_t volume) {
644 switch (channel) {
647 return writeReg(REG_HP_L_GAIN, volume);
650 return writeReg(REG_HP_R_GAIN, volume);
651 case DA7212Channel::All: {
652 bool rc = true;
653 rc &= writeReg(REG_HP_L_GAIN, volume);
654 rc &= writeReg(REG_HP_R_GAIN, volume);
655 return rc;
656 }
657 default:
658 return false;
659 }
660 }
661};
662
663} // namespace audio_driver
Header only C++ driver for the DA7212 audio codec.
Definition DA7212.h:57
bool setOutputMute(bool mute, DA7212Channel channel=DA7212Channel::All)
Mute / unmute the headphone (and line) output for the given channel(s)
Definition DA7212.h:422
static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK32
Definition DA7212.h:114
static constexpr uint8_t DAI_CLK_EN_MASK
Definition DA7212.h:112
static constexpr uint8_t CP_CTRL_EN_MASK
Definition DA7212.h:188
bool setDevices(input_device_t input_device, output_device_t output_device) override
Stores the output device selection for use by configureOutput()
Definition DA7212.h:454
bool begin(uint32_t sample_rate, uint8_t bits)
Initialize the codec: soft reset, default routing, PLL disabled (MCLK is used directly as the system ...
Definition DA7212.h:221
bool setAudioFormat(uint32_t sample_rate, uint8_t word_size=16)
Configure sample rate (SR register) and word length (DAI_CTRL)
Definition DA7212.h:351
static constexpr uint8_t DIG_ROUTING_DAC_R_RSC_DAC_R
Definition DA7212.h:133
static constexpr uint8_t PLL_FBDIV_INTEGER_RESET_VALUE
Definition DA7212.h:139
static constexpr uint8_t PC_COUNT_RESYNC_MASK
Definition DA7212.h:198
static constexpr uint8_t MIXOUT_R_SELECT_DAC_R_MASK
Definition DA7212.h:168
static constexpr uint8_t CIF_CTRL_SOFT_RESET
Definition DA7212.h:110
static constexpr uint8_t HP_DEFAULT_GAIN
Definition DA7212.h:144
bool softReset()
Soft reset of the codec (CIF_CTRL soft reset bit)
Definition DA7212.h:300
bool setOutputVolume(uint8_t volume, DA7212Channel channel=DA7212Channel::All)
Set the headphone output volume (0..63, HP_x_GAIN) for the given channel(s)
Definition DA7212.h:416
static constexpr uint8_t AMP_ZC_EN_MASK
Definition DA7212.h:158
bool setClockMode(bool master, uint8_t word_size)
Configure master/slave clock mode.
Definition DA7212.h:307
bool routeOutput()
Route the DACs to the output mixers (MixOut)
Definition DA7212.h:524
static constexpr uint8_t MIXOUT_AMP_SOFT_MIX_EN_MASK
Definition DA7212.h:163
static constexpr uint8_t AMP_EN_MASK
Definition DA7212.h:156
bool isInputVolumeSupported() override
Returns true: the input volume is supported.
Definition DA7212.h:496
static constexpr uint8_t AUX_L_CTRL_AMP_ZC_SEL_INPUT_AUX_L_IF
Definition DA7212.h:182
bool configureInput()
Configure the input (capture) path: AUX -> MixIn routing, charge pump, AUX/MIC/MixIn amps,...
Definition DA7212.h:588
bool routeDacInput(bool playback)
Route the DAI input to the DACs (playback) or bypass ADC->DAC.
Definition DA7212.h:336
bool setMute(bool mute) override
Mutes/unmutes all outputs.
Definition DA7212.h:451
static constexpr uint8_t AMP_RAMP_EN_MASK
Definition DA7212.h:157
static constexpr uint8_t MIXIN_L_SELECT_AUX_L_SEL_MASK
Definition DA7212.h:171
static constexpr uint8_t DIG_ROUTING_DAI_L_SRC_ADC_LEFT
Definition DA7212.h:130
static constexpr uint8_t EN_MASK
Definition DA7212.h:152
DA7212()
Definition DA7212.h:205
static constexpr uint8_t DAI_EN_MASK
Definition DA7212.h:119
output_device_t output_device
Output device selection set via setDevices(), used by configureOutput()
Definition DA7212.h:641
static constexpr uint8_t DIG_ROUTING_DAC_R_RSC_ADC_R_OUTPUT
Definition DA7212.h:135
static constexpr uint8_t DIG_ROUTING_DAC_L_RSC_DAC_L
Definition DA7212.h:134
static constexpr uint8_t CP_DELAY_ON_OFF_LIMITER_AUT
Definition DA7212.h:201
static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK64
Definition DA7212.h:115
bool configureOutput()
Configure the output (playback) path: charge pump, DAC -> MixOut routing, DACs, headphone amps,...
Definition DA7212.h:536
static constexpr uint8_t CP_DELAY_FCONTROL_0HZ_OR_1MHZ
Definition DA7212.h:203
static constexpr uint8_t UNMUTE_MASK
*_EN bit kept set
Definition DA7212.h:149
static constexpr uint8_t AMP_OE_MASK
Definition DA7212.h:159
static constexpr uint8_t MIXIN_R_SELECT_AUX_R_SEL_MASK
Definition DA7212.h:172
bool setProtocol(DA7212Protocol protocol)
Configure the digital audio interface protocol (I2S, LJ, RJ, DSP)
Definition DA7212.h:346
static constexpr uint8_t DAI_WORD_LENGTH_32B
Definition DA7212.h:126
static constexpr uint8_t MIXOUT_AMP_EN_MASK
Definition DA7212.h:162
Reg
Definition DA7212.h:60
@ REG_DAC_L_CTRL
Definition DA7212.h:94
@ REG_MIXOUT_L_SELECT
Definition DA7212.h:83
@ REG_HP_R_GAIN
Definition DA7212.h:81
@ REG_MIXIN_L_GAIN
Definition DA7212.h:74
@ REG_ADC_L_GAIN
Definition DA7212.h:75
@ REG_MIXIN_L_SELECT
Definition DA7212.h:72
@ REG_ADC_L_CTRL
Definition DA7212.h:92
@ REG_LINE_GAIN
Definition DA7212.h:82
@ REG_MICBIAS_CTRL
Definition DA7212.h:87
@ REG_SR
Definition DA7212.h:62
@ REG_PLL_INTEGER
Definition DA7212.h:66
@ REG_MIXIN_L_CTRL
Definition DA7212.h:90
@ REG_LINE_CTRL
Definition DA7212.h:98
@ REG_HP_L_CTRL
Definition DA7212.h:96
@ REG_AUX_L_CTRL
Definition DA7212.h:85
@ REG_CP_DETECTOR
Definition DA7212.h:106
@ REG_CIF_CTRL
Definition DA7212.h:71
@ REG_MIC_1_CTRL
Definition DA7212.h:88
@ REG_GAIN_RAMP_CTRL
Definition DA7212.h:101
@ REG_PLL_FRAC_BOT
Definition DA7212.h:65
@ REG_CP_DELAY
Definition DA7212.h:105
@ REG_PC_COUNT
Definition DA7212.h:103
@ REG_DAC_R_CTRL
Definition DA7212.h:95
@ REG_MIC_CONFIG
Definition DA7212.h:102
@ REG_MIXOUT_R_CTRL
Definition DA7212.h:100
@ REG_MIXIN_R_CTRL
Definition DA7212.h:91
@ REG_REFERENCES
Definition DA7212.h:63
@ REG_CP_VOL_THRESHOLD1
Definition DA7212.h:104
@ REG_DAI_CTRL
Definition DA7212.h:69
@ REG_AUX_R_CTRL
Definition DA7212.h:86
@ REG_MIXOUT_L_CTRL
Definition DA7212.h:99
@ REG_ADC_R_GAIN
Definition DA7212.h:76
@ REG_HP_L_GAIN
Definition DA7212.h:80
@ REG_DIG_ROUTING_DAC
Definition DA7212.h:70
@ REG_DAC_L_GAIN
Definition DA7212.h:77
@ REG_HP_R_CTRL
Definition DA7212.h:97
@ REG_DAI_CLK_MODE
Definition DA7212.h:68
@ REG_ADC_R_CTRL
Definition DA7212.h:93
@ REG_CP_CTRL
Definition DA7212.h:79
@ REG_DIG_ROUTING_DAI
Definition DA7212.h:61
@ REG_PLL_FRAC_TOP
Definition DA7212.h:64
@ REG_MIXOUT_R_SELECT
Definition DA7212.h:84
@ REG_PLL_CTRL
Definition DA7212.h:67
@ REG_DAC_R_GAIN
Definition DA7212.h:78
@ REG_MIXIN_R_SELECT
Definition DA7212.h:73
@ REG_MIC_2_CTRL
Definition DA7212.h:89
static constexpr uint8_t MIC_CTRL_AMP_IN_SEL_MIC_P
Definition DA7212.h:185
static constexpr uint8_t ADC_GAIN_MASK
Definition DA7212.h:143
static constexpr uint8_t CP_DELAY_TAU_DELAY_4MS
Definition DA7212.h:202
static constexpr uint8_t DAI_FORMAT_MASK
Definition DA7212.h:121
static constexpr uint8_t AUX_AMP_ZC_EN_MASK
Definition DA7212.h:181
static constexpr uint8_t MIXIN_AMP_MIX_EN_MASK
Definition DA7212.h:176
static constexpr uint8_t MIXIN_AMP_EN_MASK
Definition DA7212.h:175
bool begin(DA7212Protocol protocol=DA7212Protocol::I2S, uint32_t sample_rate=44100, uint8_t word_size=16, bool master=false, bool playback=true, bool capture=true)
Definition DA7212.h:251
static constexpr uint8_t REFERENCES_BIAS_EN_MASK
Definition DA7212.h:138
static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK128
Definition DA7212.h:116
static constexpr uint8_t MUTE_MASK
Definition DA7212.h:148
static constexpr uint8_t MIXOUT_L_SELECT_DAC_L_MASK
Definition DA7212.h:167
static constexpr uint8_t CP_CTRL_SMALL_SWITCH_FREQ_EN_MASK
Definition DA7212.h:189
static constexpr uint8_t DAI_WORD_LENGTH_20B
Definition DA7212.h:124
bool begin(uint32_t sample_rate, uint8_t bits, codec_mode_t mode, i2s_format_t fmt, bool is_master, uint8_t channels) override
Definition DA7212.h:229
static constexpr uint8_t CP_CTRL_MOD_CPVDD_1
Definition DA7212.h:191
static constexpr uint8_t AUX_AMP_EN_MASK
Definition DA7212.h:179
static constexpr uint8_t DAI_WORD_LENGTH_24B
Definition DA7212.h:125
static constexpr uint8_t DIG_ROUTING_DAC_L_RSC_ADC_L_OUTPUT
Definition DA7212.h:136
bool updateOutGain(DA7212Channel channel, uint8_t volume)
Definition DA7212.h:643
static constexpr uint8_t HP_GAIN_MASK
Definition DA7212.h:142
static constexpr uint8_t GAIN_RAMP_CTRL_RATE_NR_MUL_16
Definition DA7212.h:195
static constexpr uint8_t CP_CTRL_ANALOG_VLL_LV_BOOSTS_CP
Definition DA7212.h:192
static constexpr uint8_t DAI_BCLKS_PER_WCLK_MASK
Definition DA7212.h:113
bool setActive(codec_mode_t mode) override
Definition DA7212.h:462
static constexpr uint8_t DAI_WORD_LENGTH_MASK
Definition DA7212.h:122
bool setInputVolume(uint8_t volume, DA7212Channel channel=DA7212Channel::All)
Set the ADC input volume (0..127, ADC_x_GAIN) for the given channel(s)
Definition DA7212.h:469
static constexpr uint8_t DAI_OE_MASK
Definition DA7212.h:120
bool setInputVolume(int volume) override
Sets the input volume in % (0...100) for all channels.
Definition DA7212.h:488
bool setVolume(int volume) override
Sets the output volume in % (0...100) for all channels.
Definition DA7212.h:444
static constexpr uint8_t RAMP_EN_MASK
Definition DA7212.h:153
static constexpr uint8_t DAC_DEFAULT_GAIN
Definition DA7212.h:145
bool setInputMute(bool mute, DA7212Channel channel=DA7212Channel::All)
Mute / unmute the ADC input for the given channel(s)
Definition DA7212.h:499
static constexpr uint8_t CP_CTRL_MCHANGE_OUTPUT
Definition DA7212.h:190
bool routeInput(DA7212Channel channel=DA7212Channel::All)
Route the AUX input(s) to the input mixer(s) for the given channel(s)
Definition DA7212.h:514
static constexpr uint8_t DAI_WORD_LENGTH_16B
Definition DA7212.h:123
static constexpr uint8_t MIXOUT_AMP_MIX_EN_MASK
Definition DA7212.h:164
static constexpr uint8_t AUX_AMP_RAMP_EN_MASK
Definition DA7212.h:180
static constexpr uint8_t DAI_BCLKS_PER_WCLK_BCLK256
Definition DA7212.h:117
static constexpr uint8_t DIG_ROUTING_DAI_R_SRC_ADC_RIGHT
Definition DA7212.h:129
Common parent class for codec drivers that have been ported from the Zephyr RTOS audio driver impleme...
Definition ZephyrDriverCommon.h:22
uint8_t i2c_addr
Definition ZephyrDriverCommon.h:87
bool updateReg(uint8_t reg, uint8_t mask, uint8_t value)
Read-Modify-Write of a single byte register.
Definition ZephyrDriverCommon.h:110
int volume_percent
Last volume (in %) provided to setVolume()
Definition ZephyrDriverCommon.h:89
bool writeReg(uint8_t reg, uint8_t value)
Writes a single byte to an 8 bit register address.
Definition ZephyrDriverCommon.h:94
int input_volume_percent
Last input volume (in %) provided to setInputVolume()
Definition ZephyrDriverCommon.h:91
Namespace for audio driver components.
Definition AudioBoard.h:5
DA7212SampleRate
Sample rate (SR register)
Definition DA7212.h:27
DA7212Channel
Logical audio channels.
Definition DA7212.h:42
input_device_t
Definition DriverCommon.h:170
codec_mode_t
Definition DriverCommon.h:290
@ CODEC_MODE_ENCODE
Definition DriverCommon.h:293
@ CODEC_MODE_DECODE
Definition DriverCommon.h:294
output_device_t
Definition DriverCommon.h:186
@ DAC_OUTPUT_ALL
Definition DriverCommon.h:190
@ DAC_OUTPUT_NONE
Definition DriverCommon.h:187
DA7212Protocol
Digital audio interface protocol (DAI_CTRL FORMAT field)
Definition DA7212.h:19
@ DSPMode
used for both PCM-A and PCM-B
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