コード例 #1
0
/**
 * \brief Main function of the Performance Analyzer application
 * \ingroup group_app_init
 */
int main(void)
{
        irq_initialize_vectors();

	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	board_init();
	sysclk_init();
        
    /*
     * Power ON - so set the board to INIT state. All hardware, PAL, TAL and
     * stack level initialization must be done using this function
     */
    set_main_state(INIT, NULL);

    cpu_irq_enable();
    
	sio2host_init();

    
    /* INIT was a success - so change to WAIT_FOR_EVENT state */
    set_main_state(WAIT_FOR_EVENT, NULL);

    /* Endless while loop */
    while (1)
    {
        pal_task(); /* Handle platform specific tasks, like serial interface */
        tal_task(); /* Handle transceiver specific tasks */
        app_task(); /* Application task */
        serial_data_handler();
    }
}
コード例 #2
0
/**
 * @brief Main function of the Terminal Target application
 */
int main(void)
{
    irq_initialize_vectors();
	sysclk_init();

    /* Initialize the board.
     * The board-specific conf_board.h file contains the configuration of
     * the board initialization.
     */
    board_init();

    sw_timer_init();

    if (nwk_init()!= NWK_SUCCESS) {
        app_alert();
    }

    zrc_ind.vendor_data_ind_cb = vendor_data_ind;

#ifdef ZRC_CMD_DISCOVERY
	zrc_ind.zrc_cmd_disc_indication_cb =  zrc_cmd_disc_indication;
#endif
	zrc_ind.zrc_cmd_indication_cb = zrc_cmd_indication;

	register_zrc_indication_callback(&zrc_ind);

	nwk_ind.nwk_ch_agility_indication_cb = nwk_ch_agility_indication;
	nwk_ind.nlme_unpair_indication_cb = nlme_unpair_indication;
	register_nwk_indication_callback(&nwk_ind);

	/* Initialize LEDs. */
	LED_On(LED_START);     /* indicating application is started */
	LED_Off(LED_NWK_SETUP); /* indicating network is started */
	LED_Off(LED_DATA);     /* indicating data reception */

	/*
	 * The stack is initialized above, hence the global interrupts are
	 *enabled
	 * here.
	 */
	cpu_irq_enable();

#ifdef SIO_HUB
	/* Initialize the serial interface used for communication with terminal
	 *program. */

	sio2host_init();
#endif

	sw_timer_get_id(&led_timer);

	/* Endless while loop */
	while (1) {
		app_task(); /* Application task */
		nwk_task(); /* RF4CE network layer task */
	}
}
コード例 #3
0
int main(void)
{
	
    SYS_Init();

#if APP_COORDINATOR		
    sio2host_init();
#endif	
    		
    while (1)
    {
		
        SYS_TaskHandler();
	    APP_TaskHandler();
		
    }
}
コード例 #4
0
/**
 * @brief Main function of the device application
 */
