diff --git a/DCCTimerESP.cpp b/DCCTimerESP.cpp index 7ed3f28..e18cc8b 100644 --- a/DCCTimerESP.cpp +++ b/DCCTimerESP.cpp @@ -83,16 +83,34 @@ int DCCTimer::freeMemory() { #include #undef ADC_INPUT_MAX_VALUE #define ADC_INPUT_MAX_VALUE 4095 // 12 bit ADC +#if defined(ARDUINO_ESP32_DEV) #define pinToADC1Channel(X) (adc1_channel_t)(((X) > 35) ? (X)-36 : (X)-28) +#elif defined(ARDUINO_ESP32S3_DEV) +#define pinToADC1Channel(X) (adc1_channel_t)(((X) < 11) ? (X)-2 : (X)-11) +#else +#warning This ESP32 variant is not supported! +#endif int IRAM_ATTR local_adc1_get_raw(int channel) { uint16_t adc_value; +#if defined(ARDUINO_ESP32_DEV) SENS.sar_meas_start1.sar1_en_pad = (1 << channel); // only one channel is selected while (SENS.sar_slave_addr1.meas_status != 0); SENS.sar_meas_start1.meas1_start_sar = 0; SENS.sar_meas_start1.meas1_start_sar = 1; while (SENS.sar_meas_start1.meas1_done_sar == 0); adc_value = SENS.sar_meas_start1.meas1_data_sar; +#elif defined(ARDUINO_ESP32S3_DEV) + // Between variants... Espressif decides to rename things... sigh + SENS.sar_meas1_ctrl2.sar1_en_pad = (1 << channel); // only one channel is selected + while (SENS.sar_slave_addr1.meas_status != 0); + SENS.sar_meas1_ctrl2.meas1_start_sar = 0; + SENS.sar_meas1_ctrl2.meas1_start_sar = 1; + while (SENS.sar_meas1_ctrl2.meas1_done_sar == 0); + adc_value = SENS.sar_meas1_ctrl2.meas1_data_sar; +#else +#warning This ESP32 variant is not supported! +#endif return adc_value; } diff --git a/WifiESP32.cpp b/WifiESP32.cpp index 28a15fe..b2dfd12 100644 --- a/WifiESP32.cpp +++ b/WifiESP32.cpp @@ -38,6 +38,7 @@ #include "soc/timer_group_struct.h" #include "soc/timer_group_reg.h" void feedTheDog0(){ +#if defined(ARDUINO_ESP32_DEV) // feed dog 0 TIMERG0.wdt_wprotect=TIMG_WDT_WKEY_VALUE; // write enable TIMERG0.wdt_feed=1; // feed dog @@ -46,6 +47,13 @@ void feedTheDog0(){ //TIMERG1.wdt_wprotect=TIMG_WDT_WKEY_VALUE; // write enable //TIMERG1.wdt_feed=1; // feed dog //TIMERG1.wdt_wprotect=0; // write protect +#elif defined(ARDUINO_ESP32S3_DEV) + TIMERG0.wdtwprotect.wdt_wkey = TIMG_WDT_WKEY_V; // write enable + TIMERG0.wdtfeed.wdt_feed = 1; // feed dog + TIMERG0.wdtwprotect.wdt_wkey = 0; // write protect +#else +#warning This ESP32 variant not supported +#endif } /* diff --git a/WifiESP32.h b/WifiESP32.h index ec2f560..1921494 100644 --- a/WifiESP32.h +++ b/WifiESP32.h @@ -37,5 +37,5 @@ public: static void loop(); private: }; -#endif //WifiESP8266_h -#endif //ESP8266 +#endif // include guard +#endif // ARDUINO_ARCH_ESP32 diff --git a/defines.h b/defines.h index e90d7f4..2226b44 100644 --- a/defines.h +++ b/defines.h @@ -125,9 +125,15 @@ #define ARDUINO_TYPE "ESP8266" #warning "ESP8266 platform untested, you are on your own" #elif defined(ARDUINO_ARCH_ESP32) - #define ARDUINO_TYPE "ESP32" #ifndef DISABLE_EEPROM #define DISABLE_EEPROM +#if defined(ARDUINO_ESP32_DEV) + #define ARDUINO_TYPE "ESP32-WROOM" +#elif defined (ARDUINO_ESP32S3_DEV) + #define ARDUINO_TYPE "ESP32-S3" +// #undef USB_SERIAL +// #define USB_SERIAL SerialUSB +#endif #endif #elif defined(ARDUINO_ARCH_SAMD) #define ARDUINO_TYPE "SAMD21" diff --git a/platformio.ini b/platformio.ini index 8767ef1..b6a5db0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,7 +30,6 @@ include_dir = . [env] build_flags = -Wall -Wextra -; monitor_filters = time [env:samd21-dev-usb] platform = atmelsam @@ -193,9 +192,6 @@ build_flags = -std=c++17 -Os -g2 -Wunused-variable monitor_speed = 115200 monitor_echo = yes -; Experimental - no reason this should not work, but not -; tested as yet -; [env:Nucleo-F401RE] platform = ststm32 board = nucleo_f401re @@ -205,59 +201,6 @@ build_flags = -std=c++17 -Os -g2 -Wunused-variable monitor_speed = 115200 monitor_echo = yes -; Commented out by default as the F13ZH has variant files -; but NOT the nucleo_f413zh.json file which needs to be -; installed before you can let PlatformIO see this -; -; [env:Nucleo-F413ZH] -; platform = ststm32 -; board = nucleo_f413zh -; framework = arduino -; lib_deps = ${env.lib_deps} -; build_flags = -std=c++17 -Os -g2 -Wunused-variable -; monitor_speed = 115200 -; monitor_echo = yes - -; Commented out by default as the F446ZE needs variant files -; installed before you can let PlatformIO see this -; -; [env:Nucleo-F446ZE] -; platform = ststm32 -; board = nucleo_f446ze -; framework = arduino -; lib_deps = ${env.lib_deps} -; build_flags = -std=c++17 -Os -g2 -Wunused-variable -; monitor_speed = 115200 -; monitor_echo = yes - -; Commented out by default as the F412ZG needs variant files -; installed before you can let PlatformIO see this -; -; [env:Nucleo-F412ZG] -; platform = ststm32 -; board = blah_f412zg -; framework = arduino -; lib_deps = ${env.lib_deps} -; build_flags = -std=c++17 -Os -g2 -Wunused-variable -; monitor_speed = 115200 -; monitor_echo = yes -; upload_protocol = stlink - -; Experimental - Ethernet work still in progress -; -; [env:Nucleo-F429ZI] -; platform = ststm32 -; board = nucleo_f429zi -; framework = arduino -; lib_deps = ${env.lib_deps} -; arduino-libraries/Ethernet @ ^2.0.1 -; stm32duino/STM32Ethernet @ ^1.3.0 -; stm32duino/STM32duino LwIP @ ^2.1.2 -; build_flags = -std=c++17 -Os -g2 -Wunused-variable -; monitor_speed = 115200 -; monitor_echo = yes -; upload_protocol = stlink - [env:Teensy3_2] platform = teensy board = teensy31 @@ -296,4 +239,18 @@ board = teensy41 framework = arduino build_flags = -std=c++17 -Os -g2 lib_deps = ${env.lib_deps} -lib_ignore = +lib_ignore = + +[env:ESP32_S3] +platform = espressif32 +board = esp32-s3-devkitc-1 +framework = arduino +board_upload.flash_size = 8MB +board_build.partitions = default_8MB.csv +build_flags = + -std=c++17 + -DARDUINO_USB_CDC_ON_BOOT=1 +board_build.arduino.memory_type = opi_opi +lib_deps = ${env.lib_deps} +monitor_speed = 115200 +monitor_echo = yes diff --git a/version.h b/version.h index 5640feb..4a5765e 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.2.1" +#define VERSION "5.2.2" +// 5.2.2 - ESP32-S3 initial code support, WDT, ADCee(), but note RMT not tested! // 5.2.1 - Trackmanager rework for simpler structure // 5.2.0 - ESP32: Autoreverse and booster mode support // 5.1.21 - EXRAIL invoke multiple ON handlers for same event