Data Sheet
© Copyright 2013 WIZnet Co.,Ltd. All rights reserved.
70
iEthernet
W5200
{
START:
/* sets MAC raw mode with enabling MAC filter */
S0_MR = 0x44;
/* sets OPEN command */
S0_CR = OPEN;
/* wait until Sn_SR is changed to SOCK_MACRAW */
if (Sn_SR != SOCK_MACRAW) S0_CR = CLOSE; goto START;
}
▪If the free size of the internal RX memory is smaller than ‘1528 - Default MTU(1514)+PACKET
INFO(2) + DATA packet(8) + CRC(4)’, close the SOCKET and process all received data. Then
reopen the SOCKET. After closing the SOCKET, the received MACRAW data from closing time
can be lost.
{
/* check the free size of internal RX memory */
if((Sn_RXMEM_SIZE(0) * 1024) - Sn_RX_RSR0(0) < 1528)
{
recved_size = Sn_RX_RSR0(0); /* backup Sn_RX_RSR */
Sn_CR0 = CLOSE; /* SOCKET Closed */
while(Sn_SR != SOCK_CLOSED); /* wait until SOCKET is closed */
/* process all data remained in internal RX memory */
while(recved_size> 0)
{/* calculate offset address */
src_mask = Sn_RX_RD&gSn_RX_MASK; // src_mask is offset address
/* calculate start address(physical address) */
src_ptr = gSn_RX_BASE + src_mask; // src_ptr is physical start address
/* if overflow SOCKET RX memory */
If((src_mask + len) > (gSn_RX_MASK + 1))
{
/* copy upper_size bytes of get_start_address to destination_address */
upper_size = (gSn_RX_MASK + 1) – src_mask;
memcpy(src_ptr, dst_addr, upper_size);
/* update destination_address */
dst_address += upper_size;
/* copy left_size bytes of gSn_RX_BASE to destination_address */
left_size = len – upper_size;
memcpy(src_ptr, dst_addr, left_size);
}