Compare commits

...

12 Commits

Author SHA1 Message Date
Jesse Hills
7e0582a1a9
Add include 2022-06-16 20:45:43 +12:00
Jesse Hills
17596d12e9
Set up mclk 2022-06-16 20:27:47 +12:00
Jesse Hills
b8ca6aa89f
Change value 2022-06-16 16:33:37 +12:00
Jesse Hills
c3b759acd7
Try setting up later 2022-06-16 16:15:24 +12:00
Jesse Hills
7f416403d4
Set volume on amplifier 2022-06-16 15:57:40 +12:00
Jesse Hills
b9466195b8
Remove pin stuff 2022-06-16 15:37:14 +12:00
Jesse Hills
3051271dc5
Remove power_pin from test4 2022-06-14 11:19:12 +12:00
Jesse Hills
889cec4100
Merge branch 'dev' into jesserockz-2022-199 2022-06-14 10:35:31 +12:00
Jesse Hills
e0b320bf72
Remove power_pin 2022-06-14 10:34:59 +12:00
Jesse Hills
8ef27033db
Comment Keyword change 2022-06-13 16:34:40 +12:00
Jesse Hills
08f772b7d1
Fix and add to test4 2022-06-13 12:39:55 +12:00
Jesse Hills
7036412a20
Create basic ES8388 DAC amplifier component 2022-06-13 10:31:48 +12:00
4 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c
from esphome.const import CONF_ID
es8388_ns = cg.esphome_ns.namespace("es8388")
ES8388Component = es8388_ns.class_("ES8388Component", cg.Component, i2c.I2CDevice)
CONFIG_SCHEMA = (
cv.Schema({cv.GenerateID(): cv.declare_id(ES8388Component)})
.extend(i2c.i2c_device_schema(0x10))
.extend(cv.COMPONENT_SCHEMA)
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await i2c.register_i2c_device(var, config)

View File

@ -0,0 +1,57 @@
#include "es8388_component.h"
#include <soc/io_mux_reg.h>
namespace esphome {
namespace es8388 {
void ES8388Component::setup() {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
WRITE_PERI_REG(PIN_CTRL, READ_PERI_REG(PIN_CTRL) & 0xFFFFFFF0);
// reset
this->write_bytes(0x00, {0x80});
this->write_bytes(0x00, {0x00});
// mute
this->write_bytes(0x19, {0x04});
this->write_bytes(0x01, {0x50});
// powerup
this->write_bytes(0x02, {0x00});
// worker mode
this->write_bytes(0x08, {0x00});
// DAC powerdown
this->write_bytes(0x04, {0xC0});
// vmidsel/500k ADC/DAC idem
this->write_bytes(0x00, {0x12});
this->write_bytes(0x01, {0x00});
// i2s 16 bits
this->write_bytes(0x17, {0x18});
// sample freq 256
this->write_bytes(0x18, {0x02});
// LIN2/RIN2 for mixer
this->write_bytes(0x26, {0x09});
// left DAC to left mixer
this->write_bytes(0x27, {0x90});
// right DAC to right mixer
this->write_bytes(0x2A, {0x90});
// DACLRC ADCLRC idem
this->write_bytes(0x2B, {0x80});
this->write_bytes(0x2D, {0x80});
// DAC volume max
this->write_bytes(0x1B, {0x00});
this->write_bytes(0x1A, {0x00});
this->write_bytes(0x02, {0xF0});
this->write_bytes(0x02, {0x00});
this->write_bytes(0x1D, {0x1C});
// DAC power-up LOUT1/ROUT1 enabled
this->write_bytes(0x04, {0x30});
// unmute
this->write_bytes(0x19, {0x00});
this->write_bytes(0x2E, {33});
this->write_bytes(0x2F, {33});
}
} // namespace es8388
} // namespace esphome

View File

@ -0,0 +1,17 @@
#pragma once
#include "esphome/components/i2c/i2c.h"
#include "esphome/core/component.h"
namespace esphome {
namespace es8388 {
class ES8388Component : public Component, public i2c::I2CDevice {
public:
void setup() override;
float get_setup_priority() const override { return setup_priority::LATE - 1; }
};
} // namespace es8388
} // namespace esphome

View File

@ -621,3 +621,5 @@ media_player:
i2s_dout_pin: GPIO25
i2s_bclk_pin: GPIO27
mute_pin: GPIO14
es8388: