Skip to content

Commit

Permalink
fixing errata 12 by seydamir
Browse files Browse the repository at this point in the history
  • Loading branch information
cassy73 authored Jan 22, 2017
1 parent 6ff1931 commit 12c0048
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions utility/Enc28J60Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,34 @@ Enc28J60Network::sendPacket(memhandle handle)
// Set the TXND pointer to correspond to the packet size given
writeRegPair(ETXNDL, end);
// send the contents of the transmit buffer onto the network

// seydamir added
// Reset the transmit logic problem. See Rev. B7 Silicon Errata issues 12 and 13
writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST);
writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST);
writeOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF | EIR_TXIF);
// end

writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS);
// Reset the transmit logic problem. See Rev. B4 Silicon Errata point 12.
if( (readReg(EIR) & EIR_TXERIF) )
{
writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS);
}

//if( (readReg(EIR) & EIR_TXERIF) )
// {
// writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS);
// }

//seydamir added
{
uint8_t eir;
unsigned long timer = millis();
while (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == 0) {
if (millis() - timer > 1000) {
/* Transmit hardware probably hung, try again later. */
/* Shouldn't happen according to errata 12 and 13. */
writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS);
}
}
}
// end
//restore data on control-byte position
if (data)
writeByte(start, data);
Expand Down

0 comments on commit 12c0048

Please sign in to comment.