Contiki 3.x
contiki-jn516x-main.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, SICS Swedish ICT.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki OS
31  *
32  */
33 
34 /**
35  * \file
36  * Contiki main for NXP JN516X platform
37  *
38  * \author
39  * Beshr Al Nahas <beshr@sics.se>
40  * Atis Elsts <atis.elsts@sics.se>
41  */
42 
43 #include <stdio.h>
44 #include <string.h>
45 #include <unistd.h>
46 
47 #include "dev/watchdog.h"
48 #include <AppHardwareApi.h>
49 #include <BbcAndPhyRegs.h>
50 #include <recal.h>
51 #include "dev/uart0.h"
52 #include "dev/uart-driver.h"
53 
54 #include "contiki.h"
55 #include "net/netstack.h"
56 
57 #include "dev/serial-line.h"
58 
59 #include "net/ip/uip.h"
60 #include "dev/leds.h"
61 
62 #include "lib/random.h"
63 #include "sys/node-id.h"
64 #include "rtimer-arch.h"
65 
66 #if NETSTACK_CONF_WITH_IPV6
67 #include "net/ipv6/uip-ds6.h"
68 #endif /* NETSTACK_CONF_WITH_IPV6 */
69 
70 #include "net/rime/rime.h"
71 
72 #include "dev/micromac-radio.h"
73 #include "MMAC.h"
74 /* Includes depending on connected sensor boards */
75 #if SENSOR_BOARD_DR1175
76 #include "light-sensor.h"
77 #include "ht-sensor.h"
78 SENSORS(&light_sensor, &ht_sensor);
79 #elif SENSOR_BOARD_DR1199
80 #include "button-sensor.h"
81 #include "pot-sensor.h"
82 SENSORS(&pot_sensor, &button_sensor);
83 #else
84 #include "dev/button-sensor.h"
85 /* #include "dev/pir-sensor.h" */
86 /* #include "dev/vib-sensor.h" */
87 /* &pir_sensor, &vib_sensor */
88 SENSORS(&button_sensor);
89 #endif
90 unsigned char node_mac[8];
91 
92 /* Symbol defined by the linker script
93  * marks the end of the stack taking into account the used heap */
94 extern uint32_t heap_location;
95 
96 #ifndef NETSTACK_CONF_WITH_IPV4
97 #define NETSTACK_CONF_WITH_IPV4 0
98 #endif
99 
100 #if NETSTACK_CONF_WITH_IPV4
101 #include "net/ip/uip.h"
102 #include "net/ipv4/uip-fw.h"
103 #include "net/ipv4/uip-fw-drv.h"
104 #include "net/ipv4/uip-over-mesh.h"
105 static struct uip_fw_netif slipif =
106 { UIP_FW_NETIF(192, 168, 1, 2, 255, 255, 255, 255, slip_send) };
107 static struct uip_fw_netif meshif =
108 { UIP_FW_NETIF(172, 16, 0, 0, 255, 255, 0, 0, uip_over_mesh_send) };
109 
110 #define UIP_OVER_MESH_CHANNEL 8
111 static uint8_t is_gateway;
112 #endif /* NETSTACK_CONF_WITH_IPV4 */
113 
114 #ifdef EXPERIMENT_SETUP
115 #include "experiment-setup.h"
116 #endif
117 
118 /* _EXTRA_LPM is the sleep mode, _LPM is the doze mode */
119 #define ENERGEST_TYPE_EXTRA_LPM ENERGEST_TYPE_LPM
120 
121 static void main_loop(void);
122 
123 #if DCOSYNCH_CONF_ENABLED
124 static unsigned long last_dco_calibration_time;
125 #endif
126 static uint64_t sleep_start;
127 static uint32_t sleep_start_ticks;
128 
129 /*---------------------------------------------------------------------------*/
130 #define DEBUG 1
131 #if DEBUG
132 #define PRINTF(...) do { printf(__VA_ARGS__); } while(0)
133 #else
134 #define PRINTF(...) do {} while(0)
135 #endif
136 /*---------------------------------------------------------------------------*/
137 /* Reads MAC from SoC
138  * Must be called before node_id_restore()
139  * and network addresses initialization */
140 static void
141 init_node_mac(void)
142 {
143  tuAddr psExtAddress;
144  vMMAC_GetMacAddress(&psExtAddress.sExt);
145  node_mac[7] = psExtAddress.sExt.u32L;
146  node_mac[6] = psExtAddress.sExt.u32L >> (uint32_t)8;
147  node_mac[5] = psExtAddress.sExt.u32L >> (uint32_t)16;
148  node_mac[4] = psExtAddress.sExt.u32L >> (uint32_t)24;
149  node_mac[3] = psExtAddress.sExt.u32H;
150  node_mac[2] = psExtAddress.sExt.u32H >> (uint32_t)8;
151  node_mac[1] = psExtAddress.sExt.u32H >> (uint32_t)16;
152  node_mac[0] = psExtAddress.sExt.u32H >> (uint32_t)24;
153 }
154 /*---------------------------------------------------------------------------*/
155 #if !PROCESS_CONF_NO_PROCESS_NAMES
156 static void
157 print_processes(struct process *const processes[])
158 {
159  /* const struct process * const * p = processes;*/
160  PRINTF("Starting");
161  while(*processes != NULL) {
162  PRINTF(" '%s'", (*processes)->name);
163  processes++;
164  }
165  putchar('\n');
166 }
167 #endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
168 /*---------------------------------------------------------------------------*/
169 #if NETSTACK_CONF_WITH_IPV4
170 static void
171 set_gateway(void)
172 {
173  if(!is_gateway) {
174  leds_on(LEDS_RED);
175  printf("%d.%d: making myself the IP network gateway.\n\n",
177  printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n",
178  uip_ipaddr_to_quad(&uip_hostaddr));
179  uip_over_mesh_set_gateway(&linkaddr_node_addr);
180  uip_over_mesh_make_announced_gateway();
181  is_gateway = 1;
182  }
183 }
184 #endif /* NETSTACK_CONF_WITH_IPV4 */
185 /*---------------------------------------------------------------------------*/
186 static void
187 start_autostart_processes()
188 {
189 #if !PROCESS_CONF_NO_PROCESS_NAMES
190  print_processes(autostart_processes);
191 #endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
192  autostart_start(autostart_processes);
193 }
194 /*---------------------------------------------------------------------------*/
195 #if NETSTACK_CONF_WITH_IPV6
196 static void
197 start_uip6(void)
198 {
199  NETSTACK_NETWORK.init();
200 
201 #ifndef WITH_SLIP_RADIO
202  process_start(&tcpip_process, NULL);
203 #else
204 #if WITH_SLIP_RADIO == 0
205  process_start(&tcpip_process, NULL);
206 #endif
207 #endif /* WITH_SLIP_RADIO */
208 
209 #if DEBUG
210  PRINTF("Tentative link-local IPv6 address ");
211  {
212  uip_ds6_addr_t *lladdr;
213  int i;
214  lladdr = uip_ds6_get_link_local(-1);
215  for(i = 0; i < 7; ++i) {
216  PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2],
217  lladdr->ipaddr.u8[i * 2 + 1]);
218  /* make it hardcoded... */
219  }
220  lladdr->state = ADDR_AUTOCONF;
221 
222  PRINTF("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
223  }
224 #endif /* DEBUG */
225 
226  if(!UIP_CONF_IPV6_RPL) {
227  uip_ipaddr_t ipaddr;
228  int i;
229  uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
230  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
231  uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
232  PRINTF("Tentative global IPv6 address ");
233  for(i = 0; i < 7; ++i) {
234  PRINTF("%02x%02x:",
235  ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
236  }
237  PRINTF("%02x%02x\n",
238  ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
239  }
240 }
241 #endif /* NETSTACK_CONF_WITH_IPV6 */
242 /*---------------------------------------------------------------------------*/
243 static void
244 set_linkaddr(void)
245 {
246  int i;
247  linkaddr_t addr;
248  memset(&addr, 0, LINKADDR_SIZE);
249 #if NETSTACK_CONF_WITH_IPV6
250  memcpy(addr.u8, node_mac, sizeof(addr.u8));
251 #else
252  if(node_id == 0) {
253  for(i = 0; i < LINKADDR_SIZE; ++i) {
254  addr.u8[i] = node_mac[LINKADDR_SIZE - 1 - i];
255  }
256  } else {
257  addr.u8[0] = node_id & 0xff;
258  addr.u8[1] = node_id >> 8;
259  }
260 #endif
261  linkaddr_set_node_addr(&addr);
262 #if DEBUG
263  PRINTF("Link-layer address: ");
264  for(i = 0; i < sizeof(addr.u8) - 1; i++) {
265  PRINTF("%d.", addr.u8[i]);
266  }
267  PRINTF("%d\n", addr.u8[i]);
268 #endif
269 }
270 /*---------------------------------------------------------------------------*/
271 bool_t
272 xosc_init(void)
273 {
274  /* The internal 32kHz RC oscillator is used by default;
275  * Initialize and enable the external 32.768kHz crystal.
276  */
277  vAHI_Init32KhzXtal();
278  /* Switch to the 32.768kHz crystal.
279  * This will block and wait up to 1 sec for it to stabilize. */
280  return bAHI_Set32KhzClockMode(E_AHI_XTAL);
281 }
282 /*---------------------------------------------------------------------------*/
283 #if WITH_TINYOS_AUTO_IDS
284 uint16_t TOS_NODE_ID = 0x1234; /* non-zero */
285 uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */
286 #endif /* WITH_TINYOS_AUTO_IDS */
287 int
288 main(void)
289 {
290  /* Set stack overflow address for detecting overflow in runtime */
291  vAHI_SetStackOverflow(TRUE, ((uint32_t *)&heap_location)[0]);
292 
293  /* Initialize random with a seed from the SoC random generator.
294  * This must be done before selecting the high-precision external oscillator.
295  */
296  vAHI_StartRandomNumberGenerator(E_AHI_RND_SINGLE_SHOT, E_AHI_INTS_DISABLED);
297  random_init(u16AHI_ReadRandomNumber());
298 
299  clock_init();
300  rtimer_init();
301 
302 #if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR
303  /* initialize the 32kHz crystal and wait for ready */
304  xosc_init();
305  /* need to reinitialize because the wait-for-ready process uses system timers */
306  clock_init();
307  rtimer_init();
308 #endif
309 
310  watchdog_init();
311  leds_init();
312  leds_on(LEDS_ALL);
313  init_node_mac();
314 
315  energest_init();
316  ENERGEST_ON(ENERGEST_TYPE_CPU);
317 
318  node_id_restore();
319 
320 #if WITH_TINYOS_AUTO_IDS
321  node_id = TOS_NODE_ID;
322 #endif /* WITH_TINYOS_AUTO_IDS */
323  /* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
324 #ifdef IEEE_802154_MAC_ADDRESS
325  {
326  uint8_t ieee[] = IEEE_802154_MAC_ADDRESS;
327  memcpy(node_mac, ieee, sizeof(uip_lladdr.addr));
328  node_mac[7] = node_id & 0xff;
329  }
330 #endif
331 
332  process_init();
333  ctimer_init();
334  uart0_init(UART_BAUD_RATE); /* Must come before first PRINTF */
335 
336 #if NETSTACK_CONF_WITH_IPV4
337  slip_arch_init(UART_BAUD_RATE);
338 #endif /* NETSTACK_CONF_WITH_IPV4 */
339 
340  /* check for reset source */
341  if(bAHI_WatchdogResetEvent()) {
342  PRINTF("Init: Watchdog timer has reset device!\r\n");
343  }
344  process_start(&etimer_process, NULL);
345  set_linkaddr();
346  netstack_init();
347 
348 #if NETSTACK_CONF_WITH_IPV6
349 #if UIP_CONF_IPV6_RPL
350  PRINTF(CONTIKI_VERSION_STRING " started with IPV6, RPL\n");
351 #else
352  PRINTF(CONTIKI_VERSION_STRING " started with IPV6\n");
353 #endif
354 #elif NETSTACK_CONF_WITH_IPV4
355  PRINTF(CONTIKI_VERSION_STRING " started with IPV4\n");
356 #else
357  PRINTF(CONTIKI_VERSION_STRING " started\n");
358 #endif
359 
360  if(node_id > 0) {
361  PRINTF("Node id is set to %u.\n", node_id);
362  } else {
363  PRINTF("Node id is not set.\n");
364  }
365 #if NETSTACK_CONF_WITH_IPV6
366  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
367  queuebuf_init();
368 #endif /* NETSTACK_CONF_WITH_IPV6 */
369 
370  PRINTF("%s %s %s\n", NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name);
371 
372 #ifndef UIP_FALLBACK_INTERFACE
373  uart0_set_input(serial_line_input_byte);
374  serial_line_init();
375 #endif /* UIP_FALLBACK_INTERFACE */
376 
377 #if TIMESYNCH_CONF_ENABLED
378  timesynch_init();
380 #endif /* TIMESYNCH_CONF_ENABLED */
381 
382 #if NETSTACK_CONF_WITH_IPV4
383  process_start(&tcpip_process, NULL);
384  process_start(&uip_fw_process, NULL); /* Start IP output */
385  process_start(&slip_process, NULL);
386 
387  slip_set_input_callback(set_gateway);
388 
389  {
390  uip_ipaddr_t hostaddr, netmask;
391 
392  uip_init();
393 
394  uip_ipaddr(&hostaddr, 172, 16,
396  uip_ipaddr(&netmask, 255, 255, 0, 0);
397  uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
398 
399  uip_sethostaddr(&hostaddr);
400  uip_setnetmask(&netmask);
401  uip_over_mesh_set_net(&hostaddr, &netmask);
402  /* uip_fw_register(&slipif);*/
403  uip_over_mesh_set_gateway_netif(&slipif);
404  uip_fw_default(&meshif);
405  uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
406  PRINTF("uIP started with IP address %d.%d.%d.%d\n",
407  uip_ipaddr_to_quad(&hostaddr));
408  }
409 #endif /* NETSTACK_CONF_WITH_IPV4 */
410 
411  watchdog_start();
412 
413 #if NETSTACK_CONF_WITH_IPV6
414  start_uip6();
415 #endif /* NETSTACK_CONF_WITH_IPV6 */
416 
417  /* need this to reliably generate the first rtimer callback and callbacks in other
418  auto-start processes */
419  (void)u32AHI_Init();
420 
421  start_autostart_processes();
422 
423  leds_off(LEDS_ALL);
424 
425  main_loop();
426 
427  return -1;
428 }
429 
430 static void
431 main_loop(void)
432 {
433  int r;
434  clock_time_t time_to_etimer;
435  rtimer_clock_t ticks_to_rtimer;
436 
437  while(1) {
438  do {
439  /* Reset watchdog. */
441  r = process_run();
442  } while(r > 0);
443  /*
444  * Idle processing.
445  */
446  watchdog_stop();
447 
448 #if DCOSYNCH_CONF_ENABLED
449  /* Calibrate the DCO every DCOSYNCH_PERIOD
450  * if we have more than 500uSec until next rtimer
451  * PS: Calibration disables interrupts and blocks for 200uSec.
452  * */
453  if(clock_seconds() - last_dco_calibration_time > DCOSYNCH_PERIOD) {
454  if(rtimer_arch_time_to_rtimer() > RTIMER_SECOND / 2000) {
455  /* PRINTF("ContikiMain: Calibrating the DCO\n"); */
456  eAHI_AttemptCalibration();
457  /* Patch to allow CpuDoze after calibration */
458  vREG_PhyWrite(REG_PHY_IS, REG_PHY_INT_VCO_CAL_MASK);
459  last_dco_calibration_time = clock_seconds();
460  }
461  }
462 #endif /* DCOSYNCH_CONF_ENABLED */
463 
464  /* flush standard output before sleeping */
465  uart_driver_flush(E_AHI_UART_0, TRUE, FALSE);
466 
467  /* calculate the time to the next etimer and rtimer */
468  time_to_etimer = clock_arch_time_to_etimer();
469  ticks_to_rtimer = rtimer_arch_time_to_rtimer();
470 
471 #if JN516X_SLEEP_ENABLED
472  /* we can sleep only up to the next rtimer/etimer */
473  rtimer_clock_t max_sleep_time = ticks_to_rtimer;
474  if(max_sleep_time >= JN516X_MIN_SLEEP_TIME) {
475  /* also take into account etimers */
476  uint64_t ticks_to_etimer = ((uint64_t)time_to_etimer * RTIMER_SECOND) / CLOCK_SECOND;
477  max_sleep_time = MIN(ticks_to_etimer, ticks_to_rtimer);
478  }
479 
480  if(max_sleep_time >= JN516X_MIN_SLEEP_TIME) {
481  max_sleep_time -= JN516X_SLEEP_GUARD_TIME;
482  /* bound the sleep time to 1 second */
483  max_sleep_time = MIN(max_sleep_time, JN516X_MAX_SLEEP_TIME);
484 
485 #if !RTIMER_USE_32KHZ
486  /* convert to 32.768 kHz oscillator ticks */
487  max_sleep_time = (uint64_t)max_sleep_time * JN516X_XOSC_SECOND / RTIMER_SECOND;
488 #endif
489  vAHI_WakeTimerEnable(WAKEUP_TIMER, TRUE);
490  /* sync with the tick timer */
491  WAIT_FOR_EDGE(sleep_start);
492  sleep_start_ticks = u32AHI_TickTimerRead();
493 
494  vAHI_WakeTimerStartLarge(WAKEUP_TIMER, max_sleep_time);
495  ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_EXTRA_LPM);
496  vAHI_Sleep(E_AHI_SLEEP_OSCON_RAMON);
497  } else {
498 #else
499  {
500 #endif /* JN516X_SLEEP_ENABLED */
501  clock_arch_schedule_interrupt(time_to_etimer, ticks_to_rtimer);
502  ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
503  vAHI_CpuDoze();
504  watchdog_start();
505  ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
506  }
507  }
508 }
509 /*---------------------------------------------------------------------------*/
510 void
511 AppColdStart(void)
512 {
513  /* After reset or sleep with memory off */
514  main();
515 }
516 /*---------------------------------------------------------------------------*/
517 void
518 AppWarmStart(void)
519 {
520  /* Wakeup after sleep with memory on.
521  * Need to initialize devices but not the application state.
522  * Note: the actual time this function is called is
523  * ~8 ticks (32kHz timer) later than the scheduled sleep end time.
524  */
525  uint32_t sleep_ticks;
526  uint64_t sleep_end;
527  rtimer_clock_t sleep_ticks_rtimer;
528 
529  clock_arch_calibrate();
530  leds_init();
531  uart0_init(UART_BAUD_RATE); /* Must come before first PRINTF */
532  NETSTACK_RADIO.init();
533  watchdog_init();
534  watchdog_stop();
535 
536  WAIT_FOR_EDGE(sleep_end);
537  sleep_ticks = (uint32_t)(sleep_start - sleep_end) + 1;
538 
539 #if RTIMER_USE_32KHZ
540  sleep_ticks_rtimer = sleep_ticks;
541 #else
542  {
543  static uint32_t remainder;
544  uint64_t t = (uint64_t)sleep_ticks * RTIMER_SECOND + remainder;
545  sleep_ticks_rtimer = (uint32_t)(t / JN516X_XOSC_SECOND);
546  remainder = t - sleep_ticks_rtimer * JN516X_XOSC_SECOND;
547  }
548 #endif
549 
550  /* reinitialize rtimers */
551  rtimer_arch_reinit(sleep_start_ticks, sleep_ticks_rtimer);
552 
553  ENERGEST_SWITCH(ENERGEST_TYPE_EXTRA_LPM, ENERGEST_TYPE_CPU);
554 
555  watchdog_start();
556 
557  /* reinitialize clock */
558  clock_arch_init(1);
559  /* schedule etimer interrupt */
560  clock_arch_schedule_interrupt(clock_arch_time_to_etimer(), rtimer_arch_time_to_rtimer());
561 
562 #if DCOSYNCH_CONF_ENABLED
563  /* The radio is recalibrated on wakeup */
564  last_dco_calibration_time = clock_seconds();
565 #endif
566 
567  main_loop();
568 }
569 /*---------------------------------------------------------------------------*/
#define TRUE
An alias for one, used for clarity.
#define uip_sethostaddr(addr)
Set the IP address of this host.
Definition: uip.h:192
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:129
void uart0_init(unsigned long ubr)
Initalize the RS232 port.
Definition: uart0.c:143
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
Construct an IP address from four bytes.
Definition: uip.h:956
void timesynch_set_authority_level(int level)
Set the authority level of the current time.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
Definition: uip-nd6.c:124
uint8_t slip_send(void)
Send an IP packet from the uIP buffer with SLIP.
Definition: slip.c:193
Header file for IPv6-related data structures.
uip_ipaddr_t ipaddr
The IP address of this interface.
Definition: uip-fw.h:57
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
Definition: random.c:41
void watchdog_stop(void)
Stops the WDT such that it won't timeout and cause MCU reset.
Definition: watchdog.c:58
Header file for tunnelling uIP over Rime mesh
void clock_init(void)
Initialize the clock library.
Definition: clock.c:76
MICROMAC_RADIO driver header file
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Definition: uip.h:1027
int process_run(void)
Run the system once - call poll handlers and process one event.
Definition: process.c:302
Unicast address structure.
Definition: uip-ds6.h:202
void slip_arch_init(unsigned long ubr)
Initalize the RS232 port and the SLIP driver.
Definition: slip-arch.c:56
SENSORS & button_sensor
Copyright (c) 2014, Analog Devices, Inc.
void slip_set_input_callback(void(*c)(void))
Set a function to be called when there is activity on the SLIP interface; used for detecting if a nod...
Definition: slip.c:143
uip_ipaddr_t netmask
The netmask of the interface.
Definition: uip-fw.h:58
Header file for the Rime stack
#define uip_setnetmask(addr)
Set the netmask.
Definition: uip.h:236
#define NULL
The null pointer.
#define uip_ipaddr_to_quad(a)
Convert an IP address to four bytes separated by commas.
Definition: uip.h:928
uIP packet forwarding header file.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Definition: linkaddr.c:72
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
Definition: uip-fw.h:80
void watchdog_periodic(void)
Writes the WDT clear sequence.
Definition: watchdog.c:64
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
Definition: uip-ds6.h:153
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
Definition: uip.h:970
Header file for the uIP TCP/IP stack.
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99
int main(void)
This is main...
uip_ds6_addr_t * uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type)
Add a unicast address to the interface.
Definition: uip-ds6.c:326
#define FALSE
An alias for zero, used for clarity.
void timesynch_init(void)
Initialize the timesynch module.
void rtimer_init(void)
Initialize the real-time scheduler.
Definition: rtimer.c:61
void watchdog_init(void)
Copyright (c) 2014, Analog Devices, Inc.
Definition: watchdog.c:42
Generic serial I/O process header filer.
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
Definition: uip.c:118
void uip_init(void)
uIP initialization function.
Definition: uip.c:363
CCIF unsigned long clock_seconds(void)
Get the current value of the platform seconds.
Definition: clock.c:54
void process_init(void)
Initialize the process module.
Definition: process.c:208
void ctimer_init(void)
Initialize the callback timer library.
Definition: ctimer.c:91
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Definition: linkaddr.c:48
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
Definition: serial-line.c:60
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
Definition: watchdog.c:49
Include file for the Contiki low-layer network stack (NETSTACK)
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr)
set the last 64 bits of an IP address based on the MAC address
Definition: uip-ds6.c:542
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
Definition: uip-fw.c:515
Representation of a uIP network interface.
Definition: uip-fw.h:54