44 static byte
readOp(byte op, byte address)
52 uint16_t sendLength = (address & 0x80) ? 3 : 2;
54 ACross::SPI::sendReceive(
selectPin, sendLength, b, 1, b);
62 static void writeOp(byte op, byte address, byte data)
66 ACross::SPI::send(
selectPin, 1, &op, 1, &data);
96 static void writeReg(byte address, uint16_t data)
106 ACross::SPI::sendReceive(
selectPin, 1, &b, len, data);
119 ACross::SPI::send(
selectPin, 1, &b, len, (uint8_t*)data);
146 #if ENABLE_HW_CHECKSUM
149 uint16_t src =
incRxPtr(currentPacketPtr, offset);
159 uint16_t last = len + src - 1;
163 if ((src <= RXSTOP_INIT) && (last > RXSTOP_INIT))
164 last -= (RXSTOP_INIT - RXSTART_INIT);
189 inline uint16_t
incRxPtr(uint16_t ptr, uint16_t len)
192 if (ptr > RXSTOP_INIT + 1)
193 ptr -= (RXSTOP_INIT + 1);
213 uint16_t last= len+ src - 1;
232 if ((src <= RXSTOP_INIT) && (last > RXSTOP_INIT))
233 last -= (RXSTOP_INIT - RXSTART_INIT);
277 writeBuf(TXSTART_INIT_DATA, len, data);
286 static void writePhy(byte address, uint16_t data) {
380 readBuf(
sizeof header, (byte*)&header);
384 if ((header.status & 0x80) != 0)
392 NetworkService::processIncomingPacket();
402 #if (EtherDune_SAMPLE_SIZE < EtherDune_BUFFER_SIZE)
#define ENC28J60_READ_BUF_MEM
#define ENC28J60_BIT_FIELD_CLR
#define ENC28J60_SOFT_RESET
static void moveMem(uint16_t dest, uint16_t src, uint16_t len)
static void writePhy(byte address, uint16_t data)
static byte readRegByte(byte address)
#define ENC28J60_WRITE_CTRL_REG
static byte readByte(uint16_t src)
static uint16_t nextPacketPtr
static void writeOp(byte op, byte address, byte data)
static void writeRegByte(byte address, byte data)
static uint8_t begin(uint8_t cspin)
#define MAX_FRAMELEN
max frame length which the conroller will accept: (note: maximum ethernet frame length would be 1518)...
static EthBuffer packet
in-memory packet buffer currently being processed.
static void enableBroadcast()
#define EtherDune_SAMPLE_SIZE
Minimum amount of bytes to read to decide whether we want the rest of the packet or not...
static void writeByte(byte b)
static void SetBank(byte address)
ACROSS_MODULE("ENC28J60")
uint16_t incRxPtr(uint16_t ptr, uint16_t len)
#define ENC28J60_BIT_FIELD_SET
static void packetSend(uint16_t len)
static bool isLinkUp()
Determines whether the network link is ready
#define ENC28J60_READ_CTRL_REG
static byte readOp(byte op, byte address)
static MACAddress localMAC
Ethernet MAC address.
static uint16_t hardwareChecksumRxOffset(uint16_t offset, uint16_t len)
static uint16_t hardwareChecksum(uint16_t src, uint16_t len)
static uint16_t remainingPacketSize
static void readBuf(uint16_t src, uint16_t len, byte *data)
static void writeReg(byte address, uint16_t data)
static uint16_t readPhyByte(byte address)
static void writeBuf(uint16_t dst, uint16_t len, const byte *data)
#define ENC28J60_WRITE_BUF_MEM
static uint16_t readReg(byte address)