arduino-audio-driver
Loading...
Searching...
No Matches
ES7210.h
Go to the documentation of this file.
1/*
2 * ESPRESSIF MIT License
3 *
4 * Copyright (c) 2021 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
5 *
6 * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in
7 * which case, it is free of charge, to any person obtaining a copy of this
8 * software and associated documentation files (the "Software"), to deal in the
9 * Software without restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do
12 * so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 */
26
27#pragma once
28
29#include <string.h>
30
32#include "DriverCommon.h"
33#include "Platforms/API_I2C.h"
34#include "stdbool.h"
35
36
37namespace audio_driver {
38
45
52
70
71/*
72 * Clock coefficient structer
73 */
74struct _coeff_div {
75 uint32_t mclk; /* mclk frequency */
76 uint32_t lrck; /* lrck */
77 uint8_t ss_ds;
78 uint8_t adc_div; /* adcclk divider */
79 uint8_t dll; /* dll_bypass */
80 uint8_t doubler; /* doubler enable */
81 uint8_t osr; /* adc osr */
82 uint8_t mclk_src; /* select mclk source */
83 uint32_t lrck_h; /* The high 4 bits of lrck */
84 uint32_t lrck_l; /* The low 8 bits of lrck */
85};
86
87/* Codec hifi mclk clock divider coefficients
88 * MEMBER REG
89 * mclk: 0x03
90 * lrck: standard
91 * ss_ds: --
92 * adc_div: 0x02
93 * dll: 0x06
94 * doubler: 0x02
95 * osr: 0x07
96 * mclk_src: 0x03
97 * lrckh: 0x04
98 * lrckl: 0x05
99 */
100static const struct _coeff_div es7210_coeff_div[] = {
101 // mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl
102 /* 8k */
103 {12288000, 8000, 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00},
104 {16384000, 8000, 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00},
105 {19200000, 8000, 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60},
106 {4096000, 8000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
107
108 /* 11.025k */
109 {11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
110
111 /* 12k */
112 {12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
113 {19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40},
114
115 /* 16k */
116 {4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
117 {19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80},
118 {16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
119 {12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00},
120
121 /* 22.05k */
122 {11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
123
124 /* 24k */
125 {12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
126 {19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20},
127
128 /* 32k */
129 {12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80},
130 {16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
131 {19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58},
132
133 /* 44.1k */
134 {11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
135
136 /* 48k */
137 {12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
138 {19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90},
139
140 /* 64k */
141 {16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
142 {19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c},
143
144 /* 88.2k */
145 {11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
146
147 /* 96k */
148 {12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
149 {19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8},
150};
151
157class ES7210 {
158 public:
159 static constexpr uint8_t ES7210_RESET_REG00 = 0x00;
160 static constexpr uint8_t ES7210_CLOCK_OFF_REG01 = 0x01;
161 static constexpr uint8_t ES7210_MAINCLK_REG02 = 0x02;
162 static constexpr uint8_t ES7210_MASTER_CLK_REG03 = 0x03;
163 static constexpr uint8_t ES7210_LRCK_DIVH_REG04 = 0x04;
164 static constexpr uint8_t ES7210_LRCK_DIVL_REG05 = 0x05;
165 static constexpr uint8_t ES7210_POWER_DOWN_REG06 = 0x06;
166 static constexpr uint8_t ES7210_OSR_REG07 = 0x07;
167 static constexpr uint8_t ES7210_MODE_CONFIG_REG08 = 0x08;
168 static constexpr uint8_t ES7210_TIME_CONTROL0_REG09 = 0x09;
169 static constexpr uint8_t ES7210_TIME_CONTROL1_REG0A = 0x0A;
170 static constexpr uint8_t ES7210_SDP_INTERFACE1_REG11 = 0x11;
171 static constexpr uint8_t ES7210_SDP_INTERFACE2_REG12 = 0x12;
172 static constexpr uint8_t ES7210_ADC_AUTOMUTE_REG13 = 0x13;
173 static constexpr uint8_t ES7210_ADC34_MUTERANGE_REG14 = 0x14;
174 static constexpr uint8_t ES7210_ADC34_HPF2_REG20 = 0x20;
175 static constexpr uint8_t ES7210_ADC34_HPF1_REG21 = 0x21;
176 static constexpr uint8_t ES7210_ADC12_HPF1_REG22 = 0x22;
177 static constexpr uint8_t ES7210_ADC12_HPF2_REG23 = 0x23;
178 static constexpr uint8_t ES7210_ANALOG_REG40 = 0x40;
179 static constexpr uint8_t ES7210_MIC12_BIAS_REG41 = 0x41;
180 static constexpr uint8_t ES7210_MIC34_BIAS_REG42 = 0x42;
181 static constexpr uint8_t ES7210_MIC1_ES7210_GAIN_REG43 = 0x43;
182 static constexpr uint8_t ES7210_MIC2_ES7210_GAIN_REG44 = 0x44;
183 static constexpr uint8_t ES7210_MIC3_ES7210_GAIN_REG45 = 0x45;
184 static constexpr uint8_t ES7210_MIC4_ES7210_GAIN_REG46 = 0x46;
185 static constexpr uint8_t ES7210_MIC1_POWER_REG47 = 0x47;
186 static constexpr uint8_t ES7210_MIC2_POWER_REG48 = 0x48;
187 static constexpr uint8_t ES7210_MIC3_POWER_REG49 = 0x49;
188 static constexpr uint8_t ES7210_MIC4_POWER_REG4A = 0x4A;
189 static constexpr uint8_t ES7210_MIC12_POWER_REG4B = 0x4B;
190 static constexpr uint8_t ES7210_MIC34_POWER_REG4C = 0x4C;
191 static constexpr int I2S_DSP_MODE = 0;
192 static constexpr int MCLK_DIV_FRE = 256;
193 static constexpr const char* TAG_ES7210 = "ES7210";
194 static constexpr int FROM_PAD_PIN = 0;
195 static constexpr int FROM_CLOCK_DOUBLE_PIN = 1;
197 static constexpr int ES7210_ADDR = ES7210_AD1_AD0_00 >> 1;
198 ES7210() = default;
199
201 void setWire(i2c_bus_handle_t handle) { i2c_handle = handle; }
202
204 void setAddress(int addr) { i2c_addr = addr; }
205
208 // select microphones
209 error_t ret = setMicsForChannels(codec_cfg->i2s.channels);
210
211 ret |= writeReg(ES7210_RESET_REG00, 0xff);
212 ret |= writeReg(ES7210_RESET_REG00, 0x41);
213 ret |= writeReg(ES7210_CLOCK_OFF_REG01, 0x1f);
215 0x30); /* Set chip state cycle */
217 0x30); /* Set power on state cycle */
218 ret |= writeReg(ES7210_ADC12_HPF2_REG23, 0x2a); /* Quick setup */
219 ret |= writeReg(ES7210_ADC12_HPF1_REG22, 0x0a);
220 ret |= writeReg(ES7210_ADC34_HPF2_REG20, 0x0a);
221 ret |= writeReg(ES7210_ADC34_HPF1_REG21, 0x2a);
222 /* Set master/slave audio interface */
223 I2SDefinition* i2s_cfg = &(codec_cfg->i2s);
224 switch (i2s_cfg->mode) {
225 case MODE_MASTER: /* MASTER MODE */
226 AD_LOGI("ES7210 in Master mode");
227 ret |= updateRegBit(ES7210_MODE_CONFIG_REG08, 0x01, 0x01);
228 /* Select clock source for internal mclk */
229 switch (getMclkSrc()) {
230 case FROM_PAD_PIN:
231 ret |= updateRegBit(ES7210_MASTER_CLK_REG03, 0x80, 0x00);
232 break;
234 ret |= updateRegBit(ES7210_MASTER_CLK_REG03, 0x80, 0x80);
235 break;
236 default:
237 ret |= updateRegBit(ES7210_MASTER_CLK_REG03, 0x80, 0x00);
238 break;
239 }
240 break;
241 case MODE_SLAVE: /* SLAVE MODE */
242 AD_LOGI("ES7210 in Slave mode");
243 ret |= updateRegBit(ES7210_MODE_CONFIG_REG08, 0x01, 0x00);
244 break;
245 default:
246 ret |= updateRegBit(ES7210_MODE_CONFIG_REG08, 0x01, 0x00);
247 }
249 0x43); /* Select power off analog, vdda = 3.3V, close
250 vx20ff, VMID select 5KΩ start */
251 ret |= writeReg(ES7210_MIC12_BIAS_REG41, 0x70); /* Select 2.87v */
252 ret |= writeReg(ES7210_MIC34_BIAS_REG42, 0x70); /* Select 2.87v */
253 ret |= writeReg(ES7210_OSR_REG07, 0x20);
254 ret |= writeReg(
256 0xc1); /* Set the frequency division coefficient and use dll except
257 clock doubler, and need to set 0xc1 to clear the state */
258 ret |= configSample(i2s_cfg->rate);
259 ret |= micSelect(mic_select);
261
262 // set REG12
263 uint8_t reg12 = 0;
264 if (i2s_cfg->signal_type == SIGNAL_TDM) {
265 reg12 = 0x02; // TDM I2S
266 }
268
269 return RESULT_OK;
270 }
271
274
277 error_t ret = RESULT_OK;
278 ret |= setBits(iface->bits);
279 ret |= configFmt(iface->fmt);
280 ret |= configSample(iface->rate);
281 return ret;
282 }
283
285 error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active) {
286 static uint8_t regv;
287 error_t ret = RESULT_OK;
288 AD_LOGW("ES7210 only supports ADC mode");
290 if ((regv != 0x7f) && (regv != 0xff)) {
292 }
293 if (ctrl_state_active) {
294 AD_LOGI("The ES7210_CLOCK_OFF_REG01 value before stop is %x", regv);
295 ret |= start(regv);
296 } else {
297 AD_LOGW("The codec is about to stop");
299 ret |= stop();
300 }
301 return ret;
302 }
303
306 error_t ret = RESULT_OK;
307 mic_select = mic;
310 for (int i = 0; i < 4; i++) {
311 ret |= updateRegBit(ES7210_MIC1_ES7210_GAIN_REG43 + i, 0x10, 0x00);
312 }
316 AD_LOGI("Enable ES7210_INPUT_MIC1");
317 ret |= updateRegBit(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00);
320 }
322 AD_LOGI("Enable ES7210_INPUT_MIC2");
323 ret |= updateRegBit(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00);
326 }
328 AD_LOGI("Enable ES7210_INPUT_MIC3");
329 ret |= updateRegBit(ES7210_CLOCK_OFF_REG01, 0x15, 0x00);
332 }
334 AD_LOGI("Enable ES7210_INPUT_MIC4");
335 ret |= updateRegBit(ES7210_CLOCK_OFF_REG01, 0x15, 0x00);
338 }
339 } else {
340 AD_LOGE("Microphone selection error");
341 return RESULT_FAIL;
342 }
343 return ret;
344 }
345
348 AD_LOGD("setGain:%d", gain);
349 error_t ret = RESULT_OK;
350 es7210_gain_value_t max_gain_vaule = static_cast<es7210_gain_value_t>(14);
351 if (gain < 0) {
352 gain = (es7210_gain_value_t)0;
353 } else if (gain > max_gain_vaule) {
354 gain = max_gain_vaule;
355 }
358 }
361 }
364 }
367 }
368 return ret;
369 }
370
373 int regv = 0;
374 uint8_t gain_value;
377 } else if (mic_select & ES7210_INPUT_MIC2) {
379 } else if (mic_select & ES7210_INPUT_MIC3) {
381 } else if (mic_select & ES7210_INPUT_MIC4) {
383 } else {
384 AD_LOGE("No MIC selected");
385 return RESULT_FAIL;
386 }
387 if (regv == RESULT_FAIL) {
388 return regv;
389 }
390 gain_value = (regv & 0x0f); /* Retain the last four bits for gain */
391 AD_LOGI("GET: gain_value:%d", gain_value);
392 return gain_value;
393 }
394
396 error_t setVolume(int volume) {
397 error_t ret = RESULT_OK;
398 AD_LOGD("ADC can adjust gain");
399 return ret;
400 }
401
403 error_t setMute(bool enable) {
404 AD_LOGD("ES7210 SetMute :%d", enable);
405 return RESULT_OK;
406 }
407
409 void readAll(void) {
410 for (int i = 0; i <= 0x4E; i++) {
411 uint8_t reg = readReg(i);
412 AD_LOGI("REG:%02x, %02x", reg, i);
413 }
414 }
416 int readReg(uint8_t reg_addr) {
417 uint8_t data;
418 i2c_bus_read_bytes(i2c_handle, i2c_addr, &reg_addr, sizeof(reg_addr),
419 &data, sizeof(data));
420 return (int)data;
421 }
422
423 error_t writeReg(uint8_t reg_addr, uint8_t data) {
424 return i2c_bus_write_bytes(i2c_handle, i2c_addr, &reg_addr,
425 sizeof(reg_addr), &data, sizeof(data));
426 }
427
428 error_t updateRegBit(uint8_t reg_addr, uint8_t update_bits, uint8_t data) {
429 uint8_t regv;
430 regv = readReg(reg_addr);
431 regv = (regv & (~update_bits)) | (update_bits & data);
432 return writeReg(reg_addr, regv);
433 }
434
435 int getCoeff(uint32_t mclk, uint32_t lrck) {
436 for (unsigned i = 0;
437 i < (sizeof(es7210_coeff_div) / sizeof(es7210_coeff_div[0])); i++) {
438 if (es7210_coeff_div[i].lrck == lrck && es7210_coeff_div[i].mclk == mclk)
439 return i;
440 }
441 return -1;
442 }
443
444 int8_t getMclkSrc(void) { return ES7210_MCLK_SOURCE; }
445
447 uint8_t regv;
448 int coeff;
449 int sample_fre = 0;
450 int mclk_fre = 0;
451 error_t ret = RESULT_OK;
452 switch (sample) {
453 case RATE_8K:
454 sample_fre = 8000;
455 break;
456 case RATE_11K:
457 sample_fre = 11025;
458 break;
459 case RATE_16K:
460 sample_fre = 16000;
461 break;
462 case RATE_22K:
463 sample_fre = 22050;
464 break;
465 case RATE_24K:
466 sample_fre = 24000;
467 break;
468 case RATE_32K:
469 sample_fre = 32000;
470 break;
471 case RATE_44K:
472 sample_fre = 44100;
473 break;
474 case RATE_48K:
475 sample_fre = 48000;
476 break;
477 default:
478 AD_LOGE("Unable to configure sample rate %dHz", sample_fre);
479 break;
480 }
481 mclk_fre = sample_fre * MCLK_DIV_FRE;
482 coeff = getCoeff(mclk_fre, sample_fre);
483 if (coeff < 0) {
484 AD_LOGE("Unable to configure sample rate %dHz with %dHz MCLK", sample_fre,
485 mclk_fre);
486 return RESULT_FAIL;
487 }
488 /* Set clock parammeters */
489 if (coeff >= 0) {
490 /* Set adc_div & doubler & dll */
491 regv = readReg(ES7210_MAINCLK_REG02) & 0x00;
492 regv |= es7210_coeff_div[coeff].adc_div;
493 regv |= es7210_coeff_div[coeff].doubler << 6;
494 regv |= es7210_coeff_div[coeff].dll << 7;
495 ret |= writeReg(ES7210_MAINCLK_REG02, regv);
496 /* Set osr */
497 regv = es7210_coeff_div[coeff].osr;
498 ret |= writeReg(ES7210_OSR_REG07, regv);
499 /* Set lrck */
500 regv = es7210_coeff_div[coeff].lrck_h;
501 ret |= writeReg(ES7210_LRCK_DIVH_REG04, regv);
502 regv = es7210_coeff_div[coeff].lrck_l;
503 ret |= writeReg(ES7210_LRCK_DIVL_REG05, regv);
504 }
505 return ret;
506 }
507
509 error_t ret = RESULT_OK;
510 switch (ch) {
511 case CHANNELS2:
514 break;
515 case CHANNELS4:
516 mic_select = static_cast<es7210_input_mics_t>(
519 break;
520 default:
521 AD_LOGE("Unsupported channels: %d", (int)ch);
522 ret = RESULT_FAIL;
523 }
524 return ret;
525 }
526
528 error_t ret = RESULT_OK;
529 uint8_t adc_iface = 0;
530
532 adc_iface &= 0xfc;
533
534 switch (fmt) {
535 case I2S_NORMAL:
536 AD_LOGD("ES7210 in I2S Format");
537 adc_iface |= 0x00;
538 break;
539 case I2S_LEFT:
540 case I2S_RIGHT:
541 AD_LOGD("ES7210 in LJ Format");
542 adc_iface |= 0x01;
543 break;
544 case I2S_DSP:
545 if (I2S_DSP_MODE) {
546 AD_LOGD("ES7210 in DSP-A Format");
547 adc_iface |= 0x13;
548 } else {
549 AD_LOGD("ES7210 in DSP-B Format");
550 adc_iface |= 0x03;
551 }
552 break;
553 default:
554 adc_iface &= 0xfc;
555 break;
556 }
557 ret |= writeReg(ES7210_SDP_INTERFACE1_REG11, adc_iface);
558 return ret;
559 }
560
562 error_t ret = RESULT_OK;
563 uint8_t adc_iface = 0;
565 adc_iface &= 0x1f;
566 switch (bits) {
568 adc_iface |= 0x60;
569 break;
571 adc_iface |= 0x00;
572 break;
574 adc_iface |= 0x80;
575 break;
576 default:
577 adc_iface |= 0x60;
578 break;
579 }
580 ret |= writeReg(ES7210_SDP_INTERFACE1_REG11, adc_iface);
581 return ret;
582 }
583
584 error_t start(uint8_t clock_reg_value) {
585 error_t ret = RESULT_OK;
586 ret |= writeReg(ES7210_CLOCK_OFF_REG01, clock_reg_value);
587 ret |= writeReg(ES7210_POWER_DOWN_REG06, 0x00);
588 ret |= writeReg(ES7210_ANALOG_REG40, 0x43);
589 ret |= writeReg(ES7210_MIC1_POWER_REG47, 0x00);
590 ret |= writeReg(ES7210_MIC2_POWER_REG48, 0x00);
591 ret |= writeReg(ES7210_MIC3_POWER_REG49, 0x00);
592 ret |= writeReg(ES7210_MIC4_POWER_REG4A, 0x00);
593 ret |= micSelect(mic_select);
594 return ret;
595 }
596
597 error_t stop(void) {
598 error_t ret = RESULT_OK;
599 ret |= writeReg(ES7210_MIC1_POWER_REG47, 0xff);
600 ret |= writeReg(ES7210_MIC2_POWER_REG48, 0xff);
601 ret |= writeReg(ES7210_MIC3_POWER_REG49, 0xff);
602 ret |= writeReg(ES7210_MIC4_POWER_REG4A, 0xff);
605 ret |= writeReg(ES7210_ANALOG_REG40, 0xc0);
606 ret |= writeReg(ES7210_CLOCK_OFF_REG01, 0x7f);
607 ret |= writeReg(ES7210_POWER_DOWN_REG06, 0x07);
608 return ret;
609 }
610
611 protected:
615 ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2); /* Number of microphones */
616};
617
618} // namespace audio_driver
#define RESULT_OK
Definition DriverCommon.h:74
#define RESULT_FAIL
Definition DriverCommon.h:75
#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 ES7210 ADC chip.
Definition ES7210.h:157
static constexpr uint8_t ES7210_MIC12_BIAS_REG41
Definition ES7210.h:179
static constexpr uint8_t ES7210_ADC34_HPF2_REG20
Definition ES7210.h:174
error_t deinit()
Deinitialize ES7210 ADC chip.
Definition ES7210.h:273
static constexpr uint8_t ES7210_MIC12_POWER_REG4B
Definition ES7210.h:189
error_t configSample(samplerate_t sample)
Definition ES7210.h:446
static constexpr uint8_t ES7210_SDP_INTERFACE1_REG11
Definition ES7210.h:170
static constexpr uint8_t ES7210_ANALOG_REG40
Definition ES7210.h:178
error_t ctrlStateActive(codec_mode_t mode, bool ctrl_state_active)
Control ES7210 ADC chip.
Definition ES7210.h:285
es7210_input_mics_t mic_select
Definition ES7210.h:614
error_t stop(void)
Definition ES7210.h:597
static constexpr int ES7210_ADDR
Definition ES7210.h:197
static constexpr int I2S_DSP_MODE
Definition ES7210.h:191
void setAddress(int addr)
Defines the I2C device address.
Definition ES7210.h:204
int getCoeff(uint32_t mclk, uint32_t lrck)
Definition ES7210.h:435
error_t setGain(es7210_gain_value_t gain)
Set gain (Note: the enabled microphone sets the same gain)
Definition ES7210.h:347
void readAll(void)
Read all regs of ES7210.
Definition ES7210.h:409
error_t getGain(void)
Get gain.
Definition ES7210.h:372
static constexpr uint8_t ES7210_MAINCLK_REG02
Definition ES7210.h:161
static constexpr const char * TAG_ES7210
Definition ES7210.h:193
static constexpr uint8_t ES7210_LRCK_DIVH_REG04
Definition ES7210.h:163
error_t micSelect(es7210_input_mics_t mic)
Select ES7210 mic.
Definition ES7210.h:305
static constexpr uint8_t ES7210_TIME_CONTROL0_REG09
Definition ES7210.h:168
static constexpr uint8_t ES7210_MIC34_POWER_REG4C
Definition ES7210.h:190
int readReg(uint8_t reg_addr)
Read regs of ES7210.
Definition ES7210.h:416
static constexpr uint8_t ES7210_MIC3_ES7210_GAIN_REG45
Definition ES7210.h:183
static constexpr int FROM_PAD_PIN
Definition ES7210.h:194
int i2c_addr
Definition ES7210.h:613
static constexpr uint8_t ES7210_LRCK_DIVL_REG05
Definition ES7210.h:164
static constexpr uint8_t ES7210_MASTER_CLK_REG03
Definition ES7210.h:162
error_t configI2S(codec_mode_t mode, I2SDefinition *iface)
Configure ES7210 ADC mode and I2S interface.
Definition ES7210.h:276
static constexpr uint8_t ES7210_CLOCK_OFF_REG01
Definition ES7210.h:160
static constexpr uint8_t ES7210_MIC4_POWER_REG4A
Definition ES7210.h:188
static constexpr uint8_t ES7210_POWER_DOWN_REG06
Definition ES7210.h:165
static constexpr uint8_t ES7210_MIC2_ES7210_GAIN_REG44
Definition ES7210.h:182
static constexpr int ES7210_MCLK_SOURCE
Definition ES7210.h:196
error_t setBits(sample_bits_t bits)
Definition ES7210.h:561
int8_t getMclkSrc(void)
Definition ES7210.h:444
error_t setMute(bool enable)
Set ES7210 ADC mute status.
Definition ES7210.h:403
static constexpr uint8_t ES7210_MIC4_ES7210_GAIN_REG46
Definition ES7210.h:184
static constexpr uint8_t ES7210_ADC12_HPF2_REG23
Definition ES7210.h:177
static constexpr uint8_t ES7210_MIC1_POWER_REG47
Definition ES7210.h:185
void setWire(i2c_bus_handle_t handle)
Defines the I2C bus instance to be used.
Definition ES7210.h:201
error_t start(uint8_t clock_reg_value)
Definition ES7210.h:584
static constexpr uint8_t ES7210_ADC12_HPF1_REG22
Definition ES7210.h:176
static constexpr int MCLK_DIV_FRE
Definition ES7210.h:192
static constexpr uint8_t ES7210_OSR_REG07
Definition ES7210.h:166
static constexpr uint8_t ES7210_MIC2_POWER_REG48
Definition ES7210.h:186
error_t setVolume(int volume)
Set volume.
Definition ES7210.h:396
static constexpr uint8_t ES7210_MIC34_BIAS_REG42
Definition ES7210.h:180
static constexpr int FROM_CLOCK_DOUBLE_PIN
Definition ES7210.h:195
error_t setMicsForChannels(channels_t ch)
Definition ES7210.h:508
error_t writeReg(uint8_t reg_addr, uint8_t data)
Definition ES7210.h:423
static constexpr uint8_t ES7210_ADC34_HPF1_REG21
Definition ES7210.h:175
i2c_bus_handle_t i2c_handle
Definition ES7210.h:612
static constexpr uint8_t ES7210_TIME_CONTROL1_REG0A
Definition ES7210.h:169
error_t updateRegBit(uint8_t reg_addr, uint8_t update_bits, uint8_t data)
Definition ES7210.h:428
static constexpr uint8_t ES7210_MODE_CONFIG_REG08
Definition ES7210.h:167
static constexpr uint8_t ES7210_MIC1_ES7210_GAIN_REG43
Definition ES7210.h:181
static constexpr uint8_t ES7210_ADC34_MUTERANGE_REG14
Definition ES7210.h:173
static constexpr uint8_t ES7210_MIC3_POWER_REG49
Definition ES7210.h:187
error_t configFmt(i2s_format_t fmt)
Definition ES7210.h:527
static constexpr uint8_t ES7210_RESET_REG00
Definition ES7210.h:159
static constexpr uint8_t ES7210_SDP_INTERFACE2_REG12
Definition ES7210.h:171
error_t init(codec_config_t *codec_cfg)
Initialize ES7210 ADC chip.
Definition ES7210.h:207
static constexpr uint8_t ES7210_ADC_AUTOMUTE_REG13
Definition ES7210.h:172
Namespace for audio driver components.
Definition AudioBoard.h:5
static const struct _coeff_div es7210_coeff_div[]
Definition ES7210.h:100
es7210_address_t
Definition ES7210.h:39
@ ES7210_AD1_AD0_01
Definition ES7210.h:41
@ ES7210_AD1_AD0_00
Definition ES7210.h:40
@ ES7210_AD1_AD0_11
Definition ES7210.h:43
@ ES7210_AD1_AD0_10
Definition ES7210.h:42
sample_bits_t
Definition DriverCommon.h:235
@ BIT_LENGTH_24BITS
Definition DriverCommon.h:240
@ BIT_LENGTH_32BITS
Definition DriverCommon.h:241
@ BIT_LENGTH_16BITS
Definition DriverCommon.h:237
codec_mode_t
Definition DriverCommon.h:290
int error_t
Definition DriverCommon.h:150
es7210_gain_value_t
Definition ES7210.h:53
@ ES7210_GAIN_24DB
Definition ES7210.h:62
@ ES7210_GAIN_9DB
Definition ES7210.h:57
@ ES7210_GAIN_33DB
Definition ES7210.h:65
@ ES7210_GAIN_6DB
Definition ES7210.h:56
@ ES7210_GAIN_37_5DB
Definition ES7210.h:68
@ ES7210_GAIN_12DB
Definition ES7210.h:58
@ ES7210_GAIN_15DB
Definition ES7210.h:59
@ ES7210_GAIN_21DB
Definition ES7210.h:61
@ ES7210_GAIN_18DB
Definition ES7210.h:60
@ ES7210_GAIN_3DB
Definition ES7210.h:55
@ ES7210_GAIN_36DB
Definition ES7210.h:67
@ ES7210_GAIN_0DB
Definition ES7210.h:54
@ ES7210_GAIN_30DB
Definition ES7210.h:64
@ ES7210_GAIN_34_5DB
Definition ES7210.h:66
@ ES7210_GAIN_27DB
Definition ES7210.h:63
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_8K
Definition DriverCommon.h:214
@ RATE_32K
Definition DriverCommon.h:219
@ RATE_11K
Definition DriverCommon.h:215
@ RATE_16K
Definition DriverCommon.h:216
@ RATE_48K
Definition DriverCommon.h:221
channels_t
Definition DriverCommon.h:274
@ CHANNELS2
Definition DriverCommon.h:275
@ CHANNELS4
Definition DriverCommon.h:276
es7210_input_mics_t
Definition ES7210.h:46
@ ES7210_INPUT_MIC2
Definition ES7210.h:48
@ ES7210_INPUT_MIC4
Definition ES7210.h:50
@ ES7210_INPUT_MIC3
Definition ES7210.h:49
@ ES7210_INPUT_MIC1
Definition ES7210.h:47
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
@ SIGNAL_TDM
Definition DriverCommon.h:266
void * i2c_bus_handle_t
Definition DriverCommon.h:155
Definition ES7210.h:74
uint32_t mclk
Definition ES7210.h:75
uint8_t mclk_src
Definition ES7210.h:82
uint8_t dll
Definition ES7210.h:79
uint32_t lrck_l
Definition ES7210.h:84
uint8_t ss_ds
Definition ES7210.h:77
uint8_t osr
Definition ES7210.h:81
uint8_t adc_div
Definition ES7210.h:78
uint32_t lrck_h
Definition ES7210.h:83
uint8_t doubler
Definition ES7210.h:80
uint32_t lrck
Definition ES7210.h:76
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
Top-level codec configuration passed to the audio driver at init.
Definition DriverCommon.h:397
I2SDefinition i2s
Definition DriverCommon.h:400