Skip to content

Commit

Permalink
Merge pull request #69 from CelliesProjects/mclk_on_gpio
Browse files Browse the repository at this point in the history
Mclk on gpio
  • Loading branch information
schreibfaul1 authored Oct 19, 2020
2 parents 30a2489 + 53b12e9 commit 38fce6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ streamavail KEYWORD2
isRunning KEYWORD2
inBufferFilled KEYWORD2
inBufferFree KEYWORD2

i2s_mclk_pin_select KEYWORD2



Expand Down
25 changes: 25 additions & 0 deletions src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,31 @@ esp_err_t Audio::I2Sstart(uint8_t i2s_num) {
esp_err_t Audio::I2Sstop(uint8_t i2s_num) {
return i2s_stop((i2s_port_t) i2s_num);
}

esp_err_t Audio::i2s_mclk_pin_select(const uint8_t pin) {
if (pin != 0 && pin != 1 && pin != 3)
{
ESP_LOGE(TAG, "Only support GPIO0/GPIO1/GPIO3, gpio_num:%d", pin);
return ESP_ERR_INVALID_ARG;
}
switch (pin) {
case 0 :
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
WRITE_PERI_REG(PIN_CTRL, 0xFFF0);
break;
case 1 :
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_CLK_OUT3);
WRITE_PERI_REG(PIN_CTRL, 0xF0F0);
break;
case 3 :
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_CLK_OUT2);
WRITE_PERI_REG(PIN_CTRL, 0xFF00);
break;
default:
break;
}
return ESP_OK;
}
//---------------------------------------------------------------------------------------------------------------------
Audio::~Audio() {
I2Sstop(m_i2s_num);
Expand Down
1 change: 1 addition & 0 deletions src/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class Audio : private AudioBuffer{
inline void setDatamode(uint8_t dm){m_datamode=dm;}
inline uint32_t streamavail() {if(m_f_ssl==false) return client.available(); else return clientsecure.available();}
bool isRunning() {return m_f_running;}
esp_err_t i2s_mclk_pin_select(const uint8_t pin);
uint32_t inBufferFilled(); // returns the number of stored bytes in the inputbuffer
uint32_t inBufferFree(); // returns the number of free bytes in the inputbuffer

Expand Down

0 comments on commit 38fce6a

Please sign in to comment.