mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-12-03 11:43:04 +05:00
fix: make W5500 interrupt and reset pins optional
This commit is contained in:
1 parent
5fb4231201
commit
29a5bc0f43
1 file changed
+16
-6
+16
-6
@@ -192,8 +192,8 @@ bool isEthernetConfigured(const NetworkSettings& config) {
|
||||
GPIO_IS_VALID_OUTPUT(gpios.mosi) &&
|
||||
GPIO_IS_VALID_INPUT(gpios.miso) &&
|
||||
GPIO_IS_VALID_OUTPUT(gpios.cs) &&
|
||||
GPIO_IS_VALID_INPUT(gpios.irq) &&
|
||||
GPIO_IS_VALID_OUTPUT(gpios.rst);
|
||||
(gpios.irq == GPIO_IS_NOT_CONFIGURED || GPIO_IS_VALID_INPUT(gpios.irq)) &&
|
||||
(gpios.rst == GPIO_IS_NOT_CONFIGURED || GPIO_IS_VALID_OUTPUT(gpios.rst));
|
||||
#else
|
||||
(void)config;
|
||||
return false;
|
||||
@@ -589,10 +589,20 @@ static bool startEthernet() {
|
||||
|
||||
const auto& gpios = networkSettings.ethernet.w5500;
|
||||
ESP_LOGI(L_NETWORK, "Initialize W5500 Ethernet");
|
||||
if (!ETH.begin(
|
||||
ETH_PHY_W5500, 1, gpios.cs, gpios.irq, gpios.rst,
|
||||
SPI2_HOST, gpios.clk, gpios.miso, gpios.mosi, 12
|
||||
)) {
|
||||
const bool initialized = ETH.begin(
|
||||
ETH_PHY_W5500,
|
||||
1,
|
||||
gpios.cs,
|
||||
gpios.irq == GPIO_IS_NOT_CONFIGURED ? -1 : gpios.irq, // optionally
|
||||
gpios.rst == GPIO_IS_NOT_CONFIGURED ? -1 : gpios.rst, // optionally
|
||||
SPI2_HOST,
|
||||
gpios.clk,
|
||||
gpios.miso,
|
||||
gpios.mosi,
|
||||
12
|
||||
);
|
||||
|
||||
if (!initialized) {
|
||||
ESP_LOGE(L_NETWORK, "W5500 initialization failed, check GPIOs and wiring");
|
||||
stopEthernet();
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user