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  */
32 #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
33 
34 #define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
35 #if ANNOUNCE_BOOT
36 #define PRINTA(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
37 #else
38 #define PRINTA(...)
39 #endif
40 
41 #define DEBUG 0
42 #if DEBUG
43 #define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
44 #else
45 #define PRINTD(...)
46 #endif
47 
48 #include <avr/pgmspace.h>
49 #include <avr/fuse.h>
50 #include <avr/eeprom.h>
51 #include <stdio.h>
52 #include <string.h>
53 #include <dev/watchdog.h>
54 
55 #include "loader/symbols-def.h"
56 #include "loader/symtab.h"
57 
58 #include "params.h"
59 #include "radio/rf230bb/rf230bb.h"
60 #include "net/mac/frame802154.h"
61 #include "net/mac/framer-802154.h"
62 #include "net/ipv6/sicslowpan.h"
63 
64 #include "contiki.h"
65 #include "contiki-net.h"
66 #include "contiki-lib.h"
67 
68 #include "dev/rs232.h"
69 #include "dev/serial-line.h"
70 #include "dev/slip.h"
71 
72 #ifdef RAVEN_LCD_INTERFACE
73 #include "raven-lcd.h"
74 #endif
75 
76 #if AVR_WEBSERVER
77 #include "httpd-fs.h"
78 #include "httpd-cgi.h"
79 #endif
80 
81 #ifdef COFFEE_FILES
82 #include "cfs/cfs.h"
83 #include "cfs/cfs-coffee.h"
84 #endif
85 
86 #if UIP_CONF_ROUTER&&0
87 #include "net/routing/rimeroute.h"
88 #include "net/rime/rime-udp.h"
89 #endif
90 
91 #include "net/rime/rime.h"
92 
93 /* Track interrupt flow through mac, rdc and radio driver */
94 //#define DEBUGFLOWSIZE 32
95 #if DEBUGFLOWSIZE
96 uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
97 #define DEBUGFLOW(c) if (debugflowsize<(DEBUGFLOWSIZE-1)) debugflow[debugflowsize++]=c
98 #else
99 #define DEBUGFLOW(c)
100 #endif
101 
102 /* Get periodic prints from idle loop, from clock seconds or rtimer interrupts */
103 /* Use of rtimer will conflict with other rtimer interrupts such as contikimac radio cycling */
104 /* STAMPS will print ENERGEST outputs if that is enabled. */
105 #define PERIODICPRINTS 1
106 #if PERIODICPRINTS
107 //#define PINGS 64
108 #define ROUTES 600
109 #define STAMPS 60
110 #define STACKMONITOR 1024
111 uint32_t clocktime;
112 #define TESTRTIMER 0
113 #if TESTRTIMER
114 uint8_t rtimerflag=1;
115 struct rtimer rt;
116 void rtimercycle(void) {rtimerflag=1;}
117 #endif
118 #endif
119 
120 uint16_t ledtimer;
121 
122 /*-------------------------------------------------------------------------*/
123 /*----------------------Configuration of the .elf file---------------------*/
124 #if 1
125 /* The proper way to set the signature is */
126 #include <avr/signature.h>
127 #else
128 /* Older avr-gcc's may not define the needed SIGNATURE bytes. Do it manually if you get an error */
129 typedef struct {const unsigned char B2;const unsigned char B1;const unsigned char B0;} __signature_t;
130 #define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
131 SIGNATURE = {
132  .B2 = 0x01,//SIGNATURE_2, //ATMEGA128rfa1
133  .B1 = 0xA7,//SIGNATURE_1, //128KB flash
134  .B0 = 0x1E,//SIGNATURE_0, //Atmel
135 };
136 #endif
137 
138 #if 1
139 /* JTAG, SPI enabled, Internal RC osc, Boot flash size 4K, 6CK+65msec delay, brownout disabled */
140 FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
141 #else
142 /* JTAG+SPI, Boot 4096 words @ $F000, Internal oscillator, startup 6 CK +0 ms, Brownout 1.8 volts */
143 FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,};
144 #endif
145 
146 uint8_t
147 rng_get_uint8(void) {
148 #if 1
149  /* Upper two RSSI reg bits (RND_VALUE) are random in rf231 */
150  uint8_t j;
151  j = (PHY_RSSI&0xc0) + ((PHY_RSSI>>2)&0x30) + ((PHY_RSSI>>4)&0x0c) + ((PHY_RSSI>>6)&0x03);
152 #else
153 /* Get a pseudo random number using the ADC */
154  uint8_t i,j;
155  ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
156  for (i=0;i<4;i++) {
157  ADMUX = 0; //toggle reference to increase noise
158  ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
159  ADCSRA|=1<<ADSC; //Start conversion
160  while (ADCSRA&(1<<ADSC)); //Wait till done
161  j = (j<<2) + ADC;
162  }
163  ADCSRA=0; //Disable ADC
164 #endif
165  PRINTD("rng issues %d\n",j);
166  return j;
167 }
168 
169 /*-------------------------Low level initialization------------------------*/
170 /*------Done in a subroutine to keep main routine stack usage small--------*/
171 void initialize(void)
172 {
173  watchdog_init();
174  watchdog_start();
175 
176 /* The Raven implements a serial command and data interface via uart0 to a 3290p,
177  * which could be duplicated using another host computer.
178  */
179 #if !RF230BB_CONF_LEDONPORTE1 //Conflicts with USART0
180 #ifdef RAVEN_LCD_INTERFACE
181  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
182  rs232_set_input(0,raven_lcd_serial_input);
183 #else
184  /* Generic or slip connection on uart0 */
185  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
186 #endif
187 #endif
188 
189  /* Second rs232 port for debugging or slip alternative */
190  rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
191  /* Redirect stdout */
192 #if RF230BB_CONF_LEDONPORTE1 || defined(RAVEN_LCD_INTERFACE)
193  rs232_redirect_stdout(RS232_PORT_1);
194 #else
195  rs232_redirect_stdout(RS232_PORT_0);
196 #endif
197  clock_init();
198 
199  if(MCUSR & (1<<PORF )) PRINTD("Power-on reset.\n");
200  if(MCUSR & (1<<EXTRF)) PRINTD("External reset!\n");
201  if(MCUSR & (1<<BORF )) PRINTD("Brownout reset!\n");
202  if(MCUSR & (1<<WDRF )) PRINTD("Watchdog reset!\n");
203  if(MCUSR & (1<<JTRF )) PRINTD("JTAG reset!\n");
204 
205 #if STACKMONITOR
206  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
207  * loop. In conjuction with PERIODICPRINTS, never-used stack will be printed
208  * every STACKMONITOR seconds.
209  */
210 {
211 extern uint16_t __bss_end;
212 uint16_t p=(uint16_t)&__bss_end;
213  do {
214  *(uint16_t *)p = 0x4242;
215  p+=10;
216  } while (p<SP-10); //don't overwrite our own stack
217 }
218 #endif
219 
220 #define CONF_CALIBRATE_OSCCAL 0
221 #if CONF_CALIBRATE_OSCCAL
222 void calibrate_rc_osc_32k();
223 {
224 extern uint8_t osccal_calibrated;
225 uint8_t i;
226  PRINTD("\nBefore calibration OSCCAL=%x\n",OSCCAL);
227  for (i=0;i<10;i++) {
229  PRINTD("Calibrated=%x\n",osccal_calibrated);
230 //#include <util/delay_basic.h>
231 //#define delay_us( us ) ( _delay_loop_2(1+(us*F_CPU)/4000000UL) )
232 // delay_us(50000);
233  }
234  clock_init();
235 }
236 #endif
237 
238  PRINTA("\n*******Booting %s*******\n",CONTIKI_VERSION_STRING);
239 
240 /* rtimers needed for radio cycling */
241  rtimer_init();
242 
243  /* Initialize process subsystem */
244  process_init();
245 
246  /* etimers must be started before ctimer_init */
247  process_start(&etimer_process, NULL);
248  ctimer_init();
249 
250  /* Start radio and radio receive process */
251  NETSTACK_RADIO.init();
252 
253 /* Get a random seed for the 802.15.4 packet sequence number.
254  * Some layers will ignore duplicates found in a history (e.g. Contikimac)
255  * causing the initial packets to be ignored after a short-cycle restart.
256  */
257  random_init(rng_get_uint8());
258 
259  /* Set addresses BEFORE starting tcpip process */
260 
261  linkaddr_t addr;
262 
263  if (params_get_eui64(addr.u8)) {
264  PRINTA("Random EUI64 address generated\n");
265  }
266 
267 #if NETSTACK_CONF_WITH_IPV6
268  memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
269 #elif WITH_NODE_ID
270  node_id=get_panaddr_from_eeprom();
271  addr.u8[1]=node_id&0xff;
272  addr.u8[0]=(node_id&0xff00)>>8;
273  PRINTA("Node ID from eeprom: %X\n",node_id);
274 #endif
275  linkaddr_set_node_addr(&addr);
276 
277  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
278  rf230_set_channel(params_get_channel());
279  rf230_set_txpower(params_get_txpower());
280 
281 #if NETSTACK_CONF_WITH_IPV6
282  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]);
283 #else
284  PRINTA("MAC address ");
285  uint8_t i;
286  for (i=sizeof(linkaddr_t); i>0; i--){
287  PRINTA("%x:",addr.u8[i-1]);
288  }
289  PRINTA("\n");
290 #endif
291 
292  /* Initialize stack protocols */
293  queuebuf_init();
294  NETSTACK_RDC.init();
295  NETSTACK_MAC.init();
296  NETSTACK_NETWORK.init();
297 
298 #if ANNOUNCE_BOOT
299  PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
300  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
301  rf230_get_txpower());
302 #if UIP_CONF_IPV6_RPL
303  PRINTA("RPL Enabled\n");
304 #endif
305 #if UIP_CONF_ROUTER
306  PRINTA("Routing Enabled\n");
307 #endif
308 
309 #endif /* ANNOUNCE_BOOT */
310 
311 #if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4
312  process_start(&tcpip_process, NULL);
313 #endif
314 
315 #ifdef RAVEN_LCD_INTERFACE
316  process_start(&raven_lcd_process, NULL);
317 #endif
318 
319  /* Autostart other processes */
320  autostart_start(autostart_processes);
321 
322  /*---If using coffee file system create initial web content if necessary---*/
323 #if COFFEE_FILES
324  int fa = cfs_open( "/index.html", CFS_READ);
325  if (fa<0) { //Make some default web content
326  PRINTA("No index.html file found, creating upload.html!\n");
327  PRINTA("Formatting FLASH file system for coffee...");
329  PRINTA("Done!\n");
330  fa = cfs_open( "/index.html", CFS_WRITE);
331  int r = cfs_write(fa, &"It works!", 9);
332  if (r<0) PRINTA("Can''t create /index.html!\n");
333  cfs_close(fa);
334 // fa = cfs_open("upload.html"), CFW_WRITE);
335 // <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>
336  }
337 #endif /* COFFEE_FILES */
338 
339 /* Add addresses for testing */
340 #if 0
341 {
342  uip_ip6addr_t ipaddr;
343  uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
344  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
345 // uip_ds6_prefix_add(&ipaddr,64,0);
346 }
347 #endif
348 
349 /*--------------------------Announce the configuration---------------------*/
350 #if ANNOUNCE_BOOT
351 #if AVR_WEBSERVER
352 { uint8_t i;
353  char buf[80];
354  unsigned int size;
355 
356  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
357  if (uip_ds6_if.addr_list[i].isused) {
358  httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr,buf);
359  PRINTA("IPv6 Address: %s\n",buf);
360  }
361  }
362  cli();
363  eeprom_read_block (buf,eemem_server_name, sizeof(eemem_server_name));
364  sei();
365  buf[sizeof(eemem_server_name)]=0;
366  PRINTA("%s",buf);
367  cli();
368  eeprom_read_block (buf,eemem_domain_name, sizeof(eemem_domain_name));
369  sei();
370  buf[sizeof(eemem_domain_name)]=0;
371  size=httpd_fs_get_size();
372 #ifndef COFFEE_FILES
373  PRINTA(".%s online with fixed %u byte web content\n",buf,size);
374 #elif COFFEE_FILES==1
375  PRINTA(".%s online with static %u byte EEPROM file system\n",buf,size);
376 #elif COFFEE_FILES==2
377  PRINTA(".%s online with dynamic %u KB EEPROM file system\n",buf,size>>10);
378 #elif COFFEE_FILES==3
379  PRINTA(".%s online with static %u byte program memory file system\n",buf,size);
380 #elif COFFEE_FILES==4
381  PRINTA(".%s online with dynamic %u KB program memory file system\n",buf,size>>10);
382 #endif /* COFFEE_FILES */
383 }
384 #else
385  PRINTA("Online\n");
386 #endif
387 #endif /* ANNOUNCE_BOOT */
388 
389 #if RF230BB_CONF_LEDONPORTE1
390  /* NB: PORTE1 conflicts with UART0 */
391  DDRE|=(1<<DDE1); //set led pin to output (Micheal Hatrtman board)
392  PORTE&=~(1<<PE1); //and low to turn led off
393 #endif
394 }
395 
396 #if ROUTES && NETSTACK_CONF_WITH_IPV6
397 static void
398 ipaddr_add(const uip_ipaddr_t *addr)
399 {
400  uint16_t a;
401  int8_t i, f;
402  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
403  a = (addr->u8[i] << 8) + addr->u8[i + 1];
404  if(a == 0 && f >= 0) {
405  if(f++ == 0) PRINTF("::");
406  } else {
407  if(f > 0) {
408  f = -1;
409  } else if(i > 0) {
410  PRINTF(":");
411  }
412  PRINTF("%x",a);
413  }
414  }
415 }
416 #endif
417 
418 /*-------------------------------------------------------------------------*/
419 /*------------------------- Main Scheduler loop----------------------------*/
420 /*-------------------------------------------------------------------------*/
421 int
422 main(void)
423 {
424 #if NETSTACK_CONF_WITH_IPV6
426 #endif /* NETSTACK_CONF_WITH_IPV6 */
427  initialize();
428 
429  while(1) {
430  process_run();
432 
433  /* Turn off LED after a while */
434  if (ledtimer) {
435  if (--ledtimer==0) {
436 #if RF230BB_CONF_LEDONPORTE1
437  PORTE&=~(1<<PE1);
438 #endif
439 #if defined(RAVEN_LCD_INTERFACE)&&0
440  /* ledtimer can be set by received ping; ping the other way for testing */
441  extern void raven_ping6(void);
442  raven_ping6();
443 #endif
444  }
445  }
446 
447 #if 0
448 /* Various entry points for debugging in the AVR Studio simulator.
449  * Set as next statement and step into the routine.
450  */
451  NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
452  process_poll(&rf230_process);
453  packetbuf_clear();
454  len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
456  NETSTACK_RDC.input();
457 #endif
458 
459 #if 0
460 /* Clock.c can trigger a periodic PLL calibration in the RF230BB driver.
461  * This can show when that happens.
462  */
463  extern uint8_t rf230_calibrated;
464  if (rf230_calibrated) {
465  PRINTD("\nRF230 calibrated!\n");
466  rf230_calibrated=0;
467  }
468 #endif
469 
470 /* Set DEBUGFLOWSIZE in contiki-conf.h to track path through MAC, RDC, and RADIO */
471 #if DEBUGFLOWSIZE
472  if (debugflowsize) {
473  debugflow[debugflowsize]=0;
474  PRINTF("%s",debugflow);
475  debugflowsize=0;
476  }
477 #endif
478 
479 #if PERIODICPRINTS
480 #if TESTRTIMER
481 /* Timeout can be increased up to 8 seconds maximum.
482  * A one second cycle is convenient for triggering the various debug printouts.
483  * The triggers are staggered to avoid printing everything at once.
484  */
485  if (rtimerflag) {
486  rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL);
487  rtimerflag=0;
488 #else
489  if (clocktime!=clock_seconds()) {
490  clocktime=clock_seconds();
491 #endif
492 
493 #if STAMPS
494 if ((clocktime%STAMPS)==0) {
495 #if ENERGEST_CONF_ON
496 #include "lib/print-stats.h"
497  print_stats();
498 #elif RADIOSTATS
499 extern volatile unsigned long radioontime;
500  PRINTF("%u(%u)s\n",clocktime,radioontime);
501 #else
502  PRINTF("%us\n",clocktime);
503 #endif
504 
505 }
506 #endif
507 #if TESTRTIMER
508  clocktime+=1;
509 #endif
510 
511 #if PINGS && NETSTACK_CONF_WITH_IPV6
512 extern void raven_ping6(void);
513 if ((clocktime%PINGS)==1) {
514  PRINTF("**Ping\n");
515  raven_ping6();
516 }
517 #endif
518 
519 #if ROUTES && NETSTACK_CONF_WITH_IPV6
520 if ((clocktime%ROUTES)==2) {
521 
523 
524  uint8_t i,j;
525  PRINTF("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB);
526  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
527  if (uip_ds6_if.addr_list[i].isused) {
528  ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
529  PRINTF("\n");
530  }
531  }
532  PRINTF("\nNeighbors [%u max]\n",NBR_TABLE_MAX_NEIGHBORS);
533 
534  for(nbr = nbr_table_head(ds6_neighbors);
535  nbr != NULL;
536  nbr = nbr_table_next(ds6_neighbors, nbr)) {
537  ipaddr_add(&nbr->ipaddr);
538  PRINTF("\n");
539  j=0;
540  }
541  if (j) PRINTF(" <none>");
542  PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
543  {
544  uip_ds6_route_t *r;
545  PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
546  j = 1;
547  for(r = uip_ds6_route_head();
548  r != NULL;
549  r = uip_ds6_route_next(r)) {
550  ipaddr_add(&r->ipaddr);
551  PRINTF("/%u (via ", r->length);
552  ipaddr_add(uip_ds6_route_nexthop(r));
553  PRINTF(") %lus\n", r->state.lifetime);
554  j = 0;
555  }
556  }
557  if (j) PRINTF(" <none>");
558  PRINTF("\n---------\n");
559 }
560 #endif
561 
562 #if STACKMONITOR
563 if ((clocktime%STACKMONITOR)==3) {
564  extern uint16_t __bss_end;
565  uint16_t p=(uint16_t)&__bss_end;
566  do {
567  if (*(uint16_t *)p != 0x4242) {
568  PRINTF("Never-used stack > %d bytes\n",p-(uint16_t)&__bss_end);
569  break;
570  }
571  p+=10;
572  } while (p<RAMEND-10);
573 }
574 #endif
575 
576  }
577 #endif /* PERIODICPRINTS */
578 
579 #if RF230BB&&0
580 extern uint8_t rf230processflag;
581  if (rf230processflag) {
582  PRINTF("rf230p%d",rf230processflag);
583  rf230processflag=0;
584  }
585 #endif
586 
587 #if RF230BB&&0
588 extern uint8_t rf230_interrupt_flag;
589  if (rf230_interrupt_flag) {
590  // if (rf230_interrupt_flag!=11) {
591  PRINTF("**RI%u",rf230_interrupt_flag);
592  // }
593  rf230_interrupt_flag=0;
594  }
595 #endif
596  }
597  return 0;
598 }
599 
600 /*---------------------------------------------------------------------------*/
601 
602 void log_message(char *m1, char *m2)
603 {
604  PRINTF("%s%s\n", m1, m2);
605 }
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
#define PORTE
Peripheral PORTE base pointer.
Definition: MKL25Z4.h:4455
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
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