25 ESP_LOGCONFIG(TAG,
"Setting up ES8311...");
28 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG00_RESET, 0x1F));
29 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG00_RESET, 0x00));
39 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG0D_SYSTEM, 0x01));
41 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG0E_SYSTEM, 0x02));
43 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG12_SYSTEM, 0x00));
45 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG13_SYSTEM, 0x10));
47 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG1C_ADC, 0x6A));
49 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG37_DAC, 0x08));
51 ES8311_ERROR_FAILED(this->
write_byte(ES8311_REG00_RESET, 0x80));
106 uint8_t reg01 = 0x3F;
116 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG01_CLK_MANAGER, reg01));
120 if (coefficient ==
nullptr) {
121 ESP_LOGE(TAG,
"Unable to configure sample rate %" PRIu32
"Hz with %" PRIu32
"Hz MCLK", this->
sample_frequency_,
128 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG02_CLK_MANAGER, ®02));
130 reg02 |= (coefficient->pre_div - 1) << 5;
131 reg02 |= coefficient->pre_mult << 3;
132 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG02_CLK_MANAGER, reg02));
135 const uint8_t reg03 = (coefficient->fs_mode << 6) | coefficient->adc_osr;
136 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG03_CLK_MANAGER, reg03));
139 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG04_CLK_MANAGER, coefficient->dac_osr));
142 const uint8_t reg05 = ((coefficient->adc_div - 1) << 4) | (coefficient->dac_div - 1);
143 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG05_CLK_MANAGER, reg05));
147 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG06_CLK_MANAGER, ®06));
154 if (coefficient->bclk_div < 19) {
155 reg06 |= (coefficient->bclk_div - 1) << 0;
157 reg06 |= (coefficient->bclk_div) << 0;
159 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG06_CLK_MANAGER, reg06));
163 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG07_CLK_MANAGER, ®07));
165 reg07 |= coefficient->lrck_h << 0;
166 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG07_CLK_MANAGER, reg07));
169 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG08_CLK_MANAGER, coefficient->lrck_l));
178 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG00_RESET, ®00));
180 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG00_RESET, reg00));
184 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG09_SDPIN, reg09));
188 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG0A_SDPOUT, reg0a));
195 uint8_t reg14 = 0x1A;
199 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG14_SYSTEM, reg14));
202 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG17_ADC, 0xC8));