mirror of https://github.com/arendst/Tasmota.git
Remove non IDF5 code
This commit is contained in:
parent
1d7f3e8f07
commit
ac06195907
|
@ -189,9 +189,9 @@ bool RtcRebootValid(void) {
|
|||
|
||||
extern "C" {
|
||||
#include "spi_flash.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include "spi_flash_mmap.h"
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#include "spi_flash_mmap.h"
|
||||
#endif // ESP32
|
||||
}
|
||||
|
||||
#ifdef ESP8266
|
||||
|
|
|
@ -27,14 +27,10 @@ bool I2cBegin(int sda, int scl, uint32_t frequency) {
|
|||
Wire.begin(sda, scl);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#if ESP_IDF_VERSION_MAJOR > 3 // Core 2.x uses a different I2C library
|
||||
static bool reinit = false;
|
||||
if (reinit) { Wire.end(); }
|
||||
#endif // ESP_IDF_VERSION_MAJOR > 3
|
||||
result = Wire.begin(sda, scl, frequency);
|
||||
#if ESP_IDF_VERSION_MAJOR > 3 // Core 2.x uses a different I2C library
|
||||
reinit = result;
|
||||
#endif // ESP_IDF_VERSION_MAJOR > 3
|
||||
#endif
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("I2C: Bus1 %d"), result);
|
||||
return result;
|
||||
|
|
|
@ -2674,11 +2674,9 @@ void CmndWifi(void) {
|
|||
break;
|
||||
}
|
||||
#ifdef ESP32
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
case 6: // Wifi 6 = BGNAX
|
||||
option = 4;
|
||||
#endif // ESP_IDF_VERSION_MAJOR
|
||||
#endif // ESP32/ESP8266
|
||||
#endif // ESP32
|
||||
case 4: // Wifi 4 = BGN
|
||||
case 3: // Wifi 3 = BG
|
||||
case 2: // Wifi 2 = B
|
||||
|
|
|
@ -162,14 +162,8 @@ void CrashDumpClear(void)
|
|||
// esp_err_t IRAM_ATTR esp_backtrace_print(int depth)
|
||||
|
||||
#include "freertos/xtensa_api.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_cpu_utils.h"
|
||||
#elif ESP_IDF_VERSION_MAJOR >= 4
|
||||
#include "esp_debug_helpers.h"
|
||||
#else // IDF 3.x
|
||||
#include "esp_panic.h"
|
||||
#endif
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_cpu_utils.h"
|
||||
extern "C" {
|
||||
// esp-idf 3.x
|
||||
void __real_panicHandler(XtExcFrame *frame);
|
||||
|
|
|
@ -577,12 +577,8 @@ uint32_t ESP_getMaxAllocPsram(void) {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
// bool IRAM_ATTR __attribute__((pure)) esp_psram_is_initialized(void)
|
||||
bool esp_psram_is_initialized(void);
|
||||
#else
|
||||
bool esp_spiram_is_initialized(void);
|
||||
#endif
|
||||
// bool IRAM_ATTR __attribute__((pure)) esp_psram_is_initialized(void)
|
||||
bool esp_psram_is_initialized(void);
|
||||
}
|
||||
|
||||
// this function is a replacement for `psramFound()`.
|
||||
|
@ -748,11 +744,7 @@ typedef struct {
|
|||
bool rev3 = (chip_revision >= 300);
|
||||
// bool single_core = (1 == ESP.getChipCores());
|
||||
bool single_core = (1 == chip_info.cores);
|
||||
|
||||
uint32_t pkg_version = 0;
|
||||
#if (ESP_IDF_VERSION_MAJOR >= 5)
|
||||
pkg_version = bootloader_common_get_chip_ver_pkg();
|
||||
#endif
|
||||
uint32_t pkg_version = bootloader_common_get_chip_ver_pkg();
|
||||
|
||||
switch (chip_model) {
|
||||
case 0:
|
||||
|
@ -931,11 +923,7 @@ String GetDeviceHardwareRevision(void) {
|
|||
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
uint32_t chip_revision = chip_info.revision; // 16-bit chip revision number (in format MXX; where M - wafer major version, XX - wafer minor version)
|
||||
#else
|
||||
uint32_t chip_revision = chip_info.full_revision; // 16-bit chip revision number (in format MXX; where M - wafer major version, XX - wafer minor version)
|
||||
#endif
|
||||
char revision[16];
|
||||
snprintf_P(revision, sizeof(revision), PSTR(" v%d.%d"), chip_revision / 100, chip_revision % 100);
|
||||
result += revision; // ESP32-C3 v0.3
|
||||
|
|
|
@ -42,9 +42,9 @@ const uint8_t WIFI_RETRY_OFFSET_SEC = WIFI_RETRY_SECONDS; // seconds
|
|||
|
||||
#include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager
|
||||
#include "lwip/dns.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#ifdef ESP32
|
||||
#include "esp_netif.h"
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
int WifiGetRssiAsQuality(int rssi) {
|
||||
int quality = 0;
|
||||
|
|
|
@ -31,16 +31,16 @@ struct MY92X1 {
|
|||
uint8_t model = 0;
|
||||
} My92x1;
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#ifdef ESP32
|
||||
#include "rom/ets_sys.h"
|
||||
#ifndef os_delay_us
|
||||
#define os_delay_us ets_delay_us
|
||||
#endif //os_delay_us
|
||||
#else
|
||||
#else // ESP8266
|
||||
extern "C" {
|
||||
void os_delay_us(unsigned int);
|
||||
}
|
||||
#endif
|
||||
#endif // ESP8266
|
||||
|
||||
void LightDiPulse(uint8_t times)
|
||||
{
|
||||
|
|
|
@ -27,9 +27,7 @@
|
|||
#define XSNS_02 2
|
||||
|
||||
#ifdef ESP32
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include "esp32-hal-adc.h"
|
||||
#endif
|
||||
#include "esp32-hal-adc.h"
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
|
@ -179,16 +177,13 @@ struct {
|
|||
int indexOfPointer = -1;
|
||||
} Adc[MAX_ADCS];
|
||||
|
||||
#ifdef ESP8266
|
||||
bool adcAttachPin(uint8_t pin) {
|
||||
#ifdef ESP8266
|
||||
return (ADC0_PIN == pin);
|
||||
#else // ESP32
|
||||
return true;
|
||||
#endif // ESP32
|
||||
}
|
||||
#endif
|
||||
#if defined(ESP32) && (ESP_IDF_VERSION_MAJOR >= 5)
|
||||
bool adcAttachPin(uint8_t pin) {
|
||||
return true; // TODO - no more needed?
|
||||
}
|
||||
#endif
|
||||
|
||||
void AdcSaveSettings(uint32_t idx) {
|
||||
char parameters[32];
|
||||
|
@ -310,9 +305,6 @@ void AdcInit(void) {
|
|||
|
||||
if (Adcs.present) {
|
||||
#ifdef ESP32
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
analogSetClockDiv(1); // Default 1
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
xsns_127_esp32_sensors.ino - ESP32 Temperature and Hall Effect sensor for Tasmota
|
||||
xsns_127_esp32_sensors.ino - ESP32 Temperature sensor for Tasmota
|
||||
|
||||
Copyright (C) 2021 Theo Arends
|
||||
|
||||
|
@ -20,39 +20,14 @@
|
|||
#ifdef ESP32
|
||||
#ifdef USE_ESP32_SENSORS
|
||||
/*********************************************************************************************\
|
||||
* ESP32 CPU Temperature and optional Hall Effect sensor
|
||||
* ESP32 CPU Temperature sensor
|
||||
*
|
||||
* To allow for not updating the global temperature by the ESP32 temperature sensor this
|
||||
* driver needs to be the highest numbered driver (currently 127)
|
||||
*
|
||||
* ESP32 internal Hall Effect sensor connected to both GPIO36 and GPIO39
|
||||
* To enable set
|
||||
* GPIO36 as HallEffect 1
|
||||
* GPIO39 as HallEffect 2
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XSNS_127 127
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
|
||||
|
||||
#define HALLEFFECT_SAMPLE_COUNT 32 // 32 takes about 12 mS at 80MHz CPU frequency
|
||||
|
||||
struct {
|
||||
bool present = false;
|
||||
} HEData;
|
||||
|
||||
void Esp32SensorInit(void) {
|
||||
if (PinUsed(GPIO_HALLEFFECT) && PinUsed(GPIO_HALLEFFECT, 1)) {
|
||||
if (((36 == Pin(GPIO_HALLEFFECT)) && (39 == Pin(GPIO_HALLEFFECT, 1))) ||
|
||||
((39 == Pin(GPIO_HALLEFFECT)) && (36 == Pin(GPIO_HALLEFFECT, 1)))) {
|
||||
HEData.present = true;
|
||||
hallRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
|
||||
|
||||
void Esp32SensorShow(bool json) {
|
||||
bool json_end = false;
|
||||
|
||||
|
@ -84,39 +59,6 @@ void Esp32SensorShow(bool json) {
|
|||
}
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
|
||||
if (HEData.present) {
|
||||
int value = 0;
|
||||
for (uint32_t i = 0; i < HALLEFFECT_SAMPLE_COUNT; i++) {
|
||||
value += hallRead();
|
||||
}
|
||||
value /= HALLEFFECT_SAMPLE_COUNT;
|
||||
|
||||
if (json) {
|
||||
if (!json_end) {
|
||||
ResponseAppend_P(PSTR(",\"ESP32\":{"));
|
||||
} else {
|
||||
ResponseAppend_P(PSTR(","));
|
||||
}
|
||||
ResponseAppend_P(PSTR("\"" D_JSON_HALLEFFECT "\":%d"), value);
|
||||
json_end = true;
|
||||
|
||||
#ifdef USE_DOMOTICZ
|
||||
// Instead of below code use a rule like 'on tele-esp32#halleffect do dzsend1 9988,%value% endon'
|
||||
// where 9988 is the domoticz sensor Idx
|
||||
// if (0 == TasmotaGlobal.tele_period) {
|
||||
// DomoticzSensor(DZ_COUNT, value);
|
||||
// }
|
||||
#endif // USE_DOMOTICZ
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_P(HTTP_SNS_HALL_EFFECT, "ESP32", value);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
|
||||
|
||||
if (json_end) {
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
|
@ -138,11 +80,6 @@ bool Xsns127(uint32_t function) {
|
|||
Esp32SensorShow(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
#if CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5) // Hall sensor is no more supported in esp-idf 5
|
||||
case FUNC_INIT:
|
||||
Esp32SensorInit();
|
||||
break;
|
||||
#endif // CONFIG_IDF_TARGET_ESP32 && (ESP_IDF_VERSION_MAJOR < 5)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -152,9 +152,9 @@ void ChirpResetAll(void) {
|
|||
/********************************************************************************************/
|
||||
|
||||
void ChirpClockSet() { // set I2C for this slow sensor
|
||||
#if ESP_IDF_VERSION_MAJOR < 5 // setClockStretchLimit was removed
|
||||
#ifdef ESP8266
|
||||
Wire.setClockStretchLimit(4000);
|
||||
#endif
|
||||
#endif // ESP8266
|
||||
Wire.setClock(50000);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue