Functions | Variables

USB device task

Functions

void usb_device_task_init (void)
 This function initializes the USB device controller.
void usb_start_device (void)
 This function initializes the USB device controller.
void usb_device_task (void)
 Entry point of the USB device mamagement.

Variables

bit usb_suspended
 Public : (bit) usb_suspended usb_suspended is set to TRUE when USB is in suspend mode usb_suspended is set to FALSE otherwise /.
bit usb_connected
 Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /.

Function Documentation

void usb_device_task_init ( void   )

This function initializes the USB device controller.

This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager.

Parameters:
none
Returns:
none

This function initializes the USB device controller.

This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager.

Parameters:
none
Returns:
none

/

Definition at line 106 of file usb_device_task.c.

References Usb_disable, Usb_enable, Usb_enable_vbus_pad, and Usb_low_speed_mode.

Referenced by usb_task_init().

{
   Usb_disable();
   Usb_enable();
#if (USB_LOW_SPEED_DEVICE==ENABLE)
   Usb_low_speed_mode();
#endif
   Usb_enable_vbus_pad();
   Enable_interrupt();
}

Here is the caller graph for this function:

void usb_start_device ( void   )

This function initializes the USB device controller.

This function enables the USB controller and init the USB interrupts. The aim is to allow the USB connection detection in order to send the appropriate USB event to the operating mode manager. Start device function is executed once VBUS connection has been detected either by the VBUS change interrupt either by the VBUS high level

Parameters:
none
Returns:
none

Definition at line 130 of file usb_device_task.c.

References Usb_attach, Usb_enable_reset_interrupt, Usb_enable_suspend_interrupt, Usb_freeze_clock, usb_init_device(), Usb_reset_all_system, Usb_reset_macro_only, Usb_unfreeze_clock, and Wait_pll_ready.

Referenced by usb_device_task().

{
   Usb_freeze_clock();
#ifndef USE_USB_AUTOBAUD
   Pll_start_auto();
#else
   usb_autobaud();
#endif
   Wait_pll_ready();
   Disable_interrupt();
   Usb_unfreeze_clock();
   Usb_attach();
#if (USB_RESET_CPU == ENABLED)
   Usb_reset_all_system();
#else
   Usb_reset_macro_only();
#endif
   usb_init_device();         // configure the USB controller EP0
   Usb_enable_suspend_interrupt();
   Usb_enable_reset_interrupt();
   Enable_interrupt();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_device_task ( void   )

Entry point of the USB device mamagement.

This function is the entry point of the USB management. Each USB event is checked here in order to launch the appropriate action. If a Setup request occurs on the Default Control Endpoint, the usb_process_request() function is call in the usb_standard_request.c file

Parameters:
none
Returns:
none

Definition at line 163 of file usb_device_task.c.

References EP_CONTROL, EVT_USB_POWERED, EVT_USB_RESET, EVT_USB_UNPOWERED, EVT_USB_WAKE_UP, FALSE, Is_pll_ready, Is_usb_event, Is_usb_receive_setup, Is_usb_vbus_high, Is_usb_vbus_low, Is_usb_wake_up, TRUE, Usb_ack_event, Usb_ack_wake_up, Usb_attach, usb_configuration_nb, usb_connected, Usb_detach, Usb_enable, Usb_enable_suspend_interrupt, Usb_freeze_clock, usb_process_request(), Usb_reset_endpoint, Usb_select_endpoint, Usb_send_event, usb_start_device(), Usb_unfreeze_clock, Usb_vbus_off_action, Usb_vbus_on_action, Usb_wake_up_action, and Wait_pll_ready.

Referenced by usb_task().

{
   //- VBUS state detection
   if (Is_usb_vbus_high()&& (usb_connected==FALSE))
   {
      usb_connected = TRUE;
      Usb_send_event(EVT_USB_POWERED);
      Usb_vbus_on_action();
      Usb_enable();
      usb_start_device();
      Usb_attach();
   }
   if (Is_usb_vbus_low()&& (usb_connected==TRUE))
   {
      usb_connected = FALSE;
      usb_configuration_nb = 0;
      Usb_send_event(EVT_USB_UNPOWERED);
      Usb_detach();
      Usb_freeze_clock();
      Usb_vbus_off_action();
   }

   if(Is_usb_event(EVT_USB_RESET))
   {
      Usb_ack_event(EVT_USB_RESET);
      Usb_reset_endpoint(0);
      usb_configuration_nb=0;
   }

#ifdef USB_WAKEUP_POOLING
  // - Wake up event (USB activity detected): Used to resume
   if (Is_usb_wake_up() && (Is_pll_ready()==FALSE))
   {
      Pll_start_auto();
      Wait_pll_ready();
      Usb_unfreeze_clock();
      Usb_ack_wake_up();
      Usb_wake_up_action();
      Usb_send_event(EVT_USB_WAKE_UP);
      Usb_enable_suspend_interrupt();
   }
#endif

   // =======================================
   // Common Standard Device Control Requests
   // =======================================
   //   - device enumeration process
   //   - device control commands and features
   Usb_select_endpoint(EP_CONTROL);
   if (Is_usb_receive_setup())
   {
      usb_process_request();
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Public : (bit) usb_suspended usb_suspended is set to TRUE when USB is in suspend mode usb_suspended is set to FALSE otherwise /.

Definition at line 79 of file usb_device_task.c.

Referenced by usb_general_interrupt().

Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /.

Definition at line 72 of file usb_device_task.c.