mirror of https://github.com/arendst/Tasmota.git
sbox support
This commit is contained in:
parent
61734674c5
commit
c3856a6873
|
@ -59,10 +59,13 @@ bool AudioOutputI2S::SetPinout()
|
|||
return false; // Not allowed
|
||||
|
||||
i2s_pin_config_t pins = {
|
||||
.mck_io_num = mclkPin,
|
||||
.bck_io_num = bclkPin,
|
||||
.ws_io_num = wclkPin,
|
||||
.data_out_num = doutPin,
|
||||
.data_in_num = I2S_PIN_NO_CHANGE};
|
||||
.data_in_num = dinPin
|
||||
};
|
||||
//.data_in_num = I2S_PIN_NO_CHANGE};
|
||||
i2s_set_pin((i2s_port_t)portNo, &pins);
|
||||
return true;
|
||||
#else
|
||||
|
@ -73,11 +76,15 @@ bool AudioOutputI2S::SetPinout()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout)
|
||||
bool AudioOutputI2S::SetPinout(int bclk, int wclk, int dout, int mclk, int din)
|
||||
{
|
||||
bclkPin = bclk;
|
||||
wclkPin = wclk;
|
||||
doutPin = dout;
|
||||
mclkPin = mclk;
|
||||
dinPin = din;
|
||||
|
||||
|
||||
if (i2sOn)
|
||||
return SetPinout();
|
||||
|
||||
|
@ -212,6 +219,14 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (mclkPin != I2S_PIN_NO_CHANGE) {
|
||||
use_apll = false;
|
||||
}
|
||||
|
||||
if (dinPin != I2S_PIN_NO_CHANGE) {
|
||||
mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX);
|
||||
}
|
||||
|
||||
i2s_config_t i2s_config_dac = {
|
||||
.mode = mode,
|
||||
.sample_rate = 44100,
|
||||
|
@ -221,7 +236,12 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
||||
.dma_buf_count = dma_buf_count,
|
||||
.dma_buf_len = 128,
|
||||
.use_apll = use_apll // Use audio PLL
|
||||
.use_apll = use_apll, // Use audio PLL
|
||||
.tx_desc_auto_clear = true,
|
||||
.fixed_mclk = 0,
|
||||
//.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_128,
|
||||
.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)
|
||||
|
|
|
@ -19,15 +19,21 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP32
|
||||
#include <driver/i2s.h>
|
||||
#endif
|
||||
#include "AudioOutput.h"
|
||||
|
||||
#ifndef I2S_PIN_NO_CHANGE
|
||||
#define I2S_PIN_NO_CHANGE -1
|
||||
#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);
|
||||
bool SetPinout(int bclkPin, int wclkPin, int doutPin);
|
||||
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 };
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
|
@ -63,4 +69,6 @@ class AudioOutputI2S : public AudioOutput
|
|||
uint8_t bclkPin;
|
||||
uint8_t wclkPin;
|
||||
uint8_t doutPin;
|
||||
uint8_t dinPin;
|
||||
uint8_t mclkPin;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue