User manual

mikroC PRO for dsPIC
MikroElektronika
511
SPI_Ethernet_confNetwork
SPI_Ethernet_arpResolve
Prototype
void SPI_Ethernet_confNetwork(char *ipMask, char *gwIpAddr, char
*dnsIpAddr);
Description Congures network parameters (IP subnet mask, gateway IP address, DNS IP address) when DHCP
is not used.
Parameters - ipMask: IP subnet mask.
- gwIpAddr gateway IP address.
- dnsIpAddr: DNS IP address.
Returns Nothing.
Requires Ethernet module has to be initialized. See SPI_Ethernet_Init.
Example
char ipMask[4] = {255, 255, 255, 0 }; // network mask (for example :
255.255.255.0)
char gwIpAddr[4] = {192, 168, 1, 1 }; // gateway (router) IP address
char dnsIpAddr[4] = {192, 168, 1, 1 }; // DNS server IP address
...
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr); // set network
conguration parameters
Notes The above mentioned network parameters should be set by this routine only if DHCP module is not
used. Otherwise DHCP will override these settings.
Prototype
unsigned char *SPI_Ethernet_arpResolve(unsigned char *ip, unsigned char
tmax);
Description This is ARP module routine. It sends an ARP request for given IP address and waits for ARP reply. If
the requested IP address was resolved, an ARP cash entry is used for storing the conguration. ARP
cash can store up to 3 entries. For ARP cash structure refer to eth_enc28j60LibDef.hheader
le in the compiler’s Uses folder.
Parameters - ip: IP address to be resolved.
- tmax: time in seconds to wait for an reply.
Returns - MAC address behind the IP address - the requested IP address was resolved.
- 0 - otherwise.
Requires Ethernet module has to be initialized. See SPI_Ethernet_Init.
Example
unsigned char IpAddr[4] = {192, 168, 1, 1 }; // IP address
...
SPI_Ethernet_arpResolve(IpAddr, 5); // get MAC address behind the above IP
address, wait 5 secs for the response
Notes The Ethernet services are not stopped while this routine waits for ARP reply. The incoming packets will
be processed normaly during this time.