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

Commit

Permalink
v2.2.0 for LwIP W6100 Ethernet
Browse files Browse the repository at this point in the history
### Releases v2.2.0

1. Add support to `ESP32_S2/S3/C3` using `LwIP W6100 Ethernet`
2. Fix bug
  • Loading branch information
khoih-prog authored Jan 11, 2023
1 parent 2342739 commit 26082cd
Show file tree
Hide file tree
Showing 18 changed files with 400 additions and 336 deletions.
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,34 @@ However, before reporting a bug please check through the following:

If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncUDP_ESP32_SC_Ethernet/issues/new).

---

### How to submit a bug report

Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* Board Type (e.g. ESP32S3_DEV, ESP32S2_DEV, ESP32C3_DEV)
* Board Core Version (e.g. ESP32 core v2.0.5)
* Board Core Version (e.g. ESP32 core v2.0.6)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
* Network configuration


Please be educated, civilized and constructive. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.
Please be educated, civilized and constructive as you've always been. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.

---

### Example

```
Arduino IDE version: 1.8.19
ESP32S3_DEV board
ESP32 core v2.0.5
ESP32 core v2.0.6
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-57-generic #63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while using this library
Steps to reproduce:
Expand Down
Binary file added Images/W6100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v2.2.0](#releases-v220)
* [Releases v2.1.0](#releases-v210)
* [Initial Releases v2.0.0](#initial-releases-v200)

Expand All @@ -25,6 +26,11 @@

## Changelog

### Releases v2.2.0

1. Add support to `ESP32_S2/S3/C3` using `LwIP W6100 Ethernet`
2. Fix bug

### Releases v2.1.0

1. Add support to `ESP32S2/C3` boards using `LwIP W5500 or ENC28J60 Ethernet`
Expand Down
104 changes: 53 additions & 51 deletions examples/AsyncUDPClient/AsyncUDPClient.ino
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/****************************************************************************************************************************
Async_UdpClient.ino
AsyncUDP_ESP32_SC_Ethernet is a Async UDP library for the ESP32_SC_Ethernet (ESP32S2/S3/C3 + LwIP W5500 / ENC28J60)
AsyncUDP_ESP32_SC_Ethernet is a Async UDP library for the ESP32_SC_Ethernet (ESP32S2/S3/C3 + LwIP W5500 / W6100 / ENC28J60)
Based on and modified from ESPAsyncUDP Library (https://github.com/me-no-dev/ESPAsyncUDP)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncUDP_ESP32_SC_Ethernet
Licensed under GPLv3 license
*****************************************************************************************************************************/

#if !( defined(ESP32) )
#error This code is designed for (ESP32S2/S3/C3 + LwIP W5500 or ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting.
#error This code is designed for (ESP32S2/S3/C3 + LwIP W5500, W6100 or ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting.
#endif

#include <Arduino.h>

#define USING_W5500 true
#define USING_W6100 false
#define USING_ENC28J60 false

#if !USING_W5500 && !USING_ENC28J60
#if !USING_W5500 && !USING_W6100 && !USING_ENC28J60
#undef USING_W5500
#define USING_W5500 true
#endif
Expand All @@ -31,6 +32,9 @@

#if USING_W5500

#define ESP32_Ethernet_onEvent ESP32_W5500_onEvent
#define ESP32_Ethernet_waitForConnect ESP32_W5500_waitForConnect

// For ESP32_S3
// Optional values to override default settings
// Don't change unless you know what you're doing
Expand Down Expand Up @@ -61,12 +65,51 @@

//////////////////////////////////////////////////////////

#elif USING_W6100

#define ESP32_Ethernet_onEvent ESP32_W6100_onEvent
#define ESP32_Ethernet_waitForConnect ESP32_W6100_waitForConnect

// For ESP32_S3
// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI3_HOST
//#define SPI_CLOCK_MHZ 25

// Must connect INT to GPIOxx or not working
//#define INT_GPIO 4

//#define MISO_GPIO 13
//#define MOSI_GPIO 11
//#define SCK_GPIO 12
//#define CS_GPIO 10

// For ESP32_C3
// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI2_HOST
//#define SPI_CLOCK_MHZ 25

// Must connect INT to GPIOxx or not working
//#define INT_GPIO 10

//#define MISO_GPIO 5
//#define MOSI_GPIO 6
//#define SCK_GPIO 4
//#define CS_GPIO 7

//////////////////////////////////////////////////////////

#else // #if USING_W5500

//////////////////////////////////////////////////////////

// For ENC28J60

#define ESP32_Ethernet_onEvent ESP32_ENC_onEvent
#define ESP32_Ethernet_waitForConnect ESP32_ENC_waitForConnect
#define ETH_SPI_HOST SPI_HOST

// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI2_HOST
Expand Down Expand Up @@ -154,45 +197,6 @@ void parsePacket(AsyncUDPPacket packet)
packet.printf("Got %u bytes of data", packet.length());
}

#if USING_W5500

void initEthernet()
{
UDP_LOGWARN(F("Default SPI pinout:"));
UDP_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
UDP_LOGWARN1(F("MOSI:"), MOSI_GPIO);
UDP_LOGWARN1(F("MISO:"), MISO_GPIO);
UDP_LOGWARN1(F("SCK:"), SCK_GPIO);
UDP_LOGWARN1(F("CS:"), CS_GPIO);
UDP_LOGWARN1(F("INT:"), INT_GPIO);
UDP_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
UDP_LOGWARN(F("========================="));

///////////////////////////////////

// To be called before ETH.begin()
ESP32_W5500_onEvent();

// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;

//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac);
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );

// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
//ETH.config(myIP, myGW, mySN, myDNS);

ESP32_W5500_waitForConnect();

///////////////////////////////////
}

#else

void initEthernet()
{
UDP_LOGWARN(F("Default SPI pinout:"));
Expand All @@ -208,28 +212,24 @@ void initEthernet()
///////////////////////////////////

// To be called before ETH.begin()
ESP32_ENC_onEvent();
ESP32_Ethernet_onEvent();

// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;

//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *ENC28J60_Mac = ENC28J60_Default_Mac);
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] );

// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
//ETH.config(myIP, myGW, mySN, myDNS);

ESP32_ENC_waitForConnect();
ESP32_Ethernet_waitForConnect();

///////////////////////////////////
}

#endif

////////////////////////////////////

void setup()
Expand All @@ -247,6 +247,8 @@ void setup()

#if USING_W5500
Serial.println(WEBSERVER_ESP32_SC_W5500_VERSION);
#elif USING_W6100
Serial.println(WEBSERVER_ESP32_SC_W6100_VERSION);
#else
Serial.println(WEBSERVER_ESP32_SC_ENC_VERSION);
#endif
Expand Down
Loading

0 comments on commit 26082cd

Please sign in to comment.