コード例 #1
0
/**
\brief The program starts executing here.
in order to echo chunks of bytes, each chunk needs to start with character 'H' as
openserial takes different actions according to the initial character of the stream.
*/
int mote_main(void) {
   
   board_init();
   openserial_init();
   
   bsp_timer_set_callback(cb_compare);
   bsp_timer_scheduleIn(BSP_TIMER_PERIOD);
   
   while(1) {
      board_sleep();
      if (app_vars.timerFired==1) {
         app_vars.timerFired = 0;
         if (app_vars.outputting==1) {
            openserial_startInput();
            app_vars.outputting = 0;
         } else {
            openserial_startOutput();
            app_vars.outputting = 1;
         }
      }
   }
}
コード例 #2
0
void scheduler_start() {
   while (1) {                                   // IAR should halt here if nothing to do
#ifdef SERIALINSCHEDULER
      openserial_stop();
#endif
      while(num_tasks>0) {
         if (task_list[ID_ISR_RADIO]>0) {
            task_list[ID_ISR_RADIO]--;
            num_tasks--;
#ifdef ISR_RADIO
            isr_radio();
#endif
         } else if (task_list[ID_ISR_MAC_BACKOFF]>0) {
            task_list[ID_ISR_MAC_BACKOFF]--;
            num_tasks--;
#ifdef OPENWSN_STACK
            timer_mac_backoff_fired();
#endif
         } else if (task_list[ID_ISR_MAC_WATCHDOG]>0) {
            task_list[ID_ISR_MAC_WATCHDOG]--;
            num_tasks--;
#ifdef OPENWSN_STACK
            timer_mac_watchdog_fired();
#endif
         } else if (task_list[ID_ISR_MAC_PERIODIC]>0) {
            task_list[ID_ISR_MAC_PERIODIC]--;
            num_tasks--;
#ifdef OPENWSN_STACK
            timer_mac_periodic_fired();
#endif
         } else if (task_list[ID_ISR_TCP_TIMEOUT]>0) {
            task_list[ID_ISR_TCP_TIMEOUT]--;
            num_tasks--;
#ifdef OPENWSN_STACK
            timer_tcp_timeout_fired();
#endif
         } else if (task_list[ID_ISR_RPL]>0) {
            task_list[ID_ISR_RPL]--;
            num_tasks--;
#ifdef OPENWSN_STACK
            timer_rpl_fired();
#endif
         } else if (task_list[ID_ISR_TIMERB5]>0) {
            task_list[ID_ISR_TIMERB5]--;
            num_tasks--;
         } else if (task_list[ID_ISR_TIMERB6]>0) {
            task_list[ID_ISR_TIMERB6]--;
            num_tasks--;
         } else if (task_list[ID_ISR_BUTTON]>0) {
            task_list[ID_ISR_BUTTON]--;
            num_tasks--;
#ifdef ISR_BUTTON
            isr_button();
#endif
         } else if (task_list[ID_TASK_APPLICATION]>0) {
            task_list[ID_TASK_APPLICATION]--;
            num_tasks--;
#ifdef TASK_APPLICATION
            task_application();
#endif
         }
      }
#ifdef SERIALINSCHEDULER
      scheduler_serialInOutputMode = !scheduler_serialInOutputMode;
      if (scheduler_serialInOutputMode) {
         openserial_startOutput();
      } else {
         openserial_startInput();
      }
#endif
      __bis_SR_register(GIE+LPM3_bits);          // sleep, but leave interrupts and ACLK on 
   }
}