1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-27 23:38:17 +00:00

Update setup based on raspiaudio repo

This commit is contained in:
Jesse Hills 2023-05-02 14:10:47 +12:00
parent 5cef11acf0
commit 4b9732629e
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A

View File

@ -1,4 +1,5 @@
#include "es8388_component.h" #include "es8388_component.h"
#include "esphome/core/hal.h"
#include <soc/io_mux_reg.h> #include <soc/io_mux_reg.h>
@ -9,49 +10,66 @@ void ES8388Component::setup() {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
WRITE_PERI_REG(PIN_CTRL, READ_PERI_REG(PIN_CTRL) & 0xFFFFFFF0); WRITE_PERI_REG(PIN_CTRL, READ_PERI_REG(PIN_CTRL) & 0xFFFFFFF0);
// reset
this->write_bytes(0x00, {0x80});
this->write_bytes(0x00, {0x00});
// mute // mute
this->write_bytes(0x19, {0x04}); this->write_byte(0x19, 0x04);
this->write_bytes(0x01, {0x50});
// powerup // powerup
this->write_bytes(0x02, {0x00}); this->write_byte(0x01, 0x50);
this->write_byte(0x02, 0x00);
// worker mode // worker mode
this->write_bytes(0x08, {0x00}); this->write_byte(0x08, 0x00);
// DAC powerdown // DAC powerdown
this->write_bytes(0x04, {0xC0}); this->write_byte(0x04, 0xC0);
// vmidsel/500k ADC/DAC idem // vmidsel/500k ADC/DAC idem
this->write_bytes(0x00, {0x12}); this->write_byte(0x00, 0x12);
this->write_bytes(0x01, {0x00});
// i2s 16 bits // i2s 16 bits
this->write_bytes(0x17, {0x18}); this->write_byte(0x17, 0x18);
// sample freq 256 // sample freq 256
this->write_bytes(0x18, {0x02}); this->write_byte(0x18, 0x02);
// LIN2/RIN2 for mixer // LIN2/RIN2 for mixer
this->write_bytes(0x26, {0x09}); this->write_byte(0x26, 0x00);
// left DAC to left mixer // left DAC to left mixer
this->write_bytes(0x27, {0x90}); this->write_byte(0x27, 0x90);
// right DAC to right mixer // right DAC to right mixer
this->write_bytes(0x2A, {0x90}); this->write_byte(0x2A, 0x90);
// DACLRC ADCLRC idem // DACLRC ADCLRC idem
this->write_bytes(0x2B, {0x80}); this->write_byte(0x2B, 0x80);
this->write_bytes(0x2D, {0x80}); this->write_byte(0x2D, 0x00);
// DAC volume max // DAC volume max
this->write_bytes(0x1B, {0x00}); this->write_byte(0x1B, 0x00);
this->write_bytes(0x1A, {0x00}); this->write_byte(0x1A, 0x00);
this->write_bytes(0x02, {0xF0}); // ADC poweroff
this->write_bytes(0x02, {0x00}); this->write_byte(0x03, 0xFF);
this->write_bytes(0x1D, {0x1C}); // ADC amp 24dB
this->write_byte(0x09, 0x88);
// LINPUT1/RINPUT1
this->write_byte(0x0A, 0x00);
// ADC mono left
this->write_byte(0x0B, 0x02);
// i2S 16b
this->write_byte(0x0C, 0x0C);
// MCLK 256
this->write_byte(0x0D, 0x02);
// ADC Volume
this->write_byte(0x10, 0x00);
this->write_byte(0x11, 0x00);
// ALC OFF
this->write_byte(0x03, 0x09);
this->write_byte(0x2B, 0x80);
this->write_byte(0x02, 0xF0);
delay(1);
this->write_byte(0x02, 0x00);
// DAC power-up LOUT1/ROUT1 enabled // DAC power-up LOUT1/ROUT1 enabled
this->write_bytes(0x04, {0x30}); this->write_byte(0x04, 0x30);
this->write_byte(0x03, 0x00);
// DAC volume max
this->write_byte(0x2E, 0x1C);
this->write_byte(0x2F, 0x1C);
// unmute // unmute
this->write_bytes(0x19, {0x00}); this->write_byte(0x19, 0x00);
this->write_bytes(0x2E, {33});
this->write_bytes(0x2F, {33});
} }
} // namespace es8388 } // namespace es8388
} // namespace esphome } // namespace esphome