Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v2.8.5 to add support
Browse files Browse the repository at this point in the history
## Version 2.8.5

1. Use [Ethernet_Generic](https://github.com/khoih-prog/Ethernet_Generic) library as default for W5x00 Ethernet.
2. Add support to Portenta_H7
3. Add support to WIZNet W5100S, such as  [**WIZnet Ethernet HAT**](https://docs.wiznet.io/Product/Open-Source-Hardware/wiznet_ethernet_hat) and [**W5100S-EVB-Pico**](https://docs.wiznet.io/Product/iEthernet/W5100S/w5100s-evb-pico)
4. Update `Packages' Patches`
  • Loading branch information
khoih-prog authored Apr 24, 2022
1 parent 1c0c698 commit 722441a
Show file tree
Hide file tree
Showing 35 changed files with 4,692 additions and 1,710 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,65 +38,147 @@ unsigned long dispatchTime = millis() + MIN_IN_MS;
// setup function for setupEthernet connection
void setupEthernet()
{
#if USE_ETHERNET
SRP_LOGWARN(F("=========== USE_ETHERNET ==========="));
#elif USE_ETHERNET2
SRP_LOGWARN(F("=========== USE_ETHERNET2 ==========="));
#elif USE_ETHERNET3
SRP_LOGWARN(F("=========== USE_ETHERNET3 ==========="));
#elif USE_ETHERNET_LARGE
SRP_LOGWARN(F("=========== USE_ETHERNET_LARGE ==========="));
#elif USE_ETHERNET_ESP8266
SRP_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ==========="));
#else
#if USE_ETHERNET_PORTENTA_H7
SRP_LOGWARN(F("======== USE_PORTENTA_H7_ETHERNET ========"));
#elif USE_NATIVE_ETHERNET
SRP_LOGWARN(F("======== USE_NATIVE_ETHERNET ========"));
#elif USE_ETHERNET_GENERIC
SRP_LOGWARN(F("=========== USE_ETHERNET_GENERIC ==========="));
#elif USE_ETHERNET_ESP8266
SRP_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ==========="));
#elif USE_ETHERNET_ENC
SRP_LOGWARN(F("=========== USE_ETHERNET_ENC ==========="));
#else
SRP_LOGWARN(F("========================="));
#endif

#if !(USE_NATIVE_ETHERNET || USE_ETHERNET_PORTENTA_H7)

#if (USING_SPI2)
#if defined(CUR_PIN_MISO)
SRP_LOGWARN(F("Default SPI pinout:"));
SRP_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI);
SRP_LOGWARN1(F("MISO:"), CUR_PIN_MISO);
SRP_LOGWARN1(F("SCK:"), CUR_PIN_SCK);
SRP_LOGWARN1(F("SS:"), CUR_PIN_SS);
SRP_LOGWARN(F("========================="));
#endif
#else
SRP_LOGWARN(F("Default SPI pinout:"));
SRP_LOGWARN1(F("MOSI:"), MOSI);
SRP_LOGWARN1(F("MISO:"), MISO);
SRP_LOGWARN1(F("SCK:"), SCK);
SRP_LOGWARN1(F("SS:"), SS);
SRP_LOGWARN(F("========================="));

#endif

#if ETHERNET_USE_RPIPICO

pinMode(USE_THIS_SS_PIN, OUTPUT);
digitalWrite(USE_THIS_SS_PIN, HIGH);

// ETHERNET_USE_RPIPICO, use default SS = 5 or 17
#ifndef USE_THIS_SS_PIN
#if defined(ARDUINO_ARCH_MBED)
#define USE_THIS_SS_PIN 5 // For Arduino Mbed core
#else
#define USE_THIS_SS_PIN 17 // For E.Philhower core
#endif
#endif

SRP_LOGWARN1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN);

// For other boards, to change if necessary
#if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
// Must use library patch for Ethernet, EthernetLarge libraries
// For RPI Pico using Arduino Mbed RP2040 core
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
// For RPI Pico using E. Philhower RP2040 core
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
// Default pin 5/17 to SS/CS

//Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (USE_THIS_SS_PIN);

#endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )

#else // ETHERNET_USE_RPIPICO
// unknown board, do nothing, use default SS = 10
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif

SRP_LOGWARN1(F("Use default CS/SS pin : "), USE_THIS_SS_PIN);

#if defined(BOARD_NAME)
SRP_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);
#else
SRP_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN);
#endif

// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
#if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries

Ethernet.init (USE_THIS_SS_PIN);

#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
#elif USE_CUSTOM_ETHERNET

// You have to add initialization for your Custom Ethernet here
// This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
Ethernet.init(USE_THIS_SS_PIN);

Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);

#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
#endif //( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )

// start the ethernet connection and the server:
// Use Static IP
//Ethernet.begin(mac, ip);
#endif // ETHERNET_USE_RPIPICO

#endif // #if !(USE_NATIVE_ETHERNET)

// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
//srand(millis());
//uint16_t index = rand() % NUMBER_OF_MAC;
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[0], ip);
Ethernet.begin(mac[index]);

Serial.print("Index = ");
Serial.println(index);
#if !(USE_NATIVE_ETHERNET || USE_ETHERNET_PORTENTA_H7)
SRP_LOGWARN(F("========================="));

#if defined(CUR_PIN_MISO)
SRP_LOGWARN(F("Currently Used SPI pinout:"));
SRP_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI);
SRP_LOGWARN1(F("MISO:"), CUR_PIN_MISO);
SRP_LOGWARN1(F("SCK:"), CUR_PIN_SCK);
SRP_LOGWARN1(F("SS:"), CUR_PIN_SS);
#else
SRP_LOGWARN(F("Currently Used SPI pinout:"));
SRP_LOGWARN1(F("MOSI:"), MOSI);
SRP_LOGWARN1(F("MISO:"), MISO);
SRP_LOGWARN1(F("SCK:"), SCK);
SRP_LOGWARN1(F("SS:"), SS);
#endif

SRP_LOGWARN(F("========================="));

Ethernet.begin(mac[index]);
#elif (USE_ETHERNET_PORTENTA_H7)
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("No Ethernet found. Stay here forever");

while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}

Serial.print("Connected!\n[Ethernet]: IP-Address is ");
if (Ethernet.linkStatus() == LinkOFF)
{
Serial.println("Not connected Ethernet cable");
}
#endif

Serial.print(F("Using mac index = "));
Serial.println(index);

Serial.print(F("Connected! IP address: "));
Serial.println(Ethernet.localIP());
}

Expand Down
Loading

0 comments on commit 722441a

Please sign in to comment.