1 #include <AT91SAM7S64.h>
2 #include <interrupt-utils.h>
4 #include <debug-uart.h>
8 #include <dev/cc2420_const.h>
12 #include <sys/procinit.h>
21 #include "contiki-main.h"
31 #include "net/uip-fw-drv.h"
36 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
38 #define UIP_OVER_MESH_CHANNEL 9
40 uint8_t is_gateway = 0;
41 struct trickle_conn gateway_trickle;
45 extern char __heap_end__;
46 extern char __heap_start__;
57 trickle_recv(
struct trickle_conn *c)
60 struct gateway_msg *msg;
61 msg = rimebuf_dataptr();
62 printf(
"%d.%d: gateway message: %d.%d\n",
64 msg->gateway.u8[0], msg->gateway.u8[1]);
66 uip_over_mesh_set_gateway(&msg->gateway);
70 const static struct trickle_callbacks trickle_call = {trickle_recv};
87 *AT91C_WDTC_WDCR = (0xa5<<24) | AT91C_WDTC_WDRSTT;
100 *AT91C_AIC_IDCR = 0xffffffff;
101 *AT91C_PMC_PCDR = 0xffffffff;
102 *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);
105 printf(
"Initialising\n");
115 printf(
"Beginning CC2420 setup\n");
117 cc2420_set_pan_addr(0x2024, 0,
NULL);
118 cc2420_set_channel(RF_CHANNEL);
120 printf(
"CC2420 setup done\n");
123 printf(
"Rime started with address %d.%d\n", node_addr.u8[0], node_addr.u8[1]);
135 printf(
"Host addr\n");
138 uip_over_mesh_set_net(&hostaddr, &netmask);
143 printf(
"Mesh init\n");
144 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
145 printf(
"uIP started with IP address %d.%d.%d.%d\n",
156 trickle_open(&gateway_trickle,
CLOCK_SECOND * 4, GATEWAY_TRICKLE_CHANNEL,
160 printf(
"Heap size: %ld bytes\n", &__heap_end__ - (
char*)sbrk(0));
165 autostart_start(autostart_processes);
166 printf(
"Processes running\n");
174 *AT91C_PMC_SCDR |= AT91C_PMC_PCK;