Datasheet

void main()
{
// set PORTC as input
DDRC = 0;
// set PORTD as output
DDRD = 0xFF;
/*
* starts ENC28J60 with :
* reset bit on PORTB.B4
* CS bit on PORTB.B5
* my MAC & IP address
* full duplex
*/
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2,
_SPI_CLK_LO_LEADING);
Spi_Rd_Ptr = SPI1_Read; //
pass pointer to SPI Read function of used SPI module
SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDU-
PLEX) ; // full duplex, CRC + MAC Unicast + MAC Broadcast filtering
while(1) // do forever
{
/*
* if necessary, test the return value to get error
code
*/
SPI_Ethernet_doPacket() ; // process incoming
Ethernet packets
/*
* add your stuff here if needed
* Spi_Ethernet_doPacket() must be called as often
as possible
* otherwise packets could be lost
*/
}
}
451
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6