USB task entry point module

Collaboration diagram for USB task entry point module:


Modules

 USB software Events Management
 Macros to manage USB events detected under interrupt.

Defines

#define USB_MODE_UNDEFINED   0x00
#define USB_MODE_HOST   0x01
#define USB_MODE_DEVICE   0x02

Functions

void usb_task_init (void)
 This function initializes the USB proces.
void usb_task (void)
 Entry point of the USB mamnagement.

Variables

volatile U16 g_usb_event
 Public : U16 g_usb_event usb_connected is used to store USB events detected upon USB general interrupt subroutine Its value is managed by the following macros (See usb_task.h file) Usb_send_event(x) Usb_ack_event(x) Usb_clear_all_event() Is_usb_event(x) Is_not_usb_event(x).
volatile U8 private_sof_counter
 Private : (U8) private_sof_counter Incremented by host SOF interrupt subroutime This counter is used to detect timeout in host requests.

Define Documentation

#define USB_MODE_UNDEFINED   0x00
 

Definition at line 51 of file usb_task.h.

Referenced by usb_task(), and usb_task_init().

#define USB_MODE_HOST   0x01
 

Definition at line 52 of file usb_task.h.

Referenced by usb_task(), and usb_task_init().

#define USB_MODE_DEVICE   0x02
 

Definition at line 53 of file usb_task.h.

Referenced by usb_task(), and usb_task_init().


Function Documentation

void usb_task_init void   ) 
 

This function initializes the USB proces.

Depending on the mode supported (HOST/DEVICE/DUAL_ROLE) the function calls the coresponding usb mode initialization function

Parameters:
none 
Returns:
none

Definition at line 128 of file usb_task.c.

References g_old_usb_mode, g_usb_mode, Is_usb_id_device, PORTA, Usb_ack_id_transition, usb_device_task_init(), Usb_enable_id_interrupt, Usb_enable_regulator, Usb_enable_uid_pin, Usb_force_device_mode, Usb_force_host_mode, USB_MODE_DEVICE, USB_MODE_HOST, and USB_MODE_UNDEFINED.

00129 {
00130    #if (USB_HOST_FEATURE == ENABLED)
00131    U8 delay;
00132    #endif
00133 
00134    #if (USE_USB_PADS_REGULATOR==ENABLE)  // Otherwise assume USB PADs regulator is not used
00135    Usb_enable_regulator();
00136    #endif
00137 
00138 // ---- DUAL ROLE DEVICE USB MODE ---------------------------------------------
00139 #if ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == ENABLED))
00140    Usb_enable_uid_pin();
00141    delay=PORTA;
00142    g_usb_mode=USB_MODE_UNDEFINED;
00143    if(Is_usb_id_device())
00144    {
00145      g_usb_mode=USB_MODE_DEVICE;
00146      usb_device_task_init();
00147    }
00148    else
00149    {
00150      g_usb_mode=USB_MODE_HOST;
00151      Usb_ack_id_transition(); // REQUIRED !!! Startup with ID=0, Ack ID pin transistion (default hwd start up is device mode)
00152      Usb_enable_id_interrupt();
00153      Enable_interrupt();
00154      usb_host_task_init();
00155    }
00156    g_old_usb_mode=g_usb_mode;   // Store current usb mode, for mode change detection
00157 // -----------------------------------------------------------------------------
00158 
00159 // ---- DEVICE ONLY USB MODE ---------------------------------------------------
00160 #elif ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == DISABLE))
00161    Usb_force_device_mode();
00162    usb_device_task_init();
00163 // -----------------------------------------------------------------------------
00164 
00165 // ---- REDUCED HOST ONLY USB MODE ---------------------------------------------
00166 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLED))
00167    Usb_force_host_mode();
00168    usb_host_task_init();
00169 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE))
00170    #error  at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled
00171 #endif
00172 // -----------------------------------------------------------------------------
00173 
00174 
00175 }

Here is the call graph for this function:

void usb_task void   ) 
 

Entry point of the USB mamnagement.

Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function calls the coresponding usb management function.

Parameters:
none 
Returns:
none

Definition at line 187 of file usb_task.c.

References g_old_usb_mode, g_usb_mode, Is_usb_id_device, usb_device_task(), USB_MODE_DEVICE, USB_MODE_HOST, USB_MODE_UNDEFINED, and Wdt_change_16ms.

00188 {
00189 // ---- DUAL ROLE DEVICE USB MODE ---------------------------------------------
00190 #if ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == ENABLED))
00191    if(Is_usb_id_device())
00192    { g_usb_mode=USB_MODE_DEVICE;}
00193    else
00194    { g_usb_mode=USB_MODE_HOST;}
00195   // TODO !!! ID pin hot state change
00196   // Preliminary management: HARDWARE RESET !!!
00197    #if ( ID_PIN_CHANGE_GENERATE_RESET == ENABLE)
00198      // Hot ID transition generates wdt reset
00199       if((g_old_usb_mode!=g_usb_mode))
00200       {Wdt_change_16ms(); while(1);}
00201    #endif
00202   // Depending on current usb mode, launch the correct usb task (device or host)
00203    switch(g_usb_mode)
00204    {
00205       case USB_MODE_DEVICE:
00206          usb_device_task();
00207          break;
00208       case USB_MODE_HOST:
00209          usb_host_task();
00210          break;
00211       case USB_MODE_UNDEFINED:  // No break !
00212       default:
00213          break;
00214   }
00215 // -----------------------------------------------------------------------------
00216 
00217 // ---- DEVICE ONLY USB MODE ---------------------------------------------------
00218 #elif ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == DISABLE))
00219    usb_device_task();
00220 // -----------------------------------------------------------------------------
00221 
00222 // ---- REDUCED HOST ONLY USB MODE ---------------------------------------------
00223 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLED))
00224    usb_host_task();
00225 // -----------------------------------------------------------------------------
00226 
00228 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE))
00229    #error  at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled
00230    #error  otherwise the usb task has nothiing to do ...
00231 #endif
00232 // -----------------------------------------------------------------------------
00233 
00234 }

Here is the call graph for this function:


Variable Documentation

volatile U16 g_usb_event
 

Public : U16 g_usb_event usb_connected is used to store USB events detected upon USB general interrupt subroutine Its value is managed by the following macros (See usb_task.h file) Usb_send_event(x) Usb_ack_event(x) Usb_clear_all_event() Is_usb_event(x) Is_not_usb_event(x).

Definition at line 70 of file usb_task.c.

volatile U8 private_sof_counter
 

Private : (U8) private_sof_counter Incremented by host SOF interrupt subroutime This counter is used to detect timeout in host requests.

It must not be modified by the user application tasks. /

Definition at line 99 of file usb_task.c.

Referenced by usb_general_interrupt().


Generated on Fri Mar 17 16:02:13 2006 for Atmel by  doxygen 1.4.6-NO