Datasheet

435
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Requires
The appropriate hardware SPI module must be previously initialized.
Global variables :
-
SPI_Ethernet_CS: Chip Select line
- SPI_Ethernet_CS_Direction: Direction of the Chip Select pin
-
SPI_Ethernet_RST: Reset line
-
SPI_Ethernet_RST_Direction: Direction of the Reset pin
must be defined before using this function.
Example
#define SPI_Ethernet_HALFDUPLEX 0
#define SPI_Ethernet_FULLDUPLEX 1
// mE ethernet NIC pinout
sfr sbit SPI_Ethernet_Rst at PORTB.B4;
sfr sbit SPI_Ethernet_CS at PORTB.B5;
sfr sbit SPI_Ethernet_Rst_Direction at DDRB.B4;
sfr sbit SPI_Ethernet_CS_Direction at DDRB.B5;
// end ethernet NIC definitions
unsigned char myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f}
; // my MAC address
unsigned char myIpAddr = {192, 168, 1, 60 } ; // my IP
addr
SPI1_Init();
Spi_Rd_Ptr = SPI1_Read; // pass pointer to SPI Read function
of used SPI module
SPI_Ethernet_Init(&PORTC, 0, &PORTC, 1, myMacAddr, myIpAddr,
SPI_Ethernet_FULLDUPLEX);