Skip to content

Commit

Permalink
Protect W5500/ENC28J60 isLinked from interrupt
Browse files Browse the repository at this point in the history
Fixes #1786
  • Loading branch information
earlephilhower committed Nov 10, 2023
1 parent 8ac616e commit 003d91e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libraries/lwIP_enc28j60/src/utility/enc28j60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <LwipEthernet.h>

#include "enc28j60.h"

Expand Down Expand Up @@ -696,6 +697,7 @@ uint16_t ENC28J60::phyread(uint8_t reg) {

bool ENC28J60::isLinked() {
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )

return !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_begin();
auto ret = !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_end();
}
6 changes: 5 additions & 1 deletion libraries/lwIP_w5500/src/utility/w5500.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <stdint.h>
#include <Arduino.h>
#include <SPI.h>
#include <LwipEthernet.h>

class Wiznet5500 {
public:
Expand Down Expand Up @@ -83,7 +84,10 @@ class Wiznet5500 {
@return true when physical link is up
*/
bool isLinked() {
return wizphy_getphylink() == PHY_LINK_ON;
ethernet_arch_lwip_begin();
auto ret = wizphy_getphylink() == PHY_LINK_ON;
ethernet_arch_lwip_end();
return ret;
}

/**
Expand Down

0 comments on commit 003d91e

Please sign in to comment.