Import of the contiki-2.x development code from the SICS internal CVS server
This commit is contained in:
commit
c9e808d638
671 changed files with 95332 additions and 0 deletions
77
cpu/avr/dev/rtl8019dev.c
Normal file
77
cpu/avr/dev/rtl8019dev.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
#include "net/uip.h"
|
||||
#include "dev/rtl8019dev.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Module Name: Realtek 8019AS Driver Interface for uIP-AVR Port
|
||||
*
|
||||
* Created By: Louis Beaudoin (www.embedded-creations.com)
|
||||
*
|
||||
* Original Release: September 21, 2002
|
||||
*
|
||||
* Module Description:
|
||||
* Provides three functions to interface with the Realtek 8019AS driver
|
||||
* These functions can be called directly from the main uIP control loop
|
||||
* to send packets from uip_buf and uip_appbuf, and store incoming packets to
|
||||
* uip_buf
|
||||
*
|
||||
* September 30, 2002 - Louis Beaudoin
|
||||
* Modifications required to handle the packet receive function changes in
|
||||
* rtl8019.c. There is no longer a need to poll for an empty buffer or
|
||||
* an overflow.
|
||||
* Added support for the Imagecraft Compiler
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#define IP_TCP_HEADER_LENGTH 40
|
||||
#define TOTAL_HEADER_LENGTH (IP_TCP_HEADER_LENGTH+ETHERNET_HEADER_LENGTH)
|
||||
|
||||
|
||||
|
||||
void RTL8019dev_init(void)
|
||||
{
|
||||
initRTL8019();
|
||||
}
|
||||
|
||||
|
||||
void RTL8019dev_send(void)
|
||||
{
|
||||
RTL8019beginPacketSend(uip_len);
|
||||
|
||||
// send packet, using data in uip_appdata if over the IP+TCP header size
|
||||
if( uip_len <= TOTAL_HEADER_LENGTH ) {
|
||||
RTL8019sendPacketData(uip_buf, uip_len);
|
||||
} else {
|
||||
uip_len -= TOTAL_HEADER_LENGTH;
|
||||
RTL8019sendPacketData(uip_buf, TOTAL_HEADER_LENGTH);
|
||||
RTL8019sendPacketData((unsigned char *)uip_appdata, uip_len);
|
||||
}
|
||||
|
||||
RTL8019endPacketSend();
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int RTL8019dev_poll(void)
|
||||
{
|
||||
unsigned int packetLength;
|
||||
|
||||
packetLength = RTL8019beginPacketRetreive();
|
||||
|
||||
// if there's no packet or an error - exit without ending the operation
|
||||
if( !packetLength )
|
||||
return 0;
|
||||
|
||||
// drop anything too big for the buffer
|
||||
if( packetLength > UIP_BUFSIZE )
|
||||
{
|
||||
RTL8019endPacketRetreive();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// copy the packet data into the uIP packet buffer
|
||||
RTL8019retreivePacketData( uip_buf, packetLength );
|
||||
RTL8019endPacketRetreive();
|
||||
|
||||
return packetLength;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue