25 ESP_LOGCONFIG(TAG,
"Running setup");
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));
108 uint8_t reg01 = 0x3F;
118 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG01_CLK_MANAGER, reg01));
122 if (coefficient ==
nullptr) {
123 ESP_LOGE(TAG,
"Unable to configure sample rate %" PRIu32
"Hz with %" PRIu32
"Hz MCLK", this->
sample_frequency_,
130 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG02_CLK_MANAGER, ®02));
132 reg02 |= (coefficient->pre_div - 1) << 5;
133 reg02 |= coefficient->pre_mult << 3;
134 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG02_CLK_MANAGER, reg02));
137 const uint8_t reg03 = (coefficient->fs_mode << 6) | coefficient->adc_osr;
138 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG03_CLK_MANAGER, reg03));
141 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG04_CLK_MANAGER, coefficient->dac_osr));
144 const uint8_t reg05 = ((coefficient->adc_div - 1) << 4) | (coefficient->dac_div - 1);
145 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG05_CLK_MANAGER, reg05));
149 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG06_CLK_MANAGER, ®06));
156 if (coefficient->bclk_div < 19) {
157 reg06 |= (coefficient->bclk_div - 1) << 0;
159 reg06 |= (coefficient->bclk_div) << 0;
161 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG06_CLK_MANAGER, reg06));
165 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG07_CLK_MANAGER, ®07));
167 reg07 |= coefficient->lrck_h << 0;
168 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG07_CLK_MANAGER, reg07));
171 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG08_CLK_MANAGER, coefficient->lrck_l));
180 ES8311_ERROR_CHECK(this->
read_byte(ES8311_REG00_RESET, ®00));
182 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG00_RESET, reg00));
186 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG09_SDPIN, reg09));
190 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG0A_SDPOUT, reg0a));
197 uint8_t reg14 = 0x1A;
201 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG14_SYSTEM, reg14));
204 ES8311_ERROR_CHECK(this->
write_byte(ES8311_REG17_ADC, 0xC8));