int main(void)
{
	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	irq_initialize_vectors();
	board_init();
	sysclk_init();

	sw_timer_init();

	if(MAC_SUCCESS != wpan_init())
	{
		app_alert();
	}

    /* Initialize LEDs. */
    LED_On(LED_START);         // indicating application is started
    LED_Off(LED_NWK_SETUP);    // indicating node is associated
    LED_Off(LED_DATA);         // indicating successfull data transmission

	cpu_irq_enable();

#ifdef SIO_HUB
    /* Initialize the serial interface used for communication with terminal program. */
   sio2host_init();

    /* To make sure the hyper terminal gets connected to the system */
    sio2host_getchar();

    printf("\nNobeacon_Application\r\n\n");
    printf("\nDevice\r\n\n");
#endif /* SIO_HUB */

	sw_timer_get_id(&APP_TIMER_LED_OFF);
	sw_timer_get_id(&APP_TIMER_POLL_DATA);

	wpan_mlme_reset_req(true);

	while (true)
	{
		wpan_task();
	}
}
コード例 #5
0
ファイル: ota-main.c プロジェクト: songjw0820/contiki_atmel
int
main(int argc, char *argv[])
{
  node_id_restore();
  /* init system: clocks, board etc */
  system_init();
  sio2host_init();

  leds_init();
  leds_on(LEDS_ALL);

  system_interrupt_enable_global();
  flash_init();
  delay_init();

  /* Initialize Contiki and our processes. */
  
  #ifdef LOW_POWER_MODE
  configure_tc3();
  #else
  clock_init();
  #endif

  process_init();
  ctimer_init();
  rtimer_init();
  process_start(&etimer_process, NULL);
  
  /* Set MAC address and node ID */
#ifdef NODEID
  node_id = NODEID;
#ifdef BURN_NODEID
  node_id_burn(node_id);
#endif /* BURN_NODEID */
#else/* NODE_ID */
#endif /* NODE_ID */

  printf("\r\n\n\n\n Starting the SmartConnect-6LoWPAN \r\n Platform : Atmel IoT device \r\n");
  print_reset_causes();
  netstack_init();
 #if BOARD == SAMR21_XPLAINED_PRO
  eui64 = edbg_eui_read_eui64();
  SetIEEEAddr(eui64);
#else
  SetIEEEAddr(node_mac);  
#endif 
  set_link_addr();  
  rf_set_channel(RF_CHANNEL);
  printf("\r\n Configured RF channel: %d\r\n", rf_get_channel());
  leds_off(LEDS_ALL);
  process_start(&sensors_process, NULL);
  energest_init();

  ENERGEST_ON(ENERGEST_TYPE_CPU);
  if(node_id > 0) {
    printf(" Node id %u.\r\n", node_id);
  } else {
    printf(" Node id not set.\r\n");
  }

  /* Setup nullmac-like MAC for 802.15.4 */
#if SAMD
  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
#else 
  memcpy(&uip_lladdr.addr, eui64, sizeof(uip_lladdr.addr));
#endif
   
  queuebuf_init();
  printf(" %s %lu %d\r\n",
         NETSTACK_RDC.name,
         (uint32_t) (CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
                         NETSTACK_RDC.channel_check_interval())),
         RF_CHANNEL);

  process_start(&tcpip_process, NULL);
  printf(" 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\r\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
  }

  {
    uip_ipaddr_t ipaddr;
    int i;
    uip_ip6addr(&ipaddr, 0xfc00, 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\r\n",
           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
  }

  print_processes(autostart_processes);

  /* set up AES key */
#if ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES)
#ifndef NETSTACK_AES_KEY
#error Please define NETSTACK_AES_KEY!
#endif /* NETSTACK_AES_KEY */
  {
    const uint8_t key[] = NETSTACK_AES_KEY;
    netstack_aes_set_key(key);
  }
  printf("AES encryption is enabled\n");
#else /* ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES) */
  printf("\r\n Warning: AES encryption is disabled\n");
#endif /* ((THSQ_CONF_NETSTACK) & THSQ_CONF_AES) */

#ifdef ENABLE_LEDCTRL
  ledctrl_init();
#endif
  autostart_start(autostart_processes);


  while(1){
    int r = 0;

	serial_data_handler();

  do {

     
     r = process_run();

    } while(r > 0);

  }
}
コード例 #6
0
ファイル: serial_interface.c プロジェクト: thegeek82000/asf
/**
 * @brief This function does the initialization of the SIO or UART.
 */
void serial_interface_init(void)
{
	sio_rx_state = UART_RX_STATE_SOT;
	sio2host_init();
}
コード例 #7
0
/**
 * @brief Main function of the coordinator application
 *
 * This function initializes the MAC, initiates a MLME reset request
 * (@ref wpan_mlme_reset_req()), and implements a the main loop.
 */
int main(void)
{	
	irq_initialize_vectors();
	#if SAMD20
	system_init();
	delay_init();
	#else
	sysclk_init();

	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	board_init();
	#endif
	#ifdef SIO_HUB
		sio2host_init();
	#endif
	sw_timer_init();

	if (MAC_SUCCESS != wpan_init()) {
		app_alert();
	}

	/* Initialize LEDs. */
	LED_On(LED_START);     /* indicating application is started */
	LED_Off(LED_NWK_SETUP); /* indicating network is started */
	LED_Off(LED_DATA);     /* indicating data transmission */

	cpu_irq_enable();

#ifdef SIO_HUB
	/* Initialize the serial interface used for communication with terminal
	 *program. */

	/* To make sure the Hyper Terminal Connected to the system*/
	sio2host_getchar();

#ifdef BEACON_SUPPORT
printf("\nBeacon_Application\r\n\n");
#else
printf("\nNO Beacon_Application\r\n\n");
#endif
	printf("\nCoordinator\r\n\n");
	print_stack_app_build_features();
#endif /* SIO_HUB */

	sw_timer_get_id(&APP_TIMER_INDIRECT_DATA);
	sw_timer_get_id(&APP_TIMER_BCN_PAYLOAD_UPDATE);
	sw_timer_get_id(&APP_TIMER_BC_DATA);
	#ifdef GTS_SUPPORT
	sw_timer_get_id(&APP_TIMER_GTS_DATA);
    #endif
	/*
	 * Reset the MAC layer to the default values.
	 * This request will cause a mlme reset confirm message ->
	 * usr_mlme_reset_conf
	 */
	wpan_mlme_reset_req(true);

#ifdef GPIO_PUSH_BUTTON_0
	dst_addr.AddrMode = 2;
	dst_addr.PANId = DEFAULT_PAN_ID;
#endif /* GPIO_PUSH_BUTTON_0 */

	while (true) {
		wpan_task();
#ifdef GPIO_PUSH_BUTTON_0
		if (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) {
			delay_ms(DEBOUNCE_DELAY_MS);
			if (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) {
				dst_addr.Addr.short_address = BROADCAST;
				wpan_mcps_data_req(FCF_SHORT_ADDR, &dst_addr,
						strlen(broadcast_payload),
						(uint8_t *)&broadcast_payload, 1,
						WPAN_TXOPT_OFF);
			}
		}

#endif /* GPIO_PUSH_BUTTON_0 */
	}
}
コード例 #8
0
ファイル: serial_bridge.c プロジェクト: AndreyMostovov/asf
void serial_bridge_init()
{
	sio2host_init();

	sio2ncp_init();
}
コード例 #9
0
/**
 * @brief Main function of the device application
 */
int main(void)
{
    irq_initialize_vectors();
#if SAMD || SAMR21
    system_init();
    delay_init();
#else
    sysclk_init();

    /* Initialize the board.
     * The board-specific conf_board.h file contains the configuration of
     * the board initialization.
     */
    board_init();
#endif
#ifdef SIO_HUB
    sio2host_init();
#endif
    sw_timer_init();

    if (MAC_SUCCESS != wpan_init()) {
        app_alert();
    }

    /* Initialize LEDs. */
    LED_On(LED_START);     /* indicating application is started */
    LED_Off(LED_NWK_SETUP); /* indicating network is started */
    LED_Off(LED_DATA);     /* indicating data transmission */
    cpu_irq_enable();
#ifdef SIO_HUB

    /* Initialize the serial interface used for communication with terminal
     * program. */

    /* To Make sure the Hyper Terminal to the System */
    sio2host_getchar();

    printf("\nBeacon_Application\r\n\n");
    printf("\nDevice\r\n\n");
    print_stack_app_build_features();
#endif

    sw_timer_get_id(&APP_TIMER);

    wpan_mlme_reset_req(true);
#ifdef ENABLE_SLEEP
    sw_timer_get_id(&APP_TIMER_SLEEP);
#endif
    LED_Off(LED_NWK_SETUP);
    while (true) {
        wpan_task();
#if (defined ENABLE_SLEEP || defined RTC_SLEEP)
        /* Requesting MAC for Sleep Duration*/
        sleep_time = mac_ready_to_sleep();
        if ((sleep_time > (uint32_t)APP_GUARD_TIME_US)) {
            /*Entering Power save Mode when the sleep duration is
             * above the guard time*/
            enter_sleep(sleep_time);
        }
#endif
    }
}