Skip to content

Commit ea936f0

Browse files
Protect W5500/ENC28J60 isLinked from interrupt (earlephilhower#1805)
Fixes earlephilhower#1786
1 parent 8ac616e commit ea936f0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

libraries/lwIP_enc28j60/src/utility/enc28j60.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <stdio.h>
4040
#include <stdarg.h>
4141
#include <string.h>
42+
#include <LwipEthernet.h>
4243

4344
#include "enc28j60.h"
4445

@@ -696,6 +697,8 @@ uint16_t ENC28J60::phyread(uint8_t reg) {
696697

697698
bool ENC28J60::isLinked() {
698699
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )
699-
700-
return !!(phyread(MACSTAT2) & 0x400);
700+
ethernet_arch_lwip_begin();
701+
auto ret = !!(phyread(MACSTAT2) & 0x400);
702+
ethernet_arch_lwip_end();
703+
return ret;
701704
}

libraries/lwIP_w5500/src/utility/w5500.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <stdint.h>
3939
#include <Arduino.h>
4040
#include <SPI.h>
41+
#include <LwipEthernet.h>
4142

4243
class Wiznet5500 {
4344
public:
@@ -83,7 +84,10 @@ class Wiznet5500 {
8384
@return true when physical link is up
8485
*/
8586
bool isLinked() {
86-
return wizphy_getphylink() == PHY_LINK_ON;
87+
ethernet_arch_lwip_begin();
88+
auto ret = wizphy_getphylink() == PHY_LINK_ON;
89+
ethernet_arch_lwip_end();
90+
return ret;
8791
}
8892

8993
/**

0 commit comments

Comments
 (0)