Contiki 2.6
|
00001 #include "net/uip.h" 00002 #include "dev/rtl8019dev.h" 00003 00004 /***************************************************************************** 00005 * Module Name: Realtek 8019AS Driver Interface for uIP-AVR Port 00006 * 00007 * Created By: Louis Beaudoin (www.embedded-creations.com) 00008 * 00009 * Original Release: September 21, 2002 00010 * 00011 * Module Description: 00012 * Provides three functions to interface with the Realtek 8019AS driver 00013 * These functions can be called directly from the main uIP control loop 00014 * to send packets from uip_buf and uip_appbuf, and store incoming packets to 00015 * uip_buf 00016 * 00017 * September 30, 2002 - Louis Beaudoin 00018 * Modifications required to handle the packet receive function changes in 00019 * rtl8019.c. There is no longer a need to poll for an empty buffer or 00020 * an overflow. 00021 * Added support for the Imagecraft Compiler 00022 * 00023 *****************************************************************************/ 00024 00025 00026 #define IP_TCP_HEADER_LENGTH 40 00027 #define TOTAL_HEADER_LENGTH (IP_TCP_HEADER_LENGTH+ETHERNET_HEADER_LENGTH) 00028 00029 00030 00031 void RTL8019dev_init(void) 00032 { 00033 initRTL8019(); 00034 } 00035 00036 00037 void RTL8019dev_send(void) 00038 { 00039 RTL8019beginPacketSend(uip_len); 00040 00041 // send packet, using data in uip_appdata if over the IP+TCP header size 00042 if( uip_len <= TOTAL_HEADER_LENGTH ) { 00043 RTL8019sendPacketData(uip_buf, uip_len); 00044 } else { 00045 uip_len -= TOTAL_HEADER_LENGTH; 00046 RTL8019sendPacketData(uip_buf, TOTAL_HEADER_LENGTH); 00047 RTL8019sendPacketData((unsigned char *)uip_appdata, uip_len); 00048 } 00049 00050 RTL8019endPacketSend(); 00051 } 00052 00053 00054 00055 unsigned int RTL8019dev_poll(void) 00056 { 00057 unsigned int packetLength; 00058 00059 packetLength = RTL8019beginPacketRetreive(); 00060 00061 // if there's no packet or an error - exit without ending the operation 00062 if( !packetLength ) 00063 return 0; 00064 00065 // drop anything too big for the buffer 00066 if( packetLength > UIP_BUFSIZE ) 00067 { 00068 RTL8019endPacketRetreive(); 00069 return 0; 00070 } 00071 00072 // copy the packet data into the uIP packet buffer 00073 RTL8019retreivePacketData( uip_buf, packetLength ); 00074 RTL8019endPacketRetreive(); 00075 00076 return packetLength; 00077 } 00078 00079 00080 void RTL8019dev_exit(void) 00081 { 00082 }