USB device task


Functions

void usb_device_task_init (void)
void usb_start_device (void)
void usb_device_task (void)

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 and system interrupt 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 103 of file usb_device_task.c.

References Usb_disable, Usb_enable, and Usb_vbus_sense_init.

00104 {
00105    Usb_disable();
00106    Usb_enable();
00107 #if (VBUS_SENSING_IO == ENABLED)
00108    Usb_vbus_sense_init();   // init. the I/O used for Vbus sensing
00109 #endif
00110 }

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 125 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.

00126 {
00127    Usb_freeze_clock();
00128 #ifndef USE_USB_AUTOBAUD
00129    Pll_start_auto();
00130 #else
00131    usb_autobaud();
00132 #endif
00133    Wait_pll_ready();
00134    Usb_unfreeze_clock();
00135    Usb_attach();
00136 #if (USB_RESET_CPU == ENABLED)
00137    Usb_reset_all_system();
00138 #else
00139    Usb_reset_macro_only();
00140 #endif
00141    usb_init_device();         // configure the USB controller EP0
00142    Usb_enable_suspend_interrupt();
00143    Usb_enable_reset_interrupt();
00144    Enable_interrupt();
00145 }

Here is the call 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 157 of file usb_device_task.c.

References EP_CONTROL, EVT_USB_RESET, FALSE, Is_usb_event, Is_usb_receive_setup, Is_usb_vbus_off, Is_usb_vbus_on, Stop_pll, TRUE, Usb_ack_event, usb_configuration_nb, usb_connected, Usb_detach, Usb_disable, Usb_enable, usb_process_request(), Usb_reset_endpoint, Usb_select_endpoint, usb_start_device(), and Usb_vbus_on_action.

00158 {
00159    if (usb_connected == FALSE)
00160    {
00161      #if (VBUS_SENSING_IO == ENABLED)
00162      if (Is_usb_vbus_on())    // check if Vbus ON to attach
00163      {
00164        Usb_enable();
00165        usb_connected = TRUE;
00166        usb_start_device();
00167        Usb_vbus_on_action();
00168      }
00169      #else
00170      usb_connected = TRUE;    // attach if application is not self-powered
00171      usb_start_device();
00172      Usb_vbus_on_action();
00173      #endif
00174    }
00175 
00176    #if (VBUS_SENSING_IO == ENABLED)
00177    if ((usb_connected == TRUE) && Is_usb_vbus_off())  // check if Vbus OFF to detach
00178    {
00179      Usb_detach();
00180      Usb_disable();
00181      Stop_pll();
00182      usb_connected = FALSE;
00183      usb_configuration_nb=0;
00184    }
00185    #endif
00186 
00187    if(Is_usb_event(EVT_USB_RESET))
00188    {
00189       Usb_ack_event(EVT_USB_RESET);
00190       Usb_reset_endpoint(0);
00191       usb_configuration_nb=0;
00192    }
00193 
00194    // Here connection to the device enumeration process
00195    Usb_select_endpoint(EP_CONTROL);
00196    if (Is_usb_receive_setup())
00197    {
00198       usb_process_request();
00199    }
00200 }

Here is the call graph for this function:


Variable Documentation

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 /.

Definition at line 76 of file usb_device_task.c.

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 /.

Definition at line 69 of file usb_device_task.c.


Generated on Mon Nov 3 13:13:46 2008 for ATMEL by  doxygen 1.5.3