USB device task module


Functions

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


Function Documentation

void usb_device_task ( void *  pvParameters  ) 

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

Definition at line 163 of file usb_device_task.c.

References configTSK_USB_DEV_PERIOD, EP_CONTROL, EVT_USB_POWERED, EVT_USB_RESET, Is_usb_event, Is_usb_setup_received, Is_usb_vbus_high, Usb_ack_event, usb_configuration_nb, usb_connected, usb_process_request(), Usb_reset_endpoint, Usb_send_event, usb_start_device(), and Usb_vbus_on_action.

Referenced by usb_device_task_init().

00167 {
00168 #ifdef FREERTOS_USED
00169   portTickType xLastWakeTime;
00170 
00171   xLastWakeTime = xTaskGetTickCount();
00172   while (TRUE)
00173   {
00174     vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DEV_PERIOD);
00175 
00176 #endif  // FREERTOS_USED
00177     if (!usb_connected && Is_usb_vbus_high())
00178     {
00179       usb_start_device();
00180       Usb_send_event(EVT_USB_POWERED);
00181       Usb_vbus_on_action();
00182     }
00183 
00184     if (Is_usb_event(EVT_USB_RESET))
00185     {
00186       Usb_ack_event(EVT_USB_RESET);
00187       Usb_reset_endpoint(EP_CONTROL);
00188       usb_configuration_nb = 0;
00189     }
00190 
00191     // Connection to the device enumeration process
00192     if (Is_usb_setup_received())
00193     {
00194       usb_process_request();
00195     }
00196 #ifdef FREERTOS_USED
00197   }
00198 #endif
00199 }

void usb_device_task_init ( void   ) 

This function initializes the USB device controller.

This function enables the USB controller and inits 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.

Todo:
Implement this on the silicon version

Definition at line 97 of file usb_device_task.c.

References configTSK_USB_DEV_NAME, configTSK_USB_DEV_PRIORITY, configTSK_USB_DEV_STACK_SIZE, Is_usb_clock_frozen, Is_usb_enabled, Usb_ack_suspend, usb_configuration_nb, usb_connected, usb_device_task(), usb_device_tsk, Usb_disable, Usb_disable_otg_pad, Usb_enable, Usb_enable_otg_pad, Usb_enable_vbus_interrupt, and Usb_unfreeze_clock.

Referenced by usb_task().

00098 {
00099   usb_connected = FALSE;
00100   usb_configuration_nb = 0;
00102   //Pll_start_auto();
00103   //Wait_pll_ready();
00104   Disable_global_interrupt();
00105   Usb_disable();
00106   (void)Is_usb_enabled();
00107   Enable_global_interrupt();
00108   Usb_disable_otg_pad();
00109   Usb_enable_otg_pad();
00110   Usb_enable();
00111   Usb_unfreeze_clock();
00112   (void)Is_usb_clock_frozen();
00113   Usb_ack_suspend();  // A suspend condition may be detected right after enabling the USB macro
00114   Usb_enable_vbus_interrupt();
00115   Enable_global_interrupt();
00116 
00117 #ifdef FREERTOS_USED
00118   xTaskCreate(usb_device_task,
00119               configTSK_USB_DEV_NAME,
00120               configTSK_USB_DEV_STACK_SIZE,
00121               NULL,
00122               configTSK_USB_DEV_PRIORITY,
00123               &usb_device_tsk);
00124 #endif  // FREERTOS_USED
00125 }

void usb_start_device ( void   ) 

This function starts the USB device controller.

This function enables the USB controller and inits 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 or by the VBus high level.

Definition at line 137 of file usb_device_task.c.

References Usb_attach, usb_connected, Usb_enable_reset_interrupt, Usb_enable_suspend_interrupt, Usb_force_full_speed_mode, usb_init_device(), and Usb_use_dual_speed_mode.

Referenced by usb_device_task(), and usb_general_interrupt_non_naked().

00138 {
00139   Usb_enable_suspend_interrupt();
00140   Usb_enable_reset_interrupt();
00141 
00142 #if (USB_HIGH_SPEED_SUPPORT==DISABLED)
00143   Usb_force_full_speed_mode();
00144 #else
00145   Usb_use_dual_speed_mode();
00146 #endif
00147   
00148   usb_init_device();  // Configure the USB controller EP0
00149   Usb_attach();
00150   usb_connected = TRUE;
00151 }


Generated on Fri Feb 19 02:27:52 2010 for AVR32 - USB Enumeration Example by  doxygen 1.5.5