void Enc28J60Network::disableMulticast () { writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_MCEN); }
void Enc28J60Network::enableBroadcast (bool temporary) { writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_BCEN); if(!temporary) broadcast_enabled = true; }
void Enc28J60Network::disableBroadcast (bool temporary) { if(!temporary) broadcast_enabled = false; if(!broadcast_enabled) writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_BCEN); }
/* ======================================================================= */ ENC28J60Driver::ENC28J60Driver(uint8_t* macaddr, uint8_t csPin): EthernetDriver(macaddr){ this->sendBuffer = new ENC28J60Buffer(this,TXSTART_INIT+1, TXSTOP_INIT, MAX_FRAMELEN, 0,false); this->recvBuffer = new ENC28J60Buffer(this,RXSTART_INIT, RXSTOP_INIT, MAX_FRAMELEN, 0,true); this->stashBuffer = new ENC28J60Buffer(this,STASH_START_INIT, STASH_STOP_INIT, STASH_STOP_INIT - STASH_START_INIT +1, 0,false); if (bitRead(SPCR, SPE) == 0) initSPI(); selectPin = csPin; pinMode(selectPin, OUTPUT); disableChip(); writeOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET); delay(2); // errata B7/2 while (!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) ; gNextPacketPtr = RXSTART_INIT; writeReg(ERXST, RXSTART_INIT); writeReg(ERXRDPT, RXSTART_INIT); writeReg(ERXND, RXSTOP_INIT); writeReg(ETXST, TXSTART_INIT); writeReg(ETXND, TXSTOP_INIT); writeRegByte(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN); writeReg(EPMM0, 0x303f); writeReg(EPMCS, 0xf7f9); writeRegByte(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS); writeRegByte(MACON2, 0x00); writeOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN); writeReg(MAIPG, 0x0C12); writeRegByte(MABBIPG, 0x12); writeReg(MAMXFL, MAX_FRAMELEN); writeRegByte(MAADR5, macaddr[0]); writeRegByte(MAADR4, macaddr[1]); writeRegByte(MAADR3, macaddr[2]); writeRegByte(MAADR2, macaddr[3]); writeRegByte(MAADR1, macaddr[4]); writeRegByte(MAADR0, macaddr[5]); writePhy(PHCON2, PHCON2_HDLDIS); SetBank(ECON1); writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE); writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); this->revision = readRegByte(EREVID); // microchip forgot to step the number on the silcon when they // released the revision B7. 6 is now rev B7. We still have // to see what they do when they release B8. At the moment // there is no B8 out yet if (this->revision > 5) this->revision++; }