Skip to content

Commit 9601aaf

Browse files
committed
Merge branch 'master' into Arduino_1.5.5
2 parents 97b9044 + 0389c02 commit 9601aaf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

UIPEthernet/src/utility/Enc28J60Network.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,19 @@ Enc28J60Network::phyWrite(uint8_t address, uint16_t data)
586586
}
587587
}
588588

589+
uint16_t
590+
Enc28J60Network::phyRead(uint8_t address)
591+
{
592+
writeReg(MIREGADR,address);
593+
writeReg(MICMD, MICMD_MIIRD);
594+
// wait until the PHY read completes
595+
while(readReg(MISTAT) & MISTAT_BUSY){
596+
delayMicroseconds(15);
597+
} //and MIRDH
598+
writeReg(MICMD, 0);
599+
return (readReg(MIRDL) | readReg(MIRDH) << 8);
600+
}
601+
589602
void
590603
Enc28J60Network::clkout(uint8_t clk)
591604
{
@@ -671,4 +684,10 @@ Enc28J60Network::powerOn()
671684
delay(50);
672685
}
673686

687+
bool
688+
Enc28J60Network::linkStatus()
689+
{
690+
return (phyRead(PHSTAT2) & 0x0400) > 0;
691+
}
692+
674693
Enc28J60Network Enc28J60;

UIPEthernet/src/utility/Enc28J60Network.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Enc28J60Network : public MemoryPool
7171
static void writeReg(uint8_t address, uint8_t data);
7272
static void writeRegPair(uint8_t address, uint16_t data);
7373
static void phyWrite(uint8_t address, uint16_t data);
74+
static uint16_t phyRead(uint8_t address);
7475
static void clkout(uint8_t clk);
7576

7677
friend void enc28J60_mempool_block_move_callback(memaddress,memaddress,memaddress);
@@ -80,6 +81,7 @@ class Enc28J60Network : public MemoryPool
8081
uint8_t getrev(void);
8182
void powerOn();
8283
void powerOff();
84+
bool linkStatus();
8385

8486
static void init(uint8_t* macaddr);
8587
static memhandle receivePacket();

0 commit comments

Comments
 (0)