Added RAW sockets.

Fork of WIZnetInterface by WIZnet

Revision:
30:3b0481541a06
Parent:
29:c91884bd2713
Child:
31:e49acd942048
--- a/arch/int/W7500x_toe.cpp	Tue Nov 17 06:35:55 2015 +0000
+++ b/arch/int/W7500x_toe.cpp	Tue Dec 19 12:49:35 2017 +0000
@@ -112,6 +112,8 @@
 	Timer t;
 	t.reset();
 	t.start();
+	//timeout_ms=700;
+	//printf("waiting %d\r\n", timeout_ms);
 	while(!is_connected(socket)) {
 		if (t.read_ms() > timeout_ms) {
 			return false;
@@ -141,6 +143,23 @@
 	return false;
 }
 
+// Geminate Changes.
+int WIZnet_Chip::get_DHAR0(int socket)
+{
+	//sreg<uint32_t>(socket, Sn_RCR, 0x0000000);
+	reg_wr<uint32_t>(Sn_RCR, 0x00000008);
+	
+	return( sreg<uint32_t>(socket, Sn_DHAR0));
+}
+
+
+int WIZnet_Chip::get_DHAR1(int socket)
+{
+	return( sreg<uint32_t>(socket, Sn_DHAR1));
+}
+
+// End Changes.
+
 
 bool WIZnet_Chip::is_connected(int socket)
 {
@@ -258,7 +277,7 @@
 }
 
 int WIZnet_Chip::send(int socket, const char * str, int len)
-{
+{	
 	if (socket < 0) {
 		return -1;
 	}
@@ -297,6 +316,47 @@
 	return len;
 }
 
+
+int WIZnet_Chip::sendRaw(int socket, const char * str, int len)
+{	
+	if (socket < 0) {
+		return -1;
+	}
+
+	uint16_t ptr = sreg<uint16_t>(socket, Sn_TX_WR);
+	uint32_t sn_tx_base = W7500x_TXMEM_BASE + (uint32_t)(socket<<18); 
+
+	for(int i=0; i<len; i++)
+		*(volatile uint8_t *)(sn_tx_base + ((ptr+i)&0xFFFF)) = str[i];
+
+	sreg<uint16_t>(socket, Sn_TX_WR, ptr + len);
+	scmd(socket, SEND_MAC);
+
+	uint8_t tmp_Sn_IR;
+	while (( (tmp_Sn_IR = sreg<uint8_t>(socket, Sn_IR)) & INT_SEND_OK) != INT_SEND_OK) {
+		// @Jul.10, 2014 fix contant name, and udp sendto function.
+		switch (sreg<uint8_t>(socket, Sn_SR)) {
+			case SOCK_CLOSED :
+				close(socket);
+				return 0;
+				//break;
+			case SOCK_UDP :
+				// ARP timeout is possible.
+				if ((tmp_Sn_IR & INT_TIMEOUT) == INT_TIMEOUT) {
+					sreg<uint8_t>(socket, Sn_ICR, INT_TIMEOUT);
+					return 0;
+				}
+				break;
+			default :
+				break;
+		}
+	}
+
+	sreg<uint8_t>(socket, Sn_ICR, INT_SEND_OK);
+
+	return len;
+}
+
 int WIZnet_Chip::recv(int socket, char* buf, int len)
 {
 	if (socket < 0) {