Update UIPEthernet library
This commit is contained in:
@@ -155,7 +155,7 @@ Enc28J60Network::receivePacket()
|
||||
// The above does not work. See Rev. B4 Silicon Errata point 6.
|
||||
if (readReg(EPKTCNT) != 0)
|
||||
{
|
||||
uint16_t readPtr = nextPacketPtr+6;
|
||||
uint16_t readPtr = nextPacketPtr+6 > RXSTOP_INIT ? nextPacketPtr+6-RXSTOP_INIT+RXSTART_INIT : nextPacketPtr+6;
|
||||
// Set the read pointer to the start of the received packet
|
||||
writeRegPair(ERDPTL, nextPacketPtr);
|
||||
// read the next packet pointer
|
||||
@@ -168,6 +168,20 @@ Enc28J60Network::receivePacket()
|
||||
// read the receive status (see datasheet page 43)
|
||||
rxstat = readOp(ENC28J60_READ_BUF_MEM, 0);
|
||||
//rxstat |= readOp(ENC28J60_READ_BUF_MEM, 0) << 8;
|
||||
#ifdef ENC28J60DEBUG
|
||||
Serial.print("receivePacket [");
|
||||
Serial.print(readPtr,HEX);
|
||||
Serial.print("-");
|
||||
Serial.print((readPtr+len) % (RXSTOP_INIT+1),HEX);
|
||||
Serial.print("], next: ");
|
||||
Serial.print(nextPacketPtr,HEX);
|
||||
Serial.print(", stat: ");
|
||||
Serial.print(rxstat,HEX);
|
||||
Serial.print(", count: ");
|
||||
Serial.print(readReg(EPKTCNT));
|
||||
Serial.print(" -> ");
|
||||
Serial.println((rxstat & 0x80)!=0 ? "OK" : "failed");
|
||||
#endif
|
||||
// decrement the packet counter indicate we are done with this packet
|
||||
writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC);
|
||||
// check CRC and symbol errors (see datasheet page 44, table 7-3):
|
||||
@@ -215,10 +229,10 @@ Enc28J60Network::sendPacket(memhandle handle)
|
||||
Serial.print("sendPacket(");
|
||||
Serial.print(handle);
|
||||
Serial.print(") [");
|
||||
Serial.print(start);
|
||||
Serial.print(start,HEX);
|
||||
Serial.print("-");
|
||||
Serial.print(end);
|
||||
Serial.println("]:");
|
||||
Serial.print(end,HEX);
|
||||
Serial.print("]: ");
|
||||
for (uint16_t i=start; i<=end; i++)
|
||||
{
|
||||
Serial.print(readByte(i),HEX);
|
||||
@@ -248,8 +262,8 @@ uint16_t
|
||||
Enc28J60Network::setReadPtr(memhandle handle, memaddress position, uint16_t len)
|
||||
{
|
||||
memblock *packet = handle == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[handle];
|
||||
memaddress start = packet->begin + position;
|
||||
|
||||
memaddress start = handle == UIP_RECEIVEBUFFERHANDLE && packet->begin + position > RXSTOP_INIT ? packet->begin + position-RXSTOP_INIT+RXSTART_INIT : packet->begin + position;
|
||||
|
||||
writeRegPair(ERDPTL, start);
|
||||
|
||||
if (len > packet->size - position)
|
||||
@@ -313,7 +327,8 @@ Enc28J60Network::copyPacket(memhandle dest_pkt, memaddress dest_pos, memhandle s
|
||||
{
|
||||
memblock *dest = &blocks[dest_pkt];
|
||||
memblock *src = src_pkt == UIP_RECEIVEBUFFERHANDLE ? &receivePkt : &blocks[src_pkt];
|
||||
enc28J60_mempool_block_move_callback(dest->begin+dest_pos,src->begin+src_pos,len);
|
||||
memaddress start = src_pkt == UIP_RECEIVEBUFFERHANDLE && src->begin + src_pos > RXSTOP_INIT ? src->begin + src_pos-RXSTOP_INIT+RXSTART_INIT : src->begin + src_pos;
|
||||
enc28J60_mempool_block_move_callback(dest->begin+dest_pos,start,len);
|
||||
// Move the RX read pointer to the start of the next received packet
|
||||
// This frees the memory we just read out
|
||||
setERXRDPT();
|
||||
|
||||
Reference in New Issue
Block a user