Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Nov 16, 2023
1 parent cfd4f2b commit 610143a
Show file tree
Hide file tree
Showing 26 changed files with 345 additions and 203 deletions.
2 changes: 1 addition & 1 deletion lib/default/headers/esp-knx-ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/

#include "Arduino.h"
#include <EEPROM.h>
//#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ESP8266WebServer.h>
Expand Down
6 changes: 5 additions & 1 deletion lib/lib_audio/ESP8266Audio/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
"frameworks": "Arduino",
"examples": [
"examples/*/*.ino"
]
],
"build": {
"includeDir": ".",
"flags": [ "-Wno-stringop-overread" ]
}
}
4 changes: 2 additions & 2 deletions lib/lib_audio/ESP8266Audio/src/libflac/stream_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
if(rice_parameter < pesc) {
partitioned_rice_contents->raw_bits[partition] = 0;
u = (partition_order == 0 || partition > 0)? partition_samples : partition_samples - predictor_order;
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter))
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, (int*) residual + sample, u, rice_parameter))
return false; /* read_callback_ sets the state for us */
sample += u;
}
Expand All @@ -2792,7 +2792,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_
return false; /* read_callback_ sets the state for us */
partitioned_rice_contents->raw_bits[partition] = rice_parameter;
for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter))
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, (long int*) &i, rice_parameter))
return false; /* read_callback_ sets the state for us */
residual[sample] = i;
}
Expand Down
27 changes: 27 additions & 0 deletions lib/lib_audio/ESP8266Audio/tasmota_patches.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# below are the high-level patches made to the standard ESP8266audio libraries

# For Arduino 3 (gcc has a higher level of checks

libmad/layer3.c replace (line 1639)
void fastsdct(mad_fixed_t const x[9], mad_fixed_t y[18])
to
void fastsdct(mad_fixed_t const x[9], mad_fixed_t y[17])


libflac/stream_decoder.c
line 2786
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter))
to
if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, (int*) residual + sample, u, rice_parameter))

line 2795
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter))
to
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, (long int*) &i, rice_parameter))


l3loop.cpp
remove all 'register'

