Skip to content

Commit 49fa96c

Browse files
committed
add a timeout exit loop when Enc28J60Network never ready
1 parent 9e42993 commit 49fa96c

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

STM32F4/libraries/arduino_uip/examples/TcpClient/TcpClient.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ void setup() {
3030
Ethernet.begin(mac);
3131

3232
Serial.print("localIP: ");
33-
Serial.println(Ethernet.localIP());
33+
Serial.println(Ethernet.localIP().toString());
3434
Serial.print("subnetMask: ");
35-
Serial.println(Ethernet.subnetMask());
35+
Serial.println(Ethernet.subnetMask().toString());
3636
Serial.print("gatewayIP: ");
37-
Serial.println(Ethernet.gatewayIP());
37+
Serial.println(Ethernet.gatewayIP().toString());
3838
Serial.print("dnsServerIP: ");
39-
Serial.println(Ethernet.dnsServerIP());
39+
Serial.println(Ethernet.dnsServerIP().toString());
4040

4141
next = 0;
4242
}

STM32F4/libraries/arduino_uip/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ email=Norbert Truchsess <norbert.truchsess@t-online.de>
44
sentence=Ethernet library for ENC28J60
55
paragraph=implements the same API as stock Ethernet-lib. Just replace the include of Ethernet.h with UIPEthernet.h
66
url=https://github.com/ntruchsess/arduino_uip
7-
architectures=STM32F1
7+
architectures=STM32F4
88
version=1.04
99
dependencies=
1010
core-dependencies=arduino (>=1.5.0)

STM32F4/libraries/arduino_uip/utility/Enc28J60Network.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static byte selectPin;
5757

5858
void Enc28J60Network::init(uint8_t* macaddr)
5959
{
60+
uint32 timeout = 0;
6061
MemoryPool::init(); // 1 byte in between RX_STOP_INIT and pool to allow prepending of controlbyte
6162
// initialize I/O
6263
// ss as output:
@@ -100,8 +101,12 @@ void Enc28J60Network::init(uint8_t* macaddr)
100101
#ifdef ENC28J60DEBUG
101102
Serial.println("ENC28J60::initialize / before readOp(ENC28J60_READ_CTRL_REG, ESTAT)");
102103
#endif
103-
while (!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY)
104-
;
104+
while (!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) {
105+
if (++timeout > 100000) {
106+
Serial.println("ENC28J60::initialize TIMEOUT !!!\r\n");
107+
return;
108+
}
109+
}
105110
#ifdef ENC28J60DEBUG
106111
Serial.println("ENC28J60::initialize / after readOp(ENC28J60_READ_CTRL_REG, ESTAT)");
107112
#endif

STM32F4/libraries/arduino_uip/utility/Enc28J60Network.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,12 @@
2828
#include <SPI.h>
2929
#include "mempool.h"
3030

31-
//#define ENC28J60_CONTROL_CS SS
32-
//#define SPI_MOSI MOSI
33-
//#define SPI_MISO MISO
34-
//#define SPI_SCK SCK
35-
//#define SPI_SS SS
3631

32+
#ifdef ARDUINO_STM32F4_NETDUINO2PLUS
3733
#define ENC28J60_CONTROL_CS PC8
38-
//#define SPI_MOSI PA7
39-
//#define SPI_MISO PA6
40-
//#define SPI_SCK PA5
41-
//#define SPI_SS PA8
34+
#else
35+
#define ENC28J60_CONTROL_CS SPI.nssPin()
36+
#endif
4237

4338
#define UIP_RECEIVEBUFFERHANDLE 0xff
4439

0 commit comments

Comments
 (0)