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.
 Standard requests defines

Defines

#define USB_MODE_UNDEFINED   0x00
#define USB_MODE_HOST   0x01
#define USB_MODE_DEVICE   0x02
#define VBUS_PULSE   1
#define DATA_PULSE   0
#define BDEV_HNP_NB_RETRY   3
#define USER_RQST_SRP   0x01
 Definitions of OTG user requests (user software requests).
#define USER_RQST_SUSPEND   0x02
#define USER_RQST_VBUS   0x04
#define USER_RQST_HNP   0x08
#define USER_RQST_RESUME   0x10
#define USER_RQST_RESET   0x20
#define USER_RQST_DISCONNECT   0x40
#define Is_user_requested_srp()   (((otg_user_request&USER_RQST_SRP) != 0) ? TRUE : FALSE)
#define Set_user_request_srp()   (otg_user_request |= USER_RQST_SRP)
#define Ack_user_request_srp()   (otg_user_request &= ~USER_RQST_SRP)
#define Is_user_requested_suspend()   (((otg_user_request&USER_RQST_SUSPEND) != 0) ? TRUE : FALSE)
#define Set_user_request_suspend()   (otg_user_request |= USER_RQST_SUSPEND)
#define Ack_user_request_suspend()   (otg_user_request &= ~USER_RQST_SUSPEND)
#define Is_user_requested_vbus()   (((otg_user_request&USER_RQST_VBUS) != 0) ? TRUE : FALSE)
#define Set_user_request_vbus()   (otg_user_request |= USER_RQST_VBUS)
#define Ack_user_request_vbus()   (otg_user_request &= ~USER_RQST_VBUS)
#define Is_user_requested_hnp()   (((otg_user_request&USER_RQST_HNP) != 0) ? TRUE : FALSE)
#define Set_user_request_hnp()   (otg_user_request |= USER_RQST_HNP)
#define Ack_user_request_hnp()   (otg_user_request &= ~USER_RQST_HNP)
#define Is_user_requested_disc()   (((otg_user_request&USER_RQST_DISCONNECT) != 0) ? TRUE : FALSE)
#define Set_user_request_disc()   (otg_user_request |= USER_RQST_DISCONNECT)
#define Ack_user_request_disc()   (otg_user_request &= ~USER_RQST_DISCONNECT)
#define Clear_all_user_request()   (otg_user_request = 0)
#define Otg_timer_init()
 This macro initializes the timer for OTG specific timings.
#define OTG_COMPLIANCE_TRICKS   DISABLED
 Enable some additionnal feature to pass compliance plan.
#define OTG_VBUS_AUTO_AFTER_A_PLUG_INSERTION   DISABLED
 Selects a Vbus delivery option.
#define OTG_B_DEVICE_AUTORUN_HNP_IF_REQUIRED   ENABLED
 ENABLE to make the B-Device run a HNP automatically if a SetFeature(b_hnp_enable) is received and Suspend detected.
#define OTG_RESET_LENGTH   1
 Selects the Reset Length (x11ms).
#define MSG_DISPLAY_NODELAY   0xFFFF
 OTG Messaging definitions "No Silent Failure" rule makes any OTG compliant device handle messaging functions Differents means are supported : LCD display, LEDs, etc.
