Exemplo n.º 1
0
int main ()
{
    watchdog_stop();

    set_mcu_speed_dco_mclk_16MHz_smclk_8MHz(); // set global clock

    /* Initialisation begin */
    leds_init();	// leds :')
    spi_init();	//
    cc2500_init();	// radio init
    #if defined(USER_RFCONFIG)
    cc2500_configure(& USER_RFCONFIG );
    #endif

    timerA_init(); // global timer
    timerA_register_cb(&timer_tick_cb); // protothread timer increment callback
    timerA_start_milliseconds(TIMER_PERIOD_MS);

    uart_init(UART_9600_SMCLK_8MHZ); // serial link

    printf("adc test application: temperature\n\n");

    adc10_start(); // temperature sensor

    __enable_interrupt();
        
    /* Initialisation end */

    while(1)
    {
        thread_periodic_capture(&pt[0]);
        thread_periodic_radio(&pt[1]);
        //do something
    }

    return 0;
}
Exemplo n.º 2
0
int main(void)
{
    watchdog_stop();

    TIMER_ID_INPUT = UINT_MAX;
    node_id = NODE_ID_UNDEFINED;

    /* protothreads init */
    int i;
    for(i = 0; i < NUM_PT; i++)
    {
        PT_INIT(&pt[i]);
    }

    /* clock init */
    set_mcu_speed_dco_mclk_16MHz_smclk_8MHz();

    /* LEDs init */
    leds_init();
    led_red_on();
    led_green_flag = 0;

    /* timer init */
    timerA_init();
    timerA_register_cb(&timer_tick_cb);
    timerA_start_milliseconds(TIMER_PERIOD_MS);

    /* button init */
    button_init();
    button_register_cb(button_pressed_cb);
    antibouncing_flag = 0;
    button_pressed_flag = 0;

    /* UART init (serial link) */
    uart_init(UART_9600_SMCLK_8MHZ);
    uart_register_cb(uart_cb);
    uart_flag = 0;
    uart_data = 0;

    /* ADC10 init (temperature) */
    adc10_start();

    /* radio init */
    spi_init();
    cc2500_init();
    cc2500_rx_register_buffer(radio_tx_buffer, PKTLEN);
    cc2500_rx_register_cb(radio_cb);
    cc2500_rx_enter();
    radio_rx_flag = 0;

    /* retrieve node id from flash */
    node_id = *((char *) NODE_ID_LOCATION);
    //printf("node id retrieved from flash: %d\r\n", node_id);

    button_enable_interrupt();
    __enable_interrupt();

    /* simple cycle scheduling */
    while(1) {
        /*thread_led_red(&pt[0]);
        thread_led_green(&pt[1]);
        thread_uart(&pt[2]);
        thread_antibouncing(&pt[3]);*/
        thread_process_msg(&pt[4]);
        thread_periodic_send(&pt[5]);
        /*thread_button(&pt[6]);*/
    }
}