mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2025-12-11 17:30:37 +01:00
Change datatype for w5500 pins from int8_t to gpio_num_t
This commit is contained in:
@@ -27,12 +27,12 @@ struct PinMapping_t {
|
|||||||
gpio_num_t cmt_gpio3;
|
gpio_num_t cmt_gpio3;
|
||||||
gpio_num_t cmt_sdio;
|
gpio_num_t cmt_sdio;
|
||||||
|
|
||||||
int8_t w5500_mosi;
|
gpio_num_t w5500_mosi;
|
||||||
int8_t w5500_miso;
|
gpio_num_t w5500_miso;
|
||||||
int8_t w5500_sclk;
|
gpio_num_t w5500_sclk;
|
||||||
int8_t w5500_cs;
|
gpio_num_t w5500_cs;
|
||||||
int8_t w5500_int;
|
gpio_num_t w5500_int;
|
||||||
int8_t w5500_rst;
|
gpio_num_t w5500_rst;
|
||||||
|
|
||||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||||
int8_t eth_phy_addr;
|
int8_t eth_phy_addr;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
W5500& operator=(const W5500&) = delete;
|
W5500& operator=(const W5500&) = delete;
|
||||||
~W5500();
|
~W5500();
|
||||||
|
|
||||||
static std::unique_ptr<W5500> setup(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst);
|
static std::unique_ptr<W5500> setup(gpio_num_t pin_mosi, gpio_num_t pin_miso, gpio_num_t pin_sclk, gpio_num_t pin_cs, gpio_num_t pin_int, gpio_num_t pin_rst);
|
||||||
String macAddress();
|
String macAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -281,11 +281,11 @@ build_flags = ${env.build_flags}
|
|||||||
-DCMT_GPIO2=GPIO_NUM_3
|
-DCMT_GPIO2=GPIO_NUM_3
|
||||||
-DCMT_GPIO3=GPIO_NUM_8
|
-DCMT_GPIO3=GPIO_NUM_8
|
||||||
-DCMT_SDIO=GPIO_NUM_5
|
-DCMT_SDIO=GPIO_NUM_5
|
||||||
-DW5500_MOSI=40
|
-DW5500_MOSI=GPIO_NUM_40
|
||||||
-DW5500_MISO=41
|
-DW5500_MISO=GPIO_NUM_41
|
||||||
-DW5500_SCLK=39
|
-DW5500_SCLK=GPIO_NUM_39
|
||||||
-DW5500_CS=42
|
-DW5500_CS=GPIO_NUM_42
|
||||||
-DW5500_INT=44
|
-DW5500_INT=GPIO_NUM_44
|
||||||
-DW5500_RST=43
|
-DW5500_RST=GPIO_NUM_43
|
||||||
-DARDUINO_USB_MODE=1
|
-DARDUINO_USB_MODE=1
|
||||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
|||||||
@@ -86,27 +86,27 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_MOSI
|
#ifndef W5500_MOSI
|
||||||
#define W5500_MOSI -1
|
#define W5500_MOSI GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_MISO
|
#ifndef W5500_MISO
|
||||||
#define W5500_MISO -1
|
#define W5500_MISO GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_SCLK
|
#ifndef W5500_SCLK
|
||||||
#define W5500_SCLK -1
|
#define W5500_SCLK GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_CS
|
#ifndef W5500_CS
|
||||||
#define W5500_CS -1
|
#define W5500_CS GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_INT
|
#ifndef W5500_INT
|
||||||
#define W5500_INT -1
|
#define W5500_INT GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef W5500_RST
|
#ifndef W5500_RST
|
||||||
#define W5500_RST -1
|
#define W5500_RST GPIO_NUM_NC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||||
@@ -286,12 +286,12 @@ bool PinMappingClass::isValidCmt2300Config() const
|
|||||||
|
|
||||||
bool PinMappingClass::isValidW5500Config() const
|
bool PinMappingClass::isValidW5500Config() const
|
||||||
{
|
{
|
||||||
return _pinMapping.w5500_mosi >= 0
|
return _pinMapping.w5500_mosi > GPIO_NUM_NC
|
||||||
&& _pinMapping.w5500_miso >= 0
|
&& _pinMapping.w5500_miso > GPIO_NUM_NC
|
||||||
&& _pinMapping.w5500_sclk >= 0
|
&& _pinMapping.w5500_sclk > GPIO_NUM_NC
|
||||||
&& _pinMapping.w5500_cs >= 0
|
&& _pinMapping.w5500_cs > GPIO_NUM_NC
|
||||||
&& _pinMapping.w5500_int >= 0
|
&& _pinMapping.w5500_int > GPIO_NUM_NC
|
||||||
&& _pinMapping.w5500_rst >= 0;
|
&& _pinMapping.w5500_rst > GPIO_NUM_NC;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Thomas Basler and others
|
* Copyright (C) 2024-2025 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "W5500.h"
|
#include "W5500.h"
|
||||||
@@ -56,19 +56,17 @@ W5500::~W5500()
|
|||||||
// TODO(LennartF22): support cleanup at some point?
|
// TODO(LennartF22): support cleanup at some point?
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<W5500> W5500::setup(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst)
|
std::unique_ptr<W5500> W5500::setup(gpio_num_t pin_mosi, gpio_num_t pin_miso, gpio_num_t pin_sclk, gpio_num_t pin_cs, gpio_num_t pin_int, gpio_num_t pin_rst)
|
||||||
{
|
{
|
||||||
gpio_reset_pin(static_cast<gpio_num_t>(pin_rst));
|
gpio_reset_pin(pin_rst);
|
||||||
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 0);
|
gpio_set_level(pin_rst, 0);
|
||||||
gpio_set_direction(static_cast<gpio_num_t>(pin_rst), GPIO_MODE_OUTPUT);
|
gpio_set_direction(pin_rst, GPIO_MODE_OUTPUT);
|
||||||
|
|
||||||
gpio_reset_pin(static_cast<gpio_num_t>(pin_cs));
|
gpio_reset_pin(pin_cs);
|
||||||
gpio_reset_pin(static_cast<gpio_num_t>(pin_int));
|
gpio_reset_pin(pin_int);
|
||||||
|
|
||||||
auto bus_config = std::make_shared<SpiBusConfig>(
|
auto bus_config = std::make_shared<SpiBusConfig>(
|
||||||
static_cast<gpio_num_t>(pin_mosi),
|
pin_mosi, pin_miso, pin_sclk);
|
||||||
static_cast<gpio_num_t>(pin_miso),
|
|
||||||
static_cast<gpio_num_t>(pin_sclk));
|
|
||||||
|
|
||||||
spi_device_interface_config_t device_config {
|
spi_device_interface_config_t device_config {
|
||||||
.command_bits = 16, // actually address phase
|
.command_bits = 16, // actually address phase
|
||||||
@@ -93,12 +91,12 @@ std::unique_ptr<W5500> W5500::setup(int8_t pin_mosi, int8_t pin_miso, int8_t pin
|
|||||||
|
|
||||||
// Reset sequence
|
// Reset sequence
|
||||||
delayMicroseconds(500);
|
delayMicroseconds(500);
|
||||||
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 1);
|
gpio_set_level(pin_rst, 1);
|
||||||
delayMicroseconds(1000);
|
delayMicroseconds(1000);
|
||||||
|
|
||||||
if (!connection_check_spi(spi))
|
if (!connection_check_spi(spi))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!connection_check_interrupt(static_cast<gpio_num_t>(pin_int)))
|
if (!connection_check_interrupt(pin_int))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Use Arduino functions to temporarily attach interrupt to enable the GPIO ISR service
|
// Use Arduino functions to temporarily attach interrupt to enable the GPIO ISR service
|
||||||
@@ -107,9 +105,9 @@ std::unique_ptr<W5500> W5500::setup(int8_t pin_mosi, int8_t pin_miso, int8_t pin
|
|||||||
detachInterrupt(pin_int);
|
detachInterrupt(pin_int);
|
||||||
|
|
||||||
// Return to default state once again after connection check and temporary interrupt registration
|
// Return to default state once again after connection check and temporary interrupt registration
|
||||||
gpio_reset_pin(static_cast<gpio_num_t>(pin_int));
|
gpio_reset_pin(pin_int);
|
||||||
|
|
||||||
return std::unique_ptr<W5500>(new W5500(spi, static_cast<gpio_num_t>(pin_int)));
|
return std::unique_ptr<W5500>(new W5500(spi, pin_int));
|
||||||
}
|
}
|
||||||
|
|
||||||
String W5500::macAddress()
|
String W5500::macAddress()
|
||||||
|
|||||||
Reference in New Issue
Block a user