Prep ESP32S2

This commit is contained in:
Theo Arends 2021-02-03 12:22:17 +01:00
parent 54486eac56
commit cd38179f7f
5 changed files with 63 additions and 22 deletions

View File

@ -187,6 +187,7 @@ void directModeInput(IO_REG_TYPE pin)
{ {
if ( digitalPinIsValid(pin) ) if ( digitalPinIsValid(pin) )
{ {
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
uint32_t rtc_reg(rtc_gpio_desc[pin].reg); uint32_t rtc_reg(rtc_gpio_desc[pin].reg);
if ( rtc_reg ) // RTC pins PULL settings if ( rtc_reg ) // RTC pins PULL settings
@ -194,6 +195,15 @@ void directModeInput(IO_REG_TYPE pin)
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].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown); ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown);
} }
#elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
uint32_t rtc_reg(rtc_io_desc[pin].reg);
if ( rtc_reg ) // RTC pins PULL settings
{
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_io_desc[pin].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_io_desc[pin].pullup | rtc_io_desc[pin].pulldown);
}
#endif
if ( pin < 32 ) if ( pin < 32 )
GPIO.enable_w1tc = ((uint32_t)1 << pin); GPIO.enable_w1tc = ((uint32_t)1 << pin);
@ -215,6 +225,7 @@ void directModeOutput(IO_REG_TYPE pin)
{ {
if ( digitalPinIsValid(pin) && pin <= 33 ) // pins above 33 can be only inputs if ( digitalPinIsValid(pin) && pin <= 33 ) // pins above 33 can be only inputs
{ {
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
uint32_t rtc_reg(rtc_gpio_desc[pin].reg); uint32_t rtc_reg(rtc_gpio_desc[pin].reg);
if ( rtc_reg ) // RTC pins PULL settings if ( rtc_reg ) // RTC pins PULL settings
@ -222,6 +233,15 @@ void directModeOutput(IO_REG_TYPE pin)
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].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown); ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].pullup | rtc_gpio_desc[pin].pulldown);
} }
#elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
uint32_t rtc_reg(rtc_io_desc[pin].reg);
if ( rtc_reg ) // RTC pins PULL settings
{
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_io_desc[pin].mux);
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_io_desc[pin].pullup | rtc_io_desc[pin].pulldown);
}
#endif
if ( pin < 32 ) if ( pin < 32 )
GPIO.enable_w1ts = ((uint32_t)1 << pin); GPIO.enable_w1ts = ((uint32_t)1 << pin);

View File

@ -18,11 +18,17 @@
#include "lwip/apps/sntp.h" #include "lwip/apps/sntp.h"
#include <nvs.h> #include <nvs.h>
#if CONFIG_IDF_TARGET_ESP32 // See libraries\ESP32\examples\ResetReason.ino
#include <rom/rtc.h> #if ESP_IDF_VERSION_MAJOR > 3 // IDF 4+
//#include "esp32/rom/rtc.h" #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#elif CONFIG_IDF_TARGET_ESP32S2 #include "esp32/rom/rtc.h"
#include "esp32s2/rom/rtc.h" #elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
#include "esp32s2/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif #endif
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>

View File

@ -103,11 +103,17 @@ void *special_malloc(uint32_t size) {
#include <nvs.h> #include <nvs.h>
#if CONFIG_IDF_TARGET_ESP32 // See libraries\ESP32\examples\ResetReason.ino
#include <rom/rtc.h> #if ESP_IDF_VERSION_MAJOR > 3 // IDF 4+
//#include "esp32/rom/rtc.h" #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#elif CONFIG_IDF_TARGET_ESP32S2 #include "esp32/rom/rtc.h"
#include "esp32s2/rom/rtc.h" #elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
#include "esp32s2/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif #endif
#include <esp_phy_init.h> #include <esp_phy_init.h>
@ -211,15 +217,8 @@ void NvsInfo(void) {
// Flash memory mapping // Flash memory mapping
// //
// See Esp.cpp
#include "Esp.h" #include "Esp.h"
#if CONFIG_IDF_TARGET_ESP32
#include "rom/spi_flash.h"
//#include "esp32/rom/spi_flash.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/spi_flash.h"
#endif
#include "esp_spi_flash.h" #include "esp_spi_flash.h"
#include <memory> #include <memory>
#include <soc/soc.h> #include <soc/soc.h>
@ -229,6 +228,18 @@ extern "C" {
#include "esp_ota_ops.h" #include "esp_ota_ops.h"
#include "esp_image_format.h" #include "esp_image_format.h"
} }
#include "esp_system.h"
#if ESP_IDF_VERSION_MAJOR > 3 // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/spi_flash.h"
#elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2
#include "esp32s2/rom/spi_flash.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/spi_flash.h"
#endif
uint32_t EspFlashBaseAddress(void) { uint32_t EspFlashBaseAddress(void) {
const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr); const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr);

View File

@ -465,7 +465,8 @@ void StartWebserver(int type, IPAddress ipweb)
WebServer_on(uri, line.handler, pgm_read_byte(&line.method)); WebServer_on(uri, line.handler, pgm_read_byte(&line.method));
} }
Webserver->onNotFound(HandleNotFound); Webserver->onNotFound(HandleNotFound);
Webserver->on(F("/u2"), HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call // Webserver->on(F("/u2"), HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
Webserver->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
#ifndef FIRMWARE_MINIMAL #ifndef FIRMWARE_MINIMAL
XdrvCall(FUNC_WEB_ADD_HANDLER); XdrvCall(FUNC_WEB_ADD_HANDLER);
XsnsCall(FUNC_WEB_ADD_HANDLER); XsnsCall(FUNC_WEB_ADD_HANDLER);

View File

@ -762,9 +762,12 @@ bool Xdrv50(uint8_t function) {
} }
break; break;
case FUNC_WEB_ADD_HANDLER: case FUNC_WEB_ADD_HANDLER:
Webserver->on(F("/ufsd"), UfsDirectory); // Webserver->on(F("/ufsd"), UfsDirectory);
Webserver->on(F("/ufsu"), HTTP_GET, UfsDirectory); // Webserver->on(F("/ufsu"), HTTP_GET, UfsDirectory);
Webserver->on(F("/ufsu"), HTTP_POST,[](){Webserver->sendHeader(F("Location"),F("/ufsu"));Webserver->send(303);}, HandleUploadLoop); // Webserver->on(F("/ufsu"), HTTP_POST,[](){Webserver->sendHeader(F("Location"),F("/ufsu"));Webserver->send(303);}, HandleUploadLoop);
Webserver->on("/ufsd", UfsDirectory);
Webserver->on("/ufsu", HTTP_GET, UfsDirectory);
Webserver->on("/ufsu", HTTP_POST,[](){Webserver->sendHeader(F("Location"),F("/ufsu"));Webserver->send(303);}, HandleUploadLoop);
break; break;
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
} }