Include stm32_eth source files. More...
#include "stm32_def.h"#include "lwip/ip_addr.h"#include "lwip/dhcp.h"#include "lwip/udp.h"#include "lwip/tcp.h"#include "lwip/opt.h"#include <functional>

Go to the source code of this file.
Classes | |
| struct | pbuf_data |
| struct | udp_struct |
| struct | tcp_struct |
Macros | |
| #define | IP_ADDR0 (uint8_t) 192 |
| #define | IP_ADDR1 (uint8_t) 168 |
| #define | IP_ADDR2 (uint8_t) 0 |
| #define | IP_ADDR3 (uint8_t) 10 |
| #define | NETMASK_ADDR0 (uint8_t) 255 |
| #define | NETMASK_ADDR1 (uint8_t) 255 |
| #define | NETMASK_ADDR2 (uint8_t) 255 |
| #define | NETMASK_ADDR3 (uint8_t) 0 |
| #define | GW_ADDR0 (uint8_t) 192 |
| #define | GW_ADDR1 (uint8_t) 168 |
| #define | GW_ADDR2 (uint8_t) 0 |
| #define | GW_ADDR3 (uint8_t) 1 |
| #define | DHCP_OFF (uint8_t) 0 |
| #define | DHCP_START (uint8_t) 1 |
| #define | DHCP_WAIT_ADDRESS (uint8_t) 2 |
| #define | DHCP_ADDRESS_ASSIGNED (uint8_t) 3 |
| #define | DHCP_TIMEOUT (uint8_t) 4 |
| #define | DHCP_LINK_DOWN (uint8_t) 5 |
| #define | DHCP_ASK_RELEASE (uint8_t) 6 |
| #define | MAX_CLIENT 32 |
Enumerations | |
| enum | tcp_client_states { TCP_NONE = 0 , TCP_CONNECTED , TCP_RECEIVED , TCP_SENT , TCP_ACCEPTED , TCP_CLOSING } |
Functions | |
| void | stm32_eth_init (const uint8_t *mac, const uint8_t *ip, const uint8_t *gw, const uint8_t *netmask) |
| Initialize the Ethernet interface and the LwIP stack. | |
| uint8_t | stm32_eth_is_init (void) |
| Check whether the Ethernet interface has been initialized. | |
| void | stm32_eth_get_macaddr (uint8_t *mac) |
| Copy the MAC address of the Ethernet interface. | |
| void | stm32_eth_set_macaddr (const uint8_t *mac) |
| Set the MAC address of the Ethernet interface. | |
| uint8_t | stm32_eth_link_up (void) |
| Check whether the Ethernet link is up. | |
| void | stm32_eth_scheduler (void) |
| Run one LwIP scheduler pass. | |
| void | User_notification (struct netif *netif) |
| Notify the user about the network interface status. | |
| uint32_t | stm32_eth_get_ipaddr (void) |
| Return the IPv4 address of the network interface. | |
| uint32_t | stm32_eth_get_gwaddr (void) |
| Return the gateway address of the network interface. | |
| uint32_t | stm32_eth_get_netmaskaddr (void) |
| Return the netmask of the network interface. | |
| uint32_t | stm32_eth_get_dnsaddr (void) |
| Return the first DNS server address. | |
| uint32_t | stm32_eth_get_dhcpaddr (void) |
| Return the address of the DHCP server. | |
| struct pbuf * | stm32_new_data (struct pbuf *p, const uint8_t *buffer, size_t size) |
| Allocate a pbuf holding the given data. | |
| struct pbuf * | stm32_free_data (struct pbuf *p) |
| Free a pbuf chain. | |
| uint16_t | stm32_get_data (struct pbuf_data *data, uint8_t *buffer, size_t size) |
| Copy received data from a pbuf_data into a user buffer. | |
| ip_addr_t * | u8_to_ip_addr (uint8_t *ipu8, ip_addr_t *ipaddr) |
| Convert an IPv4 address from 4 bytes into an ip_addr_t. | |
| uint32_t | ip_addr_to_u32 (ip_addr_t *ipaddr) |
| Convert an ip_addr_t IPv4 address into a uint32_t. | |
Include stm32_eth source files.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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 HOLDER 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.
| #define DHCP_ADDRESS_ASSIGNED (uint8_t) 3 |
| #define DHCP_ASK_RELEASE (uint8_t) 6 |
| #define DHCP_LINK_DOWN (uint8_t) 5 |
| #define DHCP_OFF (uint8_t) 0 |
| #define DHCP_START (uint8_t) 1 |
| #define DHCP_TIMEOUT (uint8_t) 4 |
| #define DHCP_WAIT_ADDRESS (uint8_t) 2 |
| #define GW_ADDR0 (uint8_t) 192 |
| #define GW_ADDR1 (uint8_t) 168 |
| #define GW_ADDR2 (uint8_t) 0 |
| #define GW_ADDR3 (uint8_t) 1 |
| #define IP_ADDR0 (uint8_t) 192 |
| #define IP_ADDR1 (uint8_t) 168 |
| #define IP_ADDR2 (uint8_t) 0 |
| #define IP_ADDR3 (uint8_t) 10 |
| #define MAX_CLIENT 32 |
| #define NETMASK_ADDR0 (uint8_t) 255 |
| #define NETMASK_ADDR1 (uint8_t) 255 |
| #define NETMASK_ADDR2 (uint8_t) 255 |
| #define NETMASK_ADDR3 (uint8_t) 0 |
| enum tcp_client_states |
| uint32_t ip_addr_to_u32 | ( | ip_addr_t * | ipaddr | ) |
Convert an ip_addr_t IPv4 address into a uint32_t.
| ipaddr | Address to convert. |
| uint32_t stm32_eth_get_dhcpaddr | ( | void | ) |
Return the address of the DHCP server.
| uint32_t stm32_eth_get_dnsaddr | ( | void | ) |
Return the first DNS server address.
| uint32_t stm32_eth_get_gwaddr | ( | void | ) |
Return the gateway address of the network interface.
| uint32_t stm32_eth_get_ipaddr | ( | void | ) |
Return the IPv4 address of the network interface.
| void stm32_eth_get_macaddr | ( | uint8_t * | mac | ) |
Copy the MAC address of the Ethernet interface.
| mac | Receives the MAC address (6 bytes). Nothing is copied if NULL. |
| uint32_t stm32_eth_get_netmaskaddr | ( | void | ) |
Return the netmask of the network interface.
| void stm32_eth_init | ( | const uint8_t * | mac, |
| const uint8_t * | ip, | ||
| const uint8_t * | gw, | ||
| const uint8_t * | netmask | ||
| ) |
Initialize the Ethernet interface and the LwIP stack.
LwIP initialization and the scheduler timer setup run only on the first call. Every call reconfigures the network interface and runs one scheduler pass.
A NULL argument selects the default value:
| mac | MAC address (6 bytes), or NULL to keep the default MAC address. |
| ip | IPv4 address (4 bytes), or NULL for the default. |
| gw | Gateway address (4 bytes), or NULL for the default. |
| netmask | Netmask (4 bytes), or NULL for the default. |
| uint8_t stm32_eth_is_init | ( | void | ) |
Check whether the Ethernet interface has been initialized.
| uint8_t stm32_eth_link_up | ( | void | ) |
Check whether the Ethernet link is up.
| void stm32_eth_scheduler | ( | void | ) |
Run one LwIP scheduler pass.
Reads received packets (unless ETH_INPUT_USE_IT is defined), checks the link status, handles LwIP timeouts and runs the periodic DHCP processing.
| void stm32_eth_set_macaddr | ( | const uint8_t * | mac | ) |
Set the MAC address of the Ethernet interface.
The address is stored only before the interface is initialized.
| mac | MAC address (6 bytes). Ignored if NULL. |
| struct pbuf * stm32_free_data | ( | struct pbuf * | p | ) |
Free a pbuf chain.
| p | Pbuf to free; NULL is ignored. |
| uint16_t stm32_get_data | ( | struct pbuf_data * | data, |
| uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Copy received data from a pbuf_data into a user buffer.
Frees the pbufs that are fully consumed.
| data | Source of the received data. |
| buffer | Destination buffer. |
| size | Maximum number of bytes to copy. |
| struct pbuf * stm32_new_data | ( | struct pbuf * | p, |
| const uint8_t * | buffer, | ||
| size_t | size | ||
| ) |
Allocate a pbuf holding the given data.
If p is NULL, allocates a new pbuf and copies buffer into it. Otherwise, allocates a larger pbuf, copies the contents of p and appends buffer, then frees p. On failure, returns NULL and leaves p unchanged.
| p | Existing pbuf to extend, or NULL to create a new one. |
| buffer | Data to store. |
| size | Number of bytes to store from buffer. |
| ip_addr_t * u8_to_ip_addr | ( | uint8_t * | ipu8, |
| ip_addr_t * | ipaddr | ||
| ) |
Convert an IPv4 address from 4 bytes into an ip_addr_t.
| ipu8 | Address bytes (4 bytes). |
| ipaddr | Receives the converted address. |
| void User_notification | ( | struct netif * | netif | ) |
Notify the user about the network interface status.
If the interface is down and DHCP was started by the user, sets the DHCP state to DHCP_LINK_DOWN.
| netif | Network interface to check. |