#define OTG_TEMPO_1SEC   0x01F4
#define OTG_TEMPO_2SEC   0x03E8
#define OTG_TEMPO_3SEC   0x05DC
#define OTG_TEMPO_4SEC   0x07D0
#define OTR_TEMPO_5SEC   0x09C4
#define OTGMSG_SRP_STARTED   1
#define OTGMSG_SRP_A_NO_RESP   2
#define OTGMSG_A_RESPONDED   3
#define OTGMSG_CONNECTED_TO_A   4
#define OTGMSG_UNSUPPORTED   5
#define OTGMSG_UNSUPPORTED_HUB   6
#define OTGMSG_SRP_RECEIVED   7
#define OTGMSG_DEVICE_NO_RESP   8
#define OTGMSG_VBUS_SURCHARGE   9
#define OTGSTR_SRP_STARTED   "SRP Initiated "
#define OTGSTR_SRP_A_NO_RESP   "A-Dev No Response "
#define OTGSTR_A_RESPONDED   "A-Device Responded"
#define OTGSTR_CONNECTED_TO_A   "Connected to A-Dev"
#define OTGSTR_UNSUPPORTED   "Unsupported Device"
#define OTGSTR_UNSUPPORTED_HUB   "Hub Unsuppported "
#define OTGSTR_SRP_RECEIVED   "SRP Received "
#define OTGSTR_DEVICE_NO_RESP   "Device No Response"
#define OTGSTR_VBUS_SURCHARGE   "VBUS OverCurrent !"
#define OTGMSG_NONE   0
#define OTGMSG_FAIL   1
#define OTGMSG_ALL   2
#define Otg_messaging_init()
#define Otg_print_new_event_message(str, tm)
#define Otg_clear_event_message()
#define Get_event_msg_delay()
#define Decrement_event_msg_delay()
#define Otg_print_new_failure_message(str, tm)
#define Otg_clear_failure_message()
#define Get_failure_msg_delay()
#define Decrement_failure_msg_delay()

Functions

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

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).
U8 g_usb_mode
 Public : (U8) g_usb_mode Used in dual role application (both device/host) to store the current mode the usb controller is operating /.
U8 remote_wakeup_feature
 Public : (U8) remote_wakeup_feature Store a host request for remote wake up (set feature received) /.
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.
volatile U8 otg_features_supported
 External public declarations for OTG features.
U8 otg_user_request
 Public : (U8) otg_user_request; Store the last request of the user (see usb_device_task.h).
volatile U16 g_otg_event
 Public : (U16) g_otg_event; Contains several bits corresponding to differents OTG events (similar to g_usb_event).
U8 id_changed_to_host_event
U16 otg_msg_event_delay
 Public : (U16) otg_msg_event_delay; Contains the current display duration of the OTG event message.
U16 otg_msg_failure_delay
 Public : (U16) otg_msg_failure_delay; Contains the current display duration of the OTG failure message.

Define Documentation

#define USB_MODE_UNDEFINED   0x00

Definition at line 125 of file usb_task.h.

Referenced by usb_task(), and usb_task_init().

#define USB_MODE_HOST   0x01

Definition at line 126 of file usb_task.h.

Referenced by usb_general_interrupt(), usb_task(), and usb_task_init().

#define USB_MODE_DEVICE   0x02

Definition at line 127 of file usb_task.h.

Referenced by usb_general_interrupt(), usb_task(), and usb_task_init().

#define VBUS_PULSE   1

Definition at line 130 of file usb_task.h.

#define DATA_PULSE   0

Definition at line 131 of file usb_task.h.

#define BDEV_HNP_NB_RETRY   3

Definition at line 133 of file usb_task.h.

Referenced by usb_set_feature(), and usb_task_init().

#define USER_RQST_SRP   0x01

Definitions of OTG user requests (user software requests).

Definition at line 140 of file usb_task.h.

#define USER_RQST_SUSPEND   0x02

Definition at line 141 of file usb_task.h.

#define USER_RQST_VBUS   0x04

Definition at line 142 of file usb_task.h.

#define USER_RQST_HNP   0x08

Definition at line 143 of file usb_task.h.

#define USER_RQST_RESUME   0x10

Definition at line 144 of file usb_task.h.

#define USER_RQST_RESET   0x20

Definition at line 145 of file usb_task.h.

#define USER_RQST_DISCONNECT   0x40

Definition at line 146 of file usb_task.h.

 
#define Is_user_requested_srp (  )     (((otg_user_request&USER_RQST_SRP) != 0) ? TRUE : FALSE)

Definition at line 149 of file usb_task.h.

Referenced by usb_device_task().

 
#define Set_user_request_srp (  )     (otg_user_request |= USER_RQST_SRP)

Definition at line 150 of file usb_task.h.

Referenced by otg_user_task().

 
#define Ack_user_request_srp (  )     (otg_user_request &= ~USER_RQST_SRP)

Definition at line 151 of file usb_task.h.

