EX0 = 0; switch (func) { case SEL_CONTROL : // socket status information val = IndirectReadByte(SOCK_STATUS(s)); break;
case SEL_SEND : // Calculate send free buffer size k = IndirectReadByte(SHADOW_TXWR_PTR(s)); // Shadow Register needs to be read before reading buffer register wait_1us(2); IndirectReadBuf(TX_WR_PTR(s),(u_char*)&wr_ptr,4);
if( (IndirectReadByte(OPT_PROTOCOL(s)) & 0x07) != SOCK_STREAM) { k = IndirectReadByte(SHADOW_TXRD_PTR(s)); // Shadow Register needs to be read before reading buffer register wait_1us(2); IndirectReadBuf(TX_RD_PTR(s),(u_char*)&ack_ptr,4); } else { k = IndirectReadByte(SHADOW_TXACK_PTR(s)); // Shadow Register needs to be read before reading buffer register wait_1us(2); IndirectReadBuf(TX_ACK_PTR(s),(u_char*)&ack_ptr,4); }
if (wr_ptr.lVal >= ack_ptr.lVal) val = SSIZE - (wr_ptr.lVal - ack_ptr.lVal); else val = SSIZE - (0 - ack_ptr.lVal + wr_ptr.lVal); break; case SEL_RECV : // Calculate received data size k = IndirectReadByte(SHADOW_RXWR_PTR(s)); // Shadow Register needs to be read before reading buffer register wait_1us(2); IndirectReadBuf(RX_WR_PTR(s),(u_char*)&wr_ptr,4);
k = IndirectReadByte(SHADOW_RXRD_PTR(s)); // Shadow Register needs to be read before reading buffer register wait_1us(2); IndirectReadBuf(RX_RD_PTR(s),(u_char*)&rd_ptr,4);
if (wr_ptr.lVal == rd_ptr.lVal){ val = 0;} else if (wr_ptr.lVal > rd_ptr.lVal) val = wr_ptr.lVal - rd_ptr.lVal; else val = 0 - rd_ptr.lVal + wr_ptr.lVal;
文章评论(0条评论)
登录后参与讨论