38#ifndef __STM32_ETH_H__
39#define __STM32_ETH_H__
43#include "lwip/ip_addr.h"
85#define IP_ADDR0 (uint8_t) 192
86#define IP_ADDR1 (uint8_t) 168
87#define IP_ADDR2 (uint8_t) 0
88#define IP_ADDR3 (uint8_t) 10
91#define NETMASK_ADDR0 (uint8_t) 255
92#define NETMASK_ADDR1 (uint8_t) 255
93#define NETMASK_ADDR2 (uint8_t) 255
94#define NETMASK_ADDR3 (uint8_t) 0
97#define GW_ADDR0 (uint8_t) 192
98#define GW_ADDR1 (uint8_t) 168
99#define GW_ADDR2 (uint8_t) 0
100#define GW_ADDR3 (uint8_t) 1
103#define DHCP_OFF (uint8_t) 0
104#define DHCP_START (uint8_t) 1
105#define DHCP_WAIT_ADDRESS (uint8_t) 2
106#define DHCP_ADDRESS_ASSIGNED (uint8_t) 3
107#define DHCP_TIMEOUT (uint8_t) 4
108#define DHCP_LINK_DOWN (uint8_t) 5
109#define DHCP_ASK_RELEASE (uint8_t) 6
114#ifdef ETH_INPUT_USE_IT
115 extern struct netif
gnetif;
137void stm32_eth_init(
const uint8_t *mac,
const uint8_t *ip,
const uint8_t *gw,
const uint8_t *netmask);
188 void stm32_DHCP_process(
struct netif *netif);
197 void stm32_DHCP_Periodic_Handle(
struct netif *netif);
203 void stm32_DHCP_manual_config(
void);
209 uint8_t stm32_get_DHCP_lease_state(
void);
216 void stm32_set_DHCP_state(uint8_t state);
222 uint8_t stm32_get_DHCP_state(
void);
228 uint8_t stm32_dhcp_started(
void);
230 #error "LWIP_DHCP must be enabled in lwipopts.h"
242 void stm32_dns_init(
const uint8_t *dnsaddr);
255 int8_t stm32_dns_gethostbyname(
const char *hostname, uint32_t *ipaddr);
257 #error "LWIP_DNS must be enabled in lwipopts.h"
273void udp_receive_callback(
void *arg,
struct udp_pcb *pcb,
struct pbuf *p,
274 const ip_addr_t *addr, u16_t port);
276#error "LWIP_UDP must be enabled in lwipopts.h"
323struct pbuf *
stm32_new_data(
struct pbuf *p,
const uint8_t *buffer,
size_t size);
374 err_t tcp_connected_callback(
void *arg,
struct tcp_pcb *tpcb, err_t err);
391 err_t tcp_accept_callback(
void *arg,
struct tcp_pcb *newpcb, err_t err);
401 void tcp_connection_close(
struct tcp_pcb *tpcb,
struct tcp_struct *tcp);
403 #error "LWIP_TCP must be enabled in lwipopts.h"
struct netif gnetif
Definition stm32_eth.cpp:88
void stm32_eth_set_macaddr(const uint8_t *mac)
Set the MAC address of the Ethernet interface.
Definition stm32_eth.cpp:273
void stm32_eth_get_macaddr(uint8_t *mac)
Copy the MAC address of the Ethernet interface.
Definition stm32_eth.cpp:277
struct pbuf * stm32_free_data(struct pbuf *p)
Free a pbuf chain.
Definition stm32_eth.cpp:644
uint32_t stm32_eth_get_ipaddr(void)
Return the IPv4 address of the network interface.
Definition stm32_eth.cpp:443
uint32_t stm32_eth_get_dhcpaddr(void)
Return the address of the DHCP server.
Definition stm32_eth.cpp:465
void stm32_eth_scheduler(void)
Run one LwIP scheduler pass.
Definition stm32_eth.cpp:287
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.
Definition stm32_eth.cpp:660
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.
Definition stm32_eth.cpp:595
uint8_t stm32_eth_is_init(void)
Check whether the Ethernet interface has been initialized.
Definition stm32_eth.cpp:268
tcp_client_states
Definition stm32_eth.h:52
@ TCP_RECEIVED
Definition stm32_eth.h:55
@ TCP_CLOSING
Definition stm32_eth.h:58
@ TCP_CONNECTED
Definition stm32_eth.h:54
@ TCP_ACCEPTED
Definition stm32_eth.h:57
@ TCP_NONE
Definition stm32_eth.h:53
@ TCP_SENT
Definition stm32_eth.h:56
uint32_t stm32_eth_get_netmaskaddr(void)
Return the netmask of the network interface.
Definition stm32_eth.cpp:453
uint32_t stm32_eth_get_gwaddr(void)
Return the gateway address of the network interface.
Definition stm32_eth.cpp:448
void User_notification(struct netif *netif)
Notify the user about the network interface status.
Definition stm32_eth.cpp:499
uint32_t ip_addr_to_u32(ip_addr_t *ipaddr)
Convert an ip_addr_t IPv4 address into a uint32_t.
Definition stm32_eth.cpp:601
uint32_t stm32_eth_get_dnsaddr(void)
Return the first DNS server address.
Definition stm32_eth.cpp:458
struct pbuf * stm32_new_data(struct pbuf *p, const uint8_t *buffer, size_t size)
Allocate a pbuf holding the given data.
Definition stm32_eth.cpp:606
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.
Definition stm32_eth.cpp:209
uint8_t stm32_eth_link_up(void)
Check whether the Ethernet link is up.
Definition stm32_eth.cpp:282
Definition stm32_eth.h:62
struct pbuf * p
Definition stm32_eth.h:63
uint16_t available
Definition stm32_eth.h:64
Definition stm32_eth.h:77
struct pbuf_data data
Definition stm32_eth.h:79
struct tcp_pcb * pcb
Definition stm32_eth.h:78
tcp_client_states state
Definition stm32_eth.h:80
Definition stm32_eth.h:68
struct pbuf_data data
Definition stm32_eth.h:70
ip_addr_t ip
Definition stm32_eth.h:71
u16_t port
Definition stm32_eth.h:72
std::function< void()> onDataArrival
Definition stm32_eth.h:73
struct udp_pcb * pcb
Definition stm32_eth.h:69