Referenced by usb_device_task().

 
#define Is_user_requested_suspend (  )     (((otg_user_request&USER_RQST_SUSPEND) != 0) ? TRUE : FALSE)

Definition at line 154 of file usb_task.h.

Referenced by usb_device_task(), and usb_host_task().

 
#define Set_user_request_suspend (  )     (otg_user_request |= USER_RQST_SUSPEND)

Definition at line 155 of file usb_task.h.

Referenced by usb_host_task().

 
#define Ack_user_request_suspend (  )     (otg_user_request &= ~USER_RQST_SUSPEND)

Definition at line 156 of file usb_task.h.

Referenced by usb_device_task(), and usb_host_task().

 
#define Is_user_requested_vbus (  )     (((otg_user_request&USER_RQST_VBUS) != 0) ? TRUE : FALSE)

Definition at line 159 of file usb_task.h.

Referenced by usb_host_task().

 
#define Set_user_request_vbus (  )     (otg_user_request |= USER_RQST_VBUS)

Definition at line 160 of file usb_task.h.

Referenced by otg_user_task().

 
#define Ack_user_request_vbus (  )     (otg_user_request &= ~USER_RQST_VBUS)

Definition at line 161 of file usb_task.h.

Referenced by usb_host_task().

 
#define Is_user_requested_hnp (  )     (((otg_user_request&USER_RQST_HNP) != 0) ? TRUE : FALSE)

Definition at line 164 of file usb_task.h.

Referenced by usb_device_task(), usb_general_interrupt(), and usb_host_task().

 
#define Set_user_request_hnp (  )     (otg_user_request |= USER_RQST_HNP)

Definition at line 165 of file usb_task.h.

Referenced by otg_user_task().

 
#define Ack_user_request_hnp (  )     (otg_user_request &= ~USER_RQST_HNP)

Definition at line 166 of file usb_task.h.

Referenced by usb_device_task(), usb_general_interrupt(), and usb_host_task().

 
#define Is_user_requested_disc (  )     (((otg_user_request&USER_RQST_DISCONNECT) != 0) ? TRUE : FALSE)

Definition at line 169 of file usb_task.h.

Referenced by usb_device_task(), and usb_host_task().

 
#define Set_user_request_disc (  )     (otg_user_request |= USER_RQST_DISCONNECT)

Definition at line 170 of file usb_task.h.

Referenced by usb_host_task().

 
#define Ack_user_request_disc (  )     (otg_user_request &= ~USER_RQST_DISCONNECT)

Definition at line 171 of file usb_task.h.

Referenced by usb_device_task().

 
#define Clear_all_user_request (  )     (otg_user_request = 0)

Definition at line 186 of file usb_task.h.

Referenced by usb_device_task(), usb_general_interrupt(), usb_host_task(), and usb_task_init().

 
#define Otg_timer_init (  ) 

Value:

This macro initializes the timer for OTG specific timings.

The corresponding timer is selected in conf_usb.h An IT is launched every 2ms when CPU runned at 8 MHz

Parameters:
none 
Returns:
none

Definition at line 199 of file usb_task.h.

Referenced by usb_task_init().

#define OTG_COMPLIANCE_TRICKS   DISABLED

Enable some additionnal feature to pass compliance plan.

This feature must be ENABLED to pass the OTG compliance program (FS-A-UUT tests TD4.5-2.9ms and TD4.6) Possible values are : ENABLE to add a special feature to OTG firmware : the problem comes from the disconnection delay of A-PERIPH once it has detected a Suspend condition. This delay is 3ms, but compliance test is not enough precise. This feature waits 500µs freezing clock when it notices that SOF are missing DISABLE to disable this feature (that may lead to malfunction in original cases)

Definition at line 268 of file usb_task.h.

#define OTG_VBUS_AUTO_AFTER_A_PLUG_INSERTION   DISABLED

Selects a Vbus delivery option.

This feature must be ENABLED to pass the OTG compliance program (Checklist OTG Protocol P23/P24) Possible values are : ENABLE to make the application initiate a session (like an answer to SRP) once A-plug inserted DISABLE to disable this feature This feature is compatible with OTG_VBUS_AUTO_WHEN_A_PLUG feature disabled

Definition at line 278 of file usb_task.h.

#define OTG_B_DEVICE_AUTORUN_HNP_IF_REQUIRED   ENABLED

ENABLE to make the B-Device run a HNP automatically if a SetFeature(b_hnp_enable) is received and Suspend detected.

This feature must be ENABLED to pass the OTG compliance program Possible values ENABLE or DISABLE

Definition at line 286 of file usb_task.h.

Referenced by usb_general_interrupt().

#define OTG_RESET_LENGTH   1

Selects the Reset Length (x11ms).

This value is the number of consecutives Reset sent by the Host

Definition at line 293 of file usb_task.h.

Referenced by usb_host_task().

#define MSG_DISPLAY_NODELAY   0xFFFF

OTG Messaging definitions "No Silent Failure" rule makes any OTG compliant device handle messaging functions Differents means are supported : LCD display, LEDs, etc.

Definition at line 302 of file usb_task.h.

#define OTG_TEMPO_1SEC   0x01F4

Definition at line 303 of file usb_task.h.

#define OTG_TEMPO_2SEC   0x03E8

Definition at line 304 of file usb_task.h.

Referenced by usb_device_task(), and usb_host_task().

#define OTG_TEMPO_3SEC   0x05DC

Definition at line 305 of file usb_task.h.

Referenced by usb_device_task(), usb_host_task(), and usb_task().

#define OTG_TEMPO_4SEC   0x07D0

Definition at line 306 of file usb_task.h.

Referenced by host_send_control(), usb_device_task(), and usb_host_task().

#define OTR_TEMPO_5SEC   0x09C4

Definition at line 307 of file usb_task.h.

#define OTGMSG_SRP_STARTED   1

Definition at line 310 of file usb_task.h.

Referenced by usb_device_task().

#define OTGMSG_SRP_A_NO_RESP   2

Definition at line 311 of file usb_task.h.

Referenced by Otg_output_failure_msg(), and usb_device_task().

#define OTGMSG_A_RESPONDED   3

Definition at line 312 of file usb_task.h.

Referenced by usb_device_task().

#define OTGMSG_CONNECTED_TO_A   4

Definition at line 313 of file usb_task.h.

Referenced by usb_device_task().

#define OTGMSG_UNSUPPORTED   5

Definition at line 314 of file usb_task.h.

Referenced by Otg_output_failure_msg(), and usb_host_task().

#define OTGMSG_UNSUPPORTED_HUB   6

Definition at line 315 of file usb_task.h.

Referenced by Otg_output_failure_msg(), and usb_host_task().

#define OTGMSG_SRP_RECEIVED   7

Definition at line 316 of file usb_task.h.

Referenced by usb_host_task().

#define OTGMSG_DEVICE_NO_RESP   8

Definition at line 317 of file usb_task.h.

Referenced by host_send_control(), Otg_output_failure_msg(), usb_device_task(), and usb_host_task().

#define OTGMSG_VBUS_SURCHARGE   9

Definition at line 318 of file usb_task.h.

Referenced by usb_host_task(), and usb_task().

#define OTGSTR_SRP_STARTED   "SRP Initiated "

Definition at line 321 of file usb_task.h.

#define OTGSTR_SRP_A_NO_RESP   "A-Dev No Response "

Definition at line 322 of file usb_task.h.

#define OTGSTR_A_RESPONDED   "A-Device Responded"

Definition at line 323 of file usb_task.h.

#define OTGSTR_CONNECTED_TO_A   "Connected to A-Dev"

Definition at line 324 of file usb_task.h.

#define OTGSTR_UNSUPPORTED   "Unsupported Device"

Definition at line 325 of file usb_task.h.

#define OTGSTR_UNSUPPORTED_HUB   "Hub Unsuppported "

Definition at line 326 of file usb_task.h.

#define OTGSTR_SRP_RECEIVED   "SRP Received "

Definition at line 327 of file usb_task.h.

#define OTGSTR_DEVICE_NO_RESP   "Device No Response"

Definition at line 328 of file usb_task.h.

#define OTGSTR_VBUS_SURCHARGE   "VBUS OverCurrent !"

