Contiki 3.x
contiki-raven-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  */
33 #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
34 
35 #define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
36 #if ANNOUNCE_BOOT
37 #define PRINTA(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
38 #else
39 #define PRINTA(...)
40 #endif
41 
42 #define DEBUG 0
43 #if DEBUG
44 #define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
45 #else
46 #define PRINTD(...)
47 #endif
48 
49 /* Track interrupt flow through mac, rdc and radio driver */
50 //#define DEBUGFLOWSIZE 64
51 #if DEBUGFLOWSIZE
52 unsigned char debugflowsize,debugflow[DEBUGFLOWSIZE];
53 #define DEBUGFLOW(c) if (debugflowsize<(DEBUGFLOWSIZE-1)) debugflow[debugflowsize++]=c
54 #else
55 #define DEBUGFLOW(c)
56 #endif
57 
58 #include <avr/pgmspace.h>
59 #include <avr/fuse.h>
60 #include <avr/eeprom.h>
61 #include <stdio.h>
62 #include <string.h>
63 #include <dev/watchdog.h>
64 
65 #include "loader/symbols-def.h"
66 #include "loader/symtab.h"
67 
68 #if RF230BB //radio driver using contiki core mac
69 #include "radio/rf230bb/rf230bb.h"
70 #include "net/mac/frame802154.h"
71 #include "net/mac/framer-802154.h"
72 #include "net/ipv6/sicslowpan.h"
73 
74 #else //radio driver using Atmel/Cisco 802.15.4'ish MAC
75 #include <stdbool.h>
76 #include "mac.h"
77 #include "sicslowmac.h"
78 #include "sicslowpan.h"
79 #include "ieee-15-4-manager.h"
80 #endif /*RF230BB*/
81 
82 #include "contiki.h"
83 #include "contiki-net.h"
84 #include "contiki-lib.h"
85 
86 #include "dev/rs232.h"
87 #include "dev/serial-line.h"
88 #include "dev/slip.h"
89 
90 #ifdef RAVEN_LCD_INTERFACE
91 #include "raven-lcd.h"
92 #endif
93 
94 #if AVR_WEBSERVER
95 #include "httpd-fs.h"
96 #include "httpd-cgi.h"
97 #endif
98 
99 #ifdef COFFEE_FILES
100 #include "cfs/cfs.h"
101 #include "cfs/cfs-coffee.h"
102 #endif
103 
104 #if UIP_CONF_ROUTER&&0
105 #include "net/routing/rimeroute.h"
106 #include "net/rime/rime-udp.h"
107 #endif
108 
109 #include "net/rime/rime.h"
110 
111 #include "params.h"
112 
113 /* Get periodic prints from idle loop, from clock seconds or rtimer interrupts */
114 /* Use of rtimer will conflict with other rtimer interrupts such as contikimac radio cycling */
115 /* STAMPS will print ENERGEST outputs if that is enabled. */
116 #define PERIODICPRINTS 1
117 #if PERIODICPRINTS
118 //#define PINGS 64
119 #define ROUTES 600
120 #define STAMPS 60
121 #define STACKMONITOR 600
122 uint32_t clocktime;
123 #define TESTRTIMER 0
124 #if TESTRTIMER
125 uint8_t rtimerflag=1;
126 struct rtimer rt;
127 void rtimercycle(void) {rtimerflag=1;}
128 #endif
129 #endif
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;const unsigned char B1;const unsigned char B0;} __signature_t;
139 #define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
140 SIGNATURE = {
141  .B2 = 0x05,//SIGNATURE_2, //ATMEGA1284p
142  .B1 = 0x97,//SIGNATURE_1, //128KB flash
143  .B0 = 0x1E,//SIGNATURE_0, //Atmel
144 };
145 #endif
146 
147 #if !MCU_CONF_LOW_WEAR
148 /* JTAG, SPI enabled, Internal RC osc, Boot flash size 4K, 6CK+65msec delay, brownout disabled */
149 FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
150 #endif
151 
152 /* Get a pseudo random number using the ADC */
153 uint8_t
154 rng_get_uint8(void) {
155 uint8_t i,j;
156  ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
157  for (i=0,j=0;i<4;i++) {
158  ADMUX = 0; //toggle reference to increase noise
159  ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
160  ADCSRA|=1<<ADSC; //Start conversion
161  while (ADCSRA&(1<<ADSC)); //Wait till done
162  j = (j<<2) + ADC;
163  }
164  ADCSRA=0; //Disable ADC
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 #ifdef RAVEN_LCD_INTERFACE
177  /* First rs232 port for Raven 3290 port */
178  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
179  /* Set input handler for 3290 port */
180  rs232_set_input(0,raven_lcd_serial_input);
181 #else
182  /* Generic or slip connection on uart0 */
183  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
184 #endif
185 
186  /* Second rs232 port for debugging or slip alternative */
187  rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
188  /* Redirect stdout to second port */
189  rs232_redirect_stdout(RS232_PORT_1);
190  clock_init();
191 
192  PRINTD("\n\nChecking MCUSR...\n");
193  if(MCUSR & (1<<PORF )) PRINTD("Power-on reset.\n");
194  if(MCUSR & (1<<EXTRF)) PRINTD("External reset!\n");
195  if(MCUSR & (1<<BORF )) PRINTD("Brownout reset!\n");
196  if(MCUSR & (1<<WDRF )) PRINTD("Watchdog reset!\n");
197  if(MCUSR & (1<<JTRF )) PRINTD("JTAG reset!\n");
198  MCUSR = 0;
199 
200  PRINTD("CLOCK_SECOND %d\n",CLOCK_SECOND);
201  PRINTD("RTIMER_ARCH_SECOND %lu\n",RTIMER_ARCH_SECOND);
202  PRINTD("F_CPU %lu\n",F_CPU);
203 
204 #if STACKMONITOR
205  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
206  * loop. In conjuction with PERIODICPRINTS, never-used stack will be printed
207  * every STACKMONITOR seconds.
208  */
209 {
210 extern uint16_t __bss_end;
211 uint16_t p=(uint16_t)&__bss_end;
212  do {
213  *(uint16_t *)p = 0x4242;
214  p+=10;
215  } while (p<SP-10); //don't overwrite our own stack
216 }
217 #endif
218 
219 /* Calibrate internal mcu clock against external 32768Hz watch crystal */
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 
249 #if RF230BB
250 
251  ctimer_init();
252  /* Start radio and radio receive process */
253  NETSTACK_RADIO.init();
254 
255 /* Get a random seed for the 802.15.4 packet sequence number.
256  * Some layers will ignore duplicates found in a history (e.g. Contikimac)
257  * causing the initial packets to be ignored after a short-cycle restart.
258  */
259  random_init(rng_get_uint8());
260 
261  /* Set addresses BEFORE starting tcpip process */
262 
263  linkaddr_t addr;
264  if (params_get_eui64(addr.u8)) {
265  PRINTA("Random EUI64 address generated\n");
266  }
267 
268 #if UIP_CONF_IPV6
269  memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
270  linkaddr_set_node_addr(&addr);
271  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
272 #elif WITH_NODE_ID
273  node_id=get_panaddr_from_eeprom();
274  addr.u8[1]=node_id&0xff;
275  addr.u8[0]=(node_id&0xff00)>>8;
276  PRINTA("Node ID from eeprom: %X\n",node_id);
277  uint16_t inv_node_id=((node_id&0xff00)>>8)+((node_id&0xff)<<8); // change order of bytes for rf23x
278  linkaddr_set_node_addr(&addr);
279  rf230_set_pan_addr(params_get_panid(),inv_node_id,NULL);
280 #else
281  linkaddr_set_node_addr(&addr);
282  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
283 #endif
284  rf230_set_channel(params_get_channel());
285  rf230_set_txpower(params_get_txpower());
286 
287 #if UIP_CONF_IPV6
288  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]);
289 #else
290  PRINTA("MAC address ");
291  uint8_t i;
292  for (i=sizeof(linkaddr_t); i>0; i--){
293  PRINTA("%x:",addr.u8[i-1]);
294  }
295  PRINTA("\n");
296 #endif
297 
298  /* Initialize stack protocols */
299  queuebuf_init();
300  NETSTACK_RDC.init();
301  NETSTACK_MAC.init();
302  NETSTACK_NETWORK.init();
303 
304 #if ANNOUNCE_BOOT
305  PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
306  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
307  rf230_get_txpower());
308 #if UIP_CONF_IPV6_RPL
309  PRINTA("RPL Enabled\n");
310 #endif
311 #if UIP_CONF_ROUTER
312  PRINTA("Routing Enabled\n");
313 #endif
314 #endif /* ANNOUNCE_BOOT */
315 
316 // rime_init(rime_udp_init(NULL));
317 // uip_router_register(&rimeroute);
318 
319  process_start(&tcpip_process, NULL);
320 
321 #else /* !RF230BB */
322 /* Original RF230 combined mac/radio driver */
323 /* mac process must be started before tcpip process! */
324  process_start(&mac_process, NULL);
325  process_start(&tcpip_process, NULL);
326 #endif /* RF230BB */
327 
328 #ifdef RAVEN_LCD_INTERFACE
329  process_start(&raven_lcd_process, NULL);
330 #endif
331 
332  /* Autostart other processes */
333  autostart_start(autostart_processes);
334 
335  /*---If using coffee file system create initial web content if necessary---*/
336 #if COFFEE_FILES
337  int fa = cfs_open( "/index.html", CFS_READ);
338  if (fa<0) { //Make some default web content
339  PRINTA("No index.html file found, creating upload.html!\n");
340  PRINTA("Formatting FLASH file system for coffee...");
342  PRINTA("Done!\n");
343  fa = cfs_open( "/index.html", CFS_WRITE);
344  int r = cfs_write(fa, &"It works!", 9);
345  if (r<0) PRINTA("Can''t create /index.html!\n");
346  cfs_close(fa);
347 // fa = cfs_open("upload.html"), CFW_WRITE);
348 // <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>
349  }
350 #endif /* COFFEE_FILES */
351 
352 /* Add addresses for testing */
353 #if 0
354 {
355  uip_ip6addr_t ipaddr;
356  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
357  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
358 // uip_ds6_prefix_add(&ipaddr,64,0);
359 }
360 #endif
361 
362 /*--------------------------Announce the configuration---------------------*/
363 #if ANNOUNCE_BOOT
364 {
365 #if AVR_WEBSERVER
366  uint8_t i;
367  char buf1[40],buf[40];
368  unsigned int size;
369 
370  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
371  if (uip_ds6_if.addr_list[i].isused) {
372  httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr,buf);
373  PRINTA("IPv6 Address: %s\n",buf);
374  }
375  }
376  cli();
377  eeprom_read_block (buf1,eemem_server_name, sizeof(eemem_server_name));
378  eeprom_read_block (buf,eemem_domain_name, sizeof(eemem_domain_name));
379  sei();
380  buf1[sizeof(eemem_server_name)]=0;
381  PRINTA("%s",buf1);
382  buf[sizeof(eemem_domain_name)]=0;
383  size=httpd_fs_get_size();
384 #ifndef COFFEE_FILES
385  PRINTA(".%s online with fixed %u byte web content\n",buf,size);
386 #elif COFFEE_FILES==1
387  PRINTA(".%s online with static %u byte EEPROM file system\n",buf,size);
388 #elif COFFEE_FILES==2
389  PRINTA(".%s online with dynamic %u KB EEPROM file system\n",buf,size>>10);
390 #elif COFFEE_FILES==3
391  PRINTA(".%s online with static %u byte program memory file system\n",buf,size);
392 #elif COFFEE_FILES==4
393  PRINTA(".%s online with dynamic %u KB program memory file system\n",buf,size>>10);
394 #endif /* COFFEE_FILES */
395 
396 #else
397  PRINTA("Online\n");
398 #endif /* AVR_WEBSERVER */
399 
400 #endif /* ANNOUNCE_BOOT */
401 }
402 }
403 
404 #if ROUTES && UIP_CONF_IPV6
405 static void
406 ipaddr_add(const uip_ipaddr_t *addr)
407 {
408  uint16_t a;
409  int8_t i, f;
410  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
411  a = (addr->u8[i] << 8) + addr->u8[i + 1];
412  if(a == 0 && f >= 0) {
413  if(f++ == 0) PRINTF("::");
414  } else {
415  if(f > 0) {
416  f = -1;
417  } else if(i > 0) {
418  PRINTF(":");
419  }
420  PRINTF("%x",a);
421  }
422  }
423 }
424 #endif
425 
426 /*-------------------------------------------------------------------------*/
427 /*------------------------- Main Scheduler loop----------------------------*/
428 /*-------------------------------------------------------------------------*/
429 int
430 main(void)
431 {
432 #if UIP_CONF_IPV6
433  uip_ds6_nbr_t *nbr;
434 #endif /* UIP_CONF_IPV6 */
435  initialize();
436 
437  while(1) {
438  process_run();
440 
441 #if 0
442 /* Various entry points for debugging in the AVR Studio simulator.
443  * Set as next statement and step into the routine.
444  */
445  NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
446  process_poll(&rf230_process);
447  packetbuf_clear();
448  len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
450  NETSTACK_RDC.input();
451 #endif
452 
453 #if 0
454 /* Clock.c can trigger a periodic PLL calibration in the RF230BB driver.
455  * This can show when that happens.
456  */
457  extern uint8_t rf230_calibrated;
458  if (rf230_calibrated) {
459  PRINTD("\nRF230 calibrated!\n");
460  rf230_calibrated=0;
461  }
462 #endif
463 
464 /* Set DEBUGFLOWSIZE in contiki-conf.h to track path through MAC, RDC, and RADIO */
465 #if DEBUGFLOWSIZE
466  if (debugflowsize) {
467  debugflow[debugflowsize]=0;
468  PRINTF("%s",debugflow);
469  debugflowsize=0;
470  }
471 #endif
472 
473 #if PERIODICPRINTS
474 #if TESTRTIMER
475 /* Timeout can be increased up to 8 seconds maximum.
476  * A one second cycle is convenient for triggering the various debug printouts.
477  * The triggers are staggered to avoid printing everything at once.
478  */
479  if (rtimerflag) {
480  rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL);
481  rtimerflag=0;
482 #else
483  if (clocktime!=clock_seconds()) {
484  clocktime=clock_seconds();
485 #endif
486 
487 #if STAMPS
488 if ((clocktime%STAMPS)==0) {
489 #if ENERGEST_CONF_ON
490 #include "lib/print-stats.h"
491  print_stats();
492 #elif RADIOSTATS
493 extern volatile unsigned long radioontime;
494  PRINTF("%u(%u)s\n",clocktime,radioontime);
495 #else
496  PRINTF("%us\n",clocktime);
497 #endif
498 
499 }
500 #endif
501 #if TESTRTIMER
502  clocktime+=1;
503 #endif
504 
505 #if PINGS && UIP_CONF_IPV6
506 extern void raven_ping6(void);
507 if ((clocktime%PINGS)==1) {
508  PRINTF("**Ping\n");
509  raven_ping6();
510 }
511 #endif
512 
513 #if ROUTES && UIP_CONF_IPV6
514 if ((clocktime%ROUTES)==2) {
515 
516 extern uip_ds6_netif_t uip_ds6_if;
517 
518  uint8_t i,j;
519  PRINTF("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB);
520  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
521  if (uip_ds6_if.addr_list[i].isused) {
522  ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
523  PRINTF("\n");
524  }
525  }
526  PRINTF("\nNeighbors [%u max]\n",NBR_TABLE_MAX_NEIGHBORS);
527  for(nbr = nbr_table_head(ds6_neighbors);
528  nbr != NULL;
529  nbr = nbr_table_next(ds6_neighbors, nbr)) {
530  ipaddr_add(&nbr->ipaddr);
531  PRINTF("\n");
532  j=0;
533  }
534  if (j) PRINTF(" <none>");
535  {
536  uip_ds6_route_t *r;
537  PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
538  j = 1;
539  for(r = uip_ds6_route_head();
540  r != NULL;
541  r = uip_ds6_route_next(r)) {
542  ipaddr_add(&r->ipaddr);
543  PRINTF("/%u (via ", r->length);
544  ipaddr_add(uip_ds6_route_nexthop(r));
545  PRINTF(") %lus\n", r->state.lifetime);
546  j = 0;
547  }
548  }
549  if (j) PRINTF(" <none>");
550  PRINTF("\n---------\n");
551 }
552 #endif
553 
554 #if STACKMONITOR
555 if ((clocktime%STACKMONITOR)==3) {
556  extern uint16_t __bss_end;
557  uint16_t p=(uint16_t)&__bss_end;
558  do {
559  if (*(uint16_t *)p != 0x4242) {
560  PRINTF("Never-used stack > %d bytes\n",p-(uint16_t)&__bss_end);
561  break;
562  }
563  p+=10;
564  } while (p<RAMEND-10);
565 }
566 #endif
567 
568  }
569 #endif /* PERIODICPRINTS */
570 
571 #if RF230BB&&0
572 extern uint8_t rf230processflag;
573  if (rf230processflag) {
574  PRINTF("rf230p%d",rf230processflag);
575  rf230processflag=0;
576  }
577 #endif
578 
579 #if RF230BB&&0
580 extern uint8_t rf230_interrupt_flag;
581  if (rf230_interrupt_flag) {
582  // if (rf230_interrupt_flag!=11) {
583  PRINTF("**RI%u",rf230_interrupt_flag);
584  // }
585  rf230_interrupt_flag=0;
586  }
587 #endif
588  }
589  return 0;
590 }
591 
592 /*---------------------------------------------------------------------------*/
593 
594 void log_message(char *m1, char *m2)
595 {
596  PRINTF("%s%s\n", m1, m2);
597 }
void rs232_init(void)
Initialize the RS232 module.
Definition: rs232.c:50
#define F_CPU
CPU core frequency resulting from the chosen divisors and multipliers.
Definition: config-clocks.h:87
An entry in the routing table.
A MAC framer for IEEE 802.15.4
void process_poll(struct process *p)
Request a process to be polled.
Definition: process.c:371
CCIF uip_lladdr_t uip_lladdr
Host L2 address.
Definition: uip6.c:115
802.15.4 frame creation and parsing functions
int cfs_open(const char *name, int flags)
Open a file.
Definition: cfs-coffee.c:996
#define CFS_WRITE
Specify that cfs_open() should open a file for writing.
Definition: cfs.h:104
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
Definition: watchdog.c:49
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 rtimer_init(void)
Initialize the real-time scheduler.
Definition: rtimer.c:61
Example glue code between the existing MAC code and the Contiki mac interface.
void calibrate_rc_osc_32k(void)
Calibrate the internal RC oscillator.
Definition: radio.c:1332
void rs232_set_input(int(*f)(unsigned char))
Set an input handler for incoming RS232 data.
Definition: rs232.c:55
#define NULL
The null pointer.
#define CFS_READ
Specify that cfs_open() should open a file for reading.
Definition: cfs.h:90
void clock_init(void)
Initialize the clock library.
Definition: clock.c:76
int main(void)
This is main...
Definition: ethconfig.c:49
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
Definition: packetbuf.c:200
void process_init(void)
Initialize the process module.
Definition: process.c:208
Header file for the Rime stack
Header file for the 6lowpan implementation (RFC4944 and draft-hui-6lowpan-hc-01) ...
void random_init(unsigned short seed)
Seed the cc2430 random number generator.
Definition: random.c:41
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Definition: packetbuf.c:213
Convenience function for printing system statistics
Generic serial I/O process header filer.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Definition: watchdog.c:64
void ctimer_init(void)
Initialize the callback timer library.
Definition: ctimer.c:91
CCIF unsigned long clock_seconds(void)
Get the current value of the platform seconds.
Definition: clock.c:57
void packetbuf_clear(void)
Clear and reset the packetbuf.
Definition: packetbuf.c:77
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99
int cfs_coffee_format(void)
Format the storage area assigned to Coffee.
Definition: cfs-coffee.c:1346
#define RTIMER_NOW()
Get the current clock time.
Definition: rtimer.h:133
Interface structure (contains all the interface variables)
Definition: uip-ds6.h:212
int process_run(void)
Run the system once - call poll handlers and process one event.
Definition: process.c:302
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
Definition: packetbuf.h:65
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Definition: linkaddr.c:72
Representation of a real-time task.
Definition: rtimer.h:84
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Definition: packetbuf.c:207
Header for the Coffee file system.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
Definition: uip.h:969
void watchdog_init(void)
Copyright (c) 2014, Analog Devices, Inc.
Definition: watchdog.c:42
MAC driver header file
void cfs_close(int fd)
Close an open file.
Definition: cfs-coffee.c:1032
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:70
CFS header file.