This is the Interface library for WIZnet W5500 chip which forked of EthernetInterfaceW5500, WIZnetInterface and WIZ550ioInterface. This library has simple name as "W5500Interface". and can be used for Wiz550io users also.

Dependents:   EvrythngApi Websocket_Ethernet_HelloWorld_W5500 Websocket_Ethernet_W5500 CurrentWeatherData_W5500 ... more

Information

It has EthernetInterface class like official EthernetInterface , but uses Wiznet chip driver codes.

So this library can use only the WIZnet W5500 or WIZ550io users.

This library has referred to many project such as WIZ550ioInterface, WiflyInterface and WIZnet Library.

Thanks all.

Committer:
hjjeon
Date:
Wed Oct 15 06:25:21 2014 +0000
Revision:
9:dfffa4d6f022
Parent:
0:e11e8793c3ce
Child:
10:713b6d2aaefb
Add W5500 register access macro function and defines

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bongjun 0:e11e8793c3ce 1 /* Copyright (C) 2012 mbed.org, MIT License
Bongjun 0:e11e8793c3ce 2 *
Bongjun 0:e11e8793c3ce 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Bongjun 0:e11e8793c3ce 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Bongjun 0:e11e8793c3ce 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Bongjun 0:e11e8793c3ce 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Bongjun 0:e11e8793c3ce 7 * furnished to do so, subject to the following conditions:
Bongjun 0:e11e8793c3ce 8 *
Bongjun 0:e11e8793c3ce 9 * The above copyright notice and this permission notice shall be included in all copies or
Bongjun 0:e11e8793c3ce 10 * substantial portions of the Software.
Bongjun 0:e11e8793c3ce 11 *
Bongjun 0:e11e8793c3ce 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Bongjun 0:e11e8793c3ce 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Bongjun 0:e11e8793c3ce 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Bongjun 0:e11e8793c3ce 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Bongjun 0:e11e8793c3ce 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bongjun 0:e11e8793c3ce 17 */
Bongjun 0:e11e8793c3ce 18 #ifndef SOCKET_H_
Bongjun 0:e11e8793c3ce 19 #define SOCKET_H_
Bongjun 0:e11e8793c3ce 20
Bongjun 0:e11e8793c3ce 21 #include "wiznet.h"
Bongjun 0:e11e8793c3ce 22
Bongjun 0:e11e8793c3ce 23 #define htons(x) __REV16(x)
Bongjun 0:e11e8793c3ce 24 #define ntohs(x) __REV16(x)
Bongjun 0:e11e8793c3ce 25 #define htonl(x) __REV(x)
Bongjun 0:e11e8793c3ce 26 #define ntohl(x) __REV(x)
Bongjun 0:e11e8793c3ce 27
hjjeon 9:dfffa4d6f022 28 #define SOCK_OK 1 ///< Result is OK about socket process.
hjjeon 9:dfffa4d6f022 29 #define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode.
hjjeon 9:dfffa4d6f022 30 #define SOCK_FATAL -1000 ///< Result is fatal error about socket process.
hjjeon 9:dfffa4d6f022 31
hjjeon 9:dfffa4d6f022 32 #define SOCK_ERROR 0
hjjeon 9:dfffa4d6f022 33 #define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number
hjjeon 9:dfffa4d6f022 34 #define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option
hjjeon 9:dfffa4d6f022 35 #define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized
hjjeon 9:dfffa4d6f022 36 #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed.
hjjeon 9:dfffa4d6f022 37 #define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation.
hjjeon 9:dfffa4d6f022 38 #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag
hjjeon 9:dfffa4d6f022 39 #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation.
hjjeon 9:dfffa4d6f022 40 #define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argrument.
hjjeon 9:dfffa4d6f022 41 #define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero
hjjeon 9:dfffa4d6f022 42 #define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address
hjjeon 9:dfffa4d6f022 43 #define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred
hjjeon 9:dfffa4d6f022 44 #define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size.
hjjeon 9:dfffa4d6f022 45 #define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication.
hjjeon 9:dfffa4d6f022 46
hjjeon 9:dfffa4d6f022 47 #define SOCK_ANY_PORT_NUM 0xC000;
hjjeon 9:dfffa4d6f022 48
Bongjun 0:e11e8793c3ce 49 /** Socket file descriptor and select wrapper
Bongjun 0:e11e8793c3ce 50 */
Bongjun 0:e11e8793c3ce 51 class Socket
Bongjun 0:e11e8793c3ce 52 {
Bongjun 0:e11e8793c3ce 53 public:
Bongjun 0:e11e8793c3ce 54 /** Socket
Bongjun 0:e11e8793c3ce 55 */
Bongjun 0:e11e8793c3ce 56 Socket();
Bongjun 0:e11e8793c3ce 57
Bongjun 0:e11e8793c3ce 58 /** Set blocking or non-blocking mode of the socket and a timeout on
Bongjun 0:e11e8793c3ce 59 blocking socket operations
Bongjun 0:e11e8793c3ce 60 \param blocking true for blocking mode, false for non-blocking mode.
Bongjun 0:e11e8793c3ce 61 \param timeout timeout in ms [Default: (1500)ms].
Bongjun 0:e11e8793c3ce 62 */
Bongjun 0:e11e8793c3ce 63 void set_blocking(bool blocking, unsigned int timeout=1500);
Bongjun 0:e11e8793c3ce 64
Bongjun 0:e11e8793c3ce 65 /** Close the socket file descriptor
Bongjun 0:e11e8793c3ce 66 */
Bongjun 0:e11e8793c3ce 67 int close();
Bongjun 0:e11e8793c3ce 68
Bongjun 0:e11e8793c3ce 69 ~Socket();
hjjeon 9:dfffa4d6f022 70
hjjeon 9:dfffa4d6f022 71
Bongjun 0:e11e8793c3ce 72 protected:
Bongjun 0:e11e8793c3ce 73 int _sock_fd;
Bongjun 0:e11e8793c3ce 74 bool _blocking;
Bongjun 0:e11e8793c3ce 75 int _timeout;
Bongjun 0:e11e8793c3ce 76 WIZnet_Chip* eth;
hjjeon 9:dfffa4d6f022 77
hjjeon 9:dfffa4d6f022 78
Bongjun 0:e11e8793c3ce 79 };
Bongjun 0:e11e8793c3ce 80
Bongjun 0:e11e8793c3ce 81
Bongjun 0:e11e8793c3ce 82 #endif /* SOCKET_H_ */