mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Сделал сборку для esp32s2 (Wemos S2 mini)
This commit is contained in:
@@ -27,6 +27,10 @@
|
|||||||
#define FIRMWARE_NAME "esp32_4mb"
|
#define FIRMWARE_NAME "esp32_4mb"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef esp32s2_4mb
|
||||||
|
#define FIRMWARE_NAME "esp32s2_4mb"
|
||||||
|
#endif
|
||||||
|
|
||||||
//Размер буфера json
|
//Размер буфера json
|
||||||
#define JSON_BUFFER_SIZE 2048 //держим 2 кб не меняем
|
#define JSON_BUFFER_SIZE 2048 //держим 2 кб не меняем
|
||||||
#define WEB_SOCKETS_FRAME_SIZE 2048
|
#define WEB_SOCKETS_FRAME_SIZE 2048
|
||||||
|
|||||||
@@ -174,6 +174,29 @@ build_src_filter =
|
|||||||
+<modules/*.cpp>
|
+<modules/*.cpp>
|
||||||
${env:esp32_4mb_fromitems.build_src_filter}
|
${env:esp32_4mb_fromitems.build_src_filter}
|
||||||
|
|
||||||
|
[env:esp32s2_4mb]
|
||||||
|
lib_deps =
|
||||||
|
${common_env_data.lib_deps_external}
|
||||||
|
${env:esp32s2_4mb_fromitems.lib_deps}
|
||||||
|
build_flags =
|
||||||
|
-Desp32s2_4mb="esp32s2_4mb"
|
||||||
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
-DARDUINO_USB_MODE=0
|
||||||
|
framework = arduino
|
||||||
|
board = lolin_s2_mini
|
||||||
|
platform = espressif32 @6.3.1
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
|
upload_speed = 921600
|
||||||
|
monitor_speed = 115200
|
||||||
|
debug_tool = esp-prog
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
build_src_filter =
|
||||||
|
+<*.cpp>
|
||||||
|
+<classes/*.cpp>
|
||||||
|
+<utils/*.cpp>
|
||||||
|
+<modules/*.cpp>
|
||||||
|
${env:esp32s2_4mb_fromitems.build_src_filter}
|
||||||
|
|
||||||
[env:esp8266_1mb_ota_fromitems]
|
[env:esp8266_1mb_ota_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BME280 Library
|
adafruit/Adafruit BME280 Library
|
||||||
@@ -471,3 +494,6 @@ build_src_filter =
|
|||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
+<modules/display/Lcd2004>
|
+<modules/display/Lcd2004>
|
||||||
|
|
||||||
|
[env:esp32s2_4mb_fromitems]
|
||||||
|
lib_deps =
|
||||||
|
build_src_filter =
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ uint32_t ESP_getChipId(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef esp32s2_4mb
|
||||||
uint32_t ESP_getFlashChipId(void) {
|
uint32_t ESP_getFlashChipId(void) {
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
// Нет аналогичной (без доп.кода) функций в 32
|
// Нет аналогичной (без доп.кода) функций в 32
|
||||||
@@ -85,6 +86,7 @@ uint32_t ESP_getFlashChipId(void) {
|
|||||||
return ESP.getFlashChipId();
|
return ESP.getFlashChipId();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const String getMacAddress() {
|
const String getMacAddress() {
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
|
|||||||
15
src/Main.cpp
15
src/Main.cpp
@@ -3,6 +3,9 @@
|
|||||||
#include "classes/IoTDB.h"
|
#include "classes/IoTDB.h"
|
||||||
#include "utils/Statistic.h"
|
#include "utils/Statistic.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#ifdef esp32s2_4mb
|
||||||
|
#include <USB.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
IoTScenario iotScen; // объект управления сценарием
|
IoTScenario iotScen; // объект управления сценарием
|
||||||
|
|
||||||
@@ -66,14 +69,14 @@ void IRAM_ATTR onTimer(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initErrorMarker(int id) {
|
void initErrorMarker(int id) {
|
||||||
#ifdef esp32_4mb
|
#ifdef esp32_4mb
|
||||||
initErrorMarkerId = id;
|
initErrorMarkerId = id;
|
||||||
errorMarkerCounter = 0;
|
errorMarkerCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopErrorMarker(int id) {
|
void stopErrorMarker(int id) {
|
||||||
#ifdef esp32_4mb
|
#ifdef esp32_4mb
|
||||||
errorMarkerCounter = -1;
|
errorMarkerCounter = -1;
|
||||||
if (errorMarkerId)
|
if (errorMarkerId)
|
||||||
SerialPrint("I", "WARNING!", "A lazy (freezing loop more than " + (String)(COUNTER_ERRORMARKER * STEPPER_ERRORMARKER / 1000) + " ms) section has been found! With ID=" + (String)errorMarkerId);
|
SerialPrint("I", "WARNING!", "A lazy (freezing loop more than " + (String)(COUNTER_ERRORMARKER * STEPPER_ERRORMARKER / 1000) + " ms) section has been found! With ID=" + (String)errorMarkerId);
|
||||||
@@ -85,8 +88,10 @@ void stopErrorMarker(int id) {
|
|||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
#ifdef esp32s2_4mb
|
||||||
#ifdef esp32_4mb
|
USB.begin();
|
||||||
|
#endif
|
||||||
|
#ifdef esp32_4mb
|
||||||
My_timer = timerBegin(0, 80, true);
|
My_timer = timerBegin(0, 80, true);
|
||||||
timerAttachInterrupt(My_timer, &onTimer, true);
|
timerAttachInterrupt(My_timer, &onTimer, true);
|
||||||
timerAlarmWrite(My_timer, STEPPER_ERRORMARKER, true);
|
timerAlarmWrite(My_timer, STEPPER_ERRORMARKER, true);
|
||||||
@@ -129,7 +134,7 @@ void setup() {
|
|||||||
jsonRead(settingsFlashJson, "i2cFreq", i2cFreq, false);
|
jsonRead(settingsFlashJson, "i2cFreq", i2cFreq, false);
|
||||||
jsonRead(settingsFlashJson, "i2c", i2c, false);
|
jsonRead(settingsFlashJson, "i2c", i2c, false);
|
||||||
if (i2c != 0) {
|
if (i2c != 0) {
|
||||||
#ifdef esp32_4mb
|
#ifdef ESP32
|
||||||
Wire.end();
|
Wire.end();
|
||||||
Wire.begin(pinSDA, pinSCL, (uint32_t)i2cFreq);
|
Wire.begin(pinSDA, pinSCL, (uint32_t)i2cFreq);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -58,7 +58,50 @@ void printGlobalVarSize() {
|
|||||||
String ESP_getResetReason(void) {
|
String ESP_getResetReason(void) {
|
||||||
return ESP.getResetReason();
|
return ESP.getResetReason();
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
#ifdef esp32s2_4mb
|
||||||
|
String ESP_getResetReason(void) {
|
||||||
|
return ESP32GetResetReason(0); // CPU 0
|
||||||
|
}
|
||||||
|
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 RTC_SW_SYS_RESET:
|
||||||
|
return F("Software reset digital core"); // 3
|
||||||
|
// case OWDT_RESET:
|
||||||
|
// return F("Legacy Watchdog 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 Watchdog reset digital core"); // 7
|
||||||
|
case TG1WDT_SYS_RESET:
|
||||||
|
return F("Timer Group1 Watchdog reset digital core"); // 8
|
||||||
|
case RTCWDT_SYS_RESET:
|
||||||
|
return F("RTC Watchdog Reset digital core"); // 9
|
||||||
|
case INTRUSION_RESET:
|
||||||
|
return F("Instrusion tested to reset CPU"); // 10
|
||||||
|
case TG0WDT_CPU_RESET:
|
||||||
|
return F("Time Group reset CPU"); // 11
|
||||||
|
case RTC_SW_CPU_RESET:
|
||||||
|
return F("Software reset CPU"); // 12
|
||||||
|
case RTCWDT_CPU_RESET:
|
||||||
|
return F("RTC Watchdog 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 Watchdog reset digital core and rtc module"); // 16
|
||||||
|
default:
|
||||||
|
return F("NO_MEAN"); // 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef esp32_4mb
|
||||||
String ESP_getResetReason(void) {
|
String ESP_getResetReason(void) {
|
||||||
return ESP32GetResetReason(0); // CPU 0
|
return ESP32GetResetReason(0); // CPU 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ bool upgradeBuild() {
|
|||||||
ESPhttpUpdate.rebootOnUpdate(false);
|
ESPhttpUpdate.rebootOnUpdate(false);
|
||||||
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, getBinPath("firmware.bin"));
|
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, getBinPath("firmware.bin"));
|
||||||
#endif
|
#endif
|
||||||
#ifdef esp32_4mb
|
#ifdef ESP32
|
||||||
httpUpdate.rebootOnUpdate(false);
|
httpUpdate.rebootOnUpdate(false);
|
||||||
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, getBinPath("firmware.bin"));
|
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, getBinPath("firmware.bin"));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -88,6 +88,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/adafruit/Adafruit_INA219.git"
|
"https://github.com/adafruit/Adafruit_INA219.git"
|
||||||
],
|
],
|
||||||
|
"esp32s2_4mb": [
|
||||||
|
"https://github.com/adafruit/Adafruit_INA219.git"
|
||||||
|
],
|
||||||
|
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/adafruit/Adafruit_INA219.git"
|
"https://github.com/adafruit/Adafruit_INA219.git"
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user