Skip to content

Commit

Permalink
Revert "Feature: Support for W5500 ethernet module (#1231)"
Browse files Browse the repository at this point in the history
This reverts commit 89d9a40.
  • Loading branch information
schlimmchen committed Sep 30, 2024
1 parent a89c1fa commit 0a289bb
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 279 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
pip install cpplint
- name: Linting
run: |
cpplint --repository=. --recursive --filter=-build/c++11,-runtime/references,-readability/braces,-whitespace,-legal,-build/include ./src ./include ./lib/Hoymiles ./lib/MqttSubscribeParser ./lib/TimeoutHelper ./lib/ResetReason ./lib/ETHSPI
cpplint --repository=. --recursive --filter=-build/c++11,-runtime/references,-readability/braces,-whitespace,-legal,-build/include ./src ./include ./lib/Hoymiles ./lib/MqttSubscribeParser ./lib/TimeoutHelper ./lib/ResetReason
40 changes: 1 addition & 39 deletions docs/DeviceProfiles/opendtu_fusion.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,43 +186,5 @@
"data": 2,
"clk": 1
}
},
{
"name": "OpenDTU Fusion v2 with NRF24 and W5500 ethernet",
"nrf24": {
"miso": 48,
"mosi": 35,
"clk": 36,
"irq": 47,
"en": 38,
"cs": 37
},
"w5500": {
"sclk": 39,
"mosi": 40,
"miso": 41,
"cs": 42,
"rst": 43,
"int": 44
}
},
{
"name": "OpenDTU Fusion v2 with CMT2300A and W5500 ethernet",
"cmt": {
"clk": 6,
"cs": 4,
"fcs": 21,
"sdio": 5,
"gpio2": 3,
"gpio3": 8
},
"w5500": {
"sclk": 39,
"mosi": 40,
"miso": 41,
"cs": 42,
"rst": 43,
"int": 44
}
}
]
]
1 change: 0 additions & 1 deletion include/NetworkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class NetworkSettingsClass {
bool _ethConnected = false;
std::vector<NetworkEventCbList_t> _cbEventList;
bool _lastMdnsEnabled = false;
bool _spiEth = false;
};

extern NetworkSettingsClass NetworkSettings;
8 changes: 0 additions & 8 deletions include/PinMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ struct PinMapping_t {
int8_t cmt_gpio3;
int8_t cmt_sdio;

int8_t w5500_sclk;
int8_t w5500_mosi;
int8_t w5500_miso;
int8_t w5500_cs;
int8_t w5500_int;
int8_t w5500_rst;

int8_t eth_phy_addr;
bool eth_enabled;
int eth_power;
Expand Down Expand Up @@ -79,7 +72,6 @@ class PinMappingClass {

bool isValidNrf24Config() const;
bool isValidCmt2300Config() const;
bool isValidW5500Config() const;
bool isValidEthConfig() const;
bool isValidHuaweiConfig() const;

Expand Down
127 changes: 0 additions & 127 deletions lib/ETHSPI/src/ETHSPI.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions lib/ETHSPI/src/ETHSPI.h

This file was deleted.

26 changes: 5 additions & 21 deletions src/NetworkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
#include "SyslogLogger.h"
#include "PinMapping.h"
#include "Utils.h"
#include "SPIPortManager.h"
#include "defaults.h"
#include <ESPmDNS.h>
#include <ETHSPI.h>
#include <ETH.h>
#include "__compiled_constants.h"

Expand All @@ -34,22 +32,6 @@ void NetworkSettingsClass::init(Scheduler& scheduler)
WiFi.disconnect(true, true);

WiFi.onEvent(std::bind(&NetworkSettingsClass::NetworkEvent, this, _1, _2));

if (PinMapping.isValidEthConfig()) {
PinMapping_t& pin = PinMapping.get();
ETH.begin(pin.eth_phy_addr, pin.eth_power, pin.eth_mdc, pin.eth_mdio, pin.eth_type, pin.eth_clk_mode);
} else if (PinMapping.isValidW5500Config()) {
auto oSPInum = SPIPortManager.allocatePort("ETHSPI");

if (oSPInum) {
spi_host_device_t host_id = SPIPortManager.SPIhostNum(*oSPInum);
PinMapping_t& pin = PinMapping.get();
ETHSPI.begin(pin.w5500_sclk, pin.w5500_mosi, pin.w5500_miso, pin.w5500_cs, pin.w5500_int, pin.w5500_rst,
host_id);
_spiEth = true;
}
}

setupMode();

scheduler.addTask(_loopTask);
Expand Down Expand Up @@ -189,6 +171,11 @@ void NetworkSettingsClass::setupMode()
WiFi.mode(WIFI_MODE_NULL);
}
}

