summaryrefslogtreecommitdiffstats
path: root/app/lwip_glue.c
blob: d2dc4b5c3d9bb28eb5fd30eeb6fdab215caafcfb (plain)
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
#include <project.h>

struct netif if0;


uint32_t sys_now (void)
{
  return ticks;
}

void dispatch_lwip (void)
{
  sys_check_timeouts();
}


static void if_status_changed (struct netif *netif)
{
  mdns_resp_netif_settings_changed (netif);
}





void start_lwip (void)
{

  lwip_init();


  netif_add (&if0, NULL, NULL, NULL,  NULL, steth_lwip_init, ethernet_input);
  netif_set_status_callback (&if0, if_status_changed);

  /*  Registers the default network interface.*/
  netif_set_default (&if0);

  netif_set_up (&if0);

  dhcp_start (&if0);


  httpd_init();
  cgi_init();

  mdns_resp_init();
  mdns_resp_add_netif (&if0, "clock", 5);
}

static sys_prot_t ethernet_irq_enabled = 1;

sys_prot_t sys_arch_protect (void)
{
  sys_prot_t ret;

  nvic_disable_irq (NVIC_ETH_IRQ);
  compiler_mb();

  ret = ethernet_irq_enabled;
  ethernet_irq_enabled = 0;

  return ret;
}

void sys_arch_unprotect (sys_prot_t lev)
{
  if (lev) {
    ethernet_irq_enabled = 1;
    compiler_mb();
    nvic_enable_irq (NVIC_ETH_IRQ);
  }
}