Example #1
0
int
main()
{
  disableIRQ();
  disableFIQ();
  *AT91C_AIC_IDCR = 0xffffffff;
  *AT91C_PMC_PCDR = 0xffffffff;
  *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);
  
  dbg_setup_uart();
  printf("Initialising\n");
  dbg_set_input_handler(recv_input);
  leds_arch_init();
  clock_init();
  
  process_init();
  printf("Started\n");
  
  procinit_init();
  enableIRQ(); 
  printf("Processes running\n");
  while(1) {
    do {
      /* Reset watchdog. */
     } while(process_run() > 0);
    /* Idle! */
    /* Stop processor clock */
    *AT91C_PMC_SCDR |= AT91C_PMC_PCK;
  }
  return 0;
}
Example #2
0
/*---------------------------------------------------------------------------*/
int
main(void)
{
  u16_t addr[2];

  process_init();

  procinit_init();
  
  //autostart_start(autostart_processes);
  
  //uip_ipaddr(addr, 192,168,2,2);
  //uip_sethostaddr(addr);

  //uip_ipaddr(addr, 192,168,2,1);
  //uip_setdraddr(addr);

  //uip_ipaddr(addr, 255,255,255,0);
  //uip_setnetmask(addr);

  while(1) {
    int n;
    n = process_run();
    /*    if(n > 0) {
      printf("%d processes in queue\n");
      }*/
    usleep(1);
    etimer_request_poll();
  }
  
  return 0;
}
Example #3
0
/*---------------------------------------------------------------------------*/
static void
start_process_run_loop(void *data)
{
    /* Yield once during bootup */
    simProcessRunValue = 1;
    cooja_mt_yield();

    /* Initialize random generator */
    random_init(0);

    /* Start process handler */
    process_init();

    /* Start Contiki processes */
    procinit_init();

    /* Print startup information */
    printf(CONTIKI_VERSION_STRING " started. ");
    if(node_id > 0) {
      printf("Node id is set to %u.\n", node_id);
    } else {
      printf("Node id is not set.\n");
    }

    /* Initialize communication stack */
    init_net();

    /* Start serial process */
    serial_line_init();

    /* Start autostart processes (defined in Contiki application) */
    print_processes(autostart_processes);
    autostart_start(autostart_processes);

    while(1)
	{
		/* Always pretend we have processes left while inside process_run() */
		simProcessRunValue = 1;

		if (simDoReceiverCallback) {
		  simDoReceiverCallback = 0;
		  radio_call_receiver();
		}

		simProcessRunValue = process_run();
		while (simProcessRunValue-- > 0) {
		  process_run();
		}
		simProcessRunValue = process_nevents();

		// Check if we must stay awake
		if (simDontFallAsleep) {
			simDontFallAsleep=0;
			simProcessRunValue = 1;
		}

		/* Yield thread when one process_run has completed */
		cooja_mt_yield();
	}
}
Example #4
0
int
main(void)
{
  cpu_init();
  /* Initialize UART connected to Galileo Gen2 FTDI header */
  quarkX1000_uart_init(QUARK_X1000_UART_1);
  clock_init();
  rtimer_init();

  printf("Starting Contiki\n");

  ENABLE_IRQ();

  process_init();
  procinit_init();
  ctimer_init();
  autostart_start(autostart_processes);

  eth_init();

  while(1) {
    process_run();
  }

  return 0;
}
Example #5
0
void AppColdStart(void)
{
  /* default startup */
  init_hardware();

  buzzer_init();
  rgb_leds_init();
  sseg_init();

  process_init();
  init_net();

  /* start the main processes */
  procinit_init();
  autostart_start(autostart_processes);
  jts_init();

  /* enable watchdog on JN5148, there is none on JN5139 */
  watchdog_start();

  /* default main loop */
  while(1)
  {
    process_run();
    etimer_request_poll();
    watchdog_periodic();
  }
}
Example #6
0
void
AppColdStart(void)
{
  /* default startup */
  init_hardware();
  process_init();
  procinit_init();
  init_net();
  jts_init();

  /* application startup */
  autostart_start(autostart_processes);

  /* enable watchdog on JN5148, there is none on JN5139 */
#ifdef __BA2__
  watchdog_start();
#endif

  /* default main loop */
  while(1)
  {
    process_run();
    etimer_request_poll();

#ifdef __BA2__
    watchdog_periodic();
#endif
  }
}
Example #7
0
/*---------------------------------------------------------------------------*/
int
main(void)
{
  printf("Starting Contiki\n");
  process_init();
  ctimer_init();

  netstack_init();
  
  procinit_init();

  serial_line_init();
  
  autostart_start(autostart_processes);

  
  /* Make standard output unbuffered. */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);
  
  while(1) {
    fd_set fds;
    int n;
    struct timeval tv;
    
    clock_time_t next_event;
	
    n = process_run();
    next_event = etimer_next_expiration_time()-clock_time();

#if DEBUG_SLEEP
    if(n > 0) {
      printf("%d events pending\n",n);
    } else {
      printf("next event: T-%.03f\n",(double)next_event/(double)CLOCK_SECOND);
    }
#endif

	if(next_event>CLOCK_SECOND*2)
		next_event = CLOCK_SECOND*2;
    tv.tv_sec = n?0:next_event/CLOCK_SECOND;
    tv.tv_usec = n?0:next_event%1000*1000;

    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds);
    select(1, &fds, NULL, NULL, &tv);

    if(FD_ISSET(STDIN_FILENO, &fds)) {
      char c;
      if(read(STDIN_FILENO, &c, 1) > 0) {
	serial_line_input_byte(c);
      }
    }
    
    etimer_request_poll();
  }
  
  return 0;
}
Example #8
0
/*---------------------------------------------------------------------------*/
int main(void)
{

  /*
   * Initialise hardware.
   */
  //halInit();
    clock_init();

  //uart1_init(115200);

    // Led initialisation
    leds_init();
    leds_on(LEDS_RED);

    /* configure ethernet (GPIOs, clocks, MAC, DMA) */
    ETH_BSP_Config();



  //INTERRUPTS_ON();

    /*
     * Initialize Contiki and our processes.
     */

    process_init();
/*
#if WITH_SERIAL_LINE_INPUT
  uart1_set_input(serial_line_input_byte);
  serial_line_init();
#endif*/
  /* rtimer and ctimer should be initialized before radio duty cycling layers*/
    rtimer_init();
  /* etimer_process should be initialized before ctimer */
    process_start(&etimer_process, NULL);
    ctimer_init();

    netstack_init();

    procinit_init();

    autostart_start(autostart_processes);

    while (1)
    {
        int r;

        do
        {
            leds_toggle(LEDS_YELLOW);
            r = process_run();
        } while (r > 0);
    }
}
Example #9
0
void
main(int argc, char **argv)
{
  contiki_argc = argc;
  contiki_argv = argv;

#else /* WITH_ARGS */

void
main(void)
{

#endif /* WITH_ARGS */

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xDE08, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME);

    ethernet_config = &config;
  }
