Skip to content

Commit

Permalink
IDF5
Browse files Browse the repository at this point in the history
  • Loading branch information
sblantipodi committed Aug 23, 2024
1 parent 43d01f4 commit bf0a4e4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
12 changes: 10 additions & 2 deletions src/BootstrapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
launchWebServerForOTAConfig();
}
#if defined(ARDUINO_ARCH_ESP32)
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
esp_task_wdt_config_t twdt_config = {
.timeout_ms = 3000,
.trigger_panic = true,
};
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch
#endif
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
Expand Down Expand Up @@ -110,7 +114,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
#endif
}
#if defined(ARDUINO_ARCH_ESP32)
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
esp_task_wdt_config_t twdt_config = {
.timeout_ms = 3000,
.trigger_panic = true,
};
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch
#endif
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
Expand Down
40 changes: 26 additions & 14 deletions src/EthManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const ethernet_config ethernetDevices[] = {
// No Ethernet
{
},
#if CONFIG_IDF_TARGET_ESP32
// QuinLed-ESP32-Ethernet
{

0,
5,
23,
Expand Down Expand Up @@ -102,39 +102,51 @@ const ethernet_config ethernetDevices[] = {
ETH_PHY_LAN8720,
ETH_CLOCK_GPIO0_OUT
}
#endif
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)

#endif

};

/**
* Connect to ethernet
* @param deviceNumber to use
*/
void EthManager::connectToEthernet(int8_t deviceNumber) {
#if CONFIG_IDF_TARGET_ESP32
ETH.begin(
ethernetDevices[deviceNumber].type,
ethernetDevices[deviceNumber].address,
ethernetDevices[deviceNumber].power,
ethernetDevices[deviceNumber].mdc,
ethernetDevices[deviceNumber].mdio,
ethernetDevices[deviceNumber].type,
ethernetDevices[deviceNumber].power,
ethernetDevices[deviceNumber].clk_mode
);
#else
// TODO fix this
// ETH.begin(
// ethernetDevices[deviceNumber].address,
// ethernetDevices[deviceNumber].mdc,
// ethernetDevices[deviceNumber].mdio,
// ethernetDevices[deviceNumber].power
// );
#endif
}

/**
* Deallocate ethernet pins
* @param deviceNumber to deallocate
*/
void EthManager::deallocateEthernetPins(int8_t deviceNumber) {
const uint32_t MATRIX_DETACH_OUT_SIG = 0x100;
gpio_matrix_out(ethernetDevices[deviceNumber].address, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].power, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].mdc, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].mdio, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].clk_mode, MATRIX_DETACH_OUT_SIG, false, false);
pinMode(ethernetDevices[deviceNumber].address, INPUT);
pinMode(ethernetDevices[deviceNumber].power, INPUT);
pinMode(ethernetDevices[deviceNumber].mdc, INPUT);
pinMode(ethernetDevices[deviceNumber].mdio, INPUT);
pinMode(ethernetDevices[deviceNumber].clk_mode, INPUT);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].address);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].power);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdc);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdio);
#if CONFIG_IDF_TARGET_ESP32
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].clk_mode);
#endif
delay(1);
}

#endif
2 changes: 2 additions & 0 deletions src/EthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ typedef struct EthConfig {
int power;
int mdc;
int mdio;
#if CONFIG_IDF_TARGET_ESP32
eth_phy_type_t type;
eth_clock_mode_t clk_mode;
#endif
} ethernet_config;

extern const ethernet_config ethernetDevices[];
Expand Down
2 changes: 1 addition & 1 deletion src/WifiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void WifiManager::setupWiFi(void (*manageDisconnections)(), void (*manageHardwar
#if defined(ESP8266)
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif
WiFi.setAutoConnect(true);
// WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true);
Serial.println(microcontrollerIP);
if (!microcontrollerIP.equals("DHCP")) {
Expand Down

0 comments on commit bf0a4e4

Please sign in to comment.