📄 rom400_sock.h
字号:
/**
* \brief Close all sockets associated with a task.
*
* Close all sockets associtaed with a process ID. User applications should
* call this function whenever a task dies or is killed to ensure all
* associated resources are freed by the socket layer.
*
* \warning The DS80C400 Silicon Software task scheduler does <b>NOT</b>
* call this function. User applications should call <i>#cleanup</i>
* after each call to <i>#task_kill</i>.
*
* \param process_id Task PID to clean up sockets associated with
*
* \return 0 for success, non-zero for failure.
*/
//---------------------------------------------------------------------------
#define cleanup(process_id) syn_cleanup((process_id))
/**
* \brief Reports number of bytes available on a TCP socket.
*
* Reports the number of bytes available on a TCP socket. This is the number
* of bytes that can currently be read using the <i>#recv</i> function without
* blocking.
*
* \param socket_num the handle of the socket to check for available data
*
* \return The number of bytes available for a <i>#recv</i> function call on this
* socket, or 0x0FFFF on failure.
*
* \sa #recv
*/
//---------------------------------------------------------------------------
#define avail(socket_num) syn_avail((socket_num))
/**
* \brief Adds a socket to a specified multicast group.
*
* Adds a UDP socket to a specified multicast group. In order to receive
* multicasts from a group, first <i>#bind</i> the socket to the port number
* that the multicast group is using (it is not sufficient to include it
* here in order to receive).
*
* Use the <i>#leave</i> function to leave a multicast group.
*
* \warning IPv6 multicasting is not supported
*
* \param socket_num handle for the datagram socket that will join a multicast group
* \param address IP address of the multicast group to join
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure.
*
* \sa #leave
*/
//---------------------------------------------------------------------------
#define join(socket_num,address,address_length) syn_join((socket_num),(address))
/**
* \brief Removes a socket from the specified multicast group.
*
* Removes a UDP socket from the specified multicast group.
*
* \param socket_num handle for the datagram socket that will leave a multicast group
* \param address IP address of the multicast group to leave
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure.
*
* \sa #join
*/
//---------------------------------------------------------------------------
#define leave(socket_num,address,address_length) syn_leave((socket_num),(address))
/**
* \brief Get the IPv4 configuration parameters.
*
* Get the IPv4 configuration parameters, including IP address, subnet mask,
* and gateway. The parameters are returned in a buffer in the following
* form:
* <table>
* <tr> <td> <b>Parameter</b> </td> <td> <b>Offset</b> </td> <td> <b>Length</b> </td> <td> <b>Description</b> </td> </tr>
* <tr> <td> (zero) </td> <td> 0 </td> <td> 12 </td> <td> Must be 0 </td> </tr>
* <tr> <td> IP4ADDR </td> <td> 12 </td> <td> 4 </td> <td> IP address </td> </tr>
* <tr> <td> IP4SUBNET </td> <td> 16 </td> <td> 4 </td> <td> Subnet mask </td> </tr>
* <tr> <td> IP4PREFIX </td> <td> 20 </td> <td> 1 </td> <td> Number of 1 bits in subnet mask </td> </tr>
* <tr> <td> (zero) </td> <td> 21 </td> <td> 12 </td> <td> Must be 0 </td> </tr>
* <tr> <td> IP4GATEWAY </td> <td> 33 </td> <td> 4 </td> <td> Gateway IP address </td> </tr>
* </table>
*
* IPv6 addresses are autoconfigured. To retrieve the IPv6 address, use the
* <i>#getipv6params</i> function.
*
* \param param_buffer pointer to buffer to store IP configuration data
*
* \return 0 for success, non-zero for failure
*
* \sa #setnetworkparams
* \sa #getipv6params
*/
//---------------------------------------------------------------------------
#define getnetworkparams(param_buffer) syn_getnetworkparams((param_buffer))
/**
* \brief Set the IPv4 configuration parameters.
*
* Set the IPv4 configuration parameters, including IP address, subnet mask,
* and gateway. Input parameters should be formatted in the following
* form:
* <table>
* <tr> <td> <b>Parameter</b> </td> <td> <b>Offset</b> </td> <td> <b>Length</b> </td> <td> <b>Description</b> </td> </tr>
* <tr> <td> (zero) </td> <td> 0 </td> <td> 12 </td> <td> Must be 0 </td> </tr>
* <tr> <td> IP4ADDR </td> <td> 12 </td> <td> 4 </td> <td> IP address </td> </tr>
* <tr> <td> IP4SUBNET </td> <td> 16 </td> <td> 4 </td> <td> Subnet mask </td> </tr>
* <tr> <td> IP4PREFIX </td> <td> 20 </td> <td> 1 </td> <td> Number of 1 bits in subnet mask </td> </tr>
* <tr> <td> (zero) </td> <td> 21 </td> <td> 12 </td> <td> Must be 0 </td> </tr>
* <tr> <td> IP4GATEWAY </td> <td> 33 </td> <td> 4 </td> <td> Gateway IP address </td> </tr>
* </table>
*
* Use this method to give the DS80C400 a static IP address. To dynamically
* configure an IP address, use methods from the DHCP library in rom400_dhcp.h
* (IP addresses leased by the DHCP client can still be retrieved
* by calling <i>#getnetworkparams</i>).
*
* IPv6 addresses are autoconfigured. To retrieve the IPv6 address, use the
* <i>#getipv6params</i> function.
*
* \param param_buffer pointer to buffer with IP configuration data
*
* \return 0 for success, non-zero for failure
*
* \sa #getnetworkparams
* \sa #getipv6params
*/
//---------------------------------------------------------------------------
#define setnetworkparams(param_buffer) syn_setnetworkparams((param_buffer))
/**
* \brief Get the IPv6 address.
*
* Gets the IPv6 address of the ethernet interface. The format for
* the buffer after this function returns is:
* <table>
* <tr> <td> <b>Parameter</b> </td> <td> <b>Offset</b> </td> <td> <b>Length</b> </td> <td> <b>Description</b> </td> </tr>
* <tr> <td> IP6ADDR </td> <td> 0 </td> <td> 16 </td> <td> IP address </td> </tr>
* <tr> <td> IP6PREFIX </td> <td> 16 </td> <td> 1 </td> <td> IP prefix length </td> </tr>
* </table>
*
* \param param_buffer pointer to buffer to store IPv6 configuration data
*
* \return 0 for success, non-zero for failure
*
* \sa #getnetworkparams
* \sa #setnetworkparams
*/
//---------------------------------------------------------------------------
#define getipv6params(param_buffer) syn_getipv6params((param_buffer))
/**
* \brief Get the ethernet status.
*
* Returns the ethernet status byte. This is a bit-wise OR of the following
* flags:
* <table>
* <tr> <td> <b>Flag</b> </td> <td> <b>Value</b> </td> <td> <b>Description</b> </td> </tr>
* <tr> <td> ETH_STATUS_LINK </td> <td> 01h </td> <td> Ethernet link status </td> </tr>
* </table>
*
* Currently, no other flags are defined.
*
* \return Bitmapped ethernet status byte.
*/
//---------------------------------------------------------------------------
#define getethernetstatus() syn_getethernetstatus()
/**
* \brief Get the address of the TFTP server.
*
* Returns the address of the server accessed by the TFTP functions. To
* communicate with a TFTP server, use the functions listed in rom400_tftp.h,
* the TFTP library.
*
* \param address structure to store the address of the TFTP server
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure
*
* \sa #settftpserver
*/
//---------------------------------------------------------------------------
#define gettftpserver(address,address_length) syn_gettftpserver((address))
/**
* \brief Set the address of the TFTP server.
*
* Set the address of the server that the TFTP functions will use.
* The <i>#settftpserver</i> function must be used if the address of
* the TFTP server is not acquired by DHCP or 1-Wire. Once the TFTP
* server's address is set, use the functions listed in rom400_tftp.h
* to begin receiving files.
*
* \param address structure to store the address of the TFTP server
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure
*
* \sa #gettftpserver
*/
//---------------------------------------------------------------------------
#define settftpserver(address,address_length) syn_settftpserver((address))
/**
* \brief Get the pointer to the MAC ID storage area.
*
* Returns the pointer to the MAC ID storage area. This area will
* store the MAC ID after a successful call to <i>#setmacid</i>.
*
* \return Pointer to the 400's MAC ID (6 bytes stored at this location)
*
* \sa #setmacid
*/
//---------------------------------------------------------------------------
#define getmacid() syn_getmacid()
/**
* \brief Stores the MAC ID into the MAC ID storage area.
*
* This is a redirected function. The DS80C400's default implementation
* of this function searches the 1-Wire for a DS2502U-E48 1-Wire chip
* which contains a MAC ID. This MAC ID is then stored into the MAC ID
* storage area, the location of which is stored in a pointer in the
* export table. Use the <i>#getmacid</i> function to return a pointer
* to the MAC ID storage area.
*
* \sa #getmacid
*/
//---------------------------------------------------------------------------
#define setmacid() syn_setmacid()
/**
* \brief Returns the version number of this socket library.
*
* \return Version number of this SOCK library.
*/
#define sock_version() syn_version()
/**
* \brief Pings the specified address.
*
* Sends an ICMP echo request (ping) to a specified address. Note that this function
* is <b>NOT</b> safe to be called from multiple processes at the same time.
*
* \param address IP address to send an ICMP echo request to
* \param address_length the length of the address structure (ignored)
* \param time_to_live packets send by ping have this "time to live" setting
* \param response buffer to fill in returned data. If non-null, 67 bytes will be written to <i>response</i>
*
* \return response time, or 0xFFFFFFFF for failure
*/
//---------------------------------------------------------------------------
unsigned long ping(struct sockaddr* address, unsigned int address_length, unsigned int time_to_live, unsigned char* response);
/**
* \brief Unconditionally generate an ARP request for a given IPv4 address.
*
* Unconditionally generate an ARP request for a given IPv4 address.
* This functionality can be used to implement Zeroconf protocols.
*
* \param address structure to store the address
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure
*/
//---------------------------------------------------------------------------
#define arp_generaterequest(address,address_length) syn_arp_generaterequest((address))
/**
* \brief Generate an ARP request for a given IPv4 address and add to the ARP cache.
*
* If the given IP address is not in the ARP cache, generate an ARP request and
* add it to the cache.
*
* \param address structure to store the address
* \param address_length the length of the address structure (ignored)
*
* \return 0 for success, non-zero for failure
*/
//---------------------------------------------------------------------------
#define arp_cacherequest(address,address_length) syn_arp_cacherequest((address))
/**
* \brief Read a PHY register via MII.
*
* This function reads a PHY register via the MII interface. See the IEEE 802.3
* specification (22.2.4) for a description of the MII management register set.
*
* \param phy PHY address (0 to 31)
* \param reg register address (0 to 31, 16 through 31 are vendor
* specific)
*
* \return value read from the register specified
*/
//---------------------------------------------------------------------------
unsigned int eth_readmii(unsigned int phy, unsigned int reg);
/**
* \brief Write a PHY register via MII.
*
* This function writes a PHY register via the MII interface. See the IEEE 802.3
* specification (22.2.4) for a description of the MII management register set.
*
* \param phy PHY address (0 to 31)
* \param reg register address (0 to 31, 16 through 31 are vendor
* specific)
* \param val value to write to the specified register
*/
//---------------------------------------------------------------------------
void eth_writemii(unsigned int phy, unsigned int reg, un
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -