19.08.2013 Views

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

<strong>AN2120</strong><br />

}<br />

Data+=2;<br />

Sum = (Sum >> 16) + (Sum & 0xFFFF);<br />

Sum += (Sum >> 16);<br />

return (WORD) ~Sum;<br />

UDP.C<br />

User Datagram Pro<strong>to</strong>col Implementation<br />

/*/////////////////////////////////////////////////////////////////////////////<br />

File Name : UDP.c<br />

Author : Rene Trenado<br />

Location : Mo<strong>to</strong>rola Applications Lab, Baja California<br />

Date Created : December 2001<br />

Current Revision : 0.0<br />

Notes : This file contains the code <strong>to</strong> h<strong>an</strong>dle <strong>an</strong>d create UDP tr<strong>an</strong>sport<br />

packets.<br />

//////////////////////////////////////////////////////////////////////////////*/<br />

#include "IP.h"<br />

#include "UDP.h"<br />

#include "Ppp.h"<br />

#define UDP_HEADER_LENGTH 8<br />

Application Note<br />

Code Implementation<br />

static WORD UDPLocalPort = 1080; // Default UDP port (c<strong>an</strong> be set <strong>to</strong> <strong>an</strong>ything)<br />

static void UDPDefaultCallBack (BYTE *data, BYTE size, DWORD RemoteIP, WORD Port);<br />

static UDPCALLBACK UDPCallback = UDPDefaultCallBack;<br />

UDPDatagram *udp_in; // Pointer <strong>to</strong> incoming UDP packet<br />

UDPDatagram *udp_out; // Pointer for output UDP packet<br />

/***********************************************************************<br />

Function : UDPSetCallbackProc<br />

Parameters : Proc: A pointer <strong>to</strong> a function <strong>to</strong> callback each time a UDP/IP<br />

packet is received from the Internet<br />

Date : December 2000<br />

Desc : Sets the callback function <strong>to</strong> call each time a UDP packet is received<br />

over the physical interface<br />

MOTOROLA 81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!