71 lines
1.8 KiB
C
71 lines
1.8 KiB
C
#include "main.h"
|
|
#include "cmsis_os.h"
|
|
#include "ethernetif.h"
|
|
#include "lwip/tcpip.h"
|
|
#include "lwip/init.h"
|
|
#include "lwip/netif.h"
|
|
#include "lwip/opt.h"
|
|
#include "lwip/mem.h"
|
|
#include "lwip/memp.h"
|
|
#include "netif/etharp.h"
|
|
#include "lwip/dhcp.h"
|
|
#include "lwip/netif.h"
|
|
#include "lwip/timeouts.h"
|
|
#include "bsp_eth.h"
|
|
/* Variables Initialization */
|
|
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];
|
|
|
|
void MX_LWIP_Init(void)
|
|
{
|
|
/* IP addresses initialization */
|
|
IP_ADDRESS[0] = 192;
|
|
IP_ADDRESS[1] = 168;
|
|
IP_ADDRESS[2] = 1;
|
|
IP_ADDRESS[3] = 21;
|
|
NETMASK_ADDRESS[0] = 255;
|
|
NETMASK_ADDRESS[1] = 255;
|
|
NETMASK_ADDRESS[2] = 255;
|
|
NETMASK_ADDRESS[3] = 0;
|
|
GATEWAY_ADDRESS[0] = 192;
|
|
GATEWAY_ADDRESS[1] = 168;
|
|
GATEWAY_ADDRESS[2] = 1;
|
|
GATEWAY_ADDRESS[3] = 1;
|
|
|
|
/* Initilialize the LwIP stack with RTOS */
|
|
tcpip_init( NULL, NULL );
|
|
|
|
/* IP addresses initialization without DHCP (IPv4) */
|
|
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]);
|
|
|
|
(void)ethernetif_drv_register(&lan8720a_drv); /* ×¢²áÌØ¶¨Íø¿¨Çý¶¯ */
|
|
|
|
/* add the network interface (IPv4/IPv6) with RTOS */
|
|
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
|
|
|
|
/* Registers the default network interface */
|
|
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);
|
|
}
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
/* USER CODE END 3 */
|
|
}
|