mult_noarch_gcc.h
remove all 'register'
35 changes: 33 additions & 2 deletions lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ extern "C" {
}
#endif // ESP8266
#include <Arduino.h>
#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
#include <driver/gpio.h>
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif
#endif // UNIT_TEST
#include <algorithm>
#ifdef UNIT_TEST
Expand Down Expand Up @@ -242,8 +247,13 @@ static void USE_IRAM_ATTR gpio_intr() {
// @see https://github.com/espressif/arduino-esp32/blob/6b0114366baf986c155e8173ab7c22bc0c5fcedc/cores/esp32/esp32-hal-timer.c#L176-L178
timer->dev->config.alarm_en = 1;
#else // _ESP32_IRRECV_TIMER_HACK
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
timerWrite(timer, 0);
timerStart(timer);
#else // ESP_ARDUINO_VERSION_MAJOR >= 3
timerWrite(timer, 0);
timerAlarmEnable(timer);
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif // _ESP32_IRRECV_TIMER_HACK
#endif // ESP32
}
Expand Down Expand Up @@ -334,7 +344,10 @@ IRrecv::IRrecv(const uint16_t recvpin, const uint16_t bufsize,
IRrecv::~IRrecv(void) {
disableIRIn();
#if defined(ESP32)
if (timer != NULL) timerEnd(timer); // Cleanup the ESP32 timeout timer.
if (timer != NULL) {
timerEnd(timer); // Cleanup the ESP32 timeout timer.
timer = NULL;
}
#endif // ESP32
delete[] params.rawbuf;
if (params_save != NULL) {
Expand All @@ -359,20 +372,29 @@ void IRrecv::enableIRIn(const bool pullup) {
#if defined(ESP32)
// Initialise the ESP32 timer.
// 80MHz / 80 = 1 uSec granularity.
timer = timerBegin(_timer_num, 80, true);
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
timer = timerBegin(1000000); // 1 MHz
#else // ESP_ARDUINO_VERSION_MAJOR >= 3
timer = timerBegin(_timer_num, 80, true); // 1 MHz : 80 MHz with divider 80
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
#ifdef DEBUG
if (timer == NULL) {
DPRINT("FATAL: Unable enable system timer: ");
DPRINTLN((uint16_t)_timer_num);
}
#endif // DEBUG
assert(timer != NULL); // Check we actually got the timer.
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
timerAttachInterrupt(timer, &read_timeout);
timerAlarm(timer, MS_TO_USEC(params.timeout), ONCE, 0);
#else // ESP_ARDUINO_VERSION_MAJOR >= 3
// Set the timer so it only fires once, and set it's trigger in uSeconds.
timerAlarmWrite(timer, MS_TO_USEC(params.timeout), ONCE);
// Note: Interrupt needs to be attached before it can be enabled or disabled.
// Note: EDGE (true) is not supported, use LEVEL (false). Ref: #1713
// See: https://github.com/espressif/arduino-esp32/blob/caef4006af491130136b219c1205bdcf8f08bf2b/cores/esp32/esp32-hal-timer.c#L224-L227
timerAttachInterrupt(timer, &read_timeout, false);
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif // ESP32

// Initialise state machine variables
Expand All @@ -398,9 +420,14 @@ void IRrecv::disableIRIn(void) {
os_timer_disarm(&timer);
#endif // ESP8266
#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
timerDetachInterrupt(timer);
timerEnd(timer);
#else // ESP_ARDUINO_VERSION_MAJOR >= 3
timerAlarmDisable(timer);
timerDetachInterrupt(timer);
timerEnd(timer);
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif // ESP32
detachInterrupt(params.recvpin);
#endif // UNIT_TEST
Expand All @@ -426,7 +453,11 @@ void IRrecv::resume(void) {
params.rawlen = 0;
params.overflow = false;
#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
timerStop(timer);
#else // ESP_ARDUINO_VERSION_MAJOR >= 3
timerAlarmDisable(timer);
#endif // ESP_ARDUINO_VERSION_MAJOR >= 3
gpio_intr_enable((gpio_num_t)params.recvpin);
#endif // ESP32
}
Expand Down
82 changes: 43 additions & 39 deletions lib/lib_basic/OneWire-Stickbreaker/OneWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,102 +159,106 @@
static inline __attribute__((always_inline))
IO_REG_TYPE directRead(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 // max. usable Pins are 23 for C6 (below flash pins)
// return digitalRead(pin); // Works most of the time
// return gpio_ll_get_level(&GPIO, pin); // The hal is not public api, don't use in application code

//#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#if SOC_GPIO_PIN_COUNT <= 32
return (GPIO.in.val >> pin) & 0x1;
#else // plain ESP32
#else // ESP32 with over 32 gpios
if ( pin < 32 )
return (GPIO.in >> pin) & 0x1;
else if ( pin < 46 )
else
return (GPIO.in1.val >> (pin - 32)) & 0x1;
#endif

return 0;

}

static inline __attribute__((always_inline))
void directWriteLow(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
// digitalWrite(pin, 0); // Works most of the time
// gpio_ll_set_level(&GPIO, pin, 0); // The hal is not public api, don't use in application code

//#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#if SOC_GPIO_PIN_COUNT <= 32
GPIO.out_w1tc.val = ((uint32_t)1 << pin);
#else // plain ESP32
#else // ESP32 with over 32 gpios
if ( pin < 32 )
GPIO.out_w1tc = ((uint32_t)1 << pin);
else if ( pin < 46 )
else
GPIO.out1_w1tc.val = ((uint32_t)1 << (pin - 32));
#endif
}

static inline __attribute__((always_inline))
void directWriteHigh(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
// digitalWrite(pin, 1); // Works most of the time
// gpio_ll_set_level(&GPIO, pin, 1); // The hal is not public api, don't use in application code

//#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#if SOC_GPIO_PIN_COUNT <= 32
GPIO.out_w1ts.val = ((uint32_t)1 << pin);
#else // plain ESP32
#else // ESP32 with over 32 gpios
if ( pin < 32 )
GPIO.out_w1ts = ((uint32_t)1 << pin);
else if ( pin < 46 )
else
GPIO.out1_w1ts.val = ((uint32_t)1 << (pin - 32));
#endif

}

static inline __attribute__((always_inline))
void directModeInput(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
#else
// pinMode(pin, INPUT); // Too slow - doesn't work
// gpio_ll_output_disable(&GPIO, pin); // The hal is not public api, don't use in application code

if ( digitalPinIsValid(pin) )
{
#if ESP_IDF_VERSION_MAJOR < 4 // IDF 3.x ESP32/PICO-D4
uint32_t rtc_reg(rtc_gpio_desc[pin].reg);

if ( rtc_reg ) // RTC pins PULL settings
{
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown);
}
#endif
// Input
//#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#if SOC_GPIO_PIN_COUNT <= 32
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
#else // ESP32 with over 32 gpios
if ( pin < 32 )
GPIO.enable_w1tc = ((uint32_t)1 << pin);
else
GPIO.enable1_w1tc.val = ((uint32_t)1 << (pin - 32));
}
#endif
}

}

static inline __attribute__((always_inline))
void directModeOutput(IO_REG_TYPE pin)
{
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
#else
if ( digitalPinIsValid(pin) && pin <= 33 ) // pins above 33 can be only inputs
// pinMode(pin, OUTPUT); // Too slow - doesn't work
// gpio_ll_output_enable(&GPIO, pin); // The hal is not public api, don't use in application code

if ( digitalPinCanOutput(pin) )
{
#if ESP_IDF_VERSION_MAJOR < 4 // IDF 3.x ESP32/PICO-D4
uint32_t rtc_reg(rtc_gpio_desc[pin].reg);

if ( rtc_reg ) // RTC pins PULL settings
{
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown);
}
#endif
// Output
//#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#if SOC_GPIO_PIN_COUNT <= 32
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
#else // ESP32 with over 32 gpios
if ( pin < 32 )
GPIO.enable_w1ts = ((uint32_t)1 << pin);
else // already validated to pins <= 33
else
GPIO.enable1_w1ts.val = ((uint32_t)1 << (pin - 32));
}
#endif
}

}

#define DIRECT_READ(base, pin) directRead(pin)
#define DIRECT_WRITE_LOW(base, pin) directWriteLow(pin)
#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(pin)
#define DIRECT_MODE_INPUT(base, pin) directModeInput(pin)
#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(pin)
//#warning "ESP32 OneWire testing"

#elif defined(__SAMD21G18A__)
#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin))
Expand Down
24 changes: 22 additions & 2 deletions lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
uint8_t *frame;
uint8_t framepointer = 0;

#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: @%02X f:%02X r:%04X c:%u &:%08X"), device_address, function_code, start_address, count, (uint32)write_data);
if (write_data) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: Write data 0x%04X"), write_data[0]);
#endif

uint16_t byte_count = count * 2; // In register mode count is nr of registers (2 bytes)
if ((function_code == 1) || (function_code == 2) || (function_code == 15)) byte_count = ((count-1) / 8) + 1; // In bitmode count is nr of bits

Expand All @@ -104,14 +109,20 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
}
else if ((function_code == 5) || (function_code == 6))
{
if (write_data == NULL)
if (write_data == nullptr)
{
free(frame);
#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: no data (13.1)"));
#endif
return 13; // Register data not specified
}
if (count != 1)
{
free(frame);
#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: wrong count (12.1)"));
#endif
return 12; // Wrong register count
}
frame[framepointer++] = (uint8_t)(write_data[0] >> 8); // MSB
Expand All @@ -124,14 +135,20 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1

frame[framepointer++] = byte_count;

if (write_data == NULL)
if (write_data == nullptr)
{
free(frame);
#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: no data (13.2)"));
#endif
return 13; // Register data not specified
}
if (count == 0)
{
free(frame);
#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: wrong count (12.2)"));
#endif
return 12; // Wrong register count
}
for (uint16_t bytepointer = 0; bytepointer < byte_count; bytepointer++)
Expand All @@ -142,6 +159,9 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
else
{
free(frame);
#ifdef TASMOTAMODBUSDEBUG
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: wrong fct (1)"));
#endif
return 1; // Wrong function code
}

Expand Down
1 change: 1 addition & 0 deletions lib/libesp32_audio/es7210/src/es7210.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <Wire.h>
#include <string.h>
#include "esp_log.h"
#include "rom/ets_sys.h"
#include "es7210.h"


Expand Down
3 changes: 2 additions & 1 deletion lib/libesp32_audio/es7243e/src/es7243e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include <freertos/FreeRTOS.h>
#include "string.h"
#include "esp_log.h"
#include "es7243e.h"
#include "rom/ets_sys.h"
#include "es7243e.h"


static const char *TAG = "DRV7243E";
Expand Down
1 change: 1 addition & 0 deletions lib/libesp32_audio/es8156/src/es8156.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <freertos/FreeRTOS.h>
#include "string.h"
#include "esp_log.h"
#include "rom/ets_sys.h"
#include "es8156.h"

/*
Expand Down
Loading

0 comments on commit 610143a

Please sign in to comment.