Ejemplo n.º 1
0
//! Task execution scheduler
//!
//! @warning Code:XX bytes (function code length)
//!
//! @param  :none
//! @return :none
void scheduler_tasks (void)
{
   // To avoid uncalled segment warning if the empty function is not used
   scheduler_empty_fct();

   for(;;)
   {
      Scheduler_new_schedule();
      #ifdef Scheduler_task_1
         Scheduler_task_1();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_2
         Scheduler_task_2();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_3
         Scheduler_task_3();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_4
         Scheduler_task_4();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_5
         Scheduler_task_5();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_6
         Scheduler_task_6();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_7
         Scheduler_task_7();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_8
         Scheduler_task_8();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_9
         Scheduler_task_9();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_10
         Scheduler_task_10();
         Scheduler_call_next_task();
      #endif
      #ifdef Scheduler_task_11
         Scheduler_task_11();
         Scheduler_call_next_task();
      #endif
   }
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
/// Entry point of the USB mamnagement
/// Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function
/// calls the coresponding USB management function
//------------------------------------------------------------------------------
void usb_task(void)
{
    // DUAL ROLE DEVICE USB MODE
    if(Is_usb_id_device()) {
        g_usb_mode = USB_MODE_DEVICE;
    }
    else {
        g_usb_mode = USB_MODE_HOST;
    }
    g_old_usb_mode = g_usb_mode;   // Store current usb mode, for mode change detection
    // Depending on current usb mode, launch the correct usb task (device or host)

    // Configure OTG timers
    Set_otg_custom_timer(VBUSRISE_70MS);
    Set_otg_custom_timer(VBUSPULSE_40MS);
    Set_otg_custom_timer(VFALLTMOUT_131MS);
    Set_otg_custom_timer(SRPMINDET_100US);
   
    switch(g_usb_mode) {
        case USB_MODE_DEVICE:
            //usb_device_task();
            //MSDDriver_StateMachine();
            Scheduler_task_3();
            break;

        case USB_MODE_HOST:
          if( pOTGDescriptor->bOTGADevSRPReaction == VBUS_PULSE) {
            Usb_select_vbus_srp_method();
          }
          else {
            Usb_select_data_srp_method();
          }
            usb_host_task();
            // Handle Vbus overcurrent error (auto-disabled if not supported or not defined in board driver file)
            if (Is_vbus_overcurrent()) {
                Otg_print_new_event_message(OTGMSG_VBUS_SURCHARGE,OTG_TEMPO_3SEC);
            }
            break;

        case USB_MODE_UNDEFINED:  // No break !
            default:
            break;
    }
    Otg_message_task();
}