mirror of https://github.com/arendst/Tasmota.git
ad fixed is2 mclk
This commit is contained in:
parent
102d350c82
commit
ef89614b74
|
@ -29,7 +29,7 @@
|
|||
#include "AudioOutputI2S.h"
|
||||
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int use_apll)
|
||||
AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int use_apll, uint8_t mult, uint32_t freq)
|
||||
{
|
||||
this->portNo = port;
|
||||
this->i2sOn = false;
|
||||
|
@ -49,6 +49,8 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int
|
|||
bclkPin = 26;
|
||||
wclkPin = 25;
|
||||
doutPin = 22;
|
||||
mcmult = mult;
|
||||
mclk_freq = freq;
|
||||
SetGain(1.0);
|
||||
}
|
||||
|
||||
|
@ -84,7 +86,6 @@ bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout, int mclk, int din)
|
|||
mclkPin = mclk;
|
||||
dinPin = din;
|
||||
|
||||
|
||||
if (i2sOn)
|
||||
return SetPinout();
|
||||
|
||||
|
@ -238,10 +239,12 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||
.dma_buf_len = 128,
|
||||
.use_apll = use_apll, // Use audio PLL
|
||||
.tx_desc_auto_clear = true,
|
||||
.fixed_mclk = 0,
|
||||
#ifdef ESP32
|
||||
.fixed_mclk = (int)mclk_freq,
|
||||
//.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_128,
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_16BIT,
|
||||
.mclk_multiple = (i2s_mclk_multiple_t)mcmult,
|
||||
#endif
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_16BIT
|
||||
};
|
||||
audioLogger->printf("+%d %p\n", portNo, &i2s_config_dac);
|
||||
if (i2s_driver_install((i2s_port_t)portNo, &i2s_config_dac, 0, NULL) != ESP_OK)
|
||||
|
|
|
@ -28,11 +28,15 @@
|
|||
#define I2S_PIN_NO_CHANGE -1
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
#define I2S_MCLK_MULTIPLE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
class AudioOutputI2S : public AudioOutput
|
||||
{
|
||||
public:
|
||||
#if defined(ESP32) || defined(ESP8266)
|
||||
AudioOutputI2S(int port=0, int output_mode=EXTERNAL_I2S, int dma_buf_count = 8, int use_apll=APLL_DISABLE);
|
||||
AudioOutputI2S(int port=0, int output_mode=EXTERNAL_I2S, int dma_buf_count = 8, int use_apll=APLL_DISABLE, uint8_t mult=I2S_MCLK_MULTIPLE_DEFAULT, uint32_t freq=0);
|
||||
bool SetPinout(int bclkPin, int wclkPin, int doutPin, int mclk = I2S_PIN_NO_CHANGE, int din = I2S_PIN_NO_CHANGE);
|
||||
enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 };
|
||||
enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 };
|
||||
|
@ -69,6 +73,8 @@ class AudioOutputI2S : public AudioOutput
|
|||
uint8_t bclkPin;
|
||||
uint8_t wclkPin;
|
||||
uint8_t doutPin;
|
||||
uint8_t dinPin;
|
||||
uint8_t mclkPin;
|
||||
int8_t dinPin;
|
||||
int8_t mclkPin;
|
||||
uint8_t mcmult;
|
||||
uint32_t mclk_freq;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue