Other Parts Discussed in Thread: C2000WARE
Tool/software:
I got Errors that say identifier int8_t is udentified. Anyone knows what to do?
Tool/software:
I got Errors that say identifier int8_t is udentified. Anyone knows what to do?
Hello,
Please note that this C2000 device is 16-bit addressable. Do you have stdint.h included in your project C files? Are you using the type defs native to the CPU?
Best Regards,
Allison
Yes, i do have stdint.h included in all of the c files. I am also using files dedicated to wiz5500io connection (Application.h, wizchip_conf.h, wzichip_conf.c, socket.c, socket.h, w5500.c, w5500.h) downloaded from GitHub as a ioLibrary_Driver-master folder. In the wizchip_conf.h, socket.c and socket.h i have a problem mentioned in the description. I tried using an include option in properties of a project and adding stdint.h in the mentioned C files but it wasn't working.
Hello,
Thanks for following up. Let me review this information and get back to you today.
Best Regards,
Allison
Hello,
To clarify, please make sure that the include path to stdint.h is properly set in your project properties. You need to verify that the compiler can find the correct stdint.h file. Also, is the stdint.h included before the WizNet W5500 library files? If not, try reorganizing your includes to ensure stdint.h is included first at the top of your files.
Other ideas: can you check if there are any conflicting type definitions in other header files that might be interfering with the stdint.h definitions. And what compiler version are you using?
Best Regards,
Allison
I am using TI v22.6.1.LTS compiler version. I had included stdint.h as first at the top of every file, i also checked if the include path to stdint.h is correct and it all seemed fine. There is no any conflicting type definitions. I have no idea what else i can do to get rid of the type definition problem.
Hello,
Can you try to 'ctrl' + 'click' on the int8_t and see the location it takes you? Can you send a snippet of the specific error you are seeing?
Best Regards,
Allison
After clicking 'ctrl' + 'click' it took me to the file called "hw_types.h". Error: #20 identifier "int8_t" is undefined, #20 identifier "uint8_t" is undefined.
Hello,
Can you please send a screen capture of the exact error you are seeing? Are you able to share the relevant code?
Best Regards,
Allison
//***************************************************************************** // //! \file socket.h //! \brief SOCKET APIs Header file. //! \details SOCKET APIs like as berkeley socket api. //! \version 1.0.2 //! \date 2013/10/21 //! \par Revision history //! <2015/02/05> Notice //! The version history is not updated after this point. //! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. //! >> https://github.com/Wiznet/ioLibrary_Driver //! <2014/05/01> V1.0.2. Refer to M20140501 //! 1. Modify the comment : SO_REMAINED -> PACK_REMAINED //! 2. Add the comment as zero byte udp data reception in getsockopt(). //! <2013/10/21> 1st Release //! \author MidnightCow //! \copyright //! //! Copyright (c) 2013, WIZnet Co., LTD. //! All rights reserved. //! //! Redistribution and use in source and binary forms, with or without //! modification, are permitted provided that the following conditions //! are met: //! //! * Redistributions of source code must retain the above copyright //! notice, this list of conditions and the following disclaimer. //! * Redistributions in binary form must reproduce the above copyright //! notice, this list of conditions and the following disclaimer in the //! documentation and/or other materials provided with the distribution. //! * Neither the name of the <ORGANIZATION> nor the names of its //! contributors may be used to endorse or promote products derived //! from this software without specific prior written permission. //! //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF //! THE POSSIBILITY OF SUCH DAMAGE. // //***************************************************************************** /** * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs * @brief WIZnet socket APIs are based on Berkeley socket APIs, thus it has much similar name and interface. * But there is a little bit of difference. * @details * <b> Comparison between WIZnet and Berkeley SOCKET APIs </b> * <table> * <tr> <td><b>API</b></td> <td><b>WIZnet</b></td> <td><b>Berkeley</b></td> </tr> * <tr> <td>socket()</td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>bind()</b></td> <td>X</td> <td>O</td> </tr> * <tr> <td><b>listen()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>connect()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>accept()</b></td> <td>X</td> <td>O</td> </tr> * <tr> <td><b>recv()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>send()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>recvfrom()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>sendto()</b></td> <td>O</td> <td>O</td> </tr> * <tr> <td><b>closesocket()</b></td> <td>O<br>close() & disconnect()</td> <td>O</td> </tr> * </table> * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but, * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number, * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n * When you program "TCP SERVER" with Berkeley SOCKET API, you can use only one listen port. * When the listen SOCKET accepts a connection request from a client, it keeps listening. * After accepting the connection request, a new SOCKET is created and the new SOCKET is used in communication with the client. \n * Following figure shows network flow diagram by Berkeley SOCKET API. * @image html Berkeley_SOCKET.jpg "<Berkeley SOCKET API>" * But, When you program "TCP SERVER" with WIZnet SOCKET API, you can use as many as 8 listen SOCKET with same port number. \n * Because there's no accept() in WIZnet SOCKET APIs, when the listen SOCKET accepts a connection request from a client, * it is changed in order to communicate with the client. * And the changed SOCKET is not listening any more and is dedicated for communicating with the client. \n * If there're many listen SOCKET with same listen port number and a client requests a connection, * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n * Following figure shows network flow diagram by WIZnet SOCKET API. * @image html WIZnet_SOCKET.jpg "<WIZnet SOCKET API>" */ #ifndef _SOCKET_H_ #include <stdint.h> #include <stdbool.h> #define _SOCKET_H_ #ifdef __cplusplus extern "C" { #endif #include "wizchip_conf.h" #define SOCKET uint8_t ///< SOCKET type define for legacy driver #define SOCK_OK 1 ///< Result is OK about socket process. #define SOCK_BUSY 0 ///< Socket is busy on processing the operation. Valid only Non-block IO Mode. #define SOCK_FATAL -1000 ///< Result is fatal error about socket process. #define SOCK_ERROR 0 #define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number #define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option #define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized or SIPR is Zero IP address when Sn_MR_TCP #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. #define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. #define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argument. #define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero #define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address #define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred #define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. #define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. #define SOCKFATAL_PACKLEN (SOCK_FATAL - 1) ///< Invalid packet length. Fatal Error. #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) /* * SOCKET FLAG */ #define SF_ETHER_OWN (Sn_MR_MFEN) ///< In @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet #define SF_IGMP_VER2 (Sn_MR_MC) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE, Select IGMP version 2. #define SF_TCP_NODELAY (Sn_MR_ND) ///< In @ref Sn_MR_TCP, Use to nodelayed ack. #define SF_MULTI_ENABLE (Sn_MR_MULTI) ///< In @ref Sn_MR_UDP, Enable multicast mode. #define Sn_MR2_DHAM (1<<1) #define SF_DHA_MANUAL (Sn_MR2_DHAM) #define Sn_MR2_FARP (1<<0) #define SF_FORCE_ARP (Sn_MR2_FARP) #if _WIZCHIP_ == 5500 #define SF_BROAD_BLOCK (Sn_MR_BCASTB) ///< In @ref Sn_MR_UDP or @ref Sn_MR_MACRAW, Block broadcast packet. Valid only in W5500 #define SF_MULTI_BLOCK (Sn_MR_MMB) ///< In @ref Sn_MR_MACRAW, Block multicast packet. Valid only in W5500 #define SF_IPv6_BLOCK (Sn_MR_MIP6B) ///< In @ref Sn_MR_MACRAW, Block IPv6 packet. Valid only in W5500 #define SF_UNI_BLOCK (Sn_MR_UCASTB) ///< In @ref Sn_MR_UDP with \ref SF_MULTI_ENABLE. Valid only in W5500 #endif //A201505 : For W5300 #if _WIZCHIP_ == 5300 #define SF_TCP_ALIGN 0x02 ///< Valid only \ref Sn_MR_TCP and W5300, refer to \ref Sn_MR_ALIGN #endif #define SF_IO_NONBLOCK 0x01 ///< Socket nonblock io mode. It used parameter in \ref socket(). /* * UDP & MACRAW Packet Infomation */ #define PACK_FIRST 0x80 ///< In Non-TCP packet, It indicates to start receiving a packet. (When W5300, This flag can be applied) #define PACK_REMAINED 0x01 ///< In Non-TCP packet, It indicates to remain a packet to be received. (When W5300, This flag can be applied) #define PACK_COMPLETED 0x00 ///< In Non-TCP packet, It indicates to complete to receive a packet. (When W5300, This flag can be applied) //A20150601 : For Integrating with W5300 #define PACK_FIFOBYTE 0x02 ///< Valid only W5300, It indicate to have read already the Sn_RX_FIFOR. // //teddy 240122 #define PACK_IPv6 (1<<7) ///< It indicates the destination IP address of the received packet is IPv6 or IPv4. #define PACK_IPV6_ALLNODE (PACK_IPv6 | (1<<6)) ///< It indicates the destination IP address of the received packet is allnode multicast(broadcast) address or not. #define PACK_IPV6_MULTI (PACK_IPv6 | (1<<5)) ///< It indicates the destination IP address of the received packet is multicast address or not. #define PACK_IPV6_LLA (PACK_IPv6 | (1<<4)) ///< It indicates the destination IP address of the received packet is lla or gua. #define PACK_NONE (0x00) ///< It indicates no information of a packet #elif ((_WIZCHIP_ == 6100) || (_WIZCHIP_ == 6300)) /* * - @ref Sn_MR_MULTI : Support UDP Multicasting * - @ref Sn_MR_MF : Support MAC Filter Enable * - @ref Sn_MR_BRDB : Broadcast Block * - @ref Sn_MR_FPSH : Force PSH flag * - @ref Sn_MR_ND : No Delay ACK flag * - @ref Sn_MR_MC : IGMP ver2, ver1 * - @ref Sn_MR_SMB : Solicited Multicast Block * - @ref Sn_MR_MMB : IPv4 Multicast block * - @ref Sn_MR_UNIB : Unicast Block * - @ref Sn_MR_MMB6 : IPv6 UDP Multicast Block </b> * - @ref Sn_MR2_DHAM : @ref Sn_MR2_DHAM_AUTO, @ref Sn_MR2_DHAM_MANUAL * - @ref Sn_MR_FARP */ /* * SOCKET FLAG */ /** * @brief In UDP mode such as @ref Sn_MR_UDP4 and @ref Sn_MR_UDP6, @ref Sn_MR_UDP6, Enable multicast mode. When @ref Sn_MR_UDP6, Enable only IPv6 Multicating. */ #define SF_MULTI_ENABLE (Sn_MR_MULTI) #define SF_ETHER_OWN (Sn_MR_MF) ///< In MACRAW mode such as @ref Sn_MR_MACRAW, Receive only the packet as broadcast, multicast and own packet /** * @brief In UDP mode such as @ref Sn_MR_UDP4, @ref Sn_MR_UDP6 and @ref Sn_MR_UDPD, or In MACRAW mode sucha as @ref Sn_MR_MACRAW, Block a broadcast packet. */ #define SF_BROAD_BLOCK (Sn_MR_BRDB) #define SF_TCP_FPSH (Sn_MR_FPSH) ///< In TCP mode such as @ref Sn_MR_TCP4, @ref Sn_MR_TCP6 and @ref Sn_MR_TCPD, Use to forced push flag. #define SF_TCP_NODELAY (Sn_MR_ND) ///< In TCP mode such as @ref Sn_MR_TCP4, @ref Sn_MR_TCP6 and @ref Sn_MR_TCPD, Use to nodelayed ack. #define SF_IGMP_VER2 (Sn_MR_MC) ///< In UDP mode such as @ref Sn_MR_UDP4 with @ref SF_MULTI_ENABLE, Select IGMP version 2. #define SF_SOLICIT_BLOCK (Sn_MR_SMB) ///< In UDP mode such as @ref Sn_MR_UDP6 and @ref Sn_MR_UDPD, Block a solicited mutlicast packet. #define SF_ETHER_MULTI4B (Sn_MR_MMB4) ///< In MACRAW mode such as @ref Sn_MR_MACRAW with @ref SF_MULTI_ENABLE, Block a IPv4 multicast packet. #define SF_UNI_BLOCK (Sn_MR_UNIB) ///< In UDP mdoe such as @ref Sn_MR_UDP4, @ref Sn_MR_UDP6 and @ref Sn_MR_UDPD with @ref SF_MULTI_ENABLE, Block a unicast packet. #define SF_ETHER_MULIT6B (Sn_MR_MMB6) ///< In MACRAW mode such as @ref Sn_MR_MACRAW with @ref SF_MULTI_ENABLE, Block a IPv6 multicast packet. /** * @brief Force to APR. * @details In datagram mode such as @ref Sn_MR_IPRAW4, @ref Sn_MR_IPRAW6, @ref Sn_MR_UDP4, @ref Sn_MR_UDP6, and @ref Sn_MR_UDPD, * Force to request ARP before a packet is sent to a destination.\n * In TCP mode such as @ref Sn_MR_TCP4, @ref Sn_MR_TCP6, and @ref Sn_MR_TCPD and <b>TCP SERVER</b> operation mode, * Force to request ARP before SYN/ACK packet is sent to a <b>TCP CLIENT</b>. \n * When @ref SF_DHA_MANUAL is set, the ARP is process but the destination hardware address is fixed by user. */ #define SF_FORCE_ARP (Sn_MR2_FARP) /** * @brief The destination hardware address of packet to be transmitted is set by user through @ref _Sn_DHAR_. It is invalid in MACRAW mode such as @ref Sn_MR_MACRAW. */ #define SF_DHA_MANUAL (Sn_MR2_DHAM) #define SF_IO_NONBLOCK (0x01 << 3) ///< Socket nonblock io mode. It used parameter in @ref socket(). /* * UDP, IPRAW, MACRAW Packet Infomation */ #define PACK_IPv6 (1<<7) ///< It indicates the destination IP address of the received packet is IPv6 or IPv4. #define PACK_IPV6_ALLNODE (PACK_IPv6 | (1<<6)) ///< It indicates the destination IP address of the received packet is allnode multicast(broadcast) address or not. #define PACK_IPV6_MULTI (PACK_IPv6 | (1<<5)) ///< It indicates the destination IP address of the received packet is multicast address or not. #define PACK_IPV6_LLA (PACK_IPv6 | (1<<4)) ///< It indicates the destination IP address of the received packet is lla or gua. #define PACK_COMPLETED (1<<3) ///< It indicates the read data is last in the received packet. #define PACK_REMAINED (1<<2) ///< It indicates to remain data in the received packet #define PACK_FIRST (1<<1) ///< It indicates the read data is first in the received packet. #define PACK_NONE (0x00) ///< It indicates no information of a packet #define SRCV6_PREFER_AUTO (PSR_AUTO) ///< Soruce IPv6 address is preferred to auto-selection. Refer to @ref _Sn_PSR_ #define SRCV6_PREFER_LLA (PSR_LLA) ///< Soruce IPv6 address is preferred to link local address. Refer to @ref _Sn_PSR_ #define SRCV6_PREFER_GUA (PSR_GUA) ///< Soruce IPv6 address is preferred to global unique address. Refer to @ref _Sn_PSR_ #define TCPSOCK_MODE (Sn_ESR_TCPM) ///< It indicates the IP version when SOCKETn is opened as TCP6 or TCPD mode.(0 - IPv4 , 1 - IPv6) #define TCPSOCK_OP (Sn_ESR_TCPOP) ///< It indicates the operation mode when SOCKETn is connected.(0 - <b>TCP CLIENT</b> , 1 - <b>TCP SERVER</b>) #define TCPSOCK_SIP (Sn_ESR_IP6T) ///< It indicates the source ip address type when SOCKET is connected. (0 - Link Local, 1 - Global Unique) ///////////////////////////// // SOCKET CONTROL & OPTION // ///////////////////////////// #define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). #define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). #endif /** * @ingroup WIZnet_socket_APIs * @brief Open a socket. * @details Initializes the socket with 'sn' passed as parameter and open. * * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * @param protocol Protocol type to operate such as TCP, UDP and MACRAW. * @param port Port number to be bined. * @param flag Socket flags as \ref SF_ETHER_OWN, \ref SF_IGMP_VER2, \ref SF_TCP_NODELAY, \ref SF_MULTI_ENABLE, \ref SF_IO_NONBLOCK and so on.\n * Valid flags only in W5500 : @ref SF_BROAD_BLOCK, @ref SF_MULTI_BLOCK, @ref SF_IPv6_BLOCK, and @ref SF_UNI_BLOCK. * @sa Sn_MR * * @return @b Success : The socket number @b 'sn' passed as parameter\n * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n * @ref SOCKERR_SOCKMODE - Not support socket mode as TCP, UDP, and so on. \n * @ref SOCKERR_SOCKFLAG - Invaild socket flag. */ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag); /** * @ingroup WIZnet_socket_APIs * @brief Close a socket. * @details It closes the socket with @b'sn' passed as parameter. * * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * * @return @b Success : @ref SOCK_OK \n * @b Fail : @ref SOCKERR_SOCKNUM - Invalid socket number */ int8_t close(uint8_t sn); /** * @ingroup WIZnet_socket_APIs * @brief Listen to a connection request from a client. * @details It is listening to a connection request from a client. * If connection request is accepted successfully, the connection is established. Socket sn is used in passive(server) mode. * * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * @return @b Success : @ref SOCK_OK \n * @b Fail :\n @ref SOCKERR_SOCKINIT - Socket is not initialized \n * @ref SOCKERR_SOCKCLOSED - Socket closed unexpectedly. */ int8_t listen(uint8_t sn); //teddy 240122 /** * @ingroup WIZnet_socket_APIs * @brief Try to connect to a <b>TCP SERVER</b>. * @details It sends a connection-reqeust message to the server with destination IP address and port number passed as parameter.\n * SOCKET <i>sn</i> is used as active(<b>TCP CLIENT</b>) mode. * @param sn SOCKET number. It should be <b>0 ~ @ref _WIZCHIP_SOCK_NUM_</b>. * @param addr Pointer variable of destination IPv6 or IPv4 address. * @param port Destination port number. * @param addrlen the length of <i>addr</i>. \n <- removed * If addr is IPv6 address it should be 16,else if addr is IPv4 address it should be 4. Otherwize, return @ref SOCKERR_IPINVALID. * @return Success : @ref SOCK_OK \n * Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number\n * @ref SOCKERR_SOCKMODE - Invalid socket mode\n * @ref SOCKERR_SOCKINIT - Socket is not initialized\n * @ref SOCKERR_IPINVALID - Wrong server IP address\n * @ref SOCKERR_PORTZERO - Server port zero\n * @ref SOCKERR_TIMEOUT - Timeout occurred during request connection\n * @ref SOCK_BUSY - In non-block io mode, it returns immediately\n * @note It is valid only in TCP client mode. \n * In block io mode, it does not return until connection is completed. \n * In Non-block io mode(@ref SF_IO_NONBLOCK), it returns @ref SOCK_BUSY immediately. */ static int8_t connect_IO_6(uint8_t sn, uint8_t * addr, uint16_t port, uint8_t addrlen ); //int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port, uint8_t addrlen); /** * @ingroup WIZnet_socket_APIs * @brief Try to disconnect a connection socket. * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client. * @note It is valid only in TCP server or client mode. \n * In block io mode, it does not return until disconnection is completed. \n * In Non-block io mode, it return @ref SOCK_BUSY immediately. \n * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * @return @b Success : @ref SOCK_OK \n * @b Fail :\n @ref SOCKERR_SOCKNUM - Invalid socket number \n * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n * @ref SOCKERR_TIMEOUT - Timeout occurred \n * @ref SOCK_BUSY - Socket is busy. */ int8_t disconnect(uint8_t sn); /** * @ingroup WIZnet_socket_APIs * @brief Send data to the connected peer in TCP socket. * @details It is used to send outgoing data to the connected socket. * @note It is valid only in TCP server or client mode. It can't send data greater than socket buffer size. \n * In block io mode, It doesn't return until data send is completed - socket buffer size is greater than data. \n * In non-block io mode, It return @ref SOCK_BUSY immediately when socket buffer is not enough. \n * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * @param buf Pointer buffer containing data to be sent. * @param len The byte length of data in buf. * @return @b Success : The sent data size \n * @b Fail : \n @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n * @ref SOCKERR_TIMEOUT - Timeout occurred \n * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n * @ref SOCKERR_SOCKNUM - Invalid socket number \n * @ref SOCKERR_DATALEN - zero data length \n * @ref SOCK_BUSY - Socket is busy. */ int32_t send(uint8_t sn, uint8_t * buf, uint16_t len); /** * @ingroup WIZnet_socket_APIs * @brief Receive data from the connected peer. * @details It is used to read incoming data from the connected socket.\n * It waits for data as much as the application wants to receive. * @note It is valid only in TCP server or client mode. It can't receive data greater than socket buffer size. \n * In block io mode, it doesn't return until data reception is completed - data is filled as <I>len</I> in socket buffer. \n * In non-block io mode, it return @ref SOCK_BUSY immediately when <I>len</I> is greater than data size in socket buffer. \n * * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>. * @param buf Pointer buffer to read incoming data. * @param len The max data length of data in buf. * @return @b Success : The real received data size \n * @b Fail :\n * @ref SOCKERR_SOCKSTATUS - Invalid socket status for socket operation \n * @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n * @ref SOCKERR_SOCKNUM - Invalid socket number \n * @ref SOCKERR_DATALEN - zero data length \n * @ref SOCK_BUSY - Socket is busy. */ int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len); /** * @ingroup WIZnet_socket_APIs * @brief Send datagram to the peer specifed by destination IP address and port number passed as parameter. * @details It sends datagram data by using UDP,IPRAW, or MACRAW mode SOCKET. * @param sn SOCKET number. It should be <b>0 ~ @ref _WIZCHIP_SOCK_NUM_</b>. * @param buf Pointer of data buffer to be sent. * @param len The byte length of data in buf. * @param addr Pointer variable of destination IPv6 or IPv4 address. * @param port Destination port number. * @param addrlen the length of <i>addr</i>. \n * If addr is IPv6 address it should be 16,else if addr is IPv4 address it should be 4. Otherwize, return @ref SOCKERR_IPINVALID. * @return Success : The real sent data size. It may be equal to <i>len</i> or small.\n * Fail :\n @ref SOCKERR_SOCKNUM - Invalid SOCKET number \n * @ref SOCKERR_SOCKMODE - Invalid operation in the SOCKET \n * @ref SOCKERR_SOCKSTATUS - Invalid SOCKET status for SOCKET operation \n * @ref SOCKERR_IPINVALID - Invalid IP address\n * @ref SOCKERR_PORTZERO - Destination port number is zero\n * @ref SOCKERR_DATALEN - Invalid data length \n * @ref SOCKERR_SOCKCLOSED - SOCKET unexpectedly closed \n * @ref SOCKERR_TIMEOUT - Timeout occurred \n * @ref SOCK_BUSY - SOCKET is busy. * @note It is valid only in @ref Sn_MR_UDP4, @ref Sn_MR_UDP6, @ref Sn_MR_UDPD, @ref Sn_MR_IPRAW4, @ref Sn_MR_IPRAW6, and @ref Sn_MR_MACRAW. \n * In UDP mode, It can send data as many as SOCKET RX buffer size if data is greater than SOCKET TX buffer size. \n * In IPRAW and MACRAW mode, It should send data as many as MTU(maxium transmission unit) if data is greater than MTU. That is, <i>len</i> can't exceed to MTU. * In block io mode, It doesn't return until data send is completed. * In non-block io mode(@ref SF_IO_NONBLOCK), It return @ref SOCK_BUSY immediately when SOCKET transimttable buffer size is not enough. */ //int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port, uint8_t addrlen); static int32_t sendto_IO_6(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port, uint8_t addrlen); /** * @ingroup WIZnet_socket_APIs * @brief Receive datagram from a peer * @details It can read a data received from a peer by using UDP, IPRAW, or MACRAW mode SOCKET. * @param sn SOCKET number. It should be <b>0 ~ @ref _WIZCHIP_SOCK_NUM_</b>. * @param buf Pointer buffer to be saved the received data. * @param len The max read data length. \n * When the received packet size <= <i>len</i>, it can read data as many as the packet size. \n * When others, it can read data as many as len and remain to the rest data of the packet. * @param addr Pointer variable of destination IP address.\n * It is valid only when @ref recvfrom() is first called for receiving the datagram packet. * You can check it valid or not through @ref PACK_FIRST. You can get it through @ref getsockopt(sn, @ref SO_PACKINFO, &packinfo).\n * In UDP4, IPRAW mode SOCKET, it should be allocated over 4bytes. \n * In UDP6, UDPD mode SOCKET, it should be allocated over 16bytes. * @param port Pointer variable of destination port number. \n * It is valid only when @ref recvfrom() is first called for receiving the datagram packet, same as <i>port</i> case. * @param addrlen The byte length of destination IP address. \n * It is valid only when @ref recvfrom() is first called for receiving the datagram packet, same as <i>port</i> case.\n * When the destination has a IPv4 address, it is set to 4. \n * when the destination has a IPv6 address, it is set to 16. * @return Success : The real received data size. It may be equal to <i>len</i> or small.\n * Fail : @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n * @ref SOCKERR_SOCKNUM - Invalid socket number \n * @ref SOCKERR_ARG - Invalid parameter such as <i>addr</i>, <i>port</i> * @ref SOCK_BUSY - SOCKET is busy. * @note It is valid only in @ref Sn_MR_UDP4, @ref Sn_MR_UDP6, @ref Sn_MR_UDPD, @ref Sn_MR_IPRAW4, @ref Sn_MR_IPRAW6, and @ref Sn_MR_MACRAW. \n * When SOCKET is opened with @ref Sn_MR_MACRAW or When it reads the the remained data of the previous datagram packet, * the parameters such as <i>addr</i>, <i>port</i>, <i>addrlen</i> is ignored. \n * Also, It can read data as many as the received datagram packet size if <i>len</i> is greater than the datagram packet size. \n * In block io mode, it doesn't return until data reception is completed. that is, it waits until any datagram packet is received in SOCKET RX buffer. \n * In non-block io mode(@ref SF_IO_NONBLOCK), it return @ref SOCK_BUSY immediately when SOCKET RX buffer is empty. \n */ //int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port, uint8_t *addrlen); static int32_t recvfrom_IO_6(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port ,uint8_t *addrlen); ///////////////////////////// // SOCKET CONTROL & OPTION // ///////////////////////////// #define SOCK_IO_BLOCK 0 ///< Socket Block IO Mode in @ref setsockopt(). #define SOCK_IO_NONBLOCK 1 ///< Socket Non-block IO Mode in @ref setsockopt(). /** * @defgroup DATA_TYPE DATA TYPE */ /** * @ingroup DATA_TYPE * @brief The kind of Socket Interrupt. * @sa Sn_IR, Sn_IMR, setSn_IR(), getSn_IR(), setSn_IMR(), getSn_IMR() */ typedef enum { SIK_CONNECTED = (1 << 0), ///< connected SIK_DISCONNECTED = (1 << 1), ///< disconnected SIK_RECEIVED = (1 << 2), ///< data received SIK_TIMEOUT = (1 << 3), ///< timeout occurred SIK_SENT = (1 << 4), ///< send ok //M20150410 : Remove the comma of last member //SIK_ALL = 0x1F, ///< all interrupt SIK_ALL = 0x1F ///< all interrupt }sockint_kind; /** * @ingroup DATA_TYPE * @brief The type of @ref ctlsocket(). */ typedef enum { CS_SET_IOMODE, ///< set socket IO mode with @ref SOCK_IO_BLOCK or @ref SOCK_IO_NONBLOCK CS_GET_IOMODE, ///< get socket IO mode CS_GET_MAXTXBUF, ///< get the size of socket buffer allocated in TX memory CS_GET_MAXRXBUF, ///< get the size of socket buffer allocated in RX memory CS_CLR_INTERRUPT, ///< clear the interrupt of socket with @ref sockint_kind CS_GET_INTERRUPT, ///< get the socket interrupt. refer to @ref sockint_kind //teddy 240122 //#if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 CS_SET_PREFER, ///< set the preferred source IPv6 address of transmission packet.\n Refer to @ref SRCV6_PREFER_AUTO, @ref SRCV6_PREFER_LLA and @ref SRCV6_PREFER_GUA. CS_GET_PREFER, ///< get the preferred source IPv6 address of transmission packet.\n Refer to @ref SRCV6_PREFER_AUTO, @ref SRCV6_PREFER_LLA and @ref SRCV6_PREFER_GUA. //#endif #if _WIZCHIP_ >= 5100 CS_SET_INTMASK, ///< set the interrupt mask of socket with @ref sockint_kind, Not supported in W5100 CS_GET_INTMASK ///< get the masked interrupt of socket. refer to @ref sockint_kind, Not supported in W5100 #endif }ctlsock_type; /** * @ingroup DATA_TYPE * @brief The type of socket option in @ref setsockopt() or @ref getsockopt() */ typedef enum { SO_FLAG, ///< Valid only in getsockopt(), For set flag of socket refer to <I>flag</I> in @ref socket(). SO_TTL, ///< Set TTL. @ref Sn_TTL ( @ref setSn_TTL(), @ref getSn_TTL() ) SO_TOS, ///< Set TOS. @ref Sn_TOS ( @ref setSn_TOS(), @ref getSn_TOS() ) SO_MSS, ///< Set MSS. @ref Sn_MSSR ( @ref setSn_MSSR(), @ref getSn_MSSR() ) SO_DESTIP, ///< Set the destination IP address. @ref Sn_DIPR ( @ref setSn_DIPR(), @ref getSn_DIPR() ) SO_DESTPORT, ///< Set the destination Port number. @ref Sn_DPORT ( @ref setSn_DPORT(), @ref getSn_DPORT() ) #if _WIZCHIP_ != 5100 SO_KEEPALIVESEND, ///< Valid only in setsockopt. Manually send keep-alive packet in TCP mode, Not supported in W5100 #if !( (_WIZCHIP_ == 5100) || (_WIZCHIP_ == 5200) ) SO_KEEPALIVEAUTO, ///< Set/Get keep-alive auto transmission timer in TCP mode, Not supported in W5100, W5200 #endif #endif SO_SENDBUF, ///< Valid only in getsockopt. Get the free data size of Socekt TX buffer. @ref Sn_TX_FSR, @ref getSn_TX_FSR() SO_RECVBUF, ///< Valid only in getsockopt. Get the received data size in socket RX buffer. @ref Sn_RX_RSR, @ref getSn_RX_RSR() SO_STATUS, ///< Valid only in getsockopt. Get the socket status. @ref Sn_SR, @ref getSn_SR() //teddy 240122 //#if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 SO_EXTSTATUS, ///< Valid only in @ref getsockopt(). Get the extended TCP SOCKETn status. @ref getSn_ESR() SO_MODE, //#endif SO_REMAINSIZE, ///< Valid only in getsockopt. Get the remained packet size in other then TCP mode. SO_PACKINFO ///< Valid only in getsockopt. Get the packet information as @ref PACK_FIRST, @ref PACK_REMAINED, and @ref PACK_COMPLETED in other then TCP mode. }sockopt_type; /** * @ingroup WIZnet_socket_APIs * @brief Control socket. * @details Control IO mode, Interrupt & Mask of socket and get the socket buffer information. * Refer to @ref ctlsock_type. * @param sn socket number * @param cstype type of control socket. refer to @ref ctlsock_type. * @param arg Data type and value is determined according to @ref ctlsock_type. \n * <table> * <tr> <td> @b cstype </td> <td> @b data type</td><td>@b value</td></tr> * <tr> <td> @ref CS_SET_IOMODE \n @ref CS_GET_IOMODE </td> <td> uint8_t </td><td>@ref SOCK_IO_BLOCK @ref SOCK_IO_NONBLOCK</td></tr> * <tr> <td> @ref CS_GET_MAXTXBUF \n @ref CS_GET_MAXRXBUF </td> <td> uint16_t </td><td> 0 ~ 16K </td></tr> * <tr> <td> @ref CS_CLR_INTERRUPT \n @ref CS_GET_INTERRUPT \n @ref CS_SET_INTMASK \n @ref CS_GET_INTMASK </td> <td> @ref sockint_kind </td><td> @ref SIK_CONNECTED, etc. </td></tr> * </table> * @return @b Success @ref SOCK_OK \n * @b fail @ref SOCKERR_ARG - Invalid argument\n */ int8_t ctlsocket(uint8_t sn, ctlsock_type cstype, void* arg); /** * @ingroup WIZnet_socket_APIs * @brief set socket options * @details Set socket option like as TTL, MSS, TOS, and so on. Refer to @ref sockopt_type. * * @param sn socket number * @param sotype socket option type. refer to @ref sockopt_type * @param arg Data type and value is determined according to <I>sotype</I>. \n * <table> * <tr> <td> @b sotype </td> <td> @b data type</td><td>@b value</td></tr> * <tr> <td> @ref SO_TTL </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> * <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> * <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr> * <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr> * <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> * <tr> <td> @ref SO_KEEPALIVESEND </td> <td> null </td><td> null </td></tr> * <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr> * </table> * @return * - @b Success : @ref SOCK_OK \n * - @b Fail * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n * - @ref SOCKERR_TIMEOUT - Timeout occurred when sending keep-alive packet \n */ int8_t setsockopt(uint8_t sn, sockopt_type sotype, void* arg); /** * @ingroup WIZnet_socket_APIs * @brief get socket options * @details Get socket option like as FLAG, TTL, MSS, and so on. Refer to @ref sockopt_type * @param sn socket number * @param sotype socket option type. refer to @ref sockopt_type * @param arg Data type and value is determined according to <I>sotype</I>. \n * <table> * <tr> <td> @b sotype </td> <td>@b data type</td><td>@b value</td></tr> * <tr> <td> @ref SO_FLAG </td> <td> uint8_t </td><td> @ref SF_ETHER_OWN, etc... </td> </tr> * <tr> <td> @ref SO_TOS </td> <td> uint8_t </td><td> 0 ~ 255 </td> </tr> * <tr> <td> @ref SO_MSS </td> <td> uint16_t </td><td> 0 ~ 65535 </td> </tr> * <tr> <td> @ref SO_DESTIP </td> <td> uint8_t[4] </td><td> </td></tr> * <tr> <td> @ref SO_DESTPORT </td> <td> uint16_t </td><td> </td></tr> * <tr> <td> @ref SO_KEEPALIVEAUTO </td> <td> uint8_t </td><td> 0 ~ 255 </td></tr> * <tr> <td> @ref SO_SENDBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> * <tr> <td> @ref SO_RECVBUF </td> <td> uint16_t </td><td> 0 ~ 65535 </td></tr> * <tr> <td> @ref SO_STATUS </td> <td> uint8_t </td><td> @ref SOCK_ESTABLISHED, etc.. </td></tr> * <tr> <td> @ref SO_REMAINSIZE </td> <td> uint16_t </td><td> 0~ 65535 </td></tr> * <tr> <td> @ref SO_PACKINFO </td> <td> uint8_t </td><td> @ref PACK_FIRST, etc... </td></tr> * </table> * @return * - @b Success : @ref SOCK_OK \n * - @b Fail * - @ref SOCKERR_SOCKNUM - Invalid Socket number \n * - @ref SOCKERR_SOCKOPT - Invalid socket option or its value \n * - @ref SOCKERR_SOCKMODE - Invalid socket mode \n * @note * The option as PACK_REMAINED and SO_PACKINFO is valid only in NON-TCP mode and after call @ref recvfrom(). \n * When SO_PACKINFO value is PACK_FIRST and the return value of recvfrom() is zero, * This means the zero byte UDP data(UDP Header only) received. */ int8_t getsockopt(uint8_t sn, sockopt_type sotype, void* arg); //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 /** * @ingroup WIZnet_socket_APIs * @brief Peeks a sub-message in SOCKETn RX buffer * @details It peeks the incoming message of SOCKETn RX buffer. \n * It can find the specified sub-message in the incoming message and * return the length of incoming message before the sub-message. \n * It is useful when you need to read each messages from multiple message in SOCKET RX buffer. * @param sn SOCKET number * @param submsg sub-message pointer to find * @param subsize the length of <i>submsg</i> * @return * - Success : the length of incoming message length before the <i>submsg</i> \n * - Fail : -1 * @note * It is just return the length of incoming message before the found sub-message. It does not receive the message.\n * So, after calling peeksockmsg, @ref _Sn_RX_RD_ is not changed. */ int16_t peeksockmsg(uint8_t sn, uint8_t* submsg, uint16_t subsize); #endif // void setAddrlen_W6x00( uint8_t num) ; // uint8_t checkAddrlen_W6x00() ; // void inline_setAddrlen_W6x00( uint8_t num); // uint8_t inline_CheckAddrlen_W6x00( void ); #if 1 // by_Lihan /** * @ingroup WIZnet_socket_APIs * @brief by_Lihan_W5x00 */ int8_t connect_W5x00(uint8_t sn, uint8_t * addr, uint16_t port ); /** * @ingroup WIZnet_socket_APIs * @brief by_Lihan_Wx00 */ int8_t connect_W6x00(uint8_t sn , uint8_t * addr, uint16_t port,uint8_t addrlen ); #define GET_MACRO_connect(_1, _2, _3, _4, NAME, ...) NAME #define CHOOSE_TESTCODE_MACRO(...) GET_MACRO_connect(__VA_ARGS__, connect_4, connect_3) /** // by_LIhan for overroading // NOTE_LIHAN: Some sections of this code are not yet fully defined. * @note * In case of get 3 arguments - int8_t connect_W5x00(uint8_t sn, uint8_t * addr, uint16_t port );\n * In case of get 4 arguments - int8_t connect_W6x00(uint8_t sn, uint8_t * addr, uint16_t port, uint8_t addrlen ); */ #define connect(...) CHOOSE_TESTCODE_MACRO(__VA_ARGS__)(__VA_ARGS__) // In case of get 3 arguments #define connect_3(sn , addr , port ) connect_W5x00(sn , addr , port) // In case of get 4 arguments #define connect_4(sn , addr , port, addrlen ) connect_W6x00(sn , addr , port,addrlen) /** * @ingroup WIZnet_socket_APIs * @brief by_Lihan */ int32_t sendto_W5x00(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port ); /** * @ingroup WIZnet_socket_APIs * @brief by_Lihan */ int32_t sendto_W6x00(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port,uint8_t addrlen ); #define GET_MACRO_sendto(_1, _2, _3, _4, _5 , _6, NAME, ...) NAME #define CHOOSE_sendto_MACRO(...) GET_MACRO_sendto(__VA_ARGS__, sendto_6, sendto_5) // by_LIhan for overroading // NOTE_LIHAN: Some sections of this code are not yet fully defined. // In case of get 3 arguments - int8_t sendto_W5x00(uint8_t sn, uint8_t * addr, uint16_t port ); // In case of get 4 arguments - int8_t sendto_W6x00(uint8_t sn, uint8_t * addr, uint16_t port,uint8_t addrlen ); #define sendto(...) CHOOSE_sendto_MACRO(__VA_ARGS__)(__VA_ARGS__) // In case of get 3 arguments #define sendto_5( sn, buf, len, addr, port ) sendto_W5x00( sn, buf, len, addr, port) // In case of get 4 arguments #define sendto_6( sn, buf, len, addr, port, addrlen ) sendto_W6x00( sn, buf, len, addr, port, addrlen) /** * @ingroup WIZnet_socket_APIs * @brief byLihan_W5x00 */ int32_t recvfrom_W5x00(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); /** * @ingroup WIZnet_socket_APIs * @brief byLihan_Wx00 */ int32_t recvfrom_W6x00(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port, uint8_t *addrlen ); #define GET_MACRO_recvfrom(_1, _2, _3, _4, _5, _6 ,NAME, ...) NAME #define CHOOSE_recvfrom_MACRO(...) GET_MACRO_recvfrom(__VA_ARGS__, recvfrom_6, recvfrom_5) // by_LIhanfor overroading // In case of get 3 arguments - int8_t recvfrom_W5x00(uint8_t sn, uint8_t * addr, uint16_t port ); // In case of get 4 arguments - int8_t recvfrom_W6x00(uint8_t sn, uint8_t * addr, uint16_t port,uint8_t addrlen ); #define recvfrom(...) CHOOSE_recvfrom_MACRO(__VA_ARGS__)(__VA_ARGS__) // In case of get 3 arguments #define recvfrom_5(sn, buf, len, addr, port ) recvfrom_W5x00(sn, buf, len, addr, port) // In case of get 4 arguments #define recvfrom_6(sn, buf, len, addr, port, addrlen ) recvfrom_W6x00(sn, buf, len, addr, port, addrlen ) #endif #ifdef __cplusplus } #endif #endif // _SOCKET_H_
//***************************************************************************** // //! \file wizchip_conf.h //! \brief WIZCHIP Config Header File. //! \version 1.0.0 //! \date 2013/10/21 //! \par Revision history //! <2015/02/05> Notice //! The version history is not updated after this point. //! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. //! >> https://github.com/Wiznet/ioLibrary_Driver //! <2013/10/21> 1st Release //! \author MidnightCow //! \copyright //! //! Copyright (c) 2013, WIZnet Co., LTD. //! All rights reserved. //! //! Redistribution and use in source and binary forms, with or without //! modification, are permitted provided that the following conditions //! are met: //! //! * Redistributions of source code must retain the above copyright //! notice, this list of conditions and the following disclaimer. //! * Redistributions in binary form must reproduce the above copyright //! notice, this list of conditions and the following disclaimer in the //! documentation and/or other materials provided with the distribution. //! * Neither the name of the <ORGANIZATION> nor the names of its //! contributors may be used to endorse or promote products derived //! from this software without specific prior written permission. //! //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF //! THE POSSIBILITY OF SUCH DAMAGE. // //***************************************************************************** /** * @defgroup extra_functions 2. WIZnet Extra Functions * * @brief These functions is optional function. It could be replaced at WIZCHIP I/O function because they were made by WIZCHIP I/O functions. * @details There are functions of configuring WIZCHIP, network, interrupt, phy, network information and timer. \n * */ #ifndef _WIZCHIP_CONF_H_ #include <stdint.h> #include <stdbool.h> #define _WIZCHIP_CONF_H_ #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /** * @brief Select WIZCHIP. * @todo You should select one, \b W5100, \b W5100S, \b W5200, \b W5300, \b W5500 or etc. \n\n * ex> <code> #define \_WIZCHIP_ W5500 </code> */ #define W5100 5100 #define W5100S 5100+5 #define W5200 5200 #define W5300 5300 #define W5500 5500 #define W6100 6100 #define W6300 6300 #ifndef _WIZCHIP_ // NOTE_LIHAN: Some sections of this code are not yet fully defined. #define _WIZCHIP_ W6300 // W5100, W5100S, W5200, W5300, W5500, 6300 #endif // //#ifndef _WIZCHIP_ // #error please Define your WIZnet chip numer //#endif #define _WIZCHIP_IO_MODE_NONE_ 0x0000 #define _WIZCHIP_IO_MODE_BUS_ 0x0100 /**< Bus interface mode */ #define _WIZCHIP_IO_MODE_SPI_ 0x0200 /**< SPI interface mode */ //#define _WIZCHIP_IO_MODE_IIC_ 0x0400 //#define _WIZCHIP_IO_MODE_SDIO_ 0x0800 // Add to // #define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1) /**< BUS interface mode for direct */ #define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2) /**< BUS interface mode for indirect */ #define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1) /**< SPI interface mode for variable length data*/ #define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2) /**< SPI interface mode for fixed length data mode*/ #define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3) /**< SPI interface mode for fixed length data mode*/ //teddy 240122 #define _WIZCHIP_IO_MODE_SPI_QSPI_ (_WIZCHIP_IO_MODE_SPI_ + 4) /**< SPI interface mode for QSPI mode*/ /** * @brief PHY can be accessed by @ref _PHYCR0_, _PHYCR1_. * @details It provides hardware access method. * @note It is smaller s/w footprint than @ref _PHY_IO_MODE_MII_. * @sa _PHY_IO_MODE_MII_, _PHY_IO_MODE_ * @sa ctlwizchip(), getPHYCR0(), getPHYCR1(), setPHYCR1(), getPHYSR() */ #define _PHY_IO_MODE_PHYCR_ 0x0000 /** * @brief PHY can be accessed by MDC/MDIO signals of MII interface. * @details It provide software access method. * @note It is bigger s/w footprint than @ref _PHY_IO_MODE_PHYCR_. * @sa _PHY_IO_MODE_PHYCR_, _PHY_IO_MODE_ * @sa ctlwizchip(), wiz_read_mdio(), wiz_write_mdio() */ #define _PHY_IO_MODE_MII_ 0x0010 /** * @brief Select PHY Access Mode * @details @ref _PHY_IO_MODE_ selects PHY access method. * @todo You should select one of @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_. * @sa ctlwizchip() */ #define _PHY_IO_MODE_ _PHY_IO_MODE_MII_ //_PHY_IO_MODE_MII_ #if (_WIZCHIP_ == W5100) #define _WIZCHIP_ID_ "W5100\0" /** * @brief Define interface mode. * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ */ // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ //A20150601 : Define the unit of IO DATA. typedef uint8_t iodata_t; //A20150401 : Indclude W5100.h file #include "W5100/w5100.h" #elif (_WIZCHIP_ == W5100S) #define _WIZCHIP_ID_ "W5100S\0" /** * @brief Define interface mode. * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ */ #if 0 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ #elif 0 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_5500_ #else #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ #endif //A20150601 : Define the unit of IO DATA. typedef uint8_t iodata_t; //A20150401 : Indclude W5100.h file #include "W5100S/w5100s.h" #elif (_WIZCHIP_ == W5200) #define _WIZCHIP_ID_ "W5200\0" /** * @brief Define interface mode. * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ or @ref \ _WIZCHIP_IO_MODE_BUS_INDIR_ */ #ifndef _WIZCHIP_IO_MODE_ // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ #endif //A20150601 : Define the unit of IO DATA. typedef uint8_t iodata_t; #include "W5200/w5200.h" #elif (_WIZCHIP_ == W5500) #define _WIZCHIP_ID_ "W5500\0" /** * @brief Define interface mode. \n * @todo Should select interface mode as chip. * - @ref \_WIZCHIP_IO_MODE_SPI_ \n * -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n * -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == W5500 \n * - @ref \_WIZCHIP_IO_MODE_BUS_ \n * - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n * - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n * - Others will be defined in future. \n\n * ex> <code> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ </code> * */ #ifndef _WIZCHIP_IO_MODE_ //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_ #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_ #endif //A20150601 : Define the unit of IO DATA. typedef uint8_t iodata_t; #include "W5500/w5500.h" #elif ( _WIZCHIP_ == W5300) #define _WIZCHIP_ID_ "W5300\0" /** * @brief Define interface mode. * @todo you should select interface mode as chip. Select one of @ref \_WIZCHIP_IO_MODE_SPI_ , @ref \_WIZCHIP_IO_MODE_BUS_DIR_ or @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ */ #ifndef _WIZCHIP_IO_MODE_ #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_DIR_ // #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ #endif //A20150601 : Define the unit and bus width of IO DATA. /** * @brief Select the data width 8 or 16 bits. * @todo you should select the bus width. Select one of 8 or 16. */ #ifndef _WIZCHIP_IO_BUS_WIDTH_ #define _WIZCHIP_IO_BUS_WIDTH_ 16 // 8 #endif #if _WIZCHIP_IO_BUS_WIDTH_ == 8 typedef uint8_t iodata_t; #elif _WIZCHIP_IO_BUS_WIDTH_ == 16 typedef uint16_t iodata_t; #else #error "Unknown _WIZCHIP_IO_BUS_WIDTH_. It should be 8 or 16." #endif // #include "W5300/w5300.h" #elif ( _WIZCHIP_ == W6100) #define _WIZCHIP_ID_ "W6100\0" /** * @brief Define @ref _WIZCHIP_ interface mode. * @todo You should select interface mode of @ref _WIZCHIP_.\n\n * Select one of @ref _WIZCHIP_IO_MODE_SPI_VDM_, @ref _WIZCHIP_IO_MODE_SPI_FDM_, and @ref _WIZCHIP_IO_MODE_BUS_INDIR_ * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() */ #if 1 // 20231103 taylor #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ #elif 0 #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_ #else #define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPV_FDM_ #endif typedef uint8_t iodata_t; ///< IO access unit. bus width typedef int16_t datasize_t; ///< sent or received data size #include "./W6100/w6100.h" #include "../Application/Application.h" //teddy 240122 #elif ( _WIZCHIP_ == W6300) #define _WIZCHIP_ID_ "W6300\0" /** * @brief Define @ref _WIZCHIP_ interface mode. * @todo You should select interface mode of @ref _WIZCHIP_.\n\n * Select one of @ref _WIZCHIP_IO_MODE_SPI_QSPI_, @ref _WIZCHIP_IO_MODE_SPI_VDM_,@ref _WIZCHIP_IO_MODE_BUS_INDIR_ * @sa WIZCHIP_READ(), WIZCHIP_WRITE(), WIZCHIP_READ_BUF(), WIZCHIP_WRITE_BUF() */ #define QSPI_SINGLE_MODE (0x00 << 6) // 0b0000 0000 // 0x00 #define QSPI_DUAL_MODE (0x01 << 6) // 0b0100 0000 // 0x40 #define QSPI_QUAD_MODE (0x02 << 6) // 0b1000 0000 // 0x80 #ifndef _WIZCHIP_QSPI_MODE_ #define _WIZCHIP_QSPI_MODE_ QSPI_SINGLE_MODE #endif //#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_BUS_INDIR_ #define _WIZCHIP_IO_MODE_ ((_WIZCHIP_IO_MODE_SPI_ & 0xff00) | (_WIZCHIP_QSPI_MODE_ & 0x00ff)) typedef uint8_t iodata_t; ///< IO access unit. bus width typedef int16_t datasize_t; ///< sent or received data size #include "w5500.h" #include "Application.h" #else #error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, 5300, 5500, 6100 and 6300!!!" #endif #ifndef _WIZCHIP_IO_MODE_ #error "Undefined _WIZCHIP_IO_MODE_. You should define it !!!" #endif /** * @brief Define I/O base address when BUS IF mode. * @todo Should re-define it to fit your system when BUS IF Mode (@ref \_WIZCHIP_IO_MODE_BUS_, * @ref \_WIZCHIP_IO_MODE_BUS_DIR_, @ref \_WIZCHIP_IO_MODE_BUS_INDIR_). \n\n * ex> <code> #define \_WIZCHIP_IO_BASE_ 0x00008000 </code> */ #if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ #if 1 // 20231108 taylor #if (_WIZCHIP_ == W6300) #define _WIZCHIP_IO_BASE_ 0x60000000 // for W6100-EVB #elif (_WIZCHIP_ == W6100) #define _WIZCHIP_IO_BASE_ 0x60000000 // for W5100S-EV #elif (_WIZCHIP_ == W5100S) #define _WIZCHIP_IO_BASE_ 0x60000000 // for W5100S-EVB #elif (_WIZCHIP_ == W5300) #define _WIZCHIP_IO_BASE_ 0x68000000 // for W5300 by javakys 20210408 @66c27e960a813f7ea6e8b1ce083d12b3e7e86fc0 #else #define _WIZCHIP_IO_BASE_ 0x00000000 #endif #else #if (_WIZCHIP_ == W6100) #define _WIZCHIP_IO_BASE_ 0x60000000 // for W6100 BUS #else // #define _WIZCHIP_IO_BASE_ 0x60000000 // for 5100S IND #define _WIZCHIP_IO_BASE_ 0x68000000 // for W5300 #endif #endif #elif _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_ //#define _WIZCHIP_IO_BASE_ 0x00000000 // for 5100S SPI #endif #ifndef _WIZCHIP_IO_BASE_ #if 1 // 20231108 taylor #define _WIZCHIP_IO_BASE_ 0x00000000 #else #define _WIZCHIP_IO_BASE_ 0x00000000 // 0x8000 #endif #endif //M20150401 : Typing Error //#if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS #if _WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_ #ifndef _WIZCHIP_IO_BASE_ #error "You should be define _WIZCHIP_IO_BASE to fit your system memory map." #endif #endif #if _WIZCHIP_ >= W5200 #define _WIZCHIP_SOCK_NUM_ 8 ///< The count of independant socket of @b WIZCHIP #else #define _WIZCHIP_SOCK_NUM_ 4 ///< The count of independant socket of @b WIZCHIP #endif /******************************************************** * WIZCHIP BASIC IF functions for SPI, SDIO, I2C , ETC. *********************************************************/ /** * @ingroup DATA_TYPE * @brief The set of callback functions for W5500:@ref WIZCHIP_IO_Functions W5200:@ref WIZCHIP_IO_Functions_W5200 */ typedef struct __WIZCHIP { uint16_t if_mode; ///< host interface mode uint8_t id[8]; ///< @b WIZCHIP ID such as @b 5100, @b 5100S, @b 5200, @b 5500, and so on. /** * The set of critical section callback func. */ struct _CRIS { void (*_enter) (void); ///< crtical section enter void (*_exit) (void); ///< critial section exit }CRIS; /** * The set of @ref \_WIZCHIP_ select control callback func. */ struct _CS { void (*_select) (void); ///< @ref \_WIZCHIP_ selected void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected }CS; /** * The set of interface IO callback func. */ union _IF { /** * For BUS interface IO */ //M20156501 : Modify the function name for integrating with W5300 //struct //{ // uint8_t (*_read_byte) (uint32_t AddrSel); // void (*_write_byte) (uint32_t AddrSel, uint8_t wb); //}BUS; struct { iodata_t (*_read_data) (uint32_t AddrSel); void (*_write_data) (uint32_t AddrSel, iodata_t wb); #if 1 // 20231103 taylor void (*_read_data_buf) (uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc); ///< Read @ref iodata_t as many as <i>len</i> from @ref _WIZCHIP_ through BUS void (*_write_data_buf) (uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc); ///< Write @ref iodata_t data as many as <i>len</i> to @ref _WIZCHIP_ through BUS #endif }BUS; /** * For SPI interface IO */ struct { uint8_t (*_read_byte) (void); void (*_write_byte) (uint8_t wb); void (*_read_burst) (uint8_t* pBuf, uint16_t len); void (*_write_burst) (uint8_t* pBuf, uint16_t len); }SPI; /** * For QSPI interface IO */ //teddy 240122 struct { void (*_read_qspi) (uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len); void (*_write_qspi) (uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len); }QSPI; // To be added // }IF; }_WIZCHIP; extern _WIZCHIP WIZCHIP; /** * @ingroup DATA_TYPE * WIZCHIP control type enumration used in @ref ctlwizchip(). */ typedef enum { CW_SYS_LOCK, ///< Lock or Unlock @ref _WIZCHIP_ with @ref SYS_CHIP_LOCK, @ref SYS_PHY_LOCK, and @ref SYS_NET_LOCK CW_SYS_UNLOCK, ///< Lock or Unlock @ref _WIZCHIP_ with @ref SYS_CHIP_LOCK, @ref SYS_PHY_LOCK, and @ref SYS_NET_LOCK CW_GET_SYSLOCK, ///< Get the lock status of @ref _WIZCHIP_ with @ref SYS_CHIP_LOCK, @ref SYS_PHY_LOCK, and @ref SYS_NET_LOCK CW_RESET_WIZCHIP, ///< Reset @ref _WIZCHIP_ by software CW_INIT_WIZCHIP, ///< Initialize to SOCKETn buffer size with n byte array typed unsigned CW_GET_INTERRUPT, ///< Get the interrupt status with @ref intr_kind CW_CLR_INTERRUPT, ///< Clear the interrupt with @ref intr_kind CW_SET_INTRMASK, ///< Set the interrupt mask with @ref intr_kind CW_GET_INTRMASK, ///< Get the interrupt mask with @ref intr_kind CW_SET_INTRTIME, ///< Set the interrupt pending time CW_GET_INTRTIME, ///< Get the interrupt pending time CW_SET_IEN, ///< Set the global interrupt enable only when @ref SYS_CHIP_LOCK is not set CW_GET_IEN, ///< Get the global interrupt enable CW_GET_ID, ///< Get @ref _WIZCHIP_ name. CW_GET_VER, ///< Get the version of TCP/IP TOE engine CW_SET_SYSCLK, ///< Set the system clock with @ref SYSCLK_100MHZ or SYSCLK_10MHZ only when @ref SYS_CHIP_LOCK is unlock CW_GET_SYSCLK, ///< Get the system clock with @ref SYSCLK_100MHZ or SYSCLK_10MHZ CW_RESET_PHY, ///< Reset PHY CW_SET_PHYCONF, ///< Set PHY operation mode (Manual/Auto, 10/100, Half/Full) with @ref wiz_PhyConf CW_GET_PHYCONF, ///< Get PHY operation mode (Manual/Auto, 10/100, Half/Full) with @ref wiz_PhyConf CW_GET_PHYSTATUS, ///< Get real operation mode with @ref wiz_PhyConf when PHY is linked up. CW_SET_PHYPOWMODE, ///< Set PHY power mode with @ref PHY_POWER_NORM or PHY_POWER_DOWN CW_GET_PHYPOWMODE, ///< Get PHY Power mode with @ref PHY_POWER_NORM or PHY_POWER_DOWN CW_GET_PHYLINK ///< Get PHY Link status with @ref PHY_LINK_ON or @ref PHY_LINK_OFF }ctlwizchip_type; /** * @ingroup DATA_TYPE * Network control type enumration used in @ref ctlnetwork(). */ typedef enum { CN_SET_NETINFO, ///< Set Network with @ref wiz_NetInfo CN_GET_NETINFO, ///< Get Network with @ref wiz_NetInfo CN_SET_NETMODE, ///< Set network mode as WOL, PPPoE, Ping Block, and Force ARP mode CN_GET_NETMODE, ///< Get network mode as WOL, PPPoE, Ping Block, and Force ARP mode CN_SET_TIMEOUT, ///< Set network timeout as retry count and time. CN_GET_TIMEOUT, ///< Get network timeout as retry count and time. //teddy 240122 #if ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) CN_SET_PREFER, ///< Set the preferred source IPv6 address of @ref _SLCR_.\n Refer to @ref IPV6_ADDR_AUTO, @ref IPV6_ADDR_LLA, @ref IPV6_ADDR_GUA CN_GET_PREFER, ///< Get the preferred source IPv6 address of @ref _SLCR_.\n Refer to @ref IPV6_ADDR_AUTO, @ref IPV6_ADDR_LLA, @ref IPV6_ADDR_GUA #endif }ctlnetwork_type; //teddy 240122 #if ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup DATA_TYPE * @brief Network Service Control Type enumeration * @details @ref ctlnetservice_type includes network management or monitor functions for @ref _WIZCHIP_. * @sa ctlnetservice(), wiz_IPAddress, wiz_Prefix */ typedef enum { CNS_ARP, ///< ARP process with @ref wiz_IPAddress CNS_PING, ///< PING process with @ref wiz_IPAddress CNS_DAD, ///< Duplicated IPv6 Address Detection /** * @brief Stateless Address Auto-configuration(SLAAC) with @ref wiz_Prefix. * @details @ref CNS_SLAAC sends first RS message to all-router and then receives RA message from a router. * @note It is valid only when the first received RA option is the source link-layer address(0x01) and the second is prefix information(0x03).\n * Refer to @ref SLIR_RS. * @sa ctlnetservice() * @sa CNS_GET_PREFIX */ CNS_SLAAC, CNS_UNSOL_NA, ///< Unsolicited Neighbor Advertisement for update @ref _WIZCHIP_ network information to neighbors /** * @brief Get prefix information with @ref wiz_Prefix. * @details @ref CNS_GET_PREFIX can get prefix information of RA message to be sent by a router without RS message. * @note It is valid only when @ref IK_SOCKL_RA is set and the prefix information(0x03) of RA option is first received. * @sa ctlnetservice() * @sa CNS_SLAAC */ CNS_GET_PREFIX }ctlnetservice_type; #endif #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) /** * @ingroup DATA_TYPE * Interrupt kind when CW_SET_INTRRUPT, CW_GET_INTERRUPT, CW_SET_INTRMASK * and CW_GET_INTRMASK is used in @ref ctlnetwork(). * It can be used with OR operation. */ typedef enum { #if _WIZCHIP_ == W5500 IK_WOL = (1 << 4), ///< Wake On Lan by receiving the magic packet. Valid in W500. #elif _WIZCHIP_ == W5300 IK_FMTU = (1 << 4), ///< Received a ICMP message (Fragment MTU) #endif IK_PPPOE_TERMINATED = (1 << 5), ///< PPPoE Disconnected #if _WIZCHIP_ != W5200 IK_DEST_UNREACH = (1 << 6), ///< Destination IP & Port Unreachable, No use in W5200 #endif IK_IP_CONFLICT = (1 << 7), ///< IP conflict occurred IK_SOCK_0 = (1 << 8), ///< Socket 0 interrupt IK_SOCK_1 = (1 << 9), ///< Socket 1 interrupt IK_SOCK_2 = (1 << 10), ///< Socket 2 interrupt IK_SOCK_3 = (1 << 11), ///< Socket 3 interrupt #if _WIZCHIP_ > W5100S IK_SOCK_4 = (1 << 12), ///< Socket 4 interrupt, No use in 5100 IK_SOCK_5 = (1 << 13), ///< Socket 5 interrupt, No use in 5100 IK_SOCK_6 = (1 << 14), ///< Socket 6 interrupt, No use in 5100 IK_SOCK_7 = (1 << 15), ///< Socket 7 interrupt, No use in 5100 #endif #if _WIZCHIP_ > W5100S IK_SOCK_ALL = (0xFF << 8) ///< All Socket interrupt #else IK_SOCK_ALL = (0x0F << 8) ///< All Socket interrupt #endif }intr_kind; //teddy 240122 #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup DATA_TYPE * @brief Interrupt Kind * @details @ref intr_kind can be used as the interrupt bits of @ref _IR_, @ref _SIR_, and @ref _SLIR_,\n * It can be used as the interrupt mask bits of @ref _IMR_, @ref _SIMR_, and @ref _SLIMR_,\n * and also, It can be used as the interrupt clear bits of @ref _IRCLR_, @ref _Sn_IRCLR_, and @ref _SLIRCLR_. * @note It can be used with @b OR operation. * @sa ctlwizchip(), CW_GET_INTERRUPT, CW_CLR_INTERRUPT, CW_GET_INTRMASK, CW_SET_INTRMASK * @sa ctlnetservice(), ctlnetservice_type * @sa wizchip_getinterrupt(), wizchip_clrinterrupt(), wizchip_getinterruptmask(), wizchip_setinterruptmask() */ typedef enum { IK_PPPOE_TERMINATED = (1 << 0), ///< PPPoE Termination Interrupt IK_DEST_UNREACH = (1 << 1), ///< ICMPv4 Destination Unreachable Interrupt IK_IP_CONFLICT = (1 << 2), ///< IPv4 Address Conflict Interrupt IK_DEST_UNREACH6 = (1 << 4), ///< ICMPv6 Destination Unreachable Interrupt IK_WOL = (1 << 7), ///< WOL magic packet Interrupt IK_NET_ALL = (0x97), ///< All Network Interrupt IK_SOCK_0 = (1 << 8), ///< Socket 0 Interrupt IK_SOCK_1 = (1 << 9), ///< Socket 1 Interrupt IK_SOCK_2 = (1 << 10), ///< Socket 2 Interrupt IK_SOCK_3 = (1 << 11), ///< Socket 3 Interrupt IK_SOCK_4 = (1 << 12), ///< Socket 4 Interrupt IK_SOCK_5 = (1 << 13), ///< Socket 5 Interrupt IK_SOCK_6 = (1 << 14), ///< Socket 6 Interrupt IK_SOCK_7 = (1 << 15), ///< Socket 7 Interrupt IK_SOCK_ALL = (0xFF << 8), ///< All Socket Interrupt IK_SOCKL_TOUT = (1 << 16), ///< @ref _SLCR_ Timeout Interrupt.\n Refer to @ref ctlnetservice_type. IK_SOCKL_ARP4 = (1 << 17), ///< @ref _SLCR_ APR4 Interrupt.\n Refer to @ref CNS_ARP. IK_SOCKL_PING4 = (1 << 18), ///< @ref _SLCR_ PING4 Interrupt.\n Refer to @ref CNS_PING. IK_SOCKL_ARP6 = (1 << 19), ///< @ref _SLCR_ ARP6 Interrupt.\n Refer to @ref CNS_ARP. IK_SOCKL_PING6 = (1 << 20), ///< @ref _SLCR_ PING6 Interrupt.\n Refer to @ref CNS_PING. IK_SOCKL_NS = (1 << 21), ///< @ref _SLCR_ NS Interrupt.\n Refer to @ref CNS_DAD. IK_SOCKL_RS = (1 << 22), ///< @ref _SLCR_ RS Interrupt.\n Refer to @ref CNS_SLAAC. IK_SOCKL_RA = (1 << 23), ///< @ref _SLCR_ RA Interrupt.\n Refer to @ref CNS_GET_PREFIX. IK_SOCKL_ALL = (0xFF << 16), ///< @ref _SLCR_ All Interrupt IK_INT_ALL = (0x00FFFF97) ///< All Interrupt }intr_kind; #endif //teddy 240122 #if ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) #define SYS_CHIP_LOCK (1<<2) ///< CHIP LOCK. \n Refer to @ref CW_SYS_LOCK, @ref CW_SYS_UNLOCK, and @ref CW_GET_SYSLOCK. #define SYS_NET_LOCK (1<<1) ///< NETWORK Information LOCK. \n Refer to @ref CW_SYS_LOCK, @ref CW_SYS_UNLOCK, and @ref CW_GET_SYSLOCK. #define SYS_PHY_LOCK (1<<0) ///< PHY LOCK.\n Refer to @ref CW_SYS_LOCK, @ref CW_SYS_UNLOCK, and @ref CW_GET_SYSLOCK. #define SYSCLK_100MHZ 0 ///< System Clock 100MHz.\n Refer to Refer to @ref CW_SET_SYSCLK and @ref CW_GET_SYSCLK. #define SYSCLK_25MHZ 1 ///< System Clock 25MHz.\n Refer to Refer to @ref CW_SET_SYSCLK and @ref CW_GET_SYSCLK. #define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting.\n Refer to @ref CW_SET_PHYCONF and @ref CW_GET_PHYCONF. #define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation.\n Refer to @ref CW_SET_PHYCONF and @ref CW_GET_PHYCONF. #define PHY_MODE_TE 2 #define IPV6_ADDR_AUTO 0x00 ///< IPv6 Address Type : Auto.\n Refer to @ref CN_SET_PREFER, @ref CN_GET_PREFER. #define IPV6_ADDR_LLA 0x02 ///< IPv6 Address Type : LLA. \n Refer to @ref CN_SET_PREFER, @ref CN_GET_PREFER, @ref CNS_DAD. #define IPV6_ADDR_GUA 0x03 ///< IPv6 Address Type : GUA. \n Refer to @ref CN_SET_PREFER, @ref CN_GET_PREFER, @ref CNS_DAD. #endif #define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin #define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register #define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. #define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation #define PHY_SPEED_10 0 ///< Link Speed 10 #define PHY_SPEED_100 1 ///< Link Speed 100 #define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex #define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex #define PHY_LINK_OFF 0 ///< Link Off #define PHY_LINK_ON 1 ///< Link On #define PHY_POWER_NORM 0 ///< PHY power normal mode #define PHY_POWER_DOWN 1 ///< PHY power down mode //teddy 240122 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 || _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 /** * @ingroup DATA_TYPE * It configures PHY configuration when CW_SET PHYCONF or CW_GET_PHYCONF in W5500, * and it indicates the real PHY status configured by HW or SW in all WIZCHIP. \n * Valid only in W5500. */ typedef struct wiz_PhyConf_t { uint8_t by; ///< set by @ref PHY_CONFBY_HW or @ref PHY_CONFBY_SW uint8_t mode; ///< set by @ref PHY_MODE_MANUAL or @ref PHY_MODE_AUTONEGO uint8_t speed; ///< set by @ref PHY_SPEED_10 or @ref PHY_SPEED_100 uint8_t duplex; ///< set by @ref PHY_DUPLEX_HALF @ref PHY_DUPLEX_FULL //uint8_t power; ///< set by @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN //uint8_t link; ///< Valid only in CW_GET_PHYSTATUS. set by @ref PHY_LINK_ON or PHY_DUPLEX_OFF }wiz_PhyConf; #endif #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) /** * @ingroup DATA_TYPE * It used in setting dhcp_mode of @ref wiz_NetInfo. */ typedef enum { NETINFO_STATIC = 1, ///< Static IP configuration by manually. NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever }dhcp_mode; /** * @ingroup DATA_TYPE * Network Information for WIZCHIP */ typedef struct wiz_NetInfo_t { uint8_t mac[6]; ///< Source Mac Address uint8_t ip[4]; ///< Source IP Address uint8_t sn[4]; ///< Subnet Mask uint8_t gw[4]; ///< Gateway IP Address uint8_t dns[4]; ///< DNS server IP Address dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP }wiz_NetInfo; /** * @ingroup DATA_TYPE * Network mode */ typedef enum { #if _WIZCHIP_ == W5500 NM_FORCEARP = (1<<1), ///< Force to APP send whenever udp data is sent. Valid only in W5500 #endif NM_WAKEONLAN = (1<<5), ///< Wake On Lan NM_PINGBLOCK = (1<<4), ///< Block ping-request NM_PPPOE = (1<<3), ///< PPPoE mode }netmode_type; /** * @ingroup DATA_TYPE * Used in CN_SET_TIMEOUT or CN_GET_TIMEOUT of @ref ctlwizchip() for timeout configruation. */ typedef struct wiz_NetTimeout_t { uint8_t retry_cnt; ///< retry count uint16_t time_100us; ///< time unit 100us }wiz_NetTimeout; //teddy 240122 #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup DATA_TYPE * @brief IP Address Configuration Mode * @details @ref ipconf_mode can be used to save the DHCP mode running on your system. * @sa ctlnetwork(), CN_SET_NETINFO, CN_GET_NETINFO * @sa wizchip_setnetinfo(), wizchip_getnetinfo(), wiz_NetInfo */ typedef enum { NETINFO_NONE = 0x00, ///< No use DHCP NETINFO_STATIC_V4 = 0x01, ///< Static IPv4 configuration by manually. NETINFO_STATIC_V6 = 0x02, ///< Static IPv6 configuration by manually. NETINFO_STATIC_ALL = 0x03, ///< Static IPv4 and IPv6 configuration by manually. NETINFO_SLAAC_V6 = 0x04, ///< Stateless Adders Auto Configuration for IPv6 NETINFO_DHCP_V4 = 0x10, ///< Dynamic IPv4 configuration from a DHCP sever NETINFO_DHCP_V6 = 0x20, ///< Dynamic IPv6 configuration from a DHCP sever NETINFO_DHCP_ALL = 0x30 ///< Dynamic IPv4 and IPv6 configuration from a DHCP sever }ipconf_mode; /** * @ingroup DATA_TYPE * @brief Network Information for @ref _WIZCHIP_ * @details @ref wiz_NetInfo is a structure type to configure or indicate the network information of @ref _WIZCHIP_. * @sa ctlnetwork(), CN_SET_NETINFO, CN_GET_NETINFO * @sa wizchip_setnetinfo(), wizchip_getnetinfo() */ typedef enum { NETINFO_STATIC = 1, ///< Static IP configuration by manually. NETINFO_DHCP ///< Dynamic IP configruation from a DHCP sever }dhcp_mode; typedef struct wiz_NetInfo_t { uint8_t mac[6]; ///< Source Hardware Address uint8_t ip[4]; ///< Source IPv4 Address uint8_t sn[4]; ///< Subnet Mask value uint8_t gw[4]; ///< Gateway IPv4 Address uint8_t lla[16]; ///< Source Link Local Address uint8_t gua[16]; ///< Source Global Unicast Address uint8_t sn6[16]; ///< IPv6 Prefix uint8_t gw6[16]; ///< Gateway IPv6 Address uint8_t dns[4]; ///< DNS server IPv4 Address uint8_t dns6[16]; ///< DNS server IPv6 Address ipconf_mode ipmode; ///< IP Configuration Mode dhcp_mode dhcp; ///< 1 - Static, 2 - DHCP }wiz_NetInfo; /** * @ingroup DATA_TYPE * @brief Network mode Configuration * @details @ref netmode_type includes the network mode control function such as ping, TCP/RST block and etc. * @sa ctlnetwork(), CN_SET_NETMODE, CN_GET_NETMODE */ typedef enum { // NETMR Bit Values NM_IPB_V4 = (1 << 0), ///< IPv4 Packet Block NM_IPB_V6 = (1 << 1), ///< IPv6 Packet Block NM_WOL = (1 << 2), ///< Wake On Lan(WOL) Mode NM_PB6_MULTI = (1 << 4), ///< PING6 request from multicasting group address Block NM_PB6_ALLNODE = (1 << 5), ///< PING6 request from all-node multicasting address Block NM_MR_MASK = (0x37), ///< @ref _NETMR_ Mask value // NETMR2 Bit Values NM_PPPoE = (1 << 8), ///< PPPoE Mode NM_DHA_SELECT = (1 << 15), ///< Destination Hardware Address Select NM_MR2_MASK = (0x09<<8), ///< @ref _NETMR2_ Mask value //NET4MR Bit Values NM_PB4_ALL = (1 << 16), ///< All PING4 request Block NM_TRSTB_V4 = (1 << 17), ///< TCP RST packet for IPv4 Send Block NM_PARP_V4 = (1 << 18), ///< ARP request for IPv4 before PINGv4 Replay NM_UNRB_V4 = (1 << 19), ///< Unreachable Destination for IPv4 Block NM_NET4_MASK = (0x0F << 16), ///< @ref _NET4MR_ Mask value //NET4MR Bit Values NM_PB6_ALL = (1 << 24), ///< All PING6 request Block NM_TRSTB_V6 = (1 << 25), ///< TCP RST packet for IPv6 Send Block NM_PARP_V6 = (1 << 26), ///< ARP request for IPv6 before PINGv4 Replay NM_UNRB_V6 = (1 << 27), ///< Unreachable Destination for IPv6 Block NM_NET6_MASK = (0x0F << 24), ///< @ref _NET6MR_ Mask value NM_MASK_ALL = (0x0F0F0937) ///< @ref netmode_type all mask value }netmode_type; /** * @ingroup DATA_TYPE * @brief Network Timeout for @ref _WIZCHIP_ * @details @ref wiz_NetInfo is a structure type to configure or indicate the network timeout of @ref _WIZCHIP_. * @sa ctlnetwork(), CN_SET_TIMEOUT, CN_GET_TIMEOUT * @sa wizchip_settimeout(), wizchip_gettimeout() */ typedef struct wiz_NetTimeout_t { uint8_t s_retry_cnt; ///< The default retry count of SOCKETn uint16_t s_time_100us; ///< The retransmission time of SOCKETn (unit 100us) uint8_t sl_retry_cnt; ///< The retry count of SOCKET-less uint16_t sl_time_100us; ///< The retransmission time of SOCKET-less (unit 100us) }wiz_NetTimeout; /** * @ingroup DATA_TYPE * @brief Destination Information for Network Service of @ref _WIZCHIP_ * @details @ref wiz_NetInfo is a structure type to configure or indicate a destination information of network service. * @sa ctlnetservice(), CNS_ARP, CNS_PING * @sa IK_SOCKL_TOUT, IK_SOCKL_ARP4, IK_SOCKL_ARP6, IK_SOCKL_PING4, IK_SOCKL_PING6 */ typedef struct wiz_IPAddress_t { uint8_t ip[16]; ///< Destination IP Address. \n IPv4 index : 0 to 3, IPv6 index : 0 to 15 uint8_t len; ///< Destination IP Address Length.\n IPv4 : 4, IPv6 : 16. }wiz_IPAddress; /** * @ingroup DATA_TYPE * @brief Prefix Information * @details @ref wiz_Prefix is a structure type to indicate a prefix information(0x03) of received RA message from a router. * @sa ctlnetservice(), CNS_SLAAC, IK_SOCKL_RS * @sa IK_SOCKL_TOUT, IK_SOCKL_RA, CNS_GET_PREFIX */ typedef struct wiz_Prefix_t { uint8_t len; ///< Prefix Length. \n It is used to set @ref _SUB6R_ to 1 as many as <i>len</i> from LSB bit. uint8_t flag; ///< Prefix Flag uint32_t valid_lifetime; ///< Valid Lifetime uint32_t preferred_lifetime; ///< Preferred Lifetime uint8_t prefix[16]; ///< Prefix }wiz_Prefix; /** * @ingroup DATA_TYPE * @brief Destination Information & Destination Hardware Address for @ref CNS_ARP * @details @ref wiz_ARP is a structure type to set a destination IP address for ARP-request or \n * indicate a destination hardware address in APR-reply. * @sa ctlnetservice(), CNS_ARP * @sa IK_SOCKL_TOUT, IK_SOCKL_ARP4, IK_SOCKL_ARP6 */ typedef struct wiz_ARP_t { wiz_IPAddress destinfo; ///< Destination IP address for ARP-request uint8_t dha[6]; ///< Destination Hardware Address when ARP-reply is received from the destination. }wiz_ARP; /** * @ingroup DATA_TYPE * @brief Destination Information & Destination Hardware Address for @ref CNS_ARP * @details @ref wiz_PING is a structure type to set a ID, sequence number, destination IP address for PING-request. * @sa ctlnetservice(), CNS_PING * @sa IK_SOCKL_TOUT, IK_SOCKL_PING4, IK_SOCKL_PING6 */ typedef struct wiz_PING_t { uint16_t id; uint16_t seq; wiz_IPAddress destinfo; }wiz_PING; #endif /** *@brief Registers call back function for critical section of I/O functions such as *\ref WIZCHIP_READ, @ref WIZCHIP_WRITE, @ref WIZCHIP_READ_BUF and @ref WIZCHIP_WRITE_BUF. *@param cris_en : callback function for critical section enter. *@param cris_ex : callback function for critical section exit. *@todo Describe @ref WIZCHIP_CRITICAL_ENTER and @ref WIZCHIP_CRITICAL_EXIT marco or register your functions. *@note If you do not describe or register, default functions(@ref wizchip_cris_enter & @ref wizchip_cris_exit) is called. */ void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)); /** *@brief Registers call back function for WIZCHIP select & deselect. *@param cs_sel : callback function for WIZCHIP select *@param cs_desel : callback fucntion for WIZCHIP deselect *@todo Describe @ref wizchip_cs_select and @ref wizchip_cs_deselect function or register your functions. *@note If you do not describe or register, null function is called. */ void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)); /** *@brief Registers call back function for bus interface. *@param bus_rb : callback function to read byte data using system bus *@param bus_wb : callback function to write byte data using system bus *@todo Describe @ref wizchip_bus_readbyte and @ref wizchip_bus_writebyte function *or register your functions. *@note If you do not describe or register, null function is called. */ //M20150601 : For integrating with W5300 //void reg_wizchip_bus_cbfunc(uint8_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)); void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)); /** *@brief Registers call back function for SPI interface. *@param spi_rb : callback function to read byte using SPI *@param spi_wb : callback function to write byte using SPI *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function *or register your functions. *@note If you do not describe or register, null function is called. */ #if _WIZCHIP_ == W6100 void reg_wizchip_spi_cbfunc( uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb), void (*spi_rbuf)(uint8_t* buf, datasize_t len), void (*spi_wbuf)(uint8_t* buf, datasize_t len) ); #else void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)); #endif /** *@brief Registers call back function for SPI interface. *@param spi_rb : callback function to burst read using SPI *@param spi_wb : callback function to burst write using SPI *@todo Describe \ref wizchip_spi_readbyte and \ref wizchip_spi_writebyte function *or register your functions. *@note If you do not describe or register, null function is called. */ void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)); //teddy 240122 /** *@brief Registers call back function for QSPI interface. *@param spi_rb : callback function to read using QSPI *@param spi_wb : callback function to write using QSPI *@todo Describe \ref wizchip_qspi_read and \ref wizchip_qspi_write function *or register your functions. *@note If you do not describe or register, null function is called. */ void reg_wizchip_qspi_cbfunc(void (*qspi_rb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len), void (*qspi_wb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len)); /** * @ingroup extra_functions * @brief Controls to the WIZCHIP. * @details Resets WIZCHIP & internal PHY, Configures PHY mode, Monitor PHY(Link,Speed,Half/Full/Auto), * controls interrupt & mask and so on. * @param cwtype : Decides to the control type * @param arg : arg type is dependent on cwtype. * @return 0 : Success \n * -1 : Fail because of invalid \ref ctlwizchip_type or unsupported \ref ctlwizchip_type in WIZCHIP */ int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg); /** * @ingroup extra_functions * @brief Controls to network. * @details Controls to network environment, mode, timeout and so on. * @param cntype : Input. Decides to the control type * @param arg : Inout. arg type is dependent on cntype. * @return -1 : Fail because of invalid \ref ctlnetwork_type or unsupported \ref ctlnetwork_type in WIZCHIP \n * 0 : Success */ int8_t ctlnetwork(ctlnetwork_type cntype, void* arg); //teddy 240122 #if ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup extra_functions * @brief Controls to network service. * @details Controls to network environment, mode, timeout and so on. * @param cnstype : Decides to the control type * @param arg : arg type is dependent on cnstype. * @return -1 : Fail because of invalid @ref ctlnetwork_type or unsupported @ref ctlnetwork_type \n * 0 : Success */ int8_t ctlnetservice(ctlnetservice_type cnstype, void* arg); #endif /* * The following functions are implemented for internal use. * but You can call these functions for code size reduction instead of ctlwizchip() and ctlnetwork(). */ /** * @ingroup extra_functions * @brief Reset WIZCHIP by softly. */ void wizchip_sw_reset(void); /** * @ingroup extra_functions * @brief Initializes WIZCHIP with socket buffer size * @param txsize Socket tx buffer sizes. If null, initialized the default size 2KB. * @param rxsize Socket rx buffer sizes. If null, initialized the default size 2KB. * @return 0 : succcess \n * -1 : fail. Invalid buffer size */ int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize); /** * @ingroup extra_functions * @brief Clear Interrupt of WIZCHIP. * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. */ void wizchip_clrinterrupt(intr_kind intr); /** * @ingroup extra_functions * @brief Get Interrupt of WIZCHIP. * @return @ref intr_kind value operated OR. It can type-cast to uint16_t. */ intr_kind wizchip_getinterrupt(void); /** * @ingroup extra_functions * @brief Mask or Unmask Interrupt of WIZCHIP. * @param intr : @ref intr_kind value operated OR. It can type-cast to uint16_t. */ void wizchip_setinterruptmask(intr_kind intr); /** * @ingroup extra_functions * @brief Get Interrupt mask of WIZCHIP. * @return : The operated OR vaule of @ref intr_kind. It can type-cast to uint16_t. */ intr_kind wizchip_getinterruptmask(void); //todo #if _WIZCHIP_ > W5100 int8_t wizphy_getphylink(void); ///< get the link status of phy in WIZCHIP. No use in W5100 int8_t wizphy_getphypmode(void); ///< get the power mode of PHY in WIZCHIP. No use in W5100 #endif #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 /** * @ingroup extra_functions * @brief Set the phy information for WIZCHIP without power mode * @param phyconf : @ref wiz_PhyConf */ void wizphy_setphyconf(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief Get phy configuration information. * @param phyconf : @ref wiz_PhyConf */ void wizphy_getphyconf(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief Get phy status. * @param phyconf : @ref wiz_PhyConf */ void wizphy_getphystat(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief set the power mode of phy inside WIZCHIP. Refer to @ref PHYCFGR in W5500, @ref PHYSTATUS in W5200 * @param pmode Settig value of power down mode. */ int8_t wizphy_setphypmode(uint8_t pmode); //teddy 240122 #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup extra_functions * @brief Reset the integrated PHY. * @details @ref wizphy_reset() resets the integrated Ethernet PHY \n * through @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_. \n * @note In @ref _PHY_IO_MODE_PHYCR_, It needs a stable reset time. \n * So you need to wait for the stable reset time.\n * The stable reset time for each @ref _WIZCHIP_ maybe different. * @sa ctlwizchip(), CW_RESET_PHY * @sa _PHY_IO_MODE_ */ void wizphy_reset(void); ///< Reset phy. Vailid only in W5500 /** * @ingroup extra_functions * @details @ref wizphy_setphyconf() set a operation mode of the integrated Ethernet PHY \n * through @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_.\n * @param phyconf : @ref wiz_PhyConf * @note The operation mode can be applied to Ethernet PHY after the Ethernet PHY is reset by @ref wizphy_reset(). * @sa ctlwizchip(), CW_SET_PHYCONF, CW_GET_PHYCONF, CW_GET_PHYSTATUS, CW_RESET_PHY * @sa _PHY_IO_MODE_, wizphy_getphyconf(), wizphy_getphystatus(), wizphy_reset() */ void wizphy_setphyconf(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief Get the integrated Ethernet PHY operation mode. * @details @ref wizphy_getphyconf() gets a operation mode of the integrated Ethernet PHY \n * through @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_.\n * @param phyconf : @ref wiz_PhyConf * @note It gets just the configured value for PHY operation, not real PHY operation.\n * To get real PHY operation, you can call @ref wizphy_getphystatus() * @sa ctlwizchip(), CW_GET_PHYCONF, CW_SET_PHYCONF, CW_GET_PHYSTATUS * @sa _PHY_IO_MODE_, wizphy_setphyconf(), wizphy_getphystatus() */ void wizphy_getphyconf(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief Get the real PHY operation status when link is established. * @details @ref wizphy_getphystatus() gets a operation mode of the integrated Ethernet PHY. \n * @param phyconf : @ref wiz_PhyConf * @sa ctlwizchip(), CW_GET_PHYSTATUS, CW_GET_PHYCONF, CW_SET_PHYCONF * @sa wizphy_setphyconf(), wizphy_getphyconf() */ void wizphy_getphystat(wiz_PhyConf* phyconf); /** * @ingroup extra_functions * @brief Set the power mode of integrated Ethernet PHY. * @details @ref wizphy_setphypmode() sets a power mode of the integrated Ethernet PHY \n * through @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_.\n * @param pmode @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN * @note When the integrated Ethernet PHY enters in power down mode, \n * the system clock of @ref _WIZCHIP_ is changed to the lowest speed. \n * So, you should adjust the access time of @ref _WIZCHIP_ to the changed system clock. * @sa ctlwizchip(), CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE * @sa _PHY_IO_MODE_, wizphy_setphypmode(), wizphy_getphypmode() */ void wizphy_setphypmode(uint8_t pmode); /** * @ingroup extra_functions * @brief get the power mode of integrated Ethernet PHY. * @details @ref wizphy_getphypmode() gets a power mode of the integrated Ethernet PHY \n * through @ref _PHY_IO_MODE_PHYCR_ or @ref _PHY_IO_MODE_MII_.\n * @return @ref PHY_POWER_NORM or @ref PHY_POWER_DOWN * @note When the integrated Ethernet PHY enters in power down mode,\n * the system clock of @ref _WIZCHIP_ is changed to the lowest speed. \n * So, you should adjust the access time of @ref _WIZCHIP_ to the changed system clock. * @sa ctlwizchip(), CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE * @sa _PHY_IO_MODE_, wizphy_setphypmode(), wizphy_getphypmode() */ int8_t wizphy_getphypmode(void); /** * @ingroup extra_functions * @brief Set the network information for @ref _WIZCHIP_ * @param pnetinfo : @ref wiz_NetInfo * @sa ctlnetwork(), CN_SET_NETINFO, CN_GET_NETINFO * @sa wizchip_getnetinfo() */ void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Get the network information of @ref _WIZCHIP_ * @param pnetinfo : @ref wiz_NetInfo * @sa ctlnetwork(), CN_GET_NETINFO, CN_SET_NETINFO * @sa wizchip_setnetinfo() */ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Set the network mode such as WOL, PPPoE, PING Block, and etc. * @param netmode : @ref netmode_type. * @sa ctlnetwork(), CN_SET_NETMODE, CN_GET_NETMODE * @sa wizchip_getnetmode() */ void wizchip_setnetmode(netmode_type netmode); /** * @ingroup extra_functions * @brief Get the network mode such as WOL, PPPoE, PING Block, and etc. * @return @ref netmode_type. * @sa ctlnetwork(), CN_GET_NETMODE, CN_SET_NETMODE * @sa wizchip_setnetmode() */ netmode_type wizchip_getnetmode(void); /** * @ingroup extra_functions * @brief Set retransmission time values and retry counts. * @param nettime : @ref wiz_NetTimeout. * @sa ctlnetwork(), CN_SET_TIMEOUT, CN_GET_TIMEOUT * @sa wizchip_gettimeout() */ void wizchip_settimeout(wiz_NetTimeout* nettime); /** * @ingroup extra_functions * @brief Get retransmission time values and retry counts. * @param nettime : @ref wiz_NetTimeout. * @sa ctlnetwork(), CN_GET_TIMEOUT, CN_SET_TIMEOUT * @sa wizchip_settimeout() */ void wizchip_gettimeout(wiz_NetTimeout* nettime); /** * @ingroup extra_functions * @brief ARP process. * @details @ref wizchip_arp() processes ARP. \n * It sends the APR-request to destination and waits to receive the ARP-reply. * @param arp @ref wiz_ARP.\n * It sets a destination IP address and indicates the destination hardware address. * @return 0 : success, destination hardware address is valid.\n * -1 : fail. destination hardware address is invalid because timeout is occurred.\n * @sa ctlnetservice(), CNS_ARP */ int8_t wizchip_arp(wiz_ARP* arp); /** * @ingroup extra_functions * @brief PING process. * @details @ref wizchip_ping() processes PING. \n * It sends the PING-request to destination and waits to receive the PING-reply. * @param ping @ref wiz_PING, It sets a destination IP address, ID, SEQ of PING-request message * @return 0 : success, PING-reply is successfully received.\n * -1 : fail. Timeout is occurred.\n * @sa ctlnetservice(), CNS_PING */ int8_t wizchip_ping(wiz_PING* ping); /** * @ingroup extra_functions * @brief DAD(Duplcated Address Detection) process. * @details @ref wizchip_dad() detects the duplication of source IPv6 address.\n * It sends a NA message for DAD to all-node multicasting address(FF02::01). * @param ipv6 : IPv6 address to be detected the duplication. * @return 0 : success, There is no duplicated address. \n * -1 : fail. @ref _WIZCHIP_ source IP address to use is duplicated with a neighbor's one. * @sa ctlnetservice(), CNS_DAD */ int8_t wizchip_dad(uint8_t* ipv6); /** * @ingroup extra_functions * @brief Stateless Address Auto Configuration(SLAAC) process. * @details @ref wizchip_slaac() get a prefix information from a router for SLAAC.\n * It sends first a RS message to all-router and waits to receive a RS message with prefix information option from a router. * @param prefix @ref wiz_Prefix * @return 0 : success, RA message is successfully received, and <i>prefix</i> is valid. \n * -1 : fail. Timeout is occurred. * @note It is valid only when the prefix information type(0x03) of RA option received first.\n * The prefix option should be in the order of prefix length, prefix flag, valid lifetime, default lifetime and prefix address. \n * For more detail, Refer to @ref SLIR_RS. * @sa ctlnetservice(), CNS_SLAAC */ int8_t wizchip_slaac(wiz_Prefix* prefix); /** * @ingroup extra_functions * @brief Unsolicited NA process. * @details @ref wizchip_unsolicited() updates the network information of @ref _WIZCHIP_ to neighbors.\n * It sends a unsolicited NA message with @ref _LLAR_ or @ref _GUAR_ to neighbors \n * in order to update the network information of @ref _WIZCHIP_.\n * Because the unsolicited NA message have no reply, timeout is always occurred. * @return always 0. Timeout is occurred. * @sa ctlnetservice(), CNS_UNSOL */ int8_t wizchip_unsolicited(void); /** * @ingroup extra_functions * @brief Get a prefix information of RA message from a router. * @details @ref wizchip_getprefix() get a prefix information of RA is periodically sent by a router. \n * @return 0 : success, a RS message is successfully received from a router. * -1 : fail, a RS message is not received from a router yet. * @note It is valid only when the prefix information type(0x03) of RA option received first.\n * The prefix option should be in the order of prefix length, prefix flag, valid lifetime, default lifetime and prefix address. \n * For more detail, Refer to @ref SLIR_RS. * @sa ctlnetservice(), CNS_GET_PREFIX */ int8_t wizchip_getprefix(wiz_Prefix * prefix); #endif #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) /** * @ingroup extra_functions * @brief Set the network information for WIZCHIP * @param pnetinfo : @ref wizNetInfo */ void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Get the network information for WIZCHIP * @param pnetinfo : @ref wizNetInfo */ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Set the network mode such WOL, PPPoE, Ping Block, and etc. * @param pnetinfo Value of network mode. Refer to @ref netmode_type. */ int8_t wizchip_setnetmode(netmode_type netmode); /** * @ingroup extra_functions * @brief Get the network mode such WOL, PPPoE, Ping Block, and etc. * @return Value of network mode. Refer to @ref netmode_type. */ netmode_type wizchip_getnetmode(void); /** * @ingroup extra_functions * @brief Set retry time value(@ref _RTR_) and retry count(@ref _RCR_). * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. */ void wizchip_settimeout(wiz_NetTimeout* nettime); /** * @ingroup extra_functions * @brief Get retry time value(@ref _RTR_) and retry count(@ref _RCR_). * @details @ref _RTR_ configures the retransmission timeout period and @ref _RCR_ configures the number of time of retransmission. * @param nettime @ref _RTR_ value and @ref _RCR_ value. Refer to @ref wiz_NetTimeout. */ void wizchip_gettimeout(wiz_NetTimeout* nettime); //teddy 240122 #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) /** * @ingroup extra_functions * @brief Set the network information for @ref _WIZCHIP_ * @param pnetinfo : @ref wiz_NetInfo * @sa ctlnetwork(), CN_SET_NETINFO, CN_GET_NETINFO * @sa wizchip_getnetinfo() */ void wizchip_setnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Get the network information of @ref _WIZCHIP_ * @param pnetinfo : @ref wiz_NetInfo * @sa ctlnetwork(), CN_GET_NETINFO, CN_SET_NETINFO * @sa wizchip_setnetinfo() */ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo); /** * @ingroup extra_functions * @brief Set the network mode such as WOL, PPPoE, PING Block, and etc. * @param netmode : @ref netmode_type. * @sa ctlnetwork(), CN_SET_NETMODE, CN_GET_NETMODE * @sa wizchip_getnetmode() */ void wizchip_setnetmode(netmode_type netmode); /** * @ingroup extra_functions * @brief Get the network mode such as WOL, PPPoE, PING Block, and etc. * @return @ref netmode_type. * @sa ctlnetwork(), CN_GET_NETMODE, CN_SET_NETMODE * @sa wizchip_setnetmode() */ netmode_type wizchip_getnetmode(void); /** * @ingroup extra_functions * @brief Set retransmission time values and retry counts. * @param nettime : @ref wiz_NetTimeout. * @sa ctlnetwork(), CN_SET_TIMEOUT, CN_GET_TIMEOUT * @sa wizchip_gettimeout() */ void wizchip_settimeout(wiz_NetTimeout* nettime); /** * @ingroup extra_functions * @brief Get retransmission time values and retry counts. * @param nettime : @ref wiz_NetTimeout. * @sa ctlnetwork(), CN_GET_TIMEOUT, CN_SET_TIMEOUT * @sa wizchip_settimeout() */ void wizchip_gettimeout(wiz_NetTimeout* nettime); #endif #ifdef __cplusplus } #endif #endif // _WIZCHIP_CONF_H_
//****************************************************************************/ //! //! \file wizchip_conf.c //! \brief WIZCHIP Config Header File. //! \version 1.0.1 //! \date 2013/10/21 //! \par Revision history //! <2015/02/05> Notice //! The version history is not updated after this point. //! Download the latest version directly from GitHub. Please visit the our GitHub repository for ioLibrary. //! >> https://github.com/Wiznet/ioLibrary_Driver //! <2014/05/01> V1.0.1 Refer to M20140501 //! 1. Explicit type casting in wizchip_bus_readdata() & wizchip_bus_writedata() // Issued by Mathias ClauBen. //! uint32_t type converts into ptrdiff_t first. And then recoverting it into uint8_t* //! For remove the warning when pointer type size is not 32bit. //! If ptrdiff_t doesn't support in your complier, You should must replace ptrdiff_t into your suitable pointer type. //! <2013/10/21> 1st Release //! \author MidnightCow //! \copyright //! //! Copyright (c) 2013, WIZnet Co., LTD. //! All rights reserved. //! //! Redistribution and use in source and binary forms, with or without //! modification, are permitted provided that the following conditions //! are met: //! //! * Redistributions of source code must retain the above copyright //! notice, this list of conditions and the following disclaimer. //! * Redistributions in binary form must reproduce the above copyright //! notice, this list of conditions and the following disclaimer in the //! documentation and/or other materials provided with the distribution. //! * Neither the name of the <ORGANIZATION> nor the names of its //! contributors may be used to endorse or promote products derived //! from this software without specific prior written permission. //! //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF //! THE POSSIBILITY OF SUCH DAMAGE. // //*****************************************************************************/ //A20140501 : for use the type - ptrdiff_t #include <stddef.h> // #include <stdint.h> #include <stdbool.h> #include "wizchip_conf.h" ///////////// //M20150401 : Remove ; in the default callback function such as wizchip_cris_enter(), wizchip_cs_select() and etc. ///////////// /** * @brief Default function to enable interrupt. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_cris_enter(void) {}; void wizchip_cris_enter(void) {} /** * @brief Default function to disable interrupt. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_cris_exit(void) {}; void wizchip_cris_exit(void) {} /** * @brief Default function to select chip. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_cs_select(void) {}; void wizchip_cs_select(void) {} /** * @brief Default function to deselect chip. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_cs_deselect(void) {}; void wizchip_cs_deselect(void) {} /** * @brief Default function to read in direct or indirect interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //M20150601 : Rename the function for integrating with W5300 //uint8_t wizchip_bus_readbyte(uint32_t AddrSel) { return * ((volatile uint8_t *)((ptrdiff_t) AddrSel)); } iodata_t wizchip_bus_readdata(uint32_t AddrSel) { return * ((volatile iodata_t *)((ptrdiff_t) AddrSel)); } /** * @brief Default function to write in direct or indirect interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //M20150601 : Rename the function for integrating with W5300 //void wizchip_bus_writebyte(uint32_t AddrSel, uint8_t wb) { *((volatile uint8_t*)((ptrdiff_t)AddrSel)) = wb; } void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata_t*)((ptrdiff_t)AddrSel)) = wb; } #if 1 // 20231103 taylor /** * @brief Default function to read @ref iodata_t buffer by using BUS interface * @details @ref wizchip_bus_read_buf() provides the default read @ref iodata_t data as many as <i>len</i> from BUS of @ref _WIZCHIP_. * @param AddrSel It specifies the address of register to be read. * @param buf It specifies your buffer pointer to be saved the read data from @ref _WIZCHIP_. * @param len It specifies the data length to be read from @ref _WIZCHIP_. * @param addrinc It specifies whether the address is increased by every read operation or not.\n * 0 : Not Increased \n * 1 : Increased * @return void * @note It can be overwritten with your function or register your functions by calling @ref reg_wizchip_bus_cbfunc(). * @sa wizchip_bus_write_buf() */ void wizchip_bus_read_buf(uint32_t AddrSel, iodata_t* buf, int16_t len, uint8_t addrinc) { uint16_t i; if(addrinc) addrinc = sizeof(iodata_t); for ( i = 0; i < len; i++) { *buf++ = WIZCHIP.IF.BUS._read_data(AddrSel); AddrSel += (uint32_t) addrinc; } } /** * @brief Default function to write @ref iodata_t buffer by using BUS interface. * @details @ref wizchip_bus_write_buf() provides the default write @ref iodata_t data as many as <i>len</i> to BUS of @ref _WIZCHIP_. * @param AddrSel It specifies the address of register to be written. * @param buf It specifies your buffer pointer to be written to @ref _WIZCHIP_. * @param len It specifies the data length to be written to @ref _WIZCHIP_. * @param addrinc It specifies whether the address is increased by every write operation or not.\n * 0 : Not Increased \n * 1 : Increased * @return void * @note It can be overwritten with your function or register your functions by calling @ref reg_wizchip_bus_cbfunc(). * @sa wizchip_bus_read_buf() */ void wizchip_bus_write_buf(uint32_t AddrSel, iodata_t* buf, int16_t len, uint8_t addrinc) { uint16_t i; if(addrinc) addrinc = sizeof(iodata_t); for( i = 0; i < len ; i++) { WIZCHIP.IF.BUS._write_data(AddrSel,*buf++); AddrSel += (uint32_t)addrinc; } } #endif /** * @brief Default function to read in SPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //uint8_t wizchip_spi_readbyte(void) {return 0;}; uint8_t wizchip_spi_readbyte(void) {return 0;} /** * @brief Default function to write in SPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_spi_writebyte(uint8_t wb) {}; void wizchip_spi_writebyte(uint8_t wb) {} /** * @brief Default function to burst read in SPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}; #if 1 // 20231018 taylor void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) { for(uint16_t i=0; i<len; i++) { *pBuf++ = WIZCHIP.IF.SPI._read_byte(); } } #else void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {} #endif /** * @brief Default function to burst write in SPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ //void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}; #if 1 // 20231018 taylor void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) { for(uint16_t i=0; i<len; i++) { WIZCHIP.IF.SPI._write_byte(*pBuf++); } } #else void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {} #endif #if 1 //teddy 240122 /** * @brief Default function to read in QSPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ void wizchip_qspi_read(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len) {} /** * @brief Default function to write in QSPI interface. * @note This function help not to access wrong address. If you do not describe this function or register any functions, * null function is called. */ void wizchip_qspi_write(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len) {} #endif /** * @\ref _WIZCHIP instance */ // //M20150401 : For a compiler didnot support a member of structure // Replace the assignment of struct members with the assingment of array // /* _WIZCHIP WIZCHIP = { .id = _WIZCHIP_ID_, .if_mode = _WIZCHIP_IO_MODE_, .CRIS._enter = wizchip_cris_enter, .CRIS._exit = wizchip_cris_exit, .CS._select = wizchip_cs_select, .CS._deselect = wizchip_cs_deselect, .IF.BUS._read_byte = wizchip_bus_readbyte, .IF.BUS._write_byte = wizchip_bus_writebyte // .IF.SPI._read_byte = wizchip_spi_readbyte, // .IF.SPI._write_byte = wizchip_spi_writebyte }; */ _WIZCHIP WIZCHIP = { _WIZCHIP_IO_MODE_, _WIZCHIP_ID_ , { wizchip_cris_enter, wizchip_cris_exit }, { wizchip_cs_select, wizchip_cs_deselect }, { { //M20150601 : Rename the function //wizchip_bus_readbyte, //wizchip_bus_writebyte wizchip_bus_readdata, wizchip_bus_writedata }, } }; static uint8_t _DNS_[4]; // DNS server ip address #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) static dhcp_mode _DHCP_; // DHCP mode //teddy 240122 #elif ((_WIZCHIP_ == 6100) || (_WIZCHIP_ == 6300)) static uint8_t _DNS6_[16]; ///< DSN server IPv6 address static ipconf_mode _IPMODE_; ///< IP configuration mode #endif void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void)) { if(!cris_en || !cris_ex) { WIZCHIP.CRIS._enter = wizchip_cris_enter; WIZCHIP.CRIS._exit = wizchip_cris_exit; } else { WIZCHIP.CRIS._enter = cris_en; WIZCHIP.CRIS._exit = cris_ex; } } void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void)) { if(!cs_sel || !cs_desel) { WIZCHIP.CS._select = wizchip_cs_select; WIZCHIP.CS._deselect = wizchip_cs_deselect; } else { WIZCHIP.CS._select = cs_sel; WIZCHIP.CS._deselect = cs_desel; } } //M20150515 : For integrating with W5300 //void reg_wizchip_bus_cbfunc(uint8_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, uint8_t wb)) void reg_wizchip_bus_cbfunc(iodata_t(*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); //M20150601 : Rename call back function for integrating with W5300 /* if(!bus_rb || !bus_wb) { WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; } else { WIZCHIP.IF.BUS._read_byte = bus_rb; WIZCHIP.IF.BUS._write_byte = bus_wb; } */ if(!bus_rb || !bus_wb) { WIZCHIP.IF.BUS._read_data = wizchip_bus_readdata; WIZCHIP.IF.BUS._write_data = wizchip_bus_writedata; } else { WIZCHIP.IF.BUS._read_data = bus_rb; WIZCHIP.IF.BUS._write_data = bus_wb; } } #if 1 // 20231103 taylor void reg_wizchip_busbuf_cbfunc(void(*busbuf_rb)(uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc), void (*busbuf_wb)(uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_BUS_)); //M20150601 : Rename call back function for integrating with W5300 /* if(!bus_rb || !bus_wb) { WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte; WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte; } else { WIZCHIP.IF.BUS._read_byte = bus_rb; WIZCHIP.IF.BUS._write_byte = bus_wb; } */ if(!busbuf_rb || !busbuf_wb) { WIZCHIP.IF.BUS._read_data_buf = wizchip_bus_read_buf; WIZCHIP.IF.BUS._write_data_buf = wizchip_bus_write_buf; } else { WIZCHIP.IF.BUS._read_data_buf = busbuf_rb; WIZCHIP.IF.BUS._write_data_buf = busbuf_wb; } } #endif #if _WIZCHIP_ == W6100 void reg_wizchip_spi_cbfunc( uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb), void (*spi_rbuf)(uint8_t* buf, datasize_t len), void (*spi_wbuf)(uint8_t* buf, datasize_t len) ) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); if(!spi_rb) WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; else WIZCHIP.IF.SPI._read_byte = spi_rb; if(!spi_wb) WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; else WIZCHIP.IF.SPI._write_byte = spi_wb; if(!spi_rbuf) WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; else WIZCHIP.IF.SPI._read_burst = spi_rbuf; if(!spi_wbuf) WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; else WIZCHIP.IF.SPI._write_burst = spi_wbuf; } #else void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); if(!spi_rb || !spi_wb) { WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte; WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte; } else { WIZCHIP.IF.SPI._read_byte = spi_rb; WIZCHIP.IF.SPI._write_byte = spi_wb; } } #endif // 20140626 Eric Added for SPI burst operations void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_)); if(!spi_rb || !spi_wb) { WIZCHIP.IF.SPI._read_burst = wizchip_spi_readburst; WIZCHIP.IF.SPI._write_burst = wizchip_spi_writeburst; } else { WIZCHIP.IF.SPI._read_burst = spi_rb; WIZCHIP.IF.SPI._write_burst = spi_wb; } } #if 1 //teddy 240122 void reg_wizchip_qspi_cbfunc(void (*qspi_rb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len), void (*qspi_wb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len)) { while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_QSPI_)); if(!qspi_rb || !qspi_wb) { WIZCHIP.IF.QSPI._read_qspi = wizchip_qspi_read; WIZCHIP.IF.QSPI._write_qspi = wizchip_qspi_write; } else { WIZCHIP.IF.QSPI._read_qspi = qspi_rb; WIZCHIP.IF.QSPI._write_qspi = qspi_wb; } } #endif int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) { //teddy 240122 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 || _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 uint8_t tmp = *(uint8_t*) arg; #endif uint8_t* ptmp[2] = {0,0}; switch(cwtype) { //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 case CW_SYS_LOCK: if(tmp & SYS_CHIP_LOCK) CHIPLOCK(); if(tmp & SYS_NET_LOCK) NETLOCK(); if(tmp & SYS_PHY_LOCK) PHYLOCK(); break; case CW_SYS_UNLOCK: if(tmp & SYS_CHIP_LOCK) CHIPUNLOCK(); if(tmp & SYS_NET_LOCK) NETUNLOCK(); if(tmp & SYS_PHY_LOCK) PHYUNLOCK(); break; case CW_GET_SYSLOCK: *(uint8_t*)arg = getSYSR() >> 5; break; #endif case CW_RESET_WIZCHIP: wizchip_sw_reset(); break; case CW_INIT_WIZCHIP: if(arg != 0) { ptmp[0] = (uint8_t*)arg; ptmp[1] = ptmp[0] + _WIZCHIP_SOCK_NUM_; } return wizchip_init(ptmp[0], ptmp[1]); case CW_CLR_INTERRUPT: wizchip_clrinterrupt(*((intr_kind*)arg)); break; case CW_GET_INTERRUPT: *((intr_kind*)arg) = wizchip_getinterrupt(); break; case CW_SET_INTRMASK: wizchip_setinterruptmask(*((intr_kind*)arg)); break; case CW_GET_INTRMASK: *((intr_kind*)arg) = wizchip_getinterruptmask(); break; //M20150601 : This can be supported by W5200, W5500 //#if _WIZCHIP_ > W5100 #if (_WIZCHIP_ == W5200 || _WIZCHIP_ == W5500) case CW_SET_INTRTIME: setINTLEVEL(*(uint16_t*)arg); break; case CW_GET_INTRTIME: *(uint16_t*)arg = getINTLEVEL(); break; //teddy 240122 #elif ((_WIZCHIP_ == W6100) || (_WIZCHIP_ == W6300)) case CW_SET_INTRTIME: setINTPTMR(*(uint16_t*)arg); break; case CW_GET_INTRTIME: *(uint16_t*)arg = getINTPTMR(); break; #endif case CW_GET_ID: ((uint8_t*)arg)[0] = WIZCHIP.id[0]; ((uint8_t*)arg)[1] = WIZCHIP.id[1]; ((uint8_t*)arg)[2] = WIZCHIP.id[2]; ((uint8_t*)arg)[3] = WIZCHIP.id[3]; ((uint8_t*)arg)[4] = WIZCHIP.id[4]; ((uint8_t*)arg)[5] = WIZCHIP.id[5]; ((uint8_t*)arg)[6] = 0; break; #if 1 // 20231017 taylor//teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 case CW_GET_VER: *(uint16_t*)arg = getVER(); break; #endif #endif //teddy 240122 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5500 || _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 case CW_RESET_PHY: wizphy_reset(); break; case CW_SET_PHYCONF: wizphy_setphyconf((wiz_PhyConf*)arg); break; case CW_GET_PHYCONF: wizphy_getphyconf((wiz_PhyConf*)arg); break; case CW_GET_PHYSTATUS: #if 1 // 20231012 taylor #if _WIZCHIP_ == W5500 wizphy_getphystat((wiz_PhyConf*)arg); #endif #else wizphy_getphystat((wiz_PhyConf*)arg); #endif break; case CW_SET_PHYPOWMODE: //teddy 240122 #if _WIZCHIP_ == W6100 ||_WIZCHIP_ == W6300 wizphy_setphypmode(*(uint8_t*)arg); break; #else return wizphy_setphypmode(*(uint8_t*)arg); #endif #endif //teddy 240122 #if _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5500 || _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 case CW_GET_PHYPOWMODE: tmp = wizphy_getphypmode(); if((int8_t)tmp == -1) return -1; *(uint8_t*)arg = tmp; break; case CW_GET_PHYLINK: tmp = wizphy_getphylink(); if((int8_t)tmp == -1) return -1; *(uint8_t*)arg = tmp; break; #endif default: return -1; } return 0; } int8_t ctlnetwork(ctlnetwork_type cntype, void* arg) { switch(cntype) { case CN_SET_NETINFO: wizchip_setnetinfo((wiz_NetInfo*)arg); break; case CN_GET_NETINFO: wizchip_getnetinfo((wiz_NetInfo*)arg); break; case CN_SET_NETMODE: #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) return wizchip_setnetmode(*(netmode_type*)arg); //teddy 240122 #elif ((_WIZCHIP_ == 6100)||(_WIZCHIP_ == W6300)) wizchip_setnetmode(*(netmode_type*)arg); #endif case CN_GET_NETMODE: *(netmode_type*)arg = wizchip_getnetmode(); break; case CN_SET_TIMEOUT: wizchip_settimeout((wiz_NetTimeout*)arg); break; case CN_GET_TIMEOUT: wizchip_gettimeout((wiz_NetTimeout*)arg); break; //teddy 240122 #if ((_WIZCHIP_ == 6100)||(_WIZCHIP_ == 6300)) case CN_SET_PREFER: setSLPSR(*(uint8_t*)arg); break; case CN_GET_PREFER: *(uint8_t*)arg= getSLPSR(); break; #endif default: return -1; } return 0; } void wizchip_sw_reset(void) { uint8_t gw[4], sn[4], sip[4]; uint8_t mac[6]; //teddy 240122 #if ((_WIZCHIP_ == 6100) ||(_WIZCHIP_ == 6300)) uint8_t gw6[16], sn6[16], lla[16], gua[16]; uint8_t islock = getSYSR(); #endif #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) //A20150601 #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ uint16_t mr = (uint16_t)getMR(); setMR(mr | MR_IND); #endif // getSHAR(mac); getGAR(gw); getSUBR(sn); getSIPR(sip); setMR(MR_RST); getMR(); // for delay //A2015051 : For indirect bus mode #if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_BUS_INDIR_ setMR(mr | MR_IND); #endif // setSHAR(mac); setGAR(gw); setSUBR(sn); setSIPR(sip); //teddy 240122 #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) CHIPUNLOCK(); getSHAR(mac); getGAR(gw); getSUBR(sn); getSIPR(sip); getGA6R(gw6); getSUB6R(sn6); getLLAR(lla); getGUAR(gua); setSYCR0(SYCR0_RST); getSYCR0(); // for delay NETUNLOCK(); setSHAR(mac); setGAR(gw); setSUBR(sn); setSIPR(sip); setGA6R(gw6); setSUB6R(sn6); setLLAR(lla); setGUAR(gua); if(islock & SYSR_CHPL) CHIPLOCK(); if(islock & SYSR_NETL) NETLOCK(); #endif } int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize) { int8_t i; #if _WIZCHIP_ < W5200 int8_t j; #endif int8_t tmp = 0; wizchip_sw_reset(); if(txsize) { tmp = 0; //M20150601 : For integrating with W5300 #if _WIZCHIP_ == W5300 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { if(txsize[i] > 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation tmp += txsize[i]; if(tmp > 128) return -1; } if(tmp % 8) return -1; #else for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { tmp += txsize[i]; #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s if(tmp > 8) return -1; #elif _WIZCHIP_ == W6300 if(tmp > 32) return -1; #else if(tmp > 16) return -1; #endif } #endif for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 j = 0; while((txsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} setSn_TXBUF_SIZE(i, j); #else setSn_TXBUF_SIZE(i, txsize[i]); #endif } } if(rxsize) { tmp = 0; #if _WIZCHIP_ == W5300 for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { if(rxsize[i] > 64) return -1; //No use 64KB even if W5300 support max 64KB memory allocation tmp += rxsize[i]; if(tmp > 128) return -1; } if(tmp % 8) return -1; #else for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { tmp += rxsize[i]; #if _WIZCHIP_ < W5200 //2016.10.28 peter add condition for w5100 and w5100s if(tmp > 8) return -1; #elif _WIZCHIP_ == W6300 if(tmp > 32) return -1; #else if(tmp > 16) return -1; #endif } #endif for(i = 0 ; i < _WIZCHIP_SOCK_NUM_; i++) { #if _WIZCHIP_ < W5200 // add condition for w5100 j = 0; while((rxsize[i] >> j != 1)&&(txsize[i] !=0)){j++;} setSn_RXBUF_SIZE(i, j); #else setSn_RXBUF_SIZE(i, rxsize[i]); #endif } } return 0; } void wizchip_clrinterrupt(intr_kind intr) { uint8_t ir = (uint8_t)intr; uint8_t sir = (uint8_t)((uint16_t)intr >> 8); //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 int i; uint8_t slir = (uint8_t)((uint32_t)intr >> 16); setIRCLR(ir); for(i=0; i<_WIZCHIP_SOCK_NUM_; i++) { if(sir&(1<<i)) setSn_IRCLR(i,0xFF); } setSLIRCLR(slir); return; #endif #if _WIZCHIP_ < W5500 ir |= (1<<4); // IK_WOL #endif #if _WIZCHIP_ == W5200 ir |= (1 << 6); #endif #if _WIZCHIP_ < W5200 sir &= 0x0F; #endif #if _WIZCHIP_ <= W5100S ir |= sir; setIR(ir); //A20150601 : For integrating with W5300 #elif _WIZCHIP_ == W5300 setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) ); #else setIR(ir); //M20200227 : For clear //setSIR(sir); for(ir=0; ir<8; ir++){ if(sir & (0x01 <<ir) ) setSn_IR(ir, 0xff); } #endif } intr_kind wizchip_getinterrupt(void) { uint8_t ir = 0; uint8_t sir = 0; uint32_t ret = 0; #if _WIZCHIP_ <= W5100S ir = getIR(); sir = ir & 0x0F; //A20150601 : For integrating with W5300 #elif _WIZCHIP_ == W5300 ret = getIR(); ir = (uint8_t)(ret >> 8); sir = (uint8_t)ret; #else ir = getIR(); sir = getSIR(); #endif //M20150601 : For Integrating with W5300 //#if _WIZCHIP_ < W5500 #if _WIZCHIP_ < W5200 ir &= ~(1<<4); // IK_WOL #endif #if _WIZCHIP_ == W5200 ir &= ~(1 << 6); #endif ret = sir; ret = (ret << 8) + ir; //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 ret = (((uint32_t)getSLIR())<<16) | ret; #endif return (intr_kind)ret; } void wizchip_setinterruptmask(intr_kind intr) { uint8_t imr = (uint8_t)intr; uint8_t simr = (uint8_t)((uint16_t)intr >> 8); #if _WIZCHIP_ < W5500 imr &= ~(1<<4); // IK_WOL #endif #if _WIZCHIP_ == W5200 imr &= ~(1 << 6); #endif #if _WIZCHIP_ < W5200 simr &= 0x0F; imr |= simr; setIMR(imr); //A20150601 : For integrating with W5300 #elif _WIZCHIP_ == W5300 setIMR( ((((uint16_t)imr) << 8) | (((uint16_t)simr) & 0x00FF)) ); #else setIMR(imr); setSIMR(simr); //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 uint8_t slimr = (uint8_t)((uint32_t)intr >> 16); setSLIMR(slimr); #endif #endif } intr_kind wizchip_getinterruptmask(void) { uint8_t imr = 0; uint8_t simr = 0; uint32_t ret = 0; #if _WIZCHIP_ < W5200 imr = getIMR(); simr = imr & 0x0F; //A20150601 : For integrating with W5300 #elif _WIZCHIP_ == W5300 ret = getIMR(); imr = (uint8_t)(ret >> 8); simr = (uint8_t)ret; #else imr = getIMR(); simr = getSIMR(); #endif #if _WIZCHIP_ < W5500 imr &= ~(1<<4); // IK_WOL #endif #if _WIZCHIP_ == W5200 imr &= ~(1 << 6); // IK_DEST_UNREACH #endif ret = simr; ret = (ret << 8) + imr; //teddy 240122 #if _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 ret = (((uint32_t)getSLIMR())<<16) | ret; #endif return (intr_kind)ret; } int8_t wizphy_getphylink(void) { int8_t tmp = PHY_LINK_OFF; #if _WIZCHIP_ == W5100S if(getPHYSR() & PHYSR_LNK) tmp = PHY_LINK_ON; #elif _WIZCHIP_ == W5200 if(getPHYSTATUS() & PHYSTATUS_LINK) tmp = PHY_LINK_ON; #elif _WIZCHIP_ == W5500 if(getPHYCFGR() & PHYCFGR_LNK_ON) tmp = PHY_LINK_ON; #elif ((_WIZCHIP_ == W6100)||(_WIZCHIP_ == W6300)) #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) return (getPHYSR() & PHYSR_LNK); #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) if(wiz_mdio_read(PHYRAR_BMSR) & BMSR_LINK_STATUS) return PHY_LINK_ON; return PHY_LINK_OFF; #endif #else tmp = -1; #endif return tmp; } #if _WIZCHIP_ > W5100 int8_t wizphy_getphypmode(void) { int8_t tmp = 0; #if _WIZCHIP_ == W5200 if(getPHYSTATUS() & PHYSTATUS_POWERDOWN) tmp = PHY_POWER_DOWN; else tmp = PHY_POWER_NORM; #elif _WIZCHIP_ == 5500 if((getPHYCFGR() & PHYCFGR_OPMDC_ALLA) == PHYCFGR_OPMDC_PDOWN) tmp = PHY_POWER_DOWN; else tmp = PHY_POWER_NORM; //teddy 240122 #elif _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) if (getPHYCR1() & PHYCR1_PWDN) return PHY_POWER_DOWN; #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) if (wiz_mdio_read(PHYRAR_BMCR) & BMCR_PWDN) return PHY_POWER_DOWN; #endif return PHY_POWER_NORM; #else tmp = -1; #endif return tmp; } #endif #if _WIZCHIP_ == W5100S void wizphy_reset(void) { uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); tmp |= BMCR_RESET; wiz_mdio_write(PHYMDIO_BMCR, tmp); while(wiz_mdio_read(PHYMDIO_BMCR)&BMCR_RESET){} } void wizphy_setphyconf(wiz_PhyConf* phyconf) { uint16_t tmp = wiz_mdio_read(PHYMDIO_BMCR); if(phyconf->mode == PHY_MODE_AUTONEGO) tmp |= BMCR_AUTONEGO; else { tmp &= ~BMCR_AUTONEGO; if(phyconf->duplex == PHY_DUPLEX_FULL) { tmp |= BMCR_DUP; } else { tmp &= ~BMCR_DUP; } if(phyconf->speed == PHY_SPEED_100) { tmp |= BMCR_SPEED; } else { tmp &= ~BMCR_SPEED; } } wiz_mdio_write(PHYMDIO_BMCR, tmp); } void wizphy_getphyconf(wiz_PhyConf* phyconf) { uint16_t tmp = 0; tmp = wiz_mdio_read(PHYMDIO_BMCR); phyconf->by = PHY_CONFBY_SW; if(tmp & BMCR_AUTONEGO) { phyconf->mode = PHY_MODE_AUTONEGO; } else { phyconf->mode = PHY_MODE_MANUAL; if(tmp&BMCR_DUP) phyconf->duplex = PHY_DUPLEX_FULL; else phyconf->duplex = PHY_DUPLEX_HALF; if(tmp&BMCR_SPEED) phyconf->speed = PHY_SPEED_100; else phyconf->speed = PHY_SPEED_10; } } int8_t wizphy_setphypmode(uint8_t pmode) { uint16_t tmp = 0; tmp = wiz_mdio_read(PHYMDIO_BMCR); if( pmode == PHY_POWER_DOWN) { tmp |= BMCR_PWDN; } else { tmp &= ~BMCR_PWDN; } wiz_mdio_write(PHYMDIO_BMCR, tmp); tmp = wiz_mdio_read(PHYMDIO_BMCR); if( pmode == PHY_POWER_DOWN) { if(tmp & BMCR_PWDN) return 0; } else { if((tmp & BMCR_PWDN) != BMCR_PWDN) return 0; } return -1; } #elif _WIZCHIP_ == W5500 void wizphy_reset(void) { uint8_t tmp = getPHYCFGR(); tmp &= PHYCFGR_RST; setPHYCFGR(tmp); tmp = getPHYCFGR(); tmp |= ~PHYCFGR_RST; setPHYCFGR(tmp); } void wizphy_setphyconf(wiz_PhyConf* phyconf) { uint8_t tmp = 0; if(phyconf->by == PHY_CONFBY_SW) tmp |= PHYCFGR_OPMD; else tmp &= ~PHYCFGR_OPMD; if(phyconf->mode == PHY_MODE_AUTONEGO) tmp |= PHYCFGR_OPMDC_ALLA; else { if(phyconf->duplex == PHY_DUPLEX_FULL) { if(phyconf->speed == PHY_SPEED_100) tmp |= PHYCFGR_OPMDC_100F; else tmp |= PHYCFGR_OPMDC_10F; } else { if(phyconf->speed == PHY_SPEED_100) tmp |= PHYCFGR_OPMDC_100H; else tmp |= PHYCFGR_OPMDC_10H; } } setPHYCFGR(tmp); wizphy_reset(); } void wizphy_getphyconf(wiz_PhyConf* phyconf) { uint8_t tmp = 0; tmp = getPHYCFGR(); phyconf->by = (tmp & PHYCFGR_OPMD) ? PHY_CONFBY_SW : PHY_CONFBY_HW; switch(tmp & PHYCFGR_OPMDC_ALLA) { case PHYCFGR_OPMDC_ALLA: case PHYCFGR_OPMDC_100FA: phyconf->mode = PHY_MODE_AUTONEGO; break; default: phyconf->mode = PHY_MODE_MANUAL; break; } switch(tmp & PHYCFGR_OPMDC_ALLA) { case PHYCFGR_OPMDC_100FA: case PHYCFGR_OPMDC_100F: case PHYCFGR_OPMDC_100H: phyconf->speed = PHY_SPEED_100; break; default: phyconf->speed = PHY_SPEED_10; break; } switch(tmp & PHYCFGR_OPMDC_ALLA) { case PHYCFGR_OPMDC_100FA: case PHYCFGR_OPMDC_100F: case PHYCFGR_OPMDC_10F: phyconf->duplex = PHY_DUPLEX_FULL; break; default: phyconf->duplex = PHY_DUPLEX_HALF; break; } } void wizphy_getphystat(wiz_PhyConf* phyconf) { uint8_t tmp = getPHYCFGR(); phyconf->duplex = (tmp & PHYCFGR_DPX_FULL) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; phyconf->speed = (tmp & PHYCFGR_SPD_100) ? PHY_SPEED_100 : PHY_SPEED_10; } int8_t wizphy_setphypmode(uint8_t pmode) { uint8_t tmp = 0; tmp = getPHYCFGR(); if((tmp & PHYCFGR_OPMD)== 0) return -1; tmp &= ~PHYCFGR_OPMDC_ALLA; if( pmode == PHY_POWER_DOWN) tmp |= PHYCFGR_OPMDC_PDOWN; else tmp |= PHYCFGR_OPMDC_ALLA; setPHYCFGR(tmp); wizphy_reset(); tmp = getPHYCFGR(); if( pmode == PHY_POWER_DOWN) { if(tmp & PHYCFGR_OPMDC_PDOWN) return 0; } else { if(tmp & PHYCFGR_OPMDC_ALLA) return 0; } return -1; } //teddy 240122 #elif _WIZCHIP_ == W6100 || _WIZCHIP_ == W6300 void wizphy_reset(void) { #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) uint8_t tmp = getPHYCR1() | PHYCR1_RST; PHYUNLOCK(); setPHYCR1(tmp); PHYLOCK(); #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) wiz_mdio_write(PHYRAR_BMCR, wiz_mdio_read(PHYRAR_BMCR) | BMCR_RST); while(wiz_mdio_read(PHYRAR_BMCR) & BMCR_RST); #endif } void wizphy_setphyconf(wiz_PhyConf* phyconf) { #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) uint8_t tmp = 0; if(phyconf->mode == PHY_MODE_TE) { setPHYCR1(getPHYCR1() | PHYCR1_TE); tmp = PHYCR0_AUTO; } else { setPHYCR1(getPHYCR1() & ~PHYCR1_TE); if(phyconf->mode == PHY_MODE_AUTONEGO) tmp = PHYCR0_AUTO; else { tmp |= 0x04; if(phyconf->speed == PHY_SPEED_10) tmp |= 0x02; if(phyconf->duplex == PHY_DUPLEX_HALF) tmp |= 0x01; } } setPHYCR0(tmp); #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) uint16_t tmp = wiz_mdio_read(PHYRAR_BMCR); if(phyconf->mode == PHY_MODE_TE) { setPHYCR1(getPHYCR1() | PHYCR1_TE); setPHYCR0(PHYCR0_AUTO); } else { setPHYCR1(getPHYCR1() & ~PHYCR1_TE); if(phyconf->mode == PHY_MODE_AUTONEGO) tmp |= BMCR_ANE; else { tmp &= ~(BMCR_ANE|BMCR_DPX|BMCR_SPD); if(phyconf->duplex == PHY_DUPLEX_FULL) tmp |= BMCR_DPX; if(phyconf->speed == PHY_SPEED_100) tmp |= BMCR_SPD; } wiz_mdio_write(PHYRAR_BMCR, tmp); } #endif } void wizphy_getphyconf(wiz_PhyConf* phyconf) { #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) uint8_t tmp = 0; tmp = getPHYSR(); if(getPHYCR1() & PHYCR1_TE) phyconf->mode = PHY_MODE_TE; else phyconf->mode = (tmp & (1<<5)) ? PHY_MODE_MANUAL : PHY_MODE_AUTONEGO ; phyconf->speed = (tmp & (1<<4)) ? PHY_SPEED_10 : PHY_SPEED_100; phyconf->duplex = (tmp & (1<<3)) ? PHY_DUPLEX_HALF : PHY_DUPLEX_FULL; #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) uint16_t tmp = 0; tmp = wiz_mdio_read(PHYRAR_BMCR); if(getPHYCR1() & PHYCR1_TE) phyconf->mode = PHY_MODE_TE; else phyconf->mode = (tmp & BMCR_ANE) ? PHY_MODE_AUTONEGO : PHY_MODE_MANUAL; phyconf->duplex = (tmp & BMCR_DPX) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; phyconf->speed = (tmp & BMCR_SPD) ? PHY_SPEED_100 : PHY_SPEED_10; #endif } void wizphy_getphystat(wiz_PhyConf* phyconf) { uint8_t tmp = 0; tmp = getPHYSR(); if(getPHYCR1() & PHYCR1_TE) phyconf->mode = PHY_MODE_TE; else phyconf->mode = (tmp & (1<<5)) ? PHY_MODE_MANUAL : PHY_MODE_AUTONEGO ; phyconf->speed = (tmp & PHYSR_SPD) ? PHY_SPEED_10 : PHY_SPEED_100; phyconf->duplex = (tmp & PHYSR_DPX) ? PHY_DUPLEX_HALF : PHY_DUPLEX_FULL; } void wizphy_setphypmode(uint8_t pmode) { #if (_PHY_IO_MODE_ == _PHY_IO_MODE_PHYCR_) uint8_t tmp = getPHYCR1(); if (pmode == PHY_POWER_DOWN) tmp |= PHYCR1_PWDN; else tmp &= ~PHYCR1_PWDN; setPHYCR1(tmp); #elif (_PHY_IO_MODE_ == _PHY_IO_MODE_MII_) uint16_t tmp = 0; tmp = wiz_mdio_read(PHYRAR_BMCR); if (pmode == PHY_POWER_DOWN) tmp |= BMCR_PWDN; else tmp &= ~BMCR_PWDN; wiz_mdio_write(PHYRAR_BMCR, tmp); #endif } int8_t wizchip_arp(wiz_ARP* arp) { uint8_t tmp; if(arp->destinfo.len == 16) { setSLDIP6R(arp->destinfo.ip); setSLCR(SLCR_ARP6); } else { setSLDIP4R(arp->destinfo.ip); setSLCR(SLCR_ARP4); } while(getSLCR()); while((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if(tmp & (SLIR_ARP4 | SLIR_ARP6)) { getSLDHAR(arp->dha); return 0; } return -1; } int8_t wizchip_ping(wiz_PING* ping) { uint8_t tmp; setPINGIDR(ping->id); setPINGSEQR(ping->seq); if(ping->destinfo.len == 16) { setSLDIP6R(ping->destinfo.ip); setSLCR(SLCR_PING6); } else { setSLDIP4R(ping->destinfo.ip); setSLCR(SLCR_PING4); } while(getSLCR()); while((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if(tmp & (SLIR_PING4 | SLIR_PING6)) return 0; return -1; } int8_t wizchip_dad(uint8_t* ipv6) { uint8_t tmp; setSLDIP6R(ipv6); setSLCR(SLCR_NS); while(getSLCR()); while((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if(tmp & SLIR_TOUT) return 0; return -1; } int8_t wizchip_slaac(wiz_Prefix* prefix) { uint8_t tmp; setSLCR(SLCR_RS); while(getSLCR()); while((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if(tmp & SLIR_RS) { prefix->len = getPLR(); prefix->flag = getPFR(); prefix->valid_lifetime = getVLTR(); prefix->preferred_lifetime = getPLTR(); getPAR(prefix->prefix); return 0; } return -1; } int8_t wizchip_unsolicited(void) { uint8_t tmp; setSLCR(SLCR_UNA); while(getSLCR()); while((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if(tmp & SLIR_TOUT) return 0; return -1; } int8_t wizchip_getprefix(wiz_Prefix * prefix) { if(getSLIR() & SLIR_RA) { prefix->len = getPLR(); prefix->flag = getPFR(); prefix->valid_lifetime = getVLTR(); prefix->preferred_lifetime = getPLTR(); getPAR(prefix->prefix); setSLIRCLR(SLIR_RA); } return -1; } #endif #if (_WIZCHIP_ == W5100 || _WIZCHIP_ == W5100S || _WIZCHIP_ == W5200 || _WIZCHIP_ == W5300 || _WIZCHIP_ == W5500) void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) { setSHAR(pnetinfo->mac); setGAR(pnetinfo->gw); setSUBR(pnetinfo->sn); setSIPR(pnetinfo->ip); _DNS_[0] = pnetinfo->dns[0]; _DNS_[1] = pnetinfo->dns[1]; _DNS_[2] = pnetinfo->dns[2]; _DNS_[3] = pnetinfo->dns[3]; _DHCP_ = pnetinfo->dhcp; } void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) { getSHAR(pnetinfo->mac); getGAR(pnetinfo->gw); getSUBR(pnetinfo->sn); getSIPR(pnetinfo->ip); pnetinfo->dns[0]= _DNS_[0]; pnetinfo->dns[1]= _DNS_[1]; pnetinfo->dns[2]= _DNS_[2]; pnetinfo->dns[3]= _DNS_[3]; pnetinfo->dhcp = _DHCP_; } int8_t wizchip_setnetmode(netmode_type netmode) { uint8_t tmp = 0; #if _WIZCHIP_ != W5500 if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK)) return -1; #else if(netmode & ~(NM_WAKEONLAN | NM_PPPOE | NM_PINGBLOCK | NM_FORCEARP)) return -1; #endif tmp = getMR(); tmp |= (uint8_t)netmode; setMR(tmp); return 0; } netmode_type wizchip_getnetmode(void) { return (netmode_type) getMR(); } void wizchip_settimeout(wiz_NetTimeout* nettime) { setRCR(nettime->retry_cnt); setRTR(nettime->time_100us); } void wizchip_gettimeout(wiz_NetTimeout* nettime) { nettime->retry_cnt = getRCR(); nettime->time_100us = getRTR(); } //teddy 240122 #elif ((_WIZCHIP_ == 6100) ||(_WIZCHIP_ == 6300)) void wizchip_setnetinfo(wiz_NetInfo* pnetinfo) { uint8_t i=0; setSHAR(pnetinfo->mac); setGAR(pnetinfo->gw); setSUBR(pnetinfo->sn); setSIPR(pnetinfo->ip); setGA6R(pnetinfo->gw6); setSUB6R(pnetinfo->sn6); setLLAR(pnetinfo->lla); setGUAR(pnetinfo->gua); for(i=0; i<4; i++) _DNS_[i] = pnetinfo->dns[i]; for(i=0; i<16; i++) _DNS6_[i] = pnetinfo->dns6[i]; _IPMODE_ = pnetinfo->ipmode; } void wizchip_getnetinfo(wiz_NetInfo* pnetinfo) { uint8_t i = 0; getSHAR(pnetinfo->mac); getGAR(pnetinfo->gw); getSUBR(pnetinfo->sn); getSIPR(pnetinfo->ip); getGA6R(pnetinfo->gw6); getSUB6R(pnetinfo->sn6); getLLAR(pnetinfo->lla); getGUAR(pnetinfo->gua); for(i=0; i<4; i++) pnetinfo->dns[i] = _DNS_[i]; for(i=0; i<16; i++) pnetinfo->dns6[i] = _DNS6_[i]; pnetinfo->ipmode = _IPMODE_; } void wizchip_setnetmode(netmode_type netmode) { uint32_t tmp = (uint32_t) netmode; setNETMR ((uint8_t)tmp); setNETMR2((uint8_t)(tmp>>8)); setNET4MR((uint8_t)(tmp>>16)); setNET6MR((uint8_t)(tmp>>24)); } netmode_type wizchip_getnetmode(void) { uint32_t ret = 0; ret = getNETMR(); ret = (ret << 8) + getNETMR2(); ret = (ret << 16) + getNET4MR(); ret = (ret << 24) + getNET6MR(); return (netmode_type)ret; } // netmode_type wizchip_getnetmode(void) // { // return (netmode_type) getMR(); // } void wizchip_settimeout(wiz_NetTimeout* nettime) { setRCR(nettime->s_retry_cnt); setRTR(nettime->s_time_100us); setSLRCR(nettime->sl_retry_cnt); setSLRTR(nettime->sl_time_100us); } void wizchip_gettimeout(wiz_NetTimeout* nettime) { nettime->s_retry_cnt = getRCR(); nettime->s_time_100us = getRTR(); nettime->sl_retry_cnt = getSLRCR(); nettime->sl_time_100us = getSLRTR(); } #endif
Hello,
Thanks for sending these. Please allow another day for me to take a look.
Best Regards,
Allison
Hello,
Following up as I am still taking time to look into this. I appreciate your continued patience.
Best Regards,
Allison
Hello,
Thanks for your continued patience as I haven't been able to recreate your exact setup with only these files. Is there any update on your end?
Best Regards,
Allison
Hi Jedrzej,
Allison is currently out of office for the next week. Please expect a delayed response.
Best Regards,
Delaney
Hello,
Thanks for your patience while I was out of office. Are you still facing this error? Can you send your latest project?
Best Regards,
Allison
Hi
I have listened to your advises and i replaced uint8_t with uint16_t, after that there were a lot of unnamed variables so i named them and after that this 3 errors showed up.
lab_lp_f28004x (2).zip
Hello,
I will check into your project. Just to ensure we are on the same page, can you please send a snippet showing exactly which 3 errors you are seeing?
Best Regards,
Allison
Hello,
I confirm I see the same errors, so I'm checking some of the include paths. There are also many warnings that need to be addressed. I'm taking a look at those as well and will update in the next day.
Appreciate the patience!
Allison
Hello,
Thanks for the patience. I've taken a deeper look at your WizNet Ethernet controller project. There are several issues I saw preventing it from compiling. Keep in mind I don't have the same setup as you - mine had more issues showing due to having different paths etc.:
The most critical fix is the multiple definition of WIZCHIP, as this prevents compilation entirely. The other issues are important to fix but would only appear after resolving this main error. I unfortunately cannot offer more guidance since I don't have have familiarity with the WizNet libraries/software support. I can only offer support on C2000 SW.
Best Regards,
Allison