Definition at line 329 of file usb_task.h.

#define OTGMSG_NONE   0

Definition at line 335 of file usb_task.h.

#define OTGMSG_FAIL   1

Definition at line 336 of file usb_task.h.

#define OTGMSG_ALL   2

Definition at line 337 of file usb_task.h.

#define Otg_messaging_init ( void   ) 

Definition at line 368 of file usb_task.h.

Referenced by Otg_message_task_init().

#define Otg_print_new_event_message ( str,
tm   ) 

Definition at line 369 of file usb_task.h.

Referenced by usb_device_task(), usb_host_task(), and usb_task().

 
#define Otg_clear_event_message (  ) 

Definition at line 370 of file usb_task.h.

Referenced by Otg_message_task().

 
#define Get_event_msg_delay (  ) 

Definition at line 371 of file usb_task.h.

Referenced by Otg_message_task(), and otg_timer_interrupt().

 
#define Decrement_event_msg_delay (  ) 

Definition at line 372 of file usb_task.h.

Referenced by otg_timer_interrupt().

#define Otg_print_new_failure_message ( str,
tm   ) 

Definition at line 373 of file usb_task.h.

Referenced by host_send_control(), usb_device_task(), and usb_host_task().

 
#define Otg_clear_failure_message (  ) 

Definition at line 374 of file usb_task.h.

Referenced by Otg_message_task().

 
#define Get_failure_msg_delay (  ) 

Definition at line 375 of file usb_task.h.

Referenced by Otg_message_task(), and otg_timer_interrupt().

 
#define Decrement_failure_msg_delay (  ) 

Definition at line 376 of file usb_task.h.

Referenced by otg_timer_interrupt().


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 211 of file usb_task.c.

References B_IDLE, BDEV_HNP_NB_RETRY, Clear_all_user_request, device_state, DEVICE_UNATTACHED, DISABLED, ENABLED, EVT_USB_HOST_FUNCTION, g_old_usb_mode, g_usb_mode, id_changed_to_host_event, Is_usb_id_device, otg_b_device_state, otg_device_nb_hnp_retry, Otg_message_task_init(), Otg_timer_init, 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_host_task_init(), USB_MODE_DEVICE, USB_MODE_HOST, USB_MODE_UNDEFINED, and Usb_send_event.

00212 {
00213    #if (USB_HOST_FEATURE == ENABLED && USB_DEVICE_FEATURE == ENABLED)
00214    U8 delay;
00215    #endif
00216 
00217    #if (USE_USB_PADS_REGULATOR==ENABLE)  // Otherwise assume USB PADs regulator is not used
00218    Usb_enable_regulator();
00219    #endif
00220 
00221 // ---- DUAL ROLE DEVICE USB MODE ---------------------------------------------
00222 #if (USB_OTG_FEATURE == ENABLED)
00223    Otg_message_task_init();       // OTG program needs to display event messages to the user
00224    Otg_timer_init();              // OTG program requires TIMER1 or 3 to handle several OTG specific timings
00225    otg_b_device_state = B_IDLE;   // init state machines variables
00226    device_state = DEVICE_UNATTACHED;
00227    otg_device_nb_hnp_retry = BDEV_HNP_NB_RETRY;
00228    Clear_all_user_request();
00229 #endif
00230 
00231 #if (((USB_DEVICE_FEATURE == ENABLED) && (USB_HOST_FEATURE == ENABLED)) || (USB_OTG_FEATURE == ENABLED))
00232    Usb_enable_uid_pin();
00233    delay=PORTA;
00234    g_usb_mode=USB_MODE_UNDEFINED;
00235    if(Is_usb_id_device())
00236    {
00237      g_usb_mode=USB_MODE_DEVICE;
00238      usb_device_task_init();
00239      #if ((OTG_VBUS_AUTO_AFTER_A_PLUG_INSERTION == ENABLED) && (USB_OTG_FEATURE == ENABLED))
00240      id_changed_to_host_event = DISABLED;
00241      #endif
00242    }
00243    else
00244    {
00245      Usb_send_event(EVT_USB_HOST_FUNCTION);
00246      g_usb_mode=USB_MODE_HOST;
00247      Usb_ack_id_transition(); // REQUIRED !!! Startup with ID=0, Ack ID pin transistion (default hwd start up is device mode)
00248      Usb_enable_id_interrupt();
00249      Enable_interrupt();
00250      usb_host_task_init();
00251      #if ((OTG_VBUS_AUTO_AFTER_A_PLUG_INSERTION == ENABLED) && (USB_OTG_FEATURE == ENABLED))
00252      id_changed_to_host_event = ENABLED;
00253      #endif
00254    }
00255    g_old_usb_mode = g_usb_mode;   // Store current usb mode, for mode change detection
00256 // -----------------------------------------------------------------------------
00257 
00258 // ---- DEVICE ONLY USB MODE ---------------------------------------------------
00259 #elif ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == DISABLE))
00260    Usb_force_device_mode();
00261    usb_device_task_init();
00262 // -----------------------------------------------------------------------------
00263 
00264 // ---- REDUCED HOST ONLY USB MODE ---------------------------------------------
00265 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLED))
00266    Usb_force_host_mode();
00267    usb_host_task_init();
00268 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE))
00269    #error  at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled
00270 #endif
00271 // -----------------------------------------------------------------------------
00272 
00273 }

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 corresponding usb management function.

Parameters:
none 
Returns:
none

Definition at line 285 of file usb_task.c.

References g_old_usb_mode, g_usb_mode, Is_usb_id_device, Is_vbus_overcurrent, log_id_change, LOG_STR_CODE, Otg_message_task(), Otg_print_new_event_message, OTG_TEMPO_3SEC, OTGMSG_VBUS_SURCHARGE, Set_otg_custom_timer, SRPMINDET_100US, usb_device_task(), usb_host_task(), USB_MODE_DEVICE, USB_MODE_HOST, USB_MODE_UNDEFINED, Usb_select_data_srp_method, Usb_select_vbus_srp_method, VBUSPULSE_40MS, VBUSRISE_70MS, VFALLTMOUT_131MS, Wdt_change_16ms, and Wdt_change_enable.

00286 {
00287 
00288 // ---- OTG DEVICE ------------------------------------------------------------
00289 //#if (USB_OTG_FEATURE == ENABLED)
00290 
00291 
00292 
00293 
00294 // ---- DUAL ROLE DEVICE USB MODE ---------------------------------------------
00295 #if ((USB_DEVICE_FEATURE == ENABLED) && (USB_HOST_FEATURE == ENABLED))
00296    if(Is_usb_id_device())
00297    { g_usb_mode=USB_MODE_DEVICE;}
00298    else
00299    { g_usb_mode=USB_MODE_HOST;}
00300   // TODO !!! ID pin hot state change
00301   // Preliminary management: HARDWARE RESET !!!
00302    #if ( ID_PIN_CHANGE_GENERATE_RESET == ENABLE)
00303      // Hot ID transition generates wdt reset
00304       if((g_old_usb_mode!=g_usb_mode))
00305       #ifndef  AVRGCC
00306          {Wdt_change_16ms(); while(1);   LOG_STR_CODE(log_id_change);}
00307       #else
00308          {Wdt_change_enable(); while(1); LOG_STR_CODE(log_id_change);}
00309       #endif
00310 
00311    #endif
00312   g_old_usb_mode=g_usb_mode;   // Store current usb mode, for mode change detection
00313   // Depending on current usb mode, launch the correct usb task (device or host)
00314   
00315    #if (USB_OTG_FEATURE == ENABLED)  
00316      // Configure OTG timers
00317      Set_otg_custom_timer(VBUSRISE_70MS);
00318      Set_otg_custom_timer(VBUSPULSE_40MS);
00319      Set_otg_custom_timer(VFALLTMOUT_131MS);
00320      Set_otg_custom_timer(SRPMINDET_100US);
00321    #endif
00322    
00323    switch(g_usb_mode)
00324    {
00325       case USB_MODE_DEVICE:
00326          usb_device_task();
00327          break;
00328 
00329       case USB_MODE_HOST:
00330          #if (OTG_ADEV_SRP_REACTION == VBUS_PULSE)
00331            Usb_select_vbus_srp_method();
00332          #else
00333            Usb_select_data_srp_method();
00334          #endif
00335          usb_host_task();
00336          // Handle Vbus overcurrent error (auto-disabled if not supported or not defined in board driver file)
00337          #if (USB_OTG_FEATURE == ENABLED)
00338          if (Is_vbus_overcurrent())
00339          {
00340            Otg_print_new_event_message(OTGMSG_VBUS_SURCHARGE,OTG_TEMPO_3SEC);
00341          }
00342          #endif
00343          break;
00344 
00345       case USB_MODE_UNDEFINED:  // No break !
00346       default:
00347          break;
00348    }
00349 // -----------------------------------------------------------------------------
00350 
00351 // ---- DEVICE ONLY USB MODE ---------------------------------------------------
00352 #elif ((USB_DEVICE_FEATURE == ENABLED)&& (USB_HOST_FEATURE == DISABLE))
00353    usb_device_task();
00354 // -----------------------------------------------------------------------------
00355 
00356 // ---- REDUCED HOST ONLY USB MODE ---------------------------------------------
00357 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == ENABLED))
00358    usb_host_task();
00359 // -----------------------------------------------------------------------------
00360 
00362 #elif ((USB_DEVICE_FEATURE == DISABLE)&& (USB_HOST_FEATURE == DISABLE))
00363    #error  at least one of USB_DEVICE_FEATURE or USB_HOST_FEATURE should be enabled
00364    #error  otherwise the usb task has nothing to do ...
00365 #endif
00366 // -----------------------------------------------------------------------------
00367 
00368 #if (USB_OTG_FEATURE == ENABLED)
00369    Otg_message_task();
00370 #endif
00371 }

Here is the call graph for this function:

void otg_not_supported_device ( void   ) 

Definition at line 1046 of file usb_task.c.

References EVT_OTG_DEV_UNSUPPORTED, and Otg_send_event.

01047 {
01048   Otg_send_event(EVT_OTG_DEV_UNSUPPORTED);
01049 }


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 90 of file usb_task.c.

U8 g_usb_mode

Public : (U8) g_usb_mode Used in dual role application (both device/host) to store the current mode the usb controller is operating /.

Definition at line 139 of file usb_task.c.

Referenced by usb_general_interrupt(), usb_task(), and usb_task_init().

U8 remote_wakeup_feature

Public : (U8) remote_wakeup_feature Store a host request for remote wake up (set feature received) /.

Definition at line 114 of file usb_task.c.

Referenced by usb_device_task(), usb_general_interrupt(), and usb_set_feature().

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 125 of file usb_task.c.

Referenced by host_get_data(), host_get_data_interrupt(), host_send_data(), host_send_data_interrupt(), usb_general_interrupt(), and usb_pipe_interrupt().

volatile U8 otg_features_supported

External public declarations for OTG features.

Parameters:
none 
Returns:
none

Definition at line 149 of file usb_task.c.

Referenced by host_check_OTG_features(), usb_general_interrupt(), and usb_set_feature().

U8 otg_user_request

Public : (U8) otg_user_request; Store the last request of the user (see usb_device_task.h).

Definition at line 153 of file usb_task.c.

volatile U16 g_otg_event

Public : (U16) g_otg_event; Contains several bits corresponding to differents OTG events (similar to g_usb_event).

Definition at line 165 of file usb_task.c.

U8 id_changed_to_host_event

Definition at line 172 of file usb_task.c.

Referenced by usb_general_interrupt(), usb_host_task(), and usb_task_init().

U16 otg_msg_event_delay

Public : (U16) otg_msg_event_delay; Contains the current display duration of the OTG event message.

Definition at line 157 of file usb_task.c.

Referenced by Otg_message_task_init().

U16 otg_msg_failure_delay

Public : (U16) otg_msg_failure_delay; Contains the current display duration of the OTG failure message.

Definition at line 161 of file usb_task.c.

Referenced by Otg_message_task_init().


Generated on Mon Feb 19 09:32:15 2007 for Atmel by  doxygen 1.5.1-p1