Menu

ENC28J60

Majenko Technologies

The ENC28J60 is the main ethernet card this library supports.

You create a new ethernet object with:

ENC28J60 myCard(spi,cs);

Where spi is the SPI channel number (1 thru 4) and cs is the digital pin number to use for the chip-select line.

For example, to use SPI bus 1 and chip-select line D10 you would use:

ENC28J60 myCard(1,10);

Now you have a card you need to configure it:

myCard.init(m1,m2,m3,m4,m5,m6);

That will set the card up and configure it with the MAC address m1:m2:m3:m4:m5:m6. For example, to use the MAC address 12:34:56:78:9A:BC you would use:

myCard.init(0x12,0x34,0x56,0x78,0x9A,0xBC);

Now you can assign an IP address:

myCard.setIP(192,168,0,44);

and a netmask:

myCard.setNetmask(255,255,255,0);

Once you have created and configured the card object you have to add it to the network stack:

Network.addInterface(&myCard);

This will activate packet reception on the card.

You can test the status of the network link any time with:

myCard.linkup();

which returns 1 if the link is up, or 0 if it is down.


Related

Wiki: User Interface

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.