📄 rtl8019dev.c
字号:
#include <uip\uip.h>
#include "rtl8019.h"
#include "rtl8019dev.h"
#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();
}
#if UIP_BUFSIZE > 255
unsigned int RTL8019dev_poll(void)
#else
unsigned char RTL8019dev_poll(void)
#endif /* UIP_BUFSIZE > 255 */
{
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();
#if UIP_BUFSIZE > 255
return packetLength;
#else
return (unsigned char)packetLength;
#endif /* UIP_BUFSIZE > 255 */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -