STM32F746G-DISCO + TouchGFX + Ethernet
Hello, I would like to add ethernet support to my TouchGFX application.
I have got the LwIF directory from Cube, copied this in my TouchGFX app directory and integrated to gcc\Makefile with the following change:
components := TouchGFX/gui target TouchGFX/generated/gui_generated LwIP
and
$(Drivers_path)/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_eth.c \
After some include moving to compile now I have a link ok.
This is my actual code but still no DHCP work!
I don't see the new IP on router.
#include "lwip/opt.h"
#include "lwip/stats.h"
#include "lwip/sys.h"
#include "lwip/pbuf.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/dns.h"
#include "lwip/dhcp.h"
#include "lwip/init.h"
#include "lwip/netif.h"
#include "netif/etharp.h"
#include "ethernetif.h"
struct netif netif_data;void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
if (p != NULL) {
/* send received packet back to sender */
udp_sendto(pcb, p, addr, port);
/* free the pbuf */
pbuf_free(p);
}
}
void BSP_ETH_Init()
{
struct udp_pcb * pcb;
struct netif *netif = &netif_data;
struct ip4_addr ipaddr;
struct ip4_addr netmask;
struct ip4_addr gateway;
lwip_init();
IP4_ADDR(&netmask, 0,0,0,0);
IP4_ADDR(&gateway, 0,0,0,0);
IP4_ADDR(&ipaddr, 0,0,0,0);
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL,ethernetif_init,ip_input);
netif_set_default(netif);
if (netif_is_link_up(netif))
{
netif_set_up(netif);
}
else
{
netif_set_down(netif);
}
dhcp_start(netif);
pcb = udp_new();
if (pcb == NULL)
{
LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));
return;
}
if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));
return;
}
udp_recv(pcb, udp_echo_recv, NULL);
}