1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#include <project.h>
struct netif if0;
uint32_t sys_now (void)
{
return ticks;
}
void dispatch_lwip (void)
{
#if 0
if (link_lost())
netif_set_down (&if0);
if (link_gained())
netif_set_up (&if0);
#endif
sys_check_timeouts();
#if 0
/* Fine DHCP periodic process every 500ms */
if (localtime - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS) {
DHCPfineTimer = localtime;
dhcp_fine_tmr();
if ((DHCP_state != DHCP_ADDRESS_ASSIGNED) && (DHCP_state != DHCP_TIMEOUT)) {
/* toggle LED1 to indicate DHCP on-going process */
STM_EVAL_LEDToggle (LED1);
/* process DHCP state machine */
LwIP_DHCP_Process_Handle();
}
}
/* DHCP Coarse periodic process every 60s */
if (localtime - DHCPcoarseTimer >= DHCP_COARSE_TIMER_MSECS) {
DHCPcoarseTimer = localtime;
dhcp_coarse_tmr();
}
#endif
}
void start_lwip (void)
{
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
// uint8_t macaddress[6]={0,0,0,0,0,1};
lwip_init();
#if 1
IP4_ADDR (&ipaddr, 10, 32, 99, 73);
IP4_ADDR (&netmask, 255, 255, 255, 0);
IP4_ADDR (&gw, 10, 32, 99, 1);
#else
IP4_ADDR (&ipaddr, 192, 168, 1, 1);
IP4_ADDR (&netmask, 255, 255, 255, 0);
IP4_ADDR (&gw, 192, 168, 1, 254);
#endif
netif_add (&if0, &ipaddr, &netmask, &gw, NULL, steth_lwip_init , ethernet_input);
/* Registers the default network interface.*/
netif_set_default (&if0);
netif_set_up (&if0);
}
|