Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
477
SPI_Ethernet_24j600_UserUDP
Prototype
unsigned  int  SPI_Ethernet_24j600_UserUDP(unsigned  char  *remoteHost, 
unsigned  int  remotePort,  unsigned  int  destPort,  unsigned  int  reqLength, 
TEthj600PktFlags *flags);
Description This is UDP module routine. It is internally called by the library. The user accesses to the UDP request 
by using some of the SPI_Ethernet_24j600_get routines. The user puts data in the transmit buffer by 
using some of the SPI_Ethernet_24j600_put routines. The function must return the length in bytes of 
the UDP reply, or 0 if nothing to transmit. If you don’t need to reply to the UDP requests, just define this 
function with a return(0) as single statement.
Parameters 
remoteHost
: client’s IP address. 
remotePort
: client’s port. 
localPort
: port to which the request is sent. 
reqLength
: UDP request data field length. 
flags
: structure consisted of two bit fields :  
Copy Code To Clipboard 
typedef struct {
  unsigned canCloseTCP: 1;  // flag which closes TCP socket (not relevant 
to UDP)
  unsigned isBroadcast: 1;  // flag which denotes that the IP package has 
been received via subnet broadcast address
} TEthj600PktFlags;
Returns
0
 - there should not be a reply to the request. 
- Length of UDP reply data field - otherwise. 
Requires
Ethernet module has to be initialized. See SPI_Ethernet_24j600_Init.
Example
This function is internally called by the library and should not be called by the user’s code.
Notes
The function source code is provided with appropriate example projects. The code should be adjusted 
by the user to achieve desired reply.
SPI_Ethernet_24j600_getIpAddress
Prototype
unsigned char * SPI_Ethernet_24j600_getIpAddress();
Description This  routine  should  be  used  when  DHCP  server  is  present  on  the  network  to  fetch  assigned  IP 
address.
Parameters None.
Returns
Pointer to the global variable holding IP address.
Requires
Ethernet module has to be initialized. See SPI_Ethernet_24j600_Init.
Example
unsigned char ipAddr[4];  // user IP address buffer
... 
memcpy(ipAddr, SPI_Ethernet_24j600_getIpAddress(), 4); // fetch IP address
Notes
User should always copy the IP address from the RAM location returned by this routine into it’s own IP 
address buffer. These locations should not be altered by the user in any case!