Contiki 3.x
contiki-main.c
1 /*
2  * Copyright (c) 2006, Technical University of Munich
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 copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  * Reworked for avr-rss2 platform. Robert Olsson <robert@radio-sensors.com>
32  */
33 
34 #define PRINTF(FORMAT, args ...) printf_P(PSTR(FORMAT),##args)
35 
36 #define ANNOUNCE_BOOT 1 /* adds about 600 bytes to program size */
37 #if ANNOUNCE_BOOT
38 #define PRINTA(FORMAT, args ...) printf_P(PSTR(FORMAT),##args)
39 #else
40 #define PRINTA(...)
41 #endif
42 
43 #define DEBUG 0
44 #if DEBUG
45 #define PRINTD(FORMAT, args ...) printf_P(PSTR(FORMAT),##args)
46 #else
47 #define PRINTD(...)
48 #endif
49 
50 #include <avr/pgmspace.h>
51 #include <avr/fuse.h>
52 #include <avr/eeprom.h>
53 #include <stdio.h>
54 #include <string.h>
55 #include <dev/watchdog.h>
56 
57 #include "loader/symbols-def.h"
58 #include "loader/symtab.h"
59 
60 #include "params.h"
61 #include "rss2.h"
62 #include "leds.h"
63 #include "i2c.h"
64 #include "radio/rf230bb/rf230bb.h"
65 #include "net/mac/frame802154.h"
66 #include "net/mac/framer-802154.h"
67 #include "net/ipv6/sicslowpan.h"
68 
69 #include "contiki.h"
70 #include "contiki-net.h"
71 #include "contiki-lib.h"
72 
73 #include "dev/rs232.h"
74 #include "dev/serial-line.h"
75 #include "dev/slip.h"
76 
77 #if AVR_WEBSERVER
78 #include "httpd-fs.h"
79 #include "httpd-cgi.h"
80 #endif
81 
82 #ifdef COFFEE_FILES
83 #include "cfs/cfs.h"
84 #include "cfs/cfs-coffee.h"
85 #endif
86 
87 #if UIP_CONF_ROUTER && 0
88 #include "net/routing/rimeroute.h"
89 #include "net/rime/rime-udp.h"
90 #endif
91 
92 #include "net/rime/rime.h"
93 
94 /* Track interrupt flow through mac, rdc and radio driver */
95 /* #define DEBUGFLOWSIZE 32 */
96 #if DEBUGFLOWSIZE
97 uint8_t debugflowsize, debugflow[DEBUGFLOWSIZE];
98 #define DEBUGFLOW(c) if(debugflowsize < (DEBUGFLOWSIZE - 1)) debugflow[debugflowsize++] = c
99 #else
100 #define DEBUGFLOW(c)
101 #endif
102 
103 /* Get periodic prints from idle loop, from clock seconds or rtimer interrupts */
104 /* Use of rtimer will conflict with other rtimer interrupts such as contikimac radio cycling */
105 /* STAMPS will print ENERGEST outputs if that is enabled. */
106 #define PERIODICPRINTS 1
107 #if PERIODICPRINTS
108 /* #define PINGS 64 */
109 #define ROUTES 600
110 #define STAMPS 60
111 #define STACKMONITOR 1024
112 uint32_t clocktime;
113 #define TESTRTIMER 0
114 #if TESTRTIMER
115 uint8_t rtimerflag = 1;
116 struct rtimer rt;
117 void
118 rtimercycle(void)
119 {
120  rtimerflag = 1;
121 }
122 #endif
123 #endif
124 
125 uint16_t node_id; /* Can be set by cooja */
126 
127 uint16_t ledtimer_red, ledtimer_yellow;
128 uint16_t i2c_probed; /* i2c devices we have probed */
129 
130 
131 /*-------------------------------------------------------------------------*/
132 /*----------------------Configuration of the .elf file---------------------*/
133 #if 1
134 /* The proper way to set the signature is */
135 #include <avr/signature.h>
136 #else
137 /* Older avr-gcc's may not define the needed SIGNATURE bytes. Do it manually if you get an error */
138 typedef struct {const unsigned char B2;
139  const unsigned char B1;
140  const unsigned char B0;
141 } __signature_t;
142 #define SIGNATURE __signature_t __signature __attribute__((section(".signature")))
143 SIGNATURE = {
144  .B2 = 0x01, /* SIGNATURE_2, //ATMEGA128rfa1 */
145  .B1 = 0xA7, /* SIGNATURE_1, //128KB flash */
146  .B0 = 0x1E, /* SIGNATURE_0, //Atmel */
147 };
148 #endif
149 
150 #if 1
151 /* JTAG, SPI enabled, Internal RC osc, Boot flash size 4K, 6CK+65msec delay, brownout disabled */
152 FUSES = { .low = 0xe2, .high = 0x99, .extended = 0xff, };
153 #else
154 /* JTAG+SPI, Boot 4096 words @ $F000, Internal oscillator, startup 6 CK +0 ms, Brownout 1.8 volts */
155 FUSES = { .low = 0xC2, .high = 0x99, .extended = 0xfe, };
156 #endif
157 
158 uint8_t
159 rng_get_uint8(void)
160 {
161 #if 1
162  /* Upper two RSSI reg bits (RND_VALUE) are random in rf231 */
163  uint8_t j;
164  j = (PHY_RSSI & 0xc0) + ((PHY_RSSI >> 2) & 0x30) + ((PHY_RSSI >> 4) & 0x0c) + ((PHY_RSSI >> 6) & 0x03);
165 #else
166 /* Get a pseudo random number using the ADC */
167  uint8_t i, j;
168  ADCSRA = 1 << ADEN; /* Enable ADC, not free running, interrupt disabled, fastest clock */
169  for(i = 0; i < 4; i++) {
170  ADMUX = 0; /* toggle reference to increase noise */
171  ADMUX = 0x1E; /* Select AREF as reference, measure 1.1 volt bandgap reference. */
172  ADCSRA |= 1 << ADSC; /* Start conversion */
173  while(ADCSRA & (1 << ADSC)) ; /* Wait till done */
174  j = (j << 2) + ADC;
175  }
176  ADCSRA = 0; /* Disable ADC */
177 #endif
178  PRINTD("rng issues %d\n", j);
179  return j;
180 }
181 /*-------------------------Low level initialization------------------------*/
182 /*------Done in a subroutine to keep main routine stack usage small--------*/
183 void
184 initialize(void)
185 {
186  watchdog_init();
187  watchdog_start();
188  leds_init();
189  serial_line_init();
190 
191  rs232_init(RS232_PORT_0, USART_BAUD_38400, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
192  rs232_redirect_stdout(RS232_PORT_0);
193 
194 #if 0
195  /* Do it my way... */
196  //UBRR0L = 8; UBRR0H = 0; UCSR0A = (0 << U2X0); // 115.2k err=-3.5%
197  //UBRR0L = 16; UBRR0H = 0; UCSR0A = (1 << U2X0); // 115.2k 2.1%
198  //UBRR0L = 3; UBRR0H = 0; UCSR0A = (1 << U2X0); // 500k 0%
199 #endif
200 
202 
203  clock_init();
204 
205  if(MCUSR & (1 << PORF)) {
206  PRINTD("Power-on reset.\n");
207  }
208  if(MCUSR & (1 << EXTRF)) {
209  PRINTD("External reset!\n");
210  }
211  if(MCUSR & (1 << BORF)) {
212  PRINTD("Brownout reset!\n");
213  }
214  if(MCUSR & (1 << WDRF)) {
215  PRINTD("Watchdog reset!\n");
216  }
217  if(MCUSR & (1 << JTRF)) {
218  PRINTD("JTAG reset!\n");
219  }
220 
221  i2c_init(100000); /* 100 bit/s */
222 
223 #if STACKMONITOR
224  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
225  * loop. In conjuction with PERIODICPRINTS, never-used stack will be printed
226  * every STACKMONITOR seconds.
227  */
228  {
229  extern uint16_t __bss_end;
230  uint16_t p = (uint16_t)&__bss_end;
231  do {
232  *(uint16_t *)p = 0x4242;
233  p += 10;
234  } while(p < SP - 10); /* don't overwrite our own stack */
235  }
236 #endif
237 
238 #define CONF_CALIBRATE_OSCCAL 0
239 #if CONF_CALIBRATE_OSCCAL
240  void calibrate_rc_osc_32k();
241  {
242  extern uint8_t osccal_calibrated;
243  uint8_t i;
244  PRINTD("\nBefore calibration OSCCAL=%x\n", OSCCAL);
245  for(i = 0; i < 10; i++) {
247  PRINTD("Calibrated=%x\n", osccal_calibrated);
248 /* #include <util/delay_basic.h> */
249 /* #define delay_us( us ) ( _delay_loop_2(1+(us*F_CPU)/4000000UL) ) */
250 /* delay_us(50000); */
251  }
252  clock_init();
253  }
254 #endif
255 
256  PRINTA("\n*******Booting %s*******\n", CONTIKI_VERSION_STRING);
257 
258 /* rtimers needed for radio cycling */
259  rtimer_init();
260 
261  /* Initialize process subsystem */
262  process_init();
263 
264  /* etimers must be started before ctimer_init */
265  process_start(&etimer_process, NULL);
266  ctimer_init();
267 
268  /* Start radio and radio receive process */
269  NETSTACK_RADIO.init();
270 
271 /* Get a random seed for the 802.15.4 packet sequence number.
272  * Some layers will ignore duplicates found in a history (e.g. Contikimac)
273  * causing the initial packets to be ignored after a short-cycle restart.
274  */
275  random_init(rng_get_uint8());
276 
277  /* Set addresses BEFORE starting tcpip process */
278 
279  linkaddr_t addr;
280  char eui64[8];
281 
282  printf("I2C: ");
283  i2c_probed = i2c_probe();
284  printf("\n");
285 
286  if( i2c_probed & I2C_AT24MAC ) {
287  i2c_at24mac_read((char *)&eui64, 1);
288  linkaddr_set_node_addr((linkaddr_t *) &eui64);
289  node_id = (eui64[1] << 8) + eui64[7];
290  }
291  else {
292  printf("Random EUI64 address generated\n");
293  eui64[0] = 0xfc; /* Atmels OUI */
294  eui64[1] = 0xc2;
295  eui64[2] = 0x3d;
296  eui64[3] = 0;
297  eui64[4] = 0;
298  eui64[5] = 0;
299  eui64[6] = node_id >> 8;
300  eui64[7] = node_id & 0xff;
301  linkaddr_set_node_addr((linkaddr_t *)&eui64);
302  }
303 
304  /* memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t)); */
305 
306 #if NETSTACK_CONF_WITH_IPV6
307  memcpy(&addr.u8, &eui64, sizeof(linkaddr_t));
308  memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
309 #endif
310 
311  rf230_set_pan_addr(params_get_panid(), params_get_panaddr(), (uint8_t *)&addr.u8);
312  rf230_set_channel(params_get_channel());
313  rf230_set_txpower(params_get_txpower());
314 
315 #if NETSTACK_CONF_WITH_IPV6
316  PRINTA("EUI-64 MAC: %x-%x-%x-%x-%x-%x-%x-%x\n", addr.u8[0], addr.u8[1], addr.u8[2], addr.u8[3], addr.u8[4], addr.u8[5], addr.u8[6], addr.u8[7]);
317 #else
318  PRINTA("MAC address ");
319  uint8_t i;
320  addr.u8[0] = eui64[1] ;
321  addr.u8[1] = eui64[7];
322 
323  for(i = sizeof(linkaddr_t); i > 0; i--) {
324  PRINTA("%x:", addr.u8[i - 1]);
325  }
326  PRINTA("\n");
327 #endif
328 
329  /* Initialize stack protocols */
330  queuebuf_init();
331  NETSTACK_RDC.init();
332  NETSTACK_MAC.init();
333  NETSTACK_NETWORK.init();
334 
335 #if ANNOUNCE_BOOT
336  PRINTA("MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", NETSTACK_MAC.name,
337  NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(),
338  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()),
339  rf230_get_txpower());
340 #if UIP_CONF_IPV6_RPL
341  PRINTA("RPL Enabled\n");
342 #endif
343 #if UIP_CONF_ROUTER
344  PRINTA("Routing Enabled\n");
345 #endif
346 
347 #endif /* ANNOUNCE_BOOT */
348 
349 #if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4
350  process_start(&tcpip_process, NULL);
351 #endif
352 
353  /* Autostart other processes */
354  autostart_start(autostart_processes);
355 
356  /*---If using coffee file system create initial web content if necessary---*/
357 #if COFFEE_FILES
358  int fa = cfs_open("/index.html", CFS_READ);
359  if(fa < 0) { /* Make some default web content */
360  PRINTA("No index.html file found, creating upload.html!\n");
361  PRINTA("Formatting FLASH file system for coffee...");
363  PRINTA("Done!\n");
364  fa = cfs_open("/index.html", CFS_WRITE);
365  int r = cfs_write(fa, &"It works!", 9);
366  if(r < 0) {
367  PRINTA("Can''t create /index.html!\n");
368  }
369  cfs_close(fa);
370 /* fa = cfs_open("upload.html"), CFW_WRITE); */
371 /* <html><body><form action="upload.html" enctype="multipart/form-data" method="post"><input name="userfile" type="file" size="50" /><input value="Upload" type="submit" /></form></body></html> */
372  }
373 #endif /* COFFEE_FILES */
374 
375 /* Add addresses for testing */
376 #if 0
377  {
378  uip_ip6addr_t ipaddr;
379  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
380  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
381 /* uip_ds6_prefix_add(&ipaddr,64,0); */
382  }
383 #endif
384 /*--------------------------Announce the configuration---------------------*/
385 #if ANNOUNCE_BOOT
386 #if AVR_WEBSERVER
387  { uint8_t i;
388  char buf[80];
389  unsigned int size;
390 
391  for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
392  if(uip_ds6_if.addr_list[i].isused) {
393  httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr, buf);
394  PRINTA("IPv6 Address: %s\n", buf);
395  }
396  }
397  cli();
398  eeprom_read_block(buf, eemem_server_name, sizeof(eemem_server_name));
399  sei();
400  buf[sizeof(eemem_server_name)] = 0;
401  PRINTA("%s", buf);
402  cli();
403  eeprom_read_block(buf, eemem_domain_name, sizeof(eemem_domain_name));
404  sei();
405  buf[sizeof(eemem_domain_name)] = 0;
406  size = httpd_fs_get_size();
407 #ifndef COFFEE_FILES
408  PRINTA(".%s online with fixed %u byte web content\n", buf, size);
409 #elif COFFEE_FILES == 1
410  PRINTA(".%s online with static %u byte EEPROM file system\n", buf, size);
411 #elif COFFEE_FILES == 2
412  PRINTA(".%s online with dynamic %u KB EEPROM file system\n", buf, size >> 10);
413 #elif COFFEE_FILES == 3
414  PRINTA(".%s online with static %u byte program memory file system\n", buf, size);
415 #elif COFFEE_FILES == 4
416  PRINTA(".%s online with dynamic %u KB program memory file system\n", buf, size >> 10);
417 #endif /* COFFEE_FILES */
418  }
419 #else
420  PRINTA("Online\n");
421 #endif
422 #endif /* ANNOUNCE_BOOT */
423 
424  ledtimer_red = 1000;
425  leds_on(LEDS_RED);
426 }
427 
428 
429 #if ROUTES && NETSTACK_CONF_WITH_IPV6
430 static void
431 ipaddr_add(const uip_ipaddr_t *addr)
432 {
433  uint16_t a;
434  int8_t i, f;
435  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
436  a = (addr->u8[i] << 8) + addr->u8[i + 1];
437  if(a == 0 && f >= 0) {
438  if(f++ == 0) {
439  PRINTF("::");
440  }
441  } else {
442  if(f > 0) {
443  f = -1;
444  } else if(i > 0) {
445  PRINTF(":");
446  }
447  PRINTF("%x", a);
448  }
449  }
450 }
451 #endif
452 /*-------------------------------------------------------------------------*/
453 /*------------------------- Main Scheduler loop----------------------------*/
454 /*-------------------------------------------------------------------------*/
455 int
456 main(void)
457 {
458 #if NETSTACK_CONF_WITH_IPV6
460 #endif /* NETSTACK_CONF_WITH_IPV6 */
461  initialize();
462 
463  while(1) {
464  process_run();
466 
467  /* Turn off LED's */
468  if(ledtimer_red) {
469  if(--ledtimer_red == 0) {
470  leds_off(LEDS_RED);
471  }
472  }
473  if(ledtimer_yellow) {
474  if(--ledtimer_yellow == 0) {
475  leds_off(LEDS_YELLOW);
476  }
477  }
478  leds_off(LEDS_RED);
479  leds_off(LEDS_YELLOW);
480 
481 #if 0
482 /* Various entry points for debugging in the AVR Studio simulator.
483  * Set as next statement and step into the routine.
484  */
485  NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
486  process_poll(&rf230_process);
487  packetbuf_clear();
488  len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
490  NETSTACK_RDC.input();
491 #endif
492 
493 #if 0
494 /* Clock.c can trigger a periodic PLL calibration in the RF230BB driver.
495  * This can show when that happens.
496  */
497  extern uint8_t rf230_calibrated;
498  if(rf230_calibrated) {
499  PRINTD("\nRF230 calibrated!\n");
500  rf230_calibrated = 0;
501  }
502 #endif
503 
504 /* Set DEBUGFLOWSIZE in contiki-conf.h to track path through MAC, RDC, and RADIO */
505 #if DEBUGFLOWSIZE
506  if(debugflowsize) {
507  debugflow[debugflowsize] = 0;
508  PRINTF("%s", debugflow);
509  debugflowsize = 0;
510  }
511 #endif
512 
513 #if PERIODICPRINTS
514 #if TESTRTIMER
515 /* Timeout can be increased up to 8 seconds maximum.
516  * A one second cycle is convenient for triggering the various debug printouts.
517  * The triggers are staggered to avoid printing everything at once.
518  */
519  if(rtimerflag) {
520  rtimer_set(&rt, RTIMER_NOW() + RTIMER_ARCH_SECOND * 1UL, 1, (void *)rtimercycle, NULL);
521  rtimerflag = 0;
522 #else
523  if(clocktime != clock_seconds()) {
524  clocktime = clock_seconds();
525 #endif
526 
527 #if STAMPS
528  if((clocktime % STAMPS) == 0) {
529 #if ENERGEST_CONF_ON
530 #include "lib/print-stats.h"
531  print_stats();
532 #elif RADIOSTATS
533  extern volatile unsigned long radioontime;
534  PRINTF("%u(%u)s\n", clocktime, radioontime);
535 #else
536  PRINTF("%us\n", clocktime);
537 #endif
538  }
539 #endif
540 #if TESTRTIMER
541  clocktime += 1;
542 #endif
543 
544 #if PINGS && NETSTACK_CONF_WITH_IPV6
545  extern void raven_ping6(void);
546  if((clocktime % PINGS) == 1) {
547  PRINTF("**Ping\n");
548  raven_ping6();
549  }
550 #endif
551 
552 #if ROUTES && NETSTACK_CONF_WITH_IPV6
553  if((clocktime % ROUTES) == 2) {
554 
556 
557  uint8_t i, j;
558  PRINTF("\nAddresses [%u max]\n", UIP_DS6_ADDR_NB);
559  for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
560  if(uip_ds6_if.addr_list[i].isused) {
561  ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
562  PRINTF("\n");
563  }
564  }
565  PRINTF("\nNeighbors [%u max]\n", NBR_TABLE_MAX_NEIGHBORS);
566  j = 0;
567  for(nbr = nbr_table_head(ds6_neighbors);
568  nbr != NULL;
569  nbr = nbr_table_next(ds6_neighbors, nbr)) {
570  ipaddr_add(&nbr->ipaddr);
571  PRINTF("\n");
572  j++;
573  }
574  if(!j) {
575  PRINTF(" <none>");
576  }
577  PRINTF("\nRoutes [%u max]\n", UIP_DS6_ROUTE_NB);
578  {
579  uip_ds6_route_t *r;
580  j = 0;
581  for(r = uip_ds6_route_head();
582  r != NULL;
583  r = uip_ds6_route_next(r)) {
584  ipaddr_add(&r->ipaddr);
585  PRINTF("/%u (via ", r->length);
586  ipaddr_add(uip_ds6_route_nexthop(r));
587  PRINTF(") %lus\n", r->state.lifetime);
588  j++;
589  }
590  }
591  if(!j) {
592  PRINTF(" <none>");
593  }
594  PRINTF("\n---------\n");
595  }
596 #endif
597 
598 #if STACKMONITOR
599  if((clocktime % STACKMONITOR) == 3) {
600  extern uint16_t __bss_end;
601  uint16_t p = (uint16_t)&__bss_end;
602  do {
603  if(*(uint16_t *)p != 0x4242) {
604  PRINTF("Never-used stack > %d bytes\n", p - (uint16_t)&__bss_end);
605  break;
606  }
607  p += 10;
608  } while(p < RAMEND - 10);
609  }
610 #endif
611  }
612 #endif /* PERIODICPRINTS */
613 
614 #if RF230BB && 0
615  extern uint8_t rf230processflag;
616  if(rf230processflag) {
617  PRINTF("rf230p%d", rf230processflag);
618  rf230processflag = 0;
619  }
620 #endif
621 
622 #if RF230BB && 0
623  extern uint8_t rf230_interrupt_flag;
624  if(rf230_interrupt_flag) {
625  /* if (rf230_interrupt_flag!=11) { */
626  PRINTF("**RI%u", rf230_interrupt_flag);
627  /* } */
628  rf230_interrupt_flag = 0;
629  }
630 #endif
631  }
632  return 0;
633 }
634 /*---------------------------------------------------------------------------*/
635 
636 void
637 log_message(char *m1, char *m2)
638 {
639  PRINTF("%s%s\n", m1, m2);
640 }
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Definition: packetbuf.c:158
int cfs_open(const char *name, int flags)
Open a file.
Definition: cfs-coffee.c:1011
void process_poll(struct process *p)
Request a process to be polled.
Definition: process.c:371
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:129
#define CFS_WRITE
Specify that cfs_open() should open a file for writing.
Definition: cfs.h:104
static uip_ds6_addr_t * addr
Pointer to a router list entry.
Definition: uip-nd6.c:124
#define RTIMER_NOW()
Get the current clock time.
Definition: rtimer.h:135
void cfs_close(int fd)
Close an open file.
Definition: cfs-coffee.c:1047
void packetbuf_clear(void)
Clear and reset the packetbuf.
Definition: packetbuf.c:76
#define CFS_READ
Specify that cfs_open() should open a file for reading.
Definition: cfs.h:90
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
Definition: random.c:41
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
Definition: packetbuf.h:66
This file contains radio driver code.
void clock_init(void)
Initialize the clock library.
Definition: clock.c:76
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:70
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Definition: packetbuf.c:164
void i2c_init(uint8_t port_sda, uint8_t pin_sda, uint8_t port_scl, uint8_t pin_scl, uint32_t bus_speed)
Initialize the I2C peripheral and pins.
Definition: i2c.c:49
int process_run(void)
Run the system once - call poll handlers and process one event.
Definition: process.c:302
Interface structure (contains all the interface variables)
Definition: uip-ds6.h:242
Header file for the Rime stack
#define NULL
The null pointer.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:122
int cfs_coffee_format(void)
Format the storage area assigned to Coffee.
Definition: cfs-coffee.c:1378
802.15.4 frame creation and parsing functions
void rs232_init(void)
Initialize the RS232 module.
Definition: rs232.c:51
int rtimer_set(struct rtimer *rtimer, rtimer_clock_t time, rtimer_clock_t duration, rtimer_callback_t func, void *ptr)
Post a real-time task.
Definition: rtimer.c:67
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Definition: linkaddr.c:72
void watchdog_periodic(void)
Writes the WDT clear sequence.
Definition: watchdog.c:64
Convenience function for printing system statistics
void calibrate_rc_osc_32k(void)
Calibrate the internal RC oscillator.
Definition: radio.c:1332
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82
void rs232_set_input(int(*f)(unsigned char))
Set an input handler for incoming RS232 data.
Definition: rs232.c:56
#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
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
Definition: packetbuf.c:151
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99
int main(void)
This is main...
Definition: contiki-main.c:456
Header for the Coffee file system.
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
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
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
uip_ds6_netif_t uip_ds6_if
The single interface.
Definition: uip-ds6.c:71
Representation of a real-time task.
Definition: rtimer.h:86
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
CFS header file.
Header file for the 6lowpan implementation (RFC4944 and draft-hui-6lowpan-hc-01) ...
An entry in the routing table.
A MAC framer for IEEE 802.15.4