if (PinMapping.isValidEthConfig()) {
PinMapping_t& pin = PinMapping.get();
ETH.begin(pin.eth_phy_addr, pin.eth_power, pin.eth_mdc, pin.eth_mdio, pin.eth_type, pin.eth_clk_mode);
}
}

void NetworkSettingsClass::enableAdminMode()
Expand Down Expand Up @@ -418,9 +405,6 @@ String NetworkSettingsClass::macAddress() const
{
switch (_networkMode) {
case network_mode::Ethernet:
if (_spiEth) {
return ETHSPI.macAddress();
}
return ETH.macAddress();
break;
case network_mode::WiFi:
Expand Down
48 changes: 0 additions & 48 deletions src/PinMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,6 @@
#define POWERMETER_PIN_RXEN -1
#endif

#ifndef W5500_SCLK
#define W5500_SCLK -1
#endif

#ifndef W5500_MOSI
#define W5500_MOSI -1
#endif

#ifndef W5500_MISO
#define W5500_MISO -1
#endif

#ifndef W5500_CS
#define W5500_CS -1
#endif

#ifndef W5500_INT
#define W5500_INT -1
#endif

#ifndef W5500_RST
#define W5500_RST -1
#endif

PinMappingClass PinMapping;

PinMappingClass::PinMappingClass()
Expand All @@ -221,13 +197,6 @@ PinMappingClass::PinMappingClass()
_pinMapping.cmt_gpio3 = CMT_GPIO3;
_pinMapping.cmt_sdio = CMT_SDIO;

_pinMapping.w5500_sclk = W5500_SCLK;
_pinMapping.w5500_mosi = W5500_MOSI;
_pinMapping.w5500_miso = W5500_MISO;
_pinMapping.w5500_cs = W5500_CS;
_pinMapping.w5500_int = W5500_INT;
_pinMapping.w5500_rst = W5500_RST;

#ifdef OPENDTU_ETHERNET
_pinMapping.eth_enabled = true;
#else
Expand Down Expand Up @@ -317,13 +286,6 @@ bool PinMappingClass::init(const String& deviceMapping)
_pinMapping.cmt_gpio3 = doc[i]["cmt"]["gpio3"] | CMT_GPIO3;
_pinMapping.cmt_sdio = doc[i]["cmt"]["sdio"] | CMT_SDIO;

_pinMapping.w5500_sclk = doc[i]["w5500"]["sclk"] | W5500_SCLK;
_pinMapping.w5500_mosi = doc[i]["w5500"]["mosi"] | W5500_MOSI;
_pinMapping.w5500_miso = doc[i]["w5500"]["miso"] | W5500_MISO;
_pinMapping.w5500_cs = doc[i]["w5500"]["cs"] | W5500_CS;
_pinMapping.w5500_int = doc[i]["w5500"]["int"] | W5500_INT;
_pinMapping.w5500_rst = doc[i]["w5500"]["rst"] | W5500_RST;

#ifdef OPENDTU_ETHERNET
_pinMapping.eth_enabled = doc[i]["eth"]["enabled"] | true;
#else
Expand Down Expand Up @@ -397,16 +359,6 @@ bool PinMappingClass::isValidCmt2300Config() const
&& _pinMapping.cmt_sdio >= 0;
}

bool PinMappingClass::isValidW5500Config() const
{
return _pinMapping.w5500_sclk >= 0
&& _pinMapping.w5500_mosi >= 0
&& _pinMapping.w5500_miso >= 0
&& _pinMapping.w5500_cs >= 0
&& _pinMapping.w5500_int >= 0
&& _pinMapping.w5500_rst >= 0;
}

bool PinMappingClass::isValidEthConfig() const
{
return _pinMapping.eth_enabled;
Expand Down
8 changes: 0 additions & 8 deletions src/WebApi_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ void WebApiDeviceClass::onDeviceAdminGet(AsyncWebServerRequest* request)
cmtPinObj["gpio2"] = pin.cmt_gpio2;
cmtPinObj["gpio3"] = pin.cmt_gpio3;

auto w5500PinObj = curPin["w5500"].to<JsonObject>();
w5500PinObj["sclk"] = pin.w5500_sclk;
w5500PinObj["mosi"] = pin.w5500_mosi;
w5500PinObj["miso"] = pin.w5500_miso;
w5500PinObj["cs"] = pin.w5500_cs;
w5500PinObj["int"] = pin.w5500_int;
w5500PinObj["rst"] = pin.w5500_rst;

auto ethPinObj = curPin["eth"].to<JsonObject>();
ethPinObj["enabled"] = pin.eth_enabled;
ethPinObj["phy_addr"] = pin.eth_phy_addr;
Expand Down

0 comments on commit 0a289bb

Please sign in to comment.