Protect W5500/ENC28J60 isLinked from interrupt (#1805)

Fixes #1786
This commit is contained in:
Earle F. Philhower, III 2023-11-12 11:09:09 -08:00 committed by GitHub
parent 8ac616e8db
commit ea936f00e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -39,6 +39,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <LwipEthernet.h>
#include "enc28j60.h"
@ -696,6 +697,8 @@ 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();
return ret;
}

View file

@ -38,6 +38,7 @@
#include <stdint.h>
#include <Arduino.h>
#include <SPI.h>
#include <LwipEthernet.h>
class Wiznet5500 {
public:
@ -83,7 +84,10 @@ public:
@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;
}
/**