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 106 of file usb_device_task.c.

References Usb_disable, Usb_enable, Usb_enable_vbus_pad, and Usb_low_speed_mode.

00107 {
00108    Usb_disable();
00109    Usb_enable();
00110 #if (USB_LOW_SPEED_DEVICE==ENABLE)
00111    Usb_low_speed_mode();
00112 #endif
00113    Usb_enable_vbus_pad();
00114    Enable_interrupt();
00115 }

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.

00131 {
00132    Usb_freeze_clock();
00133 #ifndef USE_USB_AUTOBAUD
00134    Pll_start_auto();
00135 #else
00136    usb_autobaud();
00137 #endif
00138    Wait_pll_ready();
00139    Disable_interrupt();
00140    Usb_unfreeze_clock();
00141    Usb_attach();
00142 #if (USB_RESET_CPU == ENABLED)
00143    Usb_reset_all_system();
00144 #else
00145    Usb_reset_macro_only();
00146 #endif
00147    usb_init_device();         // configure the USB controller EP0
00148    Usb_enable_suspend_interrupt();
00149    Usb_enable_reset_interrupt();
00150    Enable_interrupt();
00151 }

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 163 of file usb_device_task.c.

References EP_CONTROL, EVT_USB_POWERED, EVT_USB_RESET, EVT_USB_UNPOWERED, FALSE, Is_usb_event, Is_usb_receive_setup, Is_usb_vbus_high, Is_usb_vbus_low, TRUE, Usb_ack_event, Usb_attach, usb_configuration_nb, usb_connected, Usb_detach, Usb_enable, Usb_freeze_clock, usb_process_request(), Usb_reset_endpoint, Usb_select_endpoint, Usb_send_event, usb_start_device(), Usb_vbus_off_action, and Usb_vbus_on_action.

00164 {
00165    //- VBUS state detection
00166    if (Is_usb_vbus_high()&& (usb_connected==FALSE))
00167    {
00168       usb_connected = TRUE;
00169       Usb_send_event(EVT_USB_POWERED);
00170       Usb_vbus_on_action();
00171       Usb_enable();
00172       usb_start_device();
00173       Usb_attach();
00174    }
00175    if (Is_usb_vbus_low()&& (usb_connected==TRUE))
00176    {
00177       usb_connected = FALSE;
00178       usb_configuration_nb = 0;
00179       Usb_send_event(EVT_USB_UNPOWERED);
00180       Usb_detach();
00181       Usb_freeze_clock();
00182       Usb_vbus_off_action();
00183    }
00184 
00185    if(Is_usb_event(EVT_USB_RESET))
00186    {
00187       Usb_ack_event(EVT_USB_RESET);
00188       Usb_reset_endpoint(0);
00189       usb_configuration_nb=0;
00190    }
00191 
00192    // Here connection to the device enumeration process
00193    Usb_select_endpoint(EP_CONTROL);
00194    if (Is_usb_receive_setup())
00195    {
00196       usb_process_request();
00197    }
00198 }

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 79 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 72 of file usb_device_task.c.


Generated on Fri Sep 11 15:02:36 2009 for ATMEL by  doxygen 1.5.3