Skip to content

Commit

Permalink
Merge branch 'checklink'
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess committed Mar 3, 2014
2 parents 7c0f6ca + 1615141 commit 0389c02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions utility/Enc28J60Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,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 @@ -575,4 +588,10 @@ Enc28J60Network::powerOn()
delay(50);
}

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

Enc28J60Network Enc28J60;
2 changes: 2 additions & 0 deletions utility/Enc28J60Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 @@ -73,6 +74,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 0389c02

Please sign in to comment.