📄 ax88796dev.c
字号:
/*****************************************************************************
* 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
*
*****************************************************************************/
#include "ax88796dev.h"
#define IP_TCP_HEADER_LENGTH 40
#define TOTAL_HEADER_LENGTH (IP_TCP_HEADER_LENGTH+ETHERNET_HEADER_LENGTH)
void ax88796devInit(void)
{
ax88796Init();
}
void ax88796devSend(void)
{
ax88796BeginPacketSend(uip_len);
// send packet, using data in uip_appdata if over the IP+TCP header size
if( uip_len <= TOTAL_HEADER_LENGTH )
{
ax88796SendPacketData(uip_buf, uip_len);
}
else
{
uip_len -= TOTAL_HEADER_LENGTH;
ax88796SendPacketData(uip_buf, TOTAL_HEADER_LENGTH);
ax88796SendPacketData((unsigned char *)uip_appdata, uip_len);
}
ax88796EndPacketSend();
}
#if UIP_BUFSIZE > 255
unsigned int ax88796devPoll(void)
#else
unsigned char ax88796devPoll(void)
#endif /* UIP_BUFSIZE > 255 */
{
unsigned int packetLength;
packetLength = ax88796BeginPacketRetreive();
// 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 )
{
ax88796EndPacketRetreive();
return 0;
}
// copy the packet data into the uIP packet buffer
ax88796RetreivePacketData( uip_buf, packetLength );
ax88796EndPacketRetreive();
#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 + -