stm32_serDes_protobuf_project/bsp/lwip/lwip.c

71 lines
1.6 KiB
C
Raw Normal View History

2024-04-30 13:10:11 +03:00
#include "lwip.h"
#include "lwip/init.h"
2024-05-02 17:19:55 +03:00
#include "lwip/netif.h"
#include "lwip/opt.h"
#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/udp.h"
#include "netif/etharp.h"
#include "lwip/timeouts.h"
#include "ethernetif.h"
2024-04-30 13:10:11 +03:00
void Error_Handler(void);
2024-05-02 17:19:55 +03:00
struct netif gnetif;
ip4_addr_t ipaddr;
ip4_addr_t netmask;
ip4_addr_t gw;
uint8_t IP_ADDRESS[4];
uint8_t NETMASK_ADDRESS[4];
uint8_t GATEWAY_ADDRESS[4];
2024-04-30 13:10:11 +03:00
2024-05-02 17:19:55 +03:00
err_t udp_client_init();
2024-04-30 13:10:11 +03:00
void init_LWIP(void)
{
2024-05-02 17:19:55 +03:00
IP_ADDRESS[0] = 192;
IP_ADDRESS[1] = 168;
2024-05-03 12:10:38 +03:00
IP_ADDRESS[2] = 1;
2024-05-02 17:19:55 +03:00
IP_ADDRESS[3] = 66;
NETMASK_ADDRESS[0] = 255;
NETMASK_ADDRESS[1] = 255;
NETMASK_ADDRESS[2] = 0;
NETMASK_ADDRESS[3] = 0;
GATEWAY_ADDRESS[0] = 0;
GATEWAY_ADDRESS[1] = 0;
GATEWAY_ADDRESS[2] = 0;
GATEWAY_ADDRESS[3] = 0;
2024-04-30 13:10:11 +03:00
/* Initilialize the LwIP stack without RTOS */
lwip_init();
2024-05-02 17:19:55 +03:00
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
2024-04-30 13:10:11 +03:00
2024-05-02 17:19:55 +03:00
/* add the network interface (IPv4b/IPv6) without RTOS */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);
2024-04-30 13:10:11 +03:00
// /* Registers the default network interface */
2024-05-02 17:19:55 +03:00
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
2024-04-30 13:10:11 +03:00
}
2024-05-02 17:19:55 +03:00
void process_LWIP()
2024-04-30 13:10:11 +03:00
{
2024-05-02 17:19:55 +03:00
ethernetif_input(&gnetif);
2024-05-04 17:20:57 +03:00
// sys_check_timeouts();
2024-04-30 13:10:11 +03:00
}