#endif

  procinit_init();

  process_start((struct process *)&ethernet_process, (void *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");

  while(1) {

    process_run();

    etimer_request_poll();
  }
}
Example #10
0
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

#if WITH_REBOOT
  rebootafterexit();
#endif /* WITH_REBOOT */

  videomode(VIDEOMODE_80COL);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xC0B0, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");
  
  while(1) {

    process_run();

    etimer_request_poll();

    clock_update();
  }
}
void
initialize(void)
{
  watchdog_init();
  watchdog_start();
  
#if STACKMONITOR
  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
   * loop. In conjuction with TESTRTIMER, never-used stack will be printed
   * every STACKMONITOR seconds.
   */
{
extern uint16_t __bss_end;
uint16_t p=(uint16_t)&__bss_end;
    do {
      *(uint16_t *)p = 0x4242;
      p+=4;
    } while (p<SP-4); //don't overwrite our own stack
}
#endif

  /* rtimers needed for radio cycling */
  rtimer_init();

  rs232_init(RS232_PORT_0, BAUD_RATE(38400), USART_DATA_BITS_8 | USART_PARITY_NONE | USART_STOP_BITS_1);
  rs232_redirect_stdout(RS232_PORT_0);

  clock_init();
  sei();

  /* Initialize drivers and event kernel */
  process_init();
 
  led_init();

#if 0
  procinit_init();
#else
  process_start(&etimer_process, NULL);
  process_start(&led_process, NULL);
  process_start(&led2_process, NULL);
#endif

  PRINTA(CONTIKI_VERSION_STRING " started\r\n");

  /* Comment this out if autostart_processes not defined at link */
  /* Note AUTOSTART_PROCESSES(...) is only effective in the .co module */
  autostart_start(autostart_processes);
  
}
Example #12
0
int contiki_main(void)
{
	struct timeval tv;

	process_init();
	procinit_init();

#if (TEST_SIM == 0)
	autostart_start((struct process **)autostart_processes);
#endif

	printf("Contiki initiated, now starting process scheduling\n");

	freakz_init();

	while(1)
	{
		process_run();
		tv.tv_sec = 0;
		tv.tv_usec = 1;
		/*
		 * int select(int n,
		 *	      fd_set *readfds,
		 *	      fd_set *writefds,
		 *	      fd_set *exceptfds,
		 *	      struct timeval *timeout);
		 *
		 * select() wait the change of the file.
		 * n: the max file describe + 1
		 * readfds, writefds and exceptfds is the set of the file,
		 *
		 * struct timeval *timeout是select的超时时间, 这个参数至关重要,
		 * 它可以使select处于三种状态:
		 * 第一. 若将NULL以形参传入, 即不传入时间结构, 就是将select置于阻塞状态,
		 * 一定等到监视文件描述符集合中某个文件描述符发生变化为止;
		 *
		 * 第二. 若将时间值设为0秒0毫秒, 就变成一个纯粹的非阻塞函数,
		 * 不管文件描述符是否有变化, 都立刻返回继续执行, 文件无变化返回0,
		 * 有变化返回一个正值;
		 *
		 * 第三. timeout的值大于0, 这就是等待的超时时间, 即select在timeout时间内阻塞,
		 * 超时时间之内有事件到来就返回了, 否则在超时后不管怎样一定返回, 返回值同上述
		 */
		select(0, NULL, NULL, NULL, &tv);
		etimer_request_poll();
	}

	return 0;
}
Example #13
0
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

  clrscr();
  bordercolor(BORDERCOLOR);
  bgcolor(SCREENCOLOR);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xD500, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");

  while(1) {

    process_run();

    etimer_request_poll();
  }
}
int
main(void)
{
  /*
   * GCC depends on register r1 set to 0.
   */
  asm volatile ("clr r1");

  /* Initialize hardware */
  init_lowlevel();

  /* Clock */
  clock_init();

  /* Process subsystem */
  process_init();

  /* Register initial processes */
  procinit_init();

  /* Perform rest of initializations */
  process_start(&contiki_stk501_main_init_process, NULL);

  rs232_print_p (RS232_PORT_1, PSTR ("Initialized.\n"));

#ifdef MT_DEMO
  mt_start (&threads[0], thread_handler1, &d1);
  mt_start (&threads[1], thread_handler2, &d2);
  mt_start (&threads[2], thread_handler2, &d3);

  uint8_t i;
#endif

  /* Main scheduler loop */
  while(1) {

    process_run();

#ifdef MT_DEMO
    for (i=0; i<3; ++i) {
      mt_exec (&threads[i]);
    }
#endif
  }

  return 0;
}
/*---------------------------------------------------------------------------*/
int
main(void)
{
  printf("Starting Contiki\n");
  process_init();
  ctimer_init();

  netstack_init();
  
  procinit_init();

  serial_line_init();
  
  //autostart_start(autostart_processes);

  
  /* Make standard output unbuffered. */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);
  
  while(1) {
    fd_set fds;
    int n;
    struct timeval tv;
    
    n = process_run();

    
    tv.tv_sec = 0;
    tv.tv_usec = 1;

    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds);
    select(1, &fds, NULL, NULL, &tv);

    if(FD_ISSET(STDIN_FILENO, &fds)) {
      char c;
      if(read(STDIN_FILENO, &c, 1) > 0) {
	serial_line_input_byte(c);
      }
    }
    
    etimer_request_poll();
  }
  
  return 0;
}
int
main(void)
{
  //calibrate_rc_osc_32k(); //CO: Had to comment this out

  /* Init LEDs */
  leds_init();

  /* Initialize hardware */
  init_lowlevel();

  /* Clock */
  clock_init();

  /* Process subsystem */
  process_init();

  /* Register initial processes */
  procinit_init();


  //Give ourselves a prefix
  //init_net();

  /* This line wasn't present in ProMini code */
  /* Make pin 5 on port B an input (PB5 SCK/PCINT5) */
  PORTB &= ~(1<<5);
  serial_line_init();

  /* Autostart processes */
  autostart_start(autostart_processes);

  printf_P(PSTR("\r\n********BOOTING CONTIKI*********\r\n"));

  printf_P(PSTR("System online.\r\n"));

  /* Main scheduler loop */
  do {

    process_run();

  } while (1);

  return 0;
}
Example #17
0
/* Jennic equivalent of main() */
void AppColdStart(void)
{
  /* default startup */
  init_hardware();
  process_init();
  init_net();

  procinit_init();
  autostart_start(autostart_processes);
  jts_init();

  /* default main loop */
  while(1)
  {
    process_run();
    etimer_request_poll();
  }
}
Example #18
0
/*---------------------------------------------------------------------------*/
void
app_main(void)
{
  printf("Starting Contiki\n");

  process_init();
  procinit_init();
  ctimer_init();
  eth_init();

  autostart_start(autostart_processes);

  while(1) {
    process_run();
  }

  halt();
}
Example #19
0
/*-----------------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
  uip_ipaddr_t addr;

  gtk_init(&argc, &argv);
  
  process_init();

  procinit_init();
  
  uip_ipaddr(&addr, 192,168,2,2);
  uip_sethostaddr(&addr);

  uip_ipaddr(&addr, 192,168,2,1);
  uip_setdraddr(&addr);

  uip_ipaddr(&addr, 255,255,255,0);
  uip_setnetmask(&addr);

  /*  program_handler_add(&netconf_dsc, "Network setup", 1);
  program_handler_add(&ftp_dsc, "FTP client", 1);
  program_handler_add(&editor_dsc, "Editor", 1);
  program_handler_add(&www_dsc, "Web browser", 1);
  program_handler_add(&processes_dsc, "Processes", 1);
  program_handler_add(&shell_dsc, "Command shell", 1);
  program_handler_add(&calc_dsc, "Calculator", 1);*/
  /*  program_handler_add(&email_dsc, "E-mail", 1);*/

  /*  program_handler_add(&irc_dsc, "IRC", 1);*/
  /*  program_handler_add(&vnc_dsc, "VNC client", 1);*/

  /*  program_handler_add(&dhcp_dsc, "DHCP client", 1);*/

  uip_fw_default(&tapif);
  
  gtk_timeout_add(20, idle_callback, NULL);
  gtk_main();

  return 0;

  argv = argv;
  argc = argc;
}
Example #20
0
int main_minimal_net(void) {

	// TODO: Pegar MAC Address do Microchip MRF24J40MA
	clock_init();

	linkaddr_set_node_addr((linkaddr_t*) &addr);
	memcpy(&uip_lladdr.addr, &linkaddr_node_addr.u8, sizeof(uip_lladdr.addr));

#if 1	
	queuebuf_init();
	netstack_init();
#endif  	

	process_init();
	/* procinit_init initializes RPL which sets a ctimer for the first DIS */
	/* We must start etimers and ctimers,before calling it */
	process_start(&etimer_process, NULL);
	ctimer_init();

	procinit_init();

#if AUTOSTART_ENABLE
	autostart_start(autostart_processes);
#endif
	OSSemBinaryCreate(0, &Contiki_Sem);

	PRINTF("\n*******%s online*******\n\r", CONTIKI_VERSION_STRING);

	while (1) {

		int n;
		//char c;
		//INT8U ret,poll;
		//clock_time_t next_event;

		do {
			n = process_run();
			//mrf24j40_get_rssi();
		} while (n > 0);

		OSSemPend(Contiki_Sem, 0);
	}
}
Example #21
0
int another_net(void) {

	clock_init();



	random_init(MOTE_ID);
	init_net(MOTE_ID);


	process_init();

	start_radio_task();

	process_start(&etimer_process, NULL);

	ctimer_init();
	rtimer_init();

	procinit_init();

	autostart_start(autostart_processes);
	start_udp_server_task();

	PRINTF("Processes running\n");

	OSSemBinaryCreate(0, &Contiki_Sem);

	PRINTF("\n*******%s online*******\n\r", CONTIKI_VERSION_STRING);

	while (1) {

		int n;

		do {
			n = process_run();
		} while (n > 0);

		OSSemPend(Contiki_Sem, 0);
	}
}
int
main(void)
{
  /*
   * GCC depends on register r1 set to 0.
   */
  asm volatile ("clr r1");

  /* Initialize hardware */
  init_lowlevel();

  /* Clock */
  clock_init();

  printf_P(PSTR("\n\n\n********BOOTING CONTIKI*********\n"));

  /* Process subsystem */
  process_init();

  /* Register initial processes */
  procinit_init();

  /* Setup USB */
  process_start(&usb_process, NULL);
  process_start(&cdc_process, NULL);
  process_start(&rndis_process, NULL);
  process_start(&storage_process, NULL);

  printf_P(PSTR("System online.\n"));

  //Fix MAC address
  init_net();

   /* Main scheduler loop */
  while(1) {
    process_run();
  }

  return 0;
}
Example #23
0
int
main(void)
{
  //calibrate_rc_osc_32k(); //CO: Had to comment this out

  /* Initialize hardware */
  init_lowlevel();

  /* Clock */
  clock_init();

  /* Process subsystem */
  process_init();

  /* Register initial processes */
  procinit_init();

  // init the freakz stack
  freakz_init();

  // init the test code
#if (TEST_RAVEN == 1)
  test_raven_init();
#else
#if (TEST_ZCL == 1)
  test_zcl_init();
#endif
#endif

  /* Main scheduler loop */
  while(1) {
    process_run();
  }

  return 0;
}
/*---------------------------------------------------------------------------*/
int
main(void)
{

  process_init();

  procinit_init();

  ctimer_init();

  autostart_start(autostart_processes);
    
#if !UIP_CONF_IPV6
  uip_ipaddr_t addr;
  uip_ipaddr(&addr, 192,168,1,2);
  printf("IP Address:  %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
  uip_sethostaddr(&addr);

  uip_ipaddr(&addr, 255,255,255,0);
  printf("Subnet Mask: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
  uip_setnetmask(&addr);

  uip_ipaddr(&addr, 192,168,1,1);
  printf("Def. Router: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
  uip_setdraddr(&addr);
#else
  {
    uip_ipaddr_t ipaddr;
    
    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
    uip_netif_addr_autoconf_set(&ipaddr, &uip_lladdr);
    uip_netif_addr_add(&ipaddr, 16, 0, TENTATIVE);
  }
#endif

  /* Make standard output unbuffered. */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);

  while(1) {
    fd_set fds;
    int n;
    struct timeval tv;
    
    n = process_run();
    /*    if(n > 0) {
      printf("%d processes in queue\n");
      }*/

    tv.tv_sec = 0;
    tv.tv_usec = 1;
    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds);
    select(1, &fds, NULL, NULL, &tv);

    if(FD_ISSET(STDIN_FILENO, &fds)) {
      char c;
      if(read(STDIN_FILENO, &c, 1) > 0) {
	serial_line_input_byte(c);
      }
    }
    etimer_request_poll();
  }
  
  return 0;
}
Example #25
0
/*---------------------------------------------------------------------------*/
int
main(void)
{
  
  /*
   * Initalize hardware.
   */
  halInit();
  clock_init();
  
  uart1_init(115200);
  
  /* Led initialization */
  leds_init();
    
  INTERRUPTS_ON(); 

  PRINTF("\r\nStarting ");
  PRINTF(CONTIKI_VERSION_STRING);
  PRINTF(" on %s\r\n", boardDescription->name); 
  boardPrintStringDescription();
  PRINTF("\r\n"); 


  /*
   * Initialize Contiki and our processes.
   */
  
  process_init();
  
#if WITH_SERIAL_LINE_INPUT
  uart1_set_input(serial_line_input_byte);
  serial_line_init();
#endif
  /* rtimer and ctimer should be initialized before radio duty cycling
     layers */
  rtimer_init();
  /* etimer_process should be initialized before ctimer */
  process_start(&etimer_process, NULL);  
  ctimer_init();

  netstack_init();

  set_rime_addr();

  printf("%s %s, channel check rate %lu Hz\n",
         NETSTACK_MAC.name, NETSTACK_RDC.name,
         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
                                  NETSTACK_RDC.channel_check_interval()));
  printf("802.15.4 PAN ID 0x%x, EUI-%d:",
      IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);
  uip_debug_lladdr_print(&linkaddr_node_addr);
  printf(", radio channel %u\n", RF_CHANNEL);

  procinit_init();

  energest_init();
  ENERGEST_ON(ENERGEST_TYPE_CPU);

  /* Set the Clear Channel Assessment (CCA) threshold of the
     radio. The CCA threshold is used both for sending packets and for
     waking up ContikiMAC nodes. If the CCA threshold is too high,
     ContikiMAC will not wake up from neighbor transmissions. If the
     CCA threshold is too low, transmissions will be too restrictive
     and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is
     defined in this file. */
  ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);
  
  autostart_start(autostart_processes);
