Skip to content

Commit 0389c02

Browse files
committed
Merge branch 'checklink'
2 parents 7c0f6ca + 1615141 commit 0389c02

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

utility/Enc28J60Network.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,19 @@ Enc28J60Network::phyWrite(uint8_t address, uint16_t data)
503503
}
504504
}
505505

506+
uint16_t
507+
Enc28J60Network::phyRead(uint8_t address)
508+
{
509+
writeReg(MIREGADR,address);
510+
writeReg(MICMD, MICMD_MIIRD);
511+
// wait until the PHY read completes
512+
while(readReg(MISTAT) & MISTAT_BUSY){
513+
delayMicroseconds(15);
514+
} //and MIRDH
515+
writeReg(MICMD, 0);
516+
return (readReg(MIRDL) | readReg(MIRDH) << 8);
517+
}
518+
506519
void
507520
Enc28J60Network::clkout(uint8_t clk)
508521
{
@@ -575,4 +588,10 @@ Enc28J60Network::powerOn()
575588
delay(50);
576589
}
577590

591+
bool
592+
Enc28J60Network::linkStatus()
593+
{
594+
return (phyRead(PHSTAT2) & 0x0400) > 0;
595+
}
596+
578597
Enc28J60Network Enc28J60;

utility/Enc28J60Network.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Enc28J60Network : public MemoryPool
6464
static void writeReg(uint8_t address, uint8_t data);
6565
static void writeRegPair(uint8_t address, uint16_t data);
6666
static void phyWrite(uint8_t address, uint16_t data);
67+
static uint16_t phyRead(uint8_t address);
6768
static void clkout(uint8_t clk);
6869

6970
friend void enc28J60_mempool_block_move_callback(memaddress,memaddress,memaddress);
@@ -73,6 +74,7 @@ class Enc28J60Network : public MemoryPool
7374
uint8_t getrev(void);
7475
void powerOn();
7576
void powerOff();
77+
bool linkStatus();
7678

7779
static void init(uint8_t* macaddr);
7880
static memhandle receivePacket();

0 commit comments

Comments
 (0)