From 5caaf60c680bbc98094ea81dcd1623996a1c03c5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 3 Feb 2021 14:12:43 +0100 Subject: [PATCH] Prep ESP32S2 --- .../TasmotaSerial-3.1.0/src/TasmotaSerial.cpp | 4 ++++ lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp | 14 ++++++++++---- .../ESP8266Audio/src/AudioOutputI2SNoDAC.cpp | 12 ++++++++---- .../ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp index 1d0445351..347457008 100644 --- a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp @@ -38,7 +38,11 @@ TasmotaSerial *tms_obj_list[16]; #endif // ESP8266 #ifdef ESP32 +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 static int tasmota_serial_index = 2; // Allow UART2 and UART1 only +#elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2 +static int tasmota_serial_index = 1; // Allow UART1 only +#endif #endif // ESP32 diff --git a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp index f7e194ea7..5ef967d6a 100644 --- a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp +++ b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp @@ -1,7 +1,7 @@ /* AudioOutputI2S Base class for I2S interface port - + Copyright (C) 2017 Earle F. Philhower, III This program is free software: you can redistribute it and/or modify @@ -48,11 +48,13 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int } i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX); +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 if (output_mode == INTERNAL_DAC) { mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN); } else if (output_mode == INTERNAL_PDM) { mode = (i2s_mode_t)(mode | I2S_MODE_PDM); } +#endif i2s_comm_format_t comm_fmt = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB); if (output_mode == INTERNAL_DAC) { @@ -81,7 +83,7 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int SetPinout(26, 25, 22); } i2s_zero_dma_buffer((i2s_port_t)portNo); - } + } #else (void) dma_buf_count; (void) use_apll; @@ -138,7 +140,7 @@ bool AudioOutputI2S::SetRate(int hz) // TODO - have a list of allowable rates from constructor, check them this->hertz = hz; #ifdef ESP32 - i2s_set_sample_rates((i2s_port_t)portNo, AdjustI2SRate(hz)); + i2s_set_sample_rates((i2s_port_t)portNo, AdjustI2SRate(hz)); #else i2s_set_rate(AdjustI2SRate(hz)); #endif @@ -192,7 +194,11 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2]) } else { s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff); } - return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0); +// Deprecated. Use i2s_write +// return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0); + size_t bytes_written; + return (ESP_OK == i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0)); +// return bytes_written; #else uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff); return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true diff --git a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp index cb36e13e6..e8cfd2352 100644 --- a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp +++ b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp @@ -1,7 +1,7 @@ /* AudioOutputI2SNoDAC Audio player using SW delta-sigma to generate "analog" on I2S data - + Copyright (C) 2017 Earle F. Philhower, III This program is free software: you can redistribute it and/or modify @@ -66,7 +66,7 @@ void AudioOutputI2SNoDAC::DeltaSigma(int16_t sample[2], uint32_t dsBuff[8]) for (int j = 0; j < oversample32; j++) { uint32_t bits = 0; // The bits we convert the sample into, MSB to go on the wire first - + for (int i = 32; i > 0; i--) { bits = bits << 1; if (cumErr < 0) { @@ -95,9 +95,13 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2]) // Either send complete pulse stream or nothing #ifdef ESP32 - if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0)) + +// Deprecated. Use i2s_write +// if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0)) + size_t bytes_written; + if (ESP_OK != i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &bytes_written, 0)) return false; -#else +#else if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn // At this point we've sent in first of possibly 8 32-bits, need to send // remaining ones even if they block. diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp index 0288f33df..65ceed801 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp @@ -15,7 +15,7 @@ */ // #include "Arduino.h" -#include "lwip/apps/sntp.h" +//#include "lwip/apps/sntp.h" #include // See libraries\ESP32\examples\ResetReason.ino