/** \brief The program starts executing here. */ int mote_main(void) { // initialize board board_init(); // switch radio LED on leds_radio_on(); // prepare bsp_timer bsp_timer_set_callback(bsp_timer_cb_compare); // prepare radiotimer radiotimer_setOverflowCb(radiotimer_cb_overflow); radiotimer_setCompareCb(radiotimer_cb_compare); // kick off first bsp_timer compare bsp_timer_scheduleIn(BSP_TIMER_PERIOD); // start periodic radiotimer overflow radiotimer_start(RADIOTIMER_OVERFLOW_PERIOD); // kick off first radiotimer compare app_vars.radiotimer_num_compares_left = RADIOTIMER_NUM_COMPARES-1; app_vars.radiotimer_last_compare_val = RADIOTIMER_COMPARE_PERIOD; radiotimer_schedule(app_vars.radiotimer_last_compare_val); while (1) { board_sleep(); } }
void cb_overflow(void) { // toggle pin debugpins_frame_toggle(); // switch radio LED on leds_error_toggle(); // reset the counter for number of remaining compares app_vars.num_compares_left = RADIOTIMER_NUM_COMPARES; app_vars.last_compare_val = RADIOTIMER_COMPARE_PERIOD; radiotimer_schedule(app_vars.last_compare_val); // increment debug counter app_dbg.num_overflow++; }
void radiotimer_cb_compare(void) { // toggle pin debugpins_fsm_toggle(); // toggle radio LED leds_radio_toggle(); // schedule a next compare, if applicable app_vars.radiotimer_last_compare_val += RADIOTIMER_COMPARE_PERIOD; app_vars.radiotimer_num_compares_left--; if (app_vars.radiotimer_num_compares_left>0) { radiotimer_schedule(app_vars.radiotimer_last_compare_val); } else { radiotimer_cancel(); } // increment debug counter app_dbg.radiotimer_num_compare++; }
void radiotimer_cb_overflow(void) { volatile uint16_t delay; // toggle pin debugpins_slot_toggle(); // switch radio LED on leds_error_toggle(); // reset the counter for number of remaining compares app_vars.radiotimer_num_compares_left = RADIOTIMER_NUM_COMPARES; app_vars.radiotimer_last_compare_val = RADIOTIMER_COMPARE_PERIOD; radiotimer_schedule(app_vars.radiotimer_last_compare_val); // increment debug counter app_dbg.radiotimer_num_overflow++; // wait a bit for (delay=0;delay<ISR_DELAY;delay++); }
/** \brief The program starts executing here. */ int mote_main(void) { // initialize board board_init(); // prepare radiotimer radiotimer_setOverflowCb(cb_overflow); radiotimer_setCompareCb(cb_compare); // kick off first compare app_vars.num_compares_left = RADIOTIMER_NUM_COMPARES-1; app_vars.last_compare_val = RADIOTIMER_COMPARE_PERIOD; // start periodic overflow radiotimer_start(RADIOTIMER_OVERFLOW_PERIOD); leds_radio_on(); radiotimer_schedule(app_vars.last_compare_val); while (1) { board_sleep(); } }