#if UIP_CONF_IPV6
  printf("Tentative link-local IPv6 address ");
  {
    uip_ds6_addr_t *lladdr;
    int i;
    lladdr = uip_ds6_get_link_local(-1);
    for(i = 0; i < 7; ++i) {
      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
             lladdr->ipaddr.u8[i * 2 + 1]);
    }
    printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
  }


  if(!UIP_CONF_IPV6_RPL) {
    uip_ipaddr_t ipaddr;
    int i;
    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
    printf("Tentative global IPv6 address ");
    for(i = 0; i < 7; ++i) {
      printf("%02x%02x:",
             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
    }
    printf("%02x%02x\n",
           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
  }
#endif /* UIP_CONF_IPV6 */
  
  watchdog_start();
  
  while(1) {
    
    int r;    
    
    do {
      /* Reset watchdog. */
      watchdog_periodic();
      r = process_run();
    } while(r > 0);
    
    
    
    ENERGEST_OFF(ENERGEST_TYPE_CPU);
    /* watchdog_stop(); */
    ENERGEST_ON(ENERGEST_TYPE_LPM);
    /* Go to idle mode. */
    halSleepWithOptions(SLEEPMODE_IDLE,0);
    /* We are awake. */
    /* watchdog_start(); */
    ENERGEST_OFF(ENERGEST_TYPE_LPM);
    ENERGEST_ON(ENERGEST_TYPE_CPU);  
    
  }
  
}
Example #26
0
/*-----------------------------------------------------------------------------------*/
int
main(void)
{
    process_init();

    procinit_init();

#ifdef PLATFORM_BUILD
    program_handler_add(&directory_dsc, "Directory",   1);
    program_handler_add(&www_dsc,       "Web browser", 1);
#endif /* PLATFORM_BUILD */

    autostart_start(autostart_processes);

#if !UIP_CONF_IPV6
    {
        uip_ipaddr_t addr;
        uip_ipaddr(&addr, 192,168,0,111);
        uip_sethostaddr(&addr);
        log_message("IP Address:  ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 255,255,255,0);
        uip_setnetmask(&addr);
        log_message("Subnet Mask: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        uip_setdraddr(&addr);
        log_message("Def. Router: ", inet_ntoa(*(struct in_addr*)&addr));

        uip_ipaddr(&addr, 192,168,0,1);
        resolv_conf(&addr);
        log_message("DNS Server:  ", inet_ntoa(*(struct in_addr*)&addr));
    }

#else /* UIP_CONF_IPV6 */

#if !UIP_CONF_IPV6_RPL
#ifdef HARD_CODED_ADDRESS
    uip_ipaddr_t ipaddr;
    uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
    if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
#if UIP_CONF_ROUTER
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
#else /* UIP_CONF_ROUTER */
        uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
#endif /* UIP_CONF_ROUTER */
#if !UIP_CONF_IPV6_RPL
        uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
        uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif
    }
#endif /* HARD_CODED_ADDRESS */
#endif
#endif

    while(1) {

        process_run();

        etimer_request_poll();

        /* Allow user-mode APC to execute. */
        SleepEx(10, TRUE);

#ifdef PLATFORM_BUILD
        if(console_resize()) {
            ctk_restore();
        }
#endif /* PLATFORM_BUILD */
    }
}
Example #27
0
/*------Done in a subroutine to keep main routine stack usage small--------*/
void initialize(void)
{
  //calibrate_rc_osc_32k(); //CO: Had to comment this out

#ifdef RAVEN_LCD_INTERFACE
  /* First rs232 port for Raven 3290 port */
  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
  /* Set input handler for 3290 port */
  rs232_set_input(0,raven_lcd_serial_input);
#endif

  /* Second rs232 port for debugging */
  rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
  /* Redirect stdout to second port */
  rs232_redirect_stdout(RS232_PORT_1);
  clock_init();
  printf_P(PSTR("\n*******Booting %s*******\n"),CONTIKI_VERSION_STRING);

 /* Initialize process subsystem */
  process_init();

#ifdef RF230BB
{
  /* Start radio and radio receive process */
  rf230_init();
  sicslowpan_init(sicslowmac_init(&rf230_driver));
//  ctimer_init();
//  sicslowpan_init(lpp_init(&rf230_driver));
//  rime_init(sicslowmac_driver.init(&rf230_driver));
//  rime_init(lpp_init(&rf230_driver));

  /* Set addresses BEFORE starting tcpip process */

  rimeaddr_t addr;
  memset(&addr, 0, sizeof(rimeaddr_t));
  AVR_ENTER_CRITICAL_REGION();
  eeprom_read_block ((void *)&addr.u8,  &mac_address, 8);
  AVR_LEAVE_CRITICAL_REGION();
 
  memcpy(&uip_lladdr.addr, &addr.u8, 8);	
  rf230_set_pan_addr(IEEE802154_PANID, 0, (uint8_t *)&addr.u8);

  rf230_set_channel(24);
  rimeaddr_set_node_addr(&addr); 
  PRINTF("MAC address %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]);

 // uip_ip6addr(&ipprefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
 // uip_netif_addr_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0, AUTOCONF);
 // uip_nd6_prefix_add(&ipprefix, UIP_DEFAULT_PREFIX_LEN, 0);
 // PRINTF("Prefix %x::/%u\n",ipprefix.u16[0],UIP_DEFAULT_PREFIX_LEN);

#if UIP_CONF_ROUTER
  rime_init(rime_udp_init(NULL));
  uip_router_register(&rimeroute);
#endif

  PRINTF("Driver: %s, Channel: %u\n", sicslowmac_driver.name, rf230_get_channel()); 
}
#endif /*RF230BB*/

  /* Register initial processes */
  procinit_init(); 

  /* Autostart processes */
  autostart_start(autostart_processes);

  //Give ourselves a prefix
  // init_net();

  /*---If using coffee file system create initial web content if necessary---*/
#if COFFEE_FILES
  int fa = cfs_open( "/index.html", CFS_READ);
  if (fa<0) {     //Make some default web content
    printf_P(PSTR("No index.html file found, creating upload.html!\n"));
    printf_P(PSTR("Formatting FLASH file system for coffee..."));
    cfs_coffee_format();
    printf_P(PSTR("Done!\n"));
    fa = cfs_open( "/index.html", CFS_WRITE);
    int r = cfs_write(fa, &"It works!", 9);
    if (r<0) printf_P(PSTR("Can''t create /index.html!\n"));
    cfs_close(fa);
//  fa = cfs_open("upload.html"), CFW_WRITE);
// <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>
  }
#endif

/*--------------------------Announce the configuration---------------------*/
#if WEBSERVER
  char buf[80];
  unsigned int size;
   eeprom_read_block (buf,server_name, sizeof(server_name));
   buf[sizeof(server_name)]=0;
   printf_P(PSTR("%s"),buf);
   eeprom_read_block (buf,domain_name, sizeof(domain_name));
   buf[sizeof(domain_name)]=0;
   size=httpd_fs_get_size();
#ifndef COFFEE_FILES
   printf_P(PSTR(".%s online with fixed %u byte web content\n"),buf,size);
#elif COFFEE_FILES==1
   printf_P(PSTR(".%s online with static %u byte EEPROM file system\n"),buf,size);
#elif COFFEE_FILES==2
   printf_P(PSTR(".%s online with dynamic %u KB EEPROM file system\n"),buf,size>>10);
#elif COFFEE_FILES==3
   printf_P(PSTR(".%s online with static %u byte program memory file system\n"),buf,size);
#elif COFFEE_FILES==4
   printf_P(PSTR(".%s online with dynamic %u KB program memory file system\n"),buf,size>>10);
#endif
#else
   printf_P(PSTR("Online\n"));
#endif /* WEBSERVER */
}
Example #28
0
void
main(int argc, char **argv)
{
  contiki_argc = argc;
  contiki_argv = argv;

#else /* WITH_ARGS */

void
main(void)
{

#endif /* WITH_ARGS */

  videomode(VIDEOMODE_80COL);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xDE08, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

#if (WITH_GUI && WITH_MOUSE)
  {
    static const uint8_t mouse_sprite[64] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x0F, 0xE0, 0x00, 0x0F, 0xC0, 0x00, 0x0F,
      0x80, 0x00, 0x0F, 0xC0, 0x00, 0x0D, 0xE0, 0x00,
      0x08, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3C,
      0x00, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00,
      0x07, 0x80, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    memcpy((void*)0x0E00, mouse_sprite, sizeof(mouse_sprite));
    *(uint8_t*)0x07F8 = 0x0E00 / 64;
    VIC.spr0_color = COLOR_WHITE;
  }
#endif /* WITH_GUI && WITH_MOUSE */

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");

  while(1) {

    process_run();

    etimer_request_poll();
  }
}
Example #29
0
/*---------------------------------------------------------------------------*/
int
main(void)
{
#if UIP_CONF_IPV6
/* A hard coded address overrides the stack default MAC address to allow multiple instances.
 * uip6.c defines it as {0x00,0x06,0x98,0x00,0x02,0x32} giving an ipv6 address of [fe80::206:98ff:fe00:232]
 * We make it simpler,  {0x02,0x00,0x00 + the last three bytes of the hard coded address (if any are nonzero).
 * HARD_CODED_ADDRESS can be defined in the contiki-conf.h file, or here to allow quick builds using different addresses.
 * If HARD_CODED_ADDRESS has a prefix it also applied, unless built as a RPL end node.
 * E.g. bbbb::12:3456 becomes fe80::ff:fe12:3456 and prefix bbbb::/64 if non-RPL
 *      ::10 becomes fe80::ff:fe00:10 and prefix awaits RA or RPL formation
 *      bbbb:: gives an address of bbbb::206:98ff:fe00:232 if non-RPL
*/
//#define HARD_CODED_ADDRESS      "bbbb::20"
#ifdef HARD_CODED_ADDRESS
{
  uip_ipaddr_t ipaddr;
  uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
  if ((ipaddr.u8[13]!=0) || (ipaddr.u8[14]!=0) || (ipaddr.u8[15]!=0)) {
    if (sizeof(uip_lladdr)==6) {  //Minimal-net uses ethernet MAC
      uip_lladdr.addr[0]=0x02;uip_lladdr.addr[1]=0;uip_lladdr.addr[2]=0;
	  uip_lladdr.addr[3]=ipaddr.u8[13];;
	  uip_lladdr.addr[4]=ipaddr.u8[14];
	  uip_lladdr.addr[5]=ipaddr.u8[15];
   }
 }
}
#endif
#endif

  process_init();
/* procinit_init initializes RPL which sets a ctimer for the first DIS */
/* We must start etimers and ctimers,before calling it */
  process_start(&etimer_process, NULL);
  ctimer_init();

  procinit_init();
  autostart_start(autostart_processes);

#if RPL_BORDER_ROUTER
  process_start(&border_router_process, NULL);
  printf("Border Router Process started\n");
#elif UIP_CONF_IPV6_RPL
  printf("RPL enabled\n");
#endif

  /* Set default IP addresses if not specified */
#if !UIP_CONF_IPV6
  uip_ipaddr_t addr;
  
  uip_gethostaddr(&addr);
  if (addr.u8[0]==0) {
    uip_ipaddr(&addr, 10,1,1,1);
  }
  printf("IP Address:  %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
  uip_sethostaddr(&addr);

  uip_getnetmask(&addr);
  if (addr.u8[0]==0) {
    uip_ipaddr(&addr, 255,0,0,0);
    uip_setnetmask(&addr);
  }
  printf("Subnet Mask: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));

  uip_getdraddr(&addr);
  if (addr.u8[0]==0) {
    uip_ipaddr(&addr, 10,1,1,100);
    uip_setdraddr(&addr);
  }
  printf("Def. Router: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));

#else /* UIP_CONF_IPV6 */

#if !UIP_CONF_IPV6_RPL
#ifdef HARD_CODED_ADDRESS
  uip_ipaddr_t ipaddr;
  uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
  if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
#if UIP_CONF_ROUTER
    uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
#else /* UIP_CONF_ROUTER */
    uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
#endif /* UIP_CONF_ROUTER */
#if !UIP_CONF_IPV6_RPL
    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
    uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif
  }
#endif /* HARD_CODED_ADDRESS */
#endif

#if !RPL_BORDER_ROUTER  //Border router process prints addresses later
{ uint8_t i;
  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
	if (uip_ds6_if.addr_list[i].isused) {	  
	  printf("IPV6 Addresss: ");sprint_ip6(uip_ds6_if.addr_list[i].ipaddr);printf("\n");
	}
  }
}
#endif
#endif /* !UIP_CONF_IPV6 */

  /* Make standard output unbuffered. */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);

  while(1) {
    fd_set fds;
    int n;
    struct timeval tv;
    
    n = process_run();
    /*    if(n > 0) {
      printf("%d processes in queue\n");
      }*/

    tv.tv_sec = 0;
    tv.tv_usec = 1;
    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds);
    select(1, &fds, NULL, NULL, &tv);

    if(FD_ISSET(STDIN_FILENO, &fds)) {
      char c;
      if(read(STDIN_FILENO, &c, 1) > 0) {
	serial_line_input_byte(c);
      }
    }
    etimer_request_poll();
  }
  
  return 0;
}
Example #30
0
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

  close(STDIN_FILENO);
  close(STDOUT_FILENO);
#if !UIP_LOGGING && !LOG_CONF_ENABLED
  close(STDERR_FILENO);
#endif /* !UIP_LOGGING && !LOG_CONF_ENABLED */

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xDE08, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

#if (WITH_GUI && WITH_MOUSE)
  {
    static const u8_t mouse_sprite[64] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x0F, 0xE0, 0x00, 0x0F, 0xC0, 0x00, 0x0F,
      0x80, 0x00, 0x0F, 0xC0, 0x00, 0x0D, 0xE0, 0x00,
      0x08, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3C,
      0x00, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00,
      0x07, 0x80, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    memcpy((void*)0x0E00, mouse_sprite, sizeof(mouse_sprite));
    *(u8_t*)0x07F8 = 0x0E00 / 64;
    VIC.spr0_color = COLOR_WHITE;
  }
#endif /* WITH_GUI && WITH_MOUSE */

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");
  
  while(1) {

    if(process_run() < 2) {

      etimer_request_poll();
    }
  }
}