More ESP32 compatibility

This commit is contained in:
Theo Arends 2020-04-16 18:33:26 +02:00
parent 538dfbef2e
commit 367658b75b
6 changed files with 46 additions and 25 deletions

View File

@ -20,18 +20,44 @@
#include <rom/rtc.h>
#include <ESP8266WiFi.h>
#include "esp8266toEsp32.h"
// ESP Stuff
struct rst_info resetInfo;
String ESP32GetResetReason(uint32_t cpu_no)
{
// tools\sdk\include\esp32\rom\rtc.h
switch (rtc_get_reset_reason( (RESET_REASON) cpu_no)) {
case POWERON_RESET : return F("Vbat power on reset"); // 1
case SW_RESET : return F("Software reset digital core"); // 3
case OWDT_RESET : return F("Legacy watch dog reset digital core"); // 4
case DEEPSLEEP_RESET : return F("Deep Sleep reset digital core"); // 5
case SDIO_RESET : return F("Reset by SLC module, reset digital core"); // 6
case TG0WDT_SYS_RESET : return F("Timer Group0 Watch dog reset digital core"); // 7
case TG1WDT_SYS_RESET : return F("Timer Group1 Watch dog reset digital core"); // 8
case RTCWDT_SYS_RESET : return F("RTC Watch dog Reset digital core"); // 9
case INTRUSION_RESET : return F("Instrusion tested to reset CPU"); // 10
case TGWDT_CPU_RESET : return F("Time Group reset CPU"); // 11
case SW_CPU_RESET : return F("Software reset CPU"); // 12
case RTCWDT_CPU_RESET : return F("RTC Watch dog Reset CPU"); // 13
case EXT_CPU_RESET : return F("or APP CPU, reseted by PRO CPU"); // 14
case RTCWDT_BROWN_OUT_RESET : return F("Reset when the vdd voltage is not stable"); // 15
case RTCWDT_RTC_RESET : return F("RTC Watch dog reset digital core and rtc module"); // 16
default : return F("NO_MEAN"); // 0
}
}
String ESP_getResetReason(void)
{
// CPU 0
return String(rtc_get_reset_reason(0));
return ESP32GetResetReason(0); // CPU 0
}
String ESP_getResetInfo(void)
uint32_t ESP_ResetInfoReason(void)
{
return String(PSTR("0"));
RESET_REASON reason = rtc_get_reset_reason(0);
if (POWERON_RESET == reason) { return REASON_DEFAULT_RST; }
if (SW_CPU_RESET == reason) { return REASON_SOFT_RESTART; }
if (DEEPSLEEP_RESET == reason) { return REASON_DEEP_SLEEP_AWAKE; }
if (SW_RESET == reason) { return REASON_EXT_SYS_RST; }
}
uint32_t ESP_getBootVersion(void)
@ -74,11 +100,6 @@ String String_ESP_getChipId()
return String(uint32_t(mac >> 32)) + String(uint32_t(mac));
}
uint32_t ESP_getFlashChipRealSize()
{
return ESP.getFlashChipSize();
}
uint32_t ESP_getSketchSize(void)
{
static uint32_t sketchsize = 0;

View File

@ -34,15 +34,14 @@
#define ESP_flashReadHeader(offset, data, size) ESP32_flashRead(offset, data, size)
#define ESP_flashRead(offset, data, size) ESP32_flashRead(offset, data, size)
String ESP_getResetReason(void);
uint32_t ESP_ResetInfoReason(void);
uint32_t ESP_getBootVersion(void);
bool ESP_rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);
bool ESP_rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
void ESP_reset();
String ESP_getResetInfo(void);
uint32_t ESP_getFlashChipId();
uint32_t ESP_getChipId();
String String_ESP_getChipId();
uint32_t ESP_getFlashChipRealSize();
uint32_t ESP_getSketchSize();
// Analog
@ -67,7 +66,6 @@ typedef double real64_t;
#define ETS_UART_INTR_DISABLE()
#define ETS_UART_INTR_ENABLE()
#define getChipId() getEfuseMac()
#define ESPhttpUpdate httpUpdate
#define getFlashChipRealSize() getFlashChipSize()
@ -92,14 +90,13 @@ typedef int SerialConfig;
#undef LWIP_IPV6
struct rst_info
{
int reason;
};
#define REASON_DEFAULT_RST 1
#define REASON_EXT_SYS_RST 2
#define REASON_DEEP_SLEEP_AWAKE 3
#define REASON_DEFAULT_RST 0 // "Power on" normal startup by power on
#define REASON_WDT_RST 1 // "Hardware Watchdog" hardware watch dog reset
#define REASON_EXCEPTION_RST 2 // "Exception" exception reset, GPIO status wont change
#define REASON_SOFT_WDT_RST 3 // "Software Watchdog" software watch dog reset, GPIO status wont change
#define REASON_SOFT_RESTART 4 // "Software/System restart" software restart ,system_restart , GPIO status wont change
#define REASON_DEEP_SLEEP_AWAKE 5 // "Deep-Sleep Wake" wake up from deep-sleep
#define REASON_EXT_SYS_RST 6 // "External System" external system reset
// memmove ...
#define memcpy_P memcpy

View File

@ -99,7 +99,11 @@ uint32_t ResetReason(void)
REASON_DEEP_SLEEP_AWAKE = 5, // "Deep-Sleep Wake" wake up from deep-sleep
REASON_EXT_SYS_RST = 6 // "External System" external system reset
*/
return resetInfo.reason;
#ifdef ESP8266
return resetInfo.reason; // Returns Tasmota reason codes
#else
return ESP_ResetInfoReason();
#endif
}
String GetResetReason(void)

View File

@ -448,7 +448,7 @@ void CmndStatus(void)
D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHCHIPID "\":\"%06X\",\"" D_JSON_FLASHMODE "\":%d,\""
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"),
ESP_getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024,
ESP.getFlashChipSize()/1024, ESP_getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(),
ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP_getFlashChipId(), ESP.getFlashChipMode(),
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, feature6);
XsnsDriverState();
ResponseAppend_P(PSTR(",\"Sensors\":"));

View File

@ -17,7 +17,6 @@
#define ESP_reset() ESP.reset()
#define ESP_getBootVersion() ESP.getBootVersion()
#define ESP_getFlashChipId() ESP.getFlashChipId()
#define ESP_getFlashChipRealSize() ESP.getFlashChipRealSize()
#define ESP_getSketchSize() ESP.getSketchSize()
#define ESP_getChipId() ESP.getChipId()
//

View File

@ -2213,7 +2213,7 @@ void HandleInformation(void)
WSContentSend_P(PSTR("}1}2&nbsp;")); // Empty line
WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP_getChipId());
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_ID "}20x%06X"), ESP_getFlashChipId());
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP_getFlashChipRealSize() / 1024);
WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%dkB"), ESP.getFlashChipRealSize() / 1024);
WSContentSend_P(PSTR("}1" D_PROGRAM_FLASH_SIZE "}2%dkB"), ESP.getFlashChipSize() / 1024);
WSContentSend_P(PSTR("}1" D_PROGRAM_SIZE "}2%dkB"), ESP_getSketchSize() / 1024);
WSContentSend_P(PSTR("}1" D_FREE_PROGRAM_SPACE "}2%dkB"), ESP.getFreeSketchSpace() / 1024);