Skip to content

Commit

Permalink
Merge branch 'master' into Arduino_1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess committed Mar 3, 2014
2 parents 97b9044 + 0389c02 commit 9601aaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions UIPEthernet/src/utility/Enc28J60Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,19 @@ Enc28J60Network::phyWrite(uint8_t address, uint16_t data)
}
}

uint16_t
Enc28J60Network::phyRead(uint8_t address)
{
writeReg(MIREGADR,address);
writeReg(MICMD, MICMD_MIIRD);
// wait until the PHY read completes
while(readReg(MISTAT) & MISTAT_BUSY){
delayMicroseconds(15);
} //and MIRDH
writeReg(MICMD, 0);
return (readReg(MIRDL) | readReg(MIRDH) << 8);
}

void
Enc28J60Network::clkout(uint8_t clk)
{
Expand Down Expand Up @@ -671,4 +684,10 @@ Enc28J60Network::powerOn()
delay(50);
}

bool
Enc28J60Network::linkStatus()
{
return (phyRead(PHSTAT2) & 0x0400) > 0;
}

Enc28J60Network Enc28J60;
2 changes: 2 additions & 0 deletions UIPEthernet/src/utility/Enc28J60Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Enc28J60Network : public MemoryPool
static void writeReg(uint8_t address, uint8_t data);
static void writeRegPair(uint8_t address, uint16_t data);
static void phyWrite(uint8_t address, uint16_t data);
static uint16_t phyRead(uint8_t address);
static void clkout(uint8_t clk);

friend void enc28J60_mempool_block_move_callback(memaddress,memaddress,memaddress);
Expand All @@ -80,6 +81,7 @@ class Enc28J60Network : public MemoryPool
uint8_t getrev(void);
void powerOn();
void powerOff();
bool linkStatus();

static void init(uint8_t* macaddr);
static memhandle receivePacket();
Expand Down

0 comments on commit 9601aaf

Please sign in to comment.