Example #1
0
File: main.c Project: Mazetti/asf
/*! \brief Main function. Execution starts here. */
int main(void)
{
	/* System clock is initialized. */
	sysclk_init();

	/* Board related init such as SPI and GPIO. */
	board_init();

	/* IRQs init. */
	irq_initialize_vectors();

	/* Transceiver init. */
	if (at86rfx_init() != AT86RFX_SUCCESS) {
		Assert("Transceiver initialization failed" == 0);
	}

	/* Interrupt enabled before USB init as it uses IRQ for enumeration. */
	cpu_irq_enable();

	/* Start USB stack */
	udc_start();

	/* Continuous looping of available tasks, starts here. */
	while (true) {
		usb_task();
		app_task();
		at86rfx_task();
	}
}
Example #2
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();
    }
}
Example #3
0
/**
 * @brief callback for timer expiry.
 * The timer interval determines how often data frames are to be transmitted
 * and also by the size relationship between frame payload and frame header.
 * Larger timer intervals result in a better ratio, although too large
 * intervals will mean data loss if the usart buffer isn't emptied fast enough
 * and flow control is disabled.

 * @param par just for compatibility with the PAL timer callback system
 */
static void data_fwd_cb(void* par)
{
    app_task();

#if(SEND_BLOCKWISE==true)
    /* restart timer */
    start_timer();
#endif
}
Example #4
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 */
	}
}
/**
 * Main function, initialization and main message loop
 *
 */
int main(void)
{
    irq_initialize_vectors();

    /* Initialize the board.*/	
    board_init();    

	/* Initialize the Software timer */
    sw_timer_init();       
    
	/* Init the RF4CE Network layer */
    if (nwk_init()!= NWK_SUCCESS)
    {
        app_alert();
    }

#ifdef RF4CE_CALLBACK_PARAM
	/* Register the ZID Callback indication */
    zid_ind.zid_report_data_indication_cb = zid_report_data_indication;
    zid_ind.zid_get_report_indication_cb = zid_get_report_indication;
    register_zid_indication_callback(&zid_ind);
#endif
    /*
     * The stack is initialized above,
     * hence the global interrupts are enabled here.
     */
     cpu_irq_enable();
	 sw_timer_get_id(&APP_TIMER_ACC_READ);
    if (get_zid_keyrc_button(button_scan()) == ZID_COLD_START)
    {        
        /* Cold start */
        LED_On(ZID_APP_LED);
        node_status = COLD_START;
        nlme_reset_request(true
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
    }
    else
    {
        /* Warm start */
        node_status = WARM_START;
        nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
    }

    /* Endless while loop */
    while (1)
    {
        app_task(); /* Application task */
        nwk_task(); /* RF4CE network layer task */
    }
}
Example #6
0
/**
 * @brief Main function of the Terminal Target application
 * @ingroup App_API
 */
int main(void)
{
    /* Initialize all layers */
    if (nwk_init() != NWK_SUCCESS)
    {
        /* something went wrong during initialization */
        pal_alert();
    }
    /* disable pull-ups */
    MCUCR |= (1u << PUD);
    
#ifdef FLASH_NVRAM
    pal_ps_set(EE_IEEE_ADDR,IEEE_ADDRESS_BYTES, &tal_pib_IeeeAddress);
#endif
    
    /* Initialize LEDs. */
    pal_led_init();
    pal_led(LED_START, LED_ON);         /* indicating application is started */
    pal_led(LED_NWK_SETUP, LED_OFF);    /* indicating network is started */
    pal_led(LED_DATA, LED_OFF);         /* indicating data reception */

    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    
    pal_global_irq_enable();
 
    /**
    * @brief TWI and QT600 interface initialization
    */
    int i;
    twi_master_init();
    RESET_QT600_PIN_INIT();
    RESET_QT600_ON();
    for (i = 0; i < 100 ; i++)
        asm("nop");
    
    /* Endless while loop */
    while (1)
    {
        app_task(); /* Application task */
        if(rf4ce_new_msg == 1)
        {
          twi_send_message();
          TX_index = 0;
          rf4ce_new_msg = 0;
        }
 
        nwk_task(); /* RF4CE network layer task */
    }
}
Example #7
0
/**
 * @brief Main function of the Wireless UART application
 */
int main(void)
{
    /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();
    pal_led(LED_START, LED_ON);     // indicating application is started
    pal_led(LED_DATA_RX, LED_OFF);  // indicating data reception
    pal_led(LED_DATA_TX, LED_OFF);  // indicating successfull data transmission

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

    /* Initialize the serial interface used for communication with terminal program */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Configure TX frame and transceiver */
    configure_frame_sending();

    /* Switch receiver on */
    tal_rx_enable(PHY_RX_ON);

#if(SEND_BLOCKWISE==true)
    start_timer();
#endif

    /* Endless while loop */
    while (1)
    {
        pal_task(); /* Handle platform specific tasks, like serial interface */
        tal_task(); /* Handle transceiver specific tasks */
#if(!(SEND_BLOCKWISE==true))
        app_task(); /* Application task */
#endif
    }
}
Example #8
0
/*! \brief Main function.
 */
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())
	{
        /*
         * Stay here; we need a valid IEEE address.
         * Check kit documentation how to create an IEEE address
         * and to store it into the EEPROM.
         */
		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();

	sw_timer_get_id(&TIMER_LED_OFF);
	sw_timer_get_id(&WAKE_TIMER);

	node_status = COLD_START_RESET;

    /*
     * 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);

    /* Main loop */
	while (true)
	{
		wpan_task();
        app_task(); /* Application task */
	}
}
Example #9
0
/**
 * @brief Main function of the Sniffer application
 */
int main(void)
{

   /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        /* something went wrong during initialization*/
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();


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

    /* Initialize the serial interface used for communication with sniffer
       GUI */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        /* something went wrong during initialization */
        pal_alert();
    }

    //sio_getchar();

    Wireshark_Settings = INIT_STATE ;

    /* Endless while loop */
    while (1)
    {
        pal_task();
        tal_task();
        app_task();
    }
}
Example #10
0
/**
 * Main function, initialization and main message loop
 *
 */
int main (void)
{
    irq_initialize_vectors();

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

    sw_timer_init();

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

    zid_indication_callback_init();
    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    cpu_irq_enable();
    /* Initializing udc stack as HID composite device*/
    udc_start();

    sw_timer_get_id(&APP_TIMER);

    /* Endless while loop */
    //udi_hid_gpd_up(16);
    while (1)
    {


        app_task(); /* Application task */
        nwk_task(); /* RF4CE network layer task */


    }
}