mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Add i2s mclk (#4885)
This commit is contained in:
parent
2153cfc749
commit
bb044a789c
3 changed files with 8 additions and 1 deletions
|
@ -18,6 +18,7 @@ MULTI_CONF = True
|
|||
|
||||
CONF_I2S_DOUT_PIN = "i2s_dout_pin"
|
||||
CONF_I2S_DIN_PIN = "i2s_din_pin"
|
||||
CONF_I2S_MCLK_PIN = "i2s_mclk_pin"
|
||||
CONF_I2S_BCLK_PIN = "i2s_bclk_pin"
|
||||
CONF_I2S_LRCLK_PIN = "i2s_lrclk_pin"
|
||||
|
||||
|
@ -44,6 +45,7 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
cv.GenerateID(): cv.declare_id(I2SAudioComponent),
|
||||
cv.Required(CONF_I2S_LRCLK_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Optional(CONF_I2S_BCLK_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Optional(CONF_I2S_MCLK_PIN): pins.internal_gpio_output_pin_number,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -69,3 +71,5 @@ async def to_code(config):
|
|||
cg.add(var.set_lrclk_pin(config[CONF_I2S_LRCLK_PIN]))
|
||||
if CONF_I2S_BCLK_PIN in config:
|
||||
cg.add(var.set_bclk_pin(config[CONF_I2S_BCLK_PIN]))
|
||||
if CONF_I2S_MCLK_PIN in config:
|
||||
cg.add(var.set_mclk_pin(config[CONF_I2S_MCLK_PIN]))
|
||||
|
|
|
@ -21,7 +21,7 @@ class I2SAudioComponent : public Component {
|
|||
|
||||
i2s_pin_config_t get_pin_config() const {
|
||||
return {
|
||||
.mck_io_num = I2S_PIN_NO_CHANGE,
|
||||
.mck_io_num = this->mclk_pin_,
|
||||
.bck_io_num = this->bclk_pin_,
|
||||
.ws_io_num = this->lrclk_pin_,
|
||||
.data_out_num = I2S_PIN_NO_CHANGE,
|
||||
|
@ -29,6 +29,7 @@ class I2SAudioComponent : public Component {
|
|||
};
|
||||
}
|
||||
|
||||
void set_mclk_pin(int pin) { this->mclk_pin_ = pin; }
|
||||
void set_bclk_pin(int pin) { this->bclk_pin_ = pin; }
|
||||
void set_lrclk_pin(int pin) { this->lrclk_pin_ = pin; }
|
||||
|
||||
|
@ -44,6 +45,7 @@ class I2SAudioComponent : public Component {
|
|||
I2SAudioIn *audio_in_{nullptr};
|
||||
I2SAudioOut *audio_out_{nullptr};
|
||||
|
||||
int mclk_pin_{I2S_PIN_NO_CHANGE};
|
||||
int bclk_pin_{I2S_PIN_NO_CHANGE};
|
||||
int lrclk_pin_;
|
||||
i2s_port_t port_{};
|
||||
|
|
|
@ -666,6 +666,7 @@ touchscreen:
|
|||
i2s_audio:
|
||||
i2s_lrclk_pin: GPIO26
|
||||
i2s_bclk_pin: GPIO27
|
||||
i2s_mclk_pin: GPIO25
|
||||
|
||||
media_player:
|
||||
- platform: i2s_audio
|
||||
|
|
Loading…
Reference in a new issue