Skip to content

Commit 73275af

Browse files
committed
Core 3
1 parent b209e4a commit 73275af

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

src/BootstrapManager.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
5151
launchWebServerForOTAConfig();
5252
}
5353
#if defined(ARDUINO_ARCH_ESP32)
54-
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
54+
esp_task_wdt_config_t twdt_config = {
55+
.timeout_ms = 3000, // TODO 3000
56+
.trigger_panic = true,
57+
};
58+
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
5559
esp_task_wdt_add(NULL); //add current thread to WDT watch
5660
#endif
5761
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
@@ -110,7 +114,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
110114
#endif
111115
}
112116
#if defined(ARDUINO_ARCH_ESP32)
113-
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
117+
esp_task_wdt_config_t twdt_config = {
118+
.timeout_ms = 3000, // TODO 3000
119+
.trigger_panic = true,
120+
};
121+
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
114122
esp_task_wdt_add(NULL); //add current thread to WDT watch
115123
#endif
116124
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3

src/EthManager.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const ethernet_config ethernetDevices[] = {
2727
// No Ethernet
2828
{
2929
},
30+
#if CONFIG_IDF_TARGET_ESP32
3031
// QuinLed-ESP32-Ethernet
3132
{
32-
3333
0,
3434
5,
3535
23,
@@ -102,39 +102,51 @@ const ethernet_config ethernetDevices[] = {
102102
ETH_PHY_LAN8720,
103103
ETH_CLOCK_GPIO0_OUT
104104
}
105+
#endif
106+
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
107+
108+
#endif
109+
105110
};
106111

107112
/**
108113
* Connect to ethernet
109114
* @param deviceNumber to use
110115
*/
111116
void EthManager::connectToEthernet(int8_t deviceNumber) {
117+
#if CONFIG_IDF_TARGET_ESP32
112118
ETH.begin(
119+
ethernetDevices[deviceNumber].type,
113120
ethernetDevices[deviceNumber].address,
114-
ethernetDevices[deviceNumber].power,
115121
ethernetDevices[deviceNumber].mdc,
116122
ethernetDevices[deviceNumber].mdio,
117-
ethernetDevices[deviceNumber].type,
123+
ethernetDevices[deviceNumber].power,
118124
ethernetDevices[deviceNumber].clk_mode
119125
);
126+
#else
127+
// TODO fix this
128+
// ETH.begin(
129+
// ethernetDevices[deviceNumber].address,
130+
// ethernetDevices[deviceNumber].mdc,
131+
// ethernetDevices[deviceNumber].mdio,
132+
// ethernetDevices[deviceNumber].power
133+
// );
134+
#endif
120135
}
121136

122137
/**
123138
* Deallocate ethernet pins
124139
* @param deviceNumber to deallocate
125140
*/
126141
void EthManager::deallocateEthernetPins(int8_t deviceNumber) {
127-
const uint32_t MATRIX_DETACH_OUT_SIG = 0x100;
128-
gpio_matrix_out(ethernetDevices[deviceNumber].address, MATRIX_DETACH_OUT_SIG, false, false);
129-
gpio_matrix_out(ethernetDevices[deviceNumber].power, MATRIX_DETACH_OUT_SIG, false, false);
130-
gpio_matrix_out(ethernetDevices[deviceNumber].mdc, MATRIX_DETACH_OUT_SIG, false, false);
131-
gpio_matrix_out(ethernetDevices[deviceNumber].mdio, MATRIX_DETACH_OUT_SIG, false, false);
132-
gpio_matrix_out(ethernetDevices[deviceNumber].clk_mode, MATRIX_DETACH_OUT_SIG, false, false);
133-
pinMode(ethernetDevices[deviceNumber].address, INPUT);
134-
pinMode(ethernetDevices[deviceNumber].power, INPUT);
135-
pinMode(ethernetDevices[deviceNumber].mdc, INPUT);
136-
pinMode(ethernetDevices[deviceNumber].mdio, INPUT);
137-
pinMode(ethernetDevices[deviceNumber].clk_mode, INPUT);
142+
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].address);
143+
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].power);
144+
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdc);
145+
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdio);
146+
#if CONFIG_IDF_TARGET_ESP32
147+
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].clk_mode);
148+
#endif
149+
delay(1);
138150
}
139151

140152
#endif

src/EthManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ typedef struct EthConfig {
3434
int power;
3535
int mdc;
3636
int mdio;
37+
#if CONFIG_IDF_TARGET_ESP32
3738
eth_phy_type_t type;
3839
eth_clock_mode_t clk_mode;
40+
#endif
3941
} ethernet_config;
4042

4143
extern const ethernet_config ethernetDevices[];

src/WifiManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void WifiManager::setupWiFi(void (*manageDisconnections)(), void (*manageHardwar
7070
#if defined(ESP8266)
7171
WiFi.setSleepMode(WIFI_NONE_SLEEP);
7272
#endif
73-
WiFi.setAutoConnect(true);
73+
// WiFi.setAutoConnect(true); // TODO
7474
WiFi.setAutoReconnect(true);
7575
Serial.println(microcontrollerIP);
7676
if (!microcontrollerIP.equals("DHCP")) {
@@ -109,7 +109,9 @@ void WifiManager::setupWiFi(void (*manageDisconnections)(), void (*manageHardwar
109109
});
110110
#elif defined(ARDUINO_ARCH_ESP32)
111111
WiFi.setHostname(helper.string2char(deviceName));
112+
#if !CONFIG_IDF_TARGET_ESP32S2
112113
btStop();
114+
#endif
113115
#endif
114116
// Start wifi connection
115117
WiFi.begin(qsid.c_str(), qpass.c_str());
@@ -224,6 +226,9 @@ void WifiManager::setupOTAUpload() {
224226
Serial.println(F("End"));
225227
});
226228
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
229+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
230+
esp_task_wdt_reset(); // TODO
231+
# endif
227232
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
228233
});
229234
ArduinoOTA.onError([](ota_error_t error) {

src/WifiManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <HTTPClient.h>
3434
#include <WiFiUdp.h>
3535
#include <WebServer.h>
36+
#include <esp_task_wdt.h>
3637

3738
#endif
3839

0 commit comments

Comments
 (0)