USB host enumeration functions module


Data Structures

struct  S_usb_setup_data
 Usb Setup Data. More...
struct  S_interface

Defines

#define REQUEST_TYPE_POS   0
#define REQUEST_POS   1
#define VALUE_HIGH_POS   2
#define VALUE_LOW_POS   3
#define INDEX_HIGH_POS   4
#define INDEX_LOW_POS   5
#define LENGTH_HIGH_POS   6
#define LENGTH_LOW_POS   7
#define UNCOMPLETE_READ_POS   8
#define DATA_ADDR_HIGH_POS   9
#define DATA_ADDR_LOW_POS   10
#define CONTROL_GOOD   0
#define CONTROL_DATA_TOGGLE   0x01
#define CONTROL_DATA_PID   0x02
#define CONTROL_PID   0x04
#define CONTROL_TIMEOUT   0x08
#define CONTROL_CRC16   0x10
#define CONTROL_STALL   0x20
#define CONTROL_NO_DEVICE   0x40
 Set of defines for offset in data stage.
#define OFFSET_FIELD_MAXPACKETSIZE   7
#define OFFSET_FIELD_MSB_VID   9
#define OFFSET_FIELD_LSB_VID   8
#define OFFSET_FIELD_MSB_PID   11
#define OFFSET_FIELD_LSB_PID   10
#define OFFSET_DESCRIPTOR_LENGHT   0
#define OFFSET_FIELD_DESCRIPTOR_TYPE   1
#define OFFSET_FIELD_TOTAL_LENGHT   2
#define OFFSET_FIELD_BMATTRIBUTES   7
#define OFFSET_FIELD_MAXPOWER   8
#define OFFSET_FIELD_OTG_FEATURES   2
#define OFFSET_FIELD_NB_INTERFACE   4
 OFFSET for INTERFACE DESCRIPTORS.
#define OFFSET_FIELD_CLASS   5
#define OFFSET_FIELD_SUB_CLASS   6
#define OFFSET_FIELD_PROTOCOL   7
#define OFFSET_FIELD_INTERFACE_NB   2
#define OFFSET_FIELD_ALT   3
#define OFFSET_FIELS_NB_OF_EP   4
#define OFFSET_FIELD_EP_ADDR   2
#define OFFSET_FIELD_EP_TYPE   3
#define OFFSET_FIELD_EP_SIZE   4
#define OFFSET_FIELD_EP_INTERVAL   6
#define OFFSET_DEV_DESC_CLASS   4
 defines for Hub detection
#define HUB_CLASS_CODE   9
#define HOST_FALSE   0
#define HOST_TRUE   1
#define host_clear_endpoint_feature(ep)
 host_clear_endpoint_featurethis function send a clear endpoint request
#define host_get_configuration()
 host_get_configurationthis function send a get configuration request
#define host_set_configuration(cfg_nb)
 host_set_configurationthis function send a set configuration request
#define host_set_interface(interface_nb, alt_setting)
 host_set_interfacethis function send a set interface request to specify a specific alt setting for an interface
#define host_get_device_descriptor_uncomplete()
 host_get_device_descriptor_uncompletethis function send a get device desriptor request. The descriptor table received is stored in data_stage array. The received descriptors is limited to the control pipe lenght
#define host_get_device_descriptor()
 host_get_device_descriptorthis function send a get device desriptor request. The descriptor table received is stored in data_stage array.
#define host_get_configuration_descriptor()
 host_get_configuration_descriptorthis function send a get device configuration request. The configuration descriptor table received is stored in data_stage array.
#define host_get_descriptor_uncomplete()
#define host_set_address(addr)
 host_set_addressthis function send a set address request.
#define host_set_feature_remote_wakeup()
 host_set_feature_remote_wakeupthis function send a set feature device remote wakeup
#define host_set_feature_a_hnp_support()
 host_set_feature_a_hnp_supportThis function send a set feature "a_hnp_support" to tell to B-Device that A-Device support HNP
#define host_set_feature_b_hnp_enable()
 host_set_feature_b_hnp_enableThis function send a set feature "b_hnp_enable" to make B-Device initiating a HNP
#define host_ms_get_max_lun()
 host_ms_get_max_lunthis function send the mass storage specific request "get max lun"
#define Get_VID()   (device_VID)
 Get_VIDthis function returns the VID of the device connected.
#define Get_PID()   (device_PID)
 Get_PIDthis function returns the PID of the device connected.
#define Get_maxpower()   (maxpower)
 Get_maxpowerthis function returns the maximum power consumption ot hte connected device (unit is 2mA).
#define Get_class(s_interface)   (interface_supported[s_interface].class)
 this function returns the USB class associated to the specified interface
#define Get_subclass(s_interface)   (interface_supported[s_interface].subclass)
 this function returns the USB subclass associated to the specified interface
#define Get_protocol(s_interface)   (interface_supported[s_interface].protocol)
 this function returns the USB protocol associated to the specified interface
#define Get_ep_addr(s_interface, n_ep)   (interface_supported[s_interface].ep_addr[n_ep])
 this function returns endpoint address associated to the specified interface and endpoint number in this interface.
#define Get_nb_ep(s_interface)   (interface_supported[s_interface].nb_ep)
 this function returns number of endpoints associated to a supported interface.
#define Get_alts_s(s_interface)   (interface_supported[s_interface].altset_nb)
 this function returns number of the alternate setting field associated to a supported interface.
#define Get_interface_number(s_interface)   (interface_supported[s_interface].interface_nb)
 this function returns number of the interface number associated to a supported interface.
#define Get_nb_supported_interface()   (nb_interface_supported)
 this function returns the number of interface supported in the device connected
#define Is_device_self_powered()   ((bmattributes & (1<<BIT_SELF_POWERED)) ? TRUE : FALSE)
 this function returns true if the device connected is self powered
#define Is_device_supports_remote_wakeup()   ((bmattributes & (1<<BIT_REMOTE_WAKEUP)) ? TRUE : FALSE)
 this function returns true if the device supports remote wake_up
#define Is_device_supports_srp()   ((otg_features_supported & (1<<BIT_SRP_SUPPORT)) ? TRUE : FALSE)
 this function returns true if the device supports SRP
#define Is_device_supports_hnp()   ((otg_features_supported & (1<<BIT_HNP_SUPPORT)) ? TRUE : FALSE)
 this function returns true if the device supports HNP

Functions

U8 host_send_control (U8 *)
 host_send_control.This function is the generic Pipe 0 management function This function is used to send and receive control request over pipe 0
U8 host_check_VID_PID (void)
 host_check_VID_PIDThis function checks if the VID and the PID are supported (if the VID/PID belongs to the VID_PID table)
U8 host_check_OTG_features (void)
 host_check_OTG_featuresThis function checks if the OTG descriptor has been received and indicates which features are supported
U8 host_check_class (void)
 host_check_classThis function checks if the device class is supported. The function looks in all interface declared in the received dewcriptors, if one of them match with the CLASS/SUB_CLASS/PROTOCOL table
U8 host_auto_configure_endpoint ()
 This function configures the pipe according to the device class of the interface selected.
U8 get_interface_descriptor_offset (U8 interface, U8 alt)
 get_interface_descriptor_offsetThis function returns the offset in data_stage where to find the interface descriptor whose number and alternate setting values are passed as parameters
U8 host_get_hwd_pipe_nb (U8 ep_addr)
 This function returns the physical pipe number linked to a logical endpoint address.

Variables

S_usb_setup_data usb_request
 For control requests management over pipe 0.
U8 data_stage [SIZEOF_DATA_STAGE]
 Public : U8 data_stage[SIZEOF_DATA_STAGE]; Internal RAM buffer for USB data stage content This buffer is required to setup host enumeration process Its contains the device descriptors received.
U8 device_status
U8 nb_interface_supported
 The number of interface the host is able to support in the device connected.
S_interface interface_supported [MAX_INTERFACE_SUPPORTED]
U16 device_PID
 PID of device connected.
U16 device_VID
 VID of device connected.
U8 bmattributes
 bmAttributes byte of the connected device
U8 maxpower
 maxpower byte of the connected device (Caution, unit is 2mA)

Define Documentation

#define REQUEST_TYPE_POS   0

Definition at line 82 of file usb_host_enum.h.

#define REQUEST_POS   1

Definition at line 83 of file usb_host_enum.h.

#define VALUE_HIGH_POS   2

Definition at line 84 of file usb_host_enum.h.

#define VALUE_LOW_POS   3

Definition at line 85 of file usb_host_enum.h.

#define INDEX_HIGH_POS   4

Definition at line 86 of file usb_host_enum.h.

#define INDEX_LOW_POS   5

Definition at line 87 of file usb_host_enum.h.

#define LENGTH_HIGH_POS   6

Definition at line 88 of file usb_host_enum.h.

#define LENGTH_LOW_POS   7

Definition at line 89 of file usb_host_enum.h.

#define UNCOMPLETE_READ_POS   8

Definition at line 90 of file usb_host_enum.h.

#define DATA_ADDR_HIGH_POS   9

Definition at line 91 of file usb_host_enum.h.

#define DATA_ADDR_LOW_POS   10

Definition at line 92 of file usb_host_enum.h.

#define CONTROL_GOOD   0

Definition at line 94 of file usb_host_enum.h.

Referenced by host_send_control(), and usb_host_task().

#define CONTROL_DATA_TOGGLE   0x01

Definition at line 95 of file usb_host_enum.h.

#define CONTROL_DATA_PID   0x02

Definition at line 96 of file usb_host_enum.h.

#define CONTROL_PID   0x04

Definition at line 97 of file usb_host_enum.h.

#define CONTROL_TIMEOUT   0x08

Definition at line 98 of file usb_host_enum.h.

Referenced by host_send_control().

#define CONTROL_CRC16   0x10

Definition at line 99 of file usb_host_enum.h.

#define CONTROL_STALL   0x20

Definition at line 100 of file usb_host_enum.h.

Referenced by host_send_control().

#define CONTROL_NO_DEVICE   0x40

Set of defines for offset in data stage.

Definition at line 101 of file usb_host_enum.h.

#define OFFSET_FIELD_MAXPACKETSIZE   7

Definition at line 105 of file usb_host_enum.h.

Referenced by usb_host_task().

#define OFFSET_FIELD_MSB_VID   9

Definition at line 106 of file usb_host_enum.h.

Referenced by host_check_VID_PID().

#define OFFSET_FIELD_LSB_VID   8

Definition at line 107 of file usb_host_enum.h.

Referenced by host_check_VID_PID().

#define OFFSET_FIELD_MSB_PID   11

Definition at line 108 of file usb_host_enum.h.

Referenced by host_check_VID_PID().

#define OFFSET_FIELD_LSB_PID   10

Definition at line 109 of file usb_host_enum.h.

Referenced by host_check_VID_PID().

#define OFFSET_DESCRIPTOR_LENGHT   0

Definition at line 111 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset(), host_auto_configure_endpoint(), and host_check_OTG_features().

#define OFFSET_FIELD_DESCRIPTOR_TYPE   1

Definition at line 112 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset(), host_auto_configure_endpoint(), host_check_class(), and host_check_OTG_features().

#define OFFSET_FIELD_TOTAL_LENGHT   2

Definition at line 113 of file usb_host_enum.h.

Referenced by host_check_class(), and host_check_OTG_features().

#define OFFSET_FIELD_BMATTRIBUTES   7

Definition at line 114 of file usb_host_enum.h.

Referenced by host_check_class().

#define OFFSET_FIELD_MAXPOWER   8

Definition at line 115 of file usb_host_enum.h.

Referenced by host_check_class().

#define OFFSET_FIELD_OTG_FEATURES   2

Definition at line 117 of file usb_host_enum.h.

Referenced by host_check_OTG_features().

#define OFFSET_FIELD_NB_INTERFACE   4

OFFSET for INTERFACE DESCRIPTORS.

Definition at line 120 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset().

#define OFFSET_FIELD_CLASS   5

Definition at line 121 of file usb_host_enum.h.

Referenced by host_check_class().

#define OFFSET_FIELD_SUB_CLASS   6

Definition at line 122 of file usb_host_enum.h.

Referenced by host_check_class().

#define OFFSET_FIELD_PROTOCOL   7

Definition at line 123 of file usb_host_enum.h.

Referenced by host_check_class().

#define OFFSET_FIELD_INTERFACE_NB   2

Definition at line 125 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset(), and host_check_class().

#define OFFSET_FIELD_ALT   3

Definition at line 126 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset(), and host_check_class().

#define OFFSET_FIELS_NB_OF_EP   4

Definition at line 127 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint(), and host_check_class().

#define OFFSET_FIELD_EP_ADDR   2

Definition at line 129 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint().

#define OFFSET_FIELD_EP_TYPE   3

Definition at line 130 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint().

#define OFFSET_FIELD_EP_SIZE   4

Definition at line 131 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint().

#define OFFSET_FIELD_EP_INTERVAL   6

Definition at line 132 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint().

#define OFFSET_DEV_DESC_CLASS   4

defines for Hub detection

Definition at line 135 of file usb_host_enum.h.

Referenced by usb_host_task().

#define HUB_CLASS_CODE   9

Definition at line 136 of file usb_host_enum.h.

Referenced by usb_host_task().

#define HOST_FALSE   0

Definition at line 139 of file usb_host_enum.h.

Referenced by get_interface_descriptor_offset(), host_auto_configure_endpoint(), host_check_class(), host_check_OTG_features(), host_check_VID_PID(), host_get_data_interrupt(), host_send_data_interrupt(), and usb_host_task().

#define HOST_TRUE   1

Definition at line 140 of file usb_host_enum.h.

Referenced by host_auto_configure_endpoint(), host_check_class(), host_check_OTG_features(), host_check_VID_PID(), host_get_data_interrupt(), host_send_data_interrupt(), and usb_host_task().

#define host_clear_endpoint_feature ( ep   ) 

Value:

host_clear_endpoint_featurethis function send a clear endpoint request

Parameters:
U8 ep (the target endpoint nb)
Returns:
status

Definition at line 153 of file usb_host_enum.h.

 
#define host_get_configuration (  ) 

Value:

host_get_configurationthis function send a get configuration request

Parameters:
none 
Returns:
status

Definition at line 169 of file usb_host_enum.h.

#define host_set_configuration ( cfg_nb   ) 

Value:

host_set_configurationthis function send a set configuration request

Parameters:
U8 configuration numer to activate
Returns:
status

Definition at line 185 of file usb_host_enum.h.

Referenced by usb_host_task().

#define host_set_interface ( interface_nb,
alt_setting   ) 

Value:

host_set_interfacethis function send a set interface request to specify a specific alt setting for an interface

Parameters:
U8 interface_nb (the interface) U8 alt_setting (the alternate setting to activate)
Returns:
status

Definition at line 203 of file usb_host_enum.h.

 
#define host_get_device_descriptor_uncomplete (  ) 

Value:

host_get_device_descriptor_uncompletethis function send a get device desriptor request. The descriptor table received is stored in data_stage array. The received descriptors is limited to the control pipe lenght

Parameters:
none 
Returns:
status

Definition at line 224 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_get_device_descriptor (  ) 

Value:

host_get_device_descriptorthis function send a get device desriptor request. The descriptor table received is stored in data_stage array.

Parameters:
none 
Returns:
status

Definition at line 244 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_get_configuration_descriptor (  ) 

Value:

host_get_configuration_descriptorthis function send a get device configuration request. The configuration descriptor table received is stored in data_stage array.

Parameters:
none 
Returns:
status

Definition at line 263 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_get_descriptor_uncomplete (  ) 

Value:

Definition at line 271 of file usb_host_enum.h.

#define host_set_address ( addr   ) 

Value:

host_set_addressthis function send a set address request.

Parameters:
U8 address (the addr attributed to the device)
Returns:
status

Definition at line 289 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_set_feature_remote_wakeup (  ) 

Value:

host_set_feature_remote_wakeupthis function send a set feature device remote wakeup

Parameters:
none 
Returns:
status

Definition at line 306 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_set_feature_a_hnp_support (  ) 

Value:

host_set_feature_a_hnp_supportThis function send a set feature "a_hnp_support" to tell to B-Device that A-Device support HNP

Parameters:
none 
Returns:
status

Definition at line 324 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_set_feature_b_hnp_enable (  ) 

Value:

host_set_feature_b_hnp_enableThis function send a set feature "b_hnp_enable" to make B-Device initiating a HNP

Parameters:
none 
Returns:
status

Definition at line 341 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define host_ms_get_max_lun (  ) 

Value:

host_ms_get_max_lunthis function send the mass storage specific request "get max lun"

Parameters:
none 
Returns:
status

Definition at line 362 of file usb_host_enum.h.

 
#define Get_VID (  )     (device_VID)

Get_VIDthis function returns the VID of the device connected.

Parameters:
none 
Returns:
U16 (VID value)

Definition at line 380 of file usb_host_enum.h.

 
#define Get_PID (  )     (device_PID)

Get_PIDthis function returns the PID of the device connected.

Parameters:
none 
Returns:
U16 (PID value)

Definition at line 392 of file usb_host_enum.h.

 
#define Get_maxpower (  )     (maxpower)

Get_maxpowerthis function returns the maximum power consumption ot hte connected device (unit is 2mA).

Parameters:
none 
Returns:
U8 (maxpower value)

Definition at line 404 of file usb_host_enum.h.

#define Get_class ( s_interface   )     (interface_supported[s_interface].class)

this function returns the USB class associated to the specified interface

Parameters:
U8 s_interface: the supported interface number
Returns:
U16 (CLASS code)

Definition at line 413 of file usb_host_enum.h.

Referenced by otg_user_task().

#define Get_subclass ( s_interface   )     (interface_supported[s_interface].subclass)

this function returns the USB subclass associated to the specified interface

Parameters:
U8 s_interface: the supported interface number
Returns:
U16 (SUBCLASS code)

Definition at line 422 of file usb_host_enum.h.

#define Get_protocol ( s_interface   )     (interface_supported[s_interface].protocol)

this function returns the USB protocol associated to the specified interface

Parameters:
U8 s_interface: the supported interface number
Returns:
U16 (protocol code)

Definition at line 431 of file usb_host_enum.h.

Referenced by otg_user_task().

#define Get_ep_addr ( s_interface,
n_ep   )     (interface_supported[s_interface].ep_addr[n_ep])

this function returns endpoint address associated to the specified interface and endpoint number in this interface.

Parameters:
U8 s_interface: the supported interface number
U8 n_ep: the endpoint number in this interface
Returns:
U8 (endpoint address)

Definition at line 442 of file usb_host_enum.h.

Referenced by otg_user_task().

#define Get_nb_ep ( s_interface   )     (interface_supported[s_interface].nb_ep)

this function returns number of endpoints associated to a supported interface.

Parameters:
U8 s_interface: the supported interface number
Returns:
U8 (number of enpoints)

Definition at line 452 of file usb_host_enum.h.

#define Get_alts_s ( s_interface   )     (interface_supported[s_interface].altset_nb)

this function returns number of the alternate setting field associated to a supported interface.

Parameters:
U8 s_interface: the supported interface number
Returns:
U8 (number of alt setting value)

Definition at line 462 of file usb_host_enum.h.

#define Get_interface_number ( s_interface   )     (interface_supported[s_interface].interface_nb)

this function returns number of the interface number associated to a supported interface.

Parameters:
U8 s_interface: the supported interface number
Returns:
U8 (number of the interface)

Definition at line 472 of file usb_host_enum.h.

 
#define Get_nb_supported_interface (  )     (nb_interface_supported)

this function returns the number of interface supported in the device connected

Parameters:
none 
Returns:
U8 : The number of interface

Definition at line 481 of file usb_host_enum.h.

Referenced by otg_user_task().

 
#define Is_device_self_powered (  )     ((bmattributes & (1<<BIT_SELF_POWERED)) ? TRUE : FALSE)

this function returns true if the device connected is self powered

Parameters:
none 
Returns:
U8 : The number of interface

Definition at line 490 of file usb_host_enum.h.

 
#define Is_device_supports_remote_wakeup (  )     ((bmattributes & (1<<BIT_REMOTE_WAKEUP)) ? TRUE : FALSE)

this function returns true if the device supports remote wake_up

Parameters:
none 
Returns:
U8 : The number of interface

Definition at line 499 of file usb_host_enum.h.

Referenced by usb_host_task().

 
#define Is_device_supports_srp (  )     ((otg_features_supported & (1<<BIT_SRP_SUPPORT)) ? TRUE : FALSE)

this function returns true if the device supports SRP

Parameters:
none 
Returns:
U8 : SRP status

Definition at line 508 of file usb_host_enum.h.

 
#define Is_device_supports_hnp (  )     ((otg_features_supported & (1<<BIT_HNP_SUPPORT)) ? TRUE : FALSE)

this function returns true if the device supports HNP

Parameters:
none 
Returns:
U8 : HNP status

Definition at line 517 of file usb_host_enum.h.

Referenced by usb_host_task().


Function Documentation

U8 host_send_control ( U8 data_pointer  ) 

host_send_control.This function is the generic Pipe 0 management function This function is used to send and receive control request over pipe 0

Todo:
Fix all timeout errors and disconnection in active wait loop
Parameters:
data_pointer 
Returns:
status
Note:
This function uses the usb_request global structure as parameter. Thus this structure should be filled before calling this function.

Definition at line 439 of file usb_host_enum.c.

References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, c, CONTROL_GOOD, CONTROL_STALL, CONTROL_TIMEOUT, EVT_HOST_SOF, FALSE, Host_ack_all_errors, Host_ack_control_in, Host_ack_control_out, Host_ack_setup, Host_ack_stall, Host_data_length_U8, Host_disable_sof_interrupt, Host_enable_sof_interrupt, Host_error_status, Host_freeze_pipe, Host_get_pipe_length, Host_read_byte, Host_reset_pipe, Host_select_pipe, Host_send_control_in, Host_send_control_out, Host_send_setup, Host_set_token_in, Host_set_token_out, Host_set_token_setup, Host_standard_in_mode, Host_unfreeze_pipe, Host_write_byte, Is_host_control_in_received, Is_host_control_out_sent, Is_host_emergency_exit, Is_host_pipe_error, Is_host_setup_sent, Is_host_sof_interrupt_enabled, Is_host_stall, Is_not_usb_event, Is_timeout_bdev_response_overflow, LSB, MSB, Otg_print_new_failure_message, OTG_TEMPO_4SEC, OTGMSG_DEVICE_NO_RESP, TRUE, S_usb_setup_data::uncomplete_read, Usb_ack_event, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.

00440 {
00441 U16 data_length;
00442 U8 sav_int_sof_enable;
00443 U8 c;
00444 
00445    Usb_ack_event(EVT_HOST_SOF);
00446    sav_int_sof_enable=Is_host_sof_interrupt_enabled();
00447    Host_enable_sof_interrupt();                   // SOF software detection is in interrupt sub-routine
00448    while(Is_not_usb_event(EVT_HOST_SOF))          // Wait 1 sof
00449    {
00450       if (Is_host_emergency_exit())
00451       {
00452          c=CONTROL_TIMEOUT;
00453          Host_freeze_pipe();
00454          Host_reset_pipe(0);
00455          goto host_send_control_end;
00456       }
00457    }
00458    if (sav_int_sof_enable==FALSE)
00459    {
00460       Host_disable_sof_interrupt();
00461    }
00462 
00463    Host_select_pipe(0);
00464    Host_set_token_setup();
00465    Host_ack_setup();
00466    Host_unfreeze_pipe();
00467   // Build the setup request fields
00468    Host_write_byte(usb_request.bmRequestType);
00469    Host_write_byte(usb_request.bRequest);
00470    Host_write_byte(LSB(usb_request.wValue));
00471    Host_write_byte(MSB(usb_request.wValue));
00472    Host_write_byte(LSB(usb_request.wIndex));
00473    Host_write_byte(MSB(usb_request.wIndex));
00474    Host_write_byte(LSB(usb_request.wLength));
00475    Host_write_byte(MSB(usb_request.wLength));
00476 
00477    Host_send_setup();
00478    while(Is_host_setup_sent() == FALSE)  // wait for SETUP ack
00479    {
00480 #if (USB_OTG_FEATURE == ENABLED)
00481       if (Is_timeout_bdev_response_overflow())
00482       {
00483          Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC);
00484          c=CONTROL_TIMEOUT;
00485          Host_freeze_pipe();
00486          Host_reset_pipe(0);
00487          goto host_send_control_end;
00488       }
00489 #endif
00490       if (Is_host_emergency_exit())
00491       {
00492          c=CONTROL_TIMEOUT;
00493          Host_freeze_pipe();
00494          Host_reset_pipe(0);
00495          goto host_send_control_end;
00496       }
00497       if(Is_host_pipe_error())           // Any error ?
00498       {
00499          c = Host_error_status();
00500          Host_ack_all_errors();
00501          goto host_send_control_end;     // Send error status
00502       }
00503    }
00504   // Setup token sent now send In or OUT token
00505   // Before just wait one SOF
00506    Usb_ack_event(EVT_HOST_SOF);
00507    sav_int_sof_enable=Is_host_sof_interrupt_enabled();
00508    Host_enable_sof_interrupt();
00509    Host_freeze_pipe();
00510    data_length = usb_request.wLength;
00511    while(Is_not_usb_event(EVT_HOST_SOF))         // Wait 1 sof
00512    {
00513       if (Is_host_emergency_exit())
00514       {
00515          c=CONTROL_TIMEOUT;
00516          Host_freeze_pipe();
00517          Host_reset_pipe(0);
00518          goto host_send_control_end;
00519       }
00520    }
00521    if (sav_int_sof_enable==FALSE)
00522    {  Host_disable_sof_interrupt();  }   // Restore SOF interrupt enable
00523 
00524   // IN request management ---------------------------------------------
00525    if(usb_request.bmRequestType & 0x80)           // bmRequestType : Data stage IN (bmRequestType==1)
00526    {
00527       Host_standard_in_mode();
00528       Host_set_token_in();
00529       while(data_length != 0)
00530       {
00531          Host_unfreeze_pipe();
00532          while(!Is_host_control_in_received())
00533          {
00534             if (Is_host_emergency_exit())
00535             {
00536                c=CONTROL_TIMEOUT;
00537                Host_freeze_pipe();
00538                Host_reset_pipe(0);
00539                goto host_send_control_end;
00540             }
00541       #if (USB_OTG_FEATURE == ENABLED)
00542             if (Is_timeout_bdev_response_overflow())
00543             {
00544                Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC);
00545                c=CONTROL_TIMEOUT;
00546                Host_freeze_pipe();
00547                Host_reset_pipe(0);
00548                goto host_send_control_end;
00549             }
00550       #endif
00551             if(Is_host_pipe_error())
00552             {
00553                c = Host_error_status();
00554                Host_ack_all_errors();
00555                goto host_send_control_end;
00556             }
00557             if(Is_host_stall())
00558             {
00559                c=CONTROL_STALL;
00560                Host_ack_stall();
00561                goto host_send_control_end;
00562             }
00563          }
00564          c = Host_data_length_U8();
00565          if (c == Host_get_pipe_length())
00566          {
00567             data_length -= c;
00568             if (usb_request.uncomplete_read == TRUE)           // uncomplete_read
00569             {
00570                data_length = 0;
00571             }
00572          }
00573          else
00574          {
00575             data_length = 0;
00576          }
00577          while (c!=0)
00578          {
00579             *data_pointer = Host_read_byte();
00580             data_pointer++;
00581             c--;
00582          }
00583          Host_freeze_pipe();
00584          Host_ack_control_in();
00585          Host_send_control_in();
00586       }                                // end of IN data stage
00587 
00588       Host_set_token_out();
00589       Host_unfreeze_pipe();
00590       Host_ack_control_out();
00591       Host_send_control_out();
00592       while(!Is_host_control_out_sent())
00593       {
00594     #if (USB_OTG_FEATURE == ENABLED)
00595           if (Is_timeout_bdev_response_overflow())
00596           {
00597              Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC);
00598              c=CONTROL_TIMEOUT;
00599              Host_freeze_pipe();
00600              Host_reset_pipe(0);
00601              goto host_send_control_end;
00602           }
00603     #endif
00604          if (Is_host_emergency_exit())
00605          {
00606             c=CONTROL_TIMEOUT;
00607             Host_freeze_pipe();
00608             Host_reset_pipe(0);
00609             goto host_send_control_end;
00610          }
00611          if(Is_host_pipe_error())
00612          {
00613             c = Host_error_status();
00614             Host_ack_all_errors();
00615             goto host_send_control_end;
00616          }
00617          if(Is_host_stall())
00618          {
00619             c=CONTROL_STALL;
00620             Host_ack_stall();
00621             goto host_send_control_end;
00622          }
00623       }
00624       Host_ack_control_out();
00625       c=(CONTROL_GOOD);
00626       goto host_send_control_end;
00627    }
00628 
00629   // OUT request management ---------------------------------------------
00630    else                                 // Data stage OUT (bmRequestType==0)
00631    {
00632       Host_set_token_out();
00633       Host_ack_control_out();
00634       while(data_length != 0)
00635       {
00636          Host_unfreeze_pipe();
00637          c = Host_get_pipe_length();
00638          if ( (U16)c > data_length)
00639          {
00640             c = (U8)data_length;
00641             data_length = 0;
00642          }
00643          else
00644          {
00645             data_length -= c;
00646          }
00647          while (c!=0)
00648          {
00649             Host_write_byte(*data_pointer);
00650             data_pointer++;
00651             c--;
00652          }
00653          Host_send_control_out();
00654          while (!Is_host_control_out_sent())
00655          {
00656             if (Is_host_emergency_exit())
00657             {
00658                c=CONTROL_TIMEOUT;
00659                Host_freeze_pipe();
00660                Host_reset_pipe(0);
00661                goto host_send_control_end;
00662             }
00663       #if (USB_OTG_FEATURE == ENABLED)
00664             if (Is_timeout_bdev_response_overflow())
00665             {
00666                Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC);
00667                c=CONTROL_TIMEOUT;
00668                Host_freeze_pipe();
00669                Host_reset_pipe(0);
00670                goto host_send_control_end;
00671             }
00672       #endif
00673             if(Is_host_pipe_error())
00674             {
00675                c = Host_error_status();
00676                Host_ack_all_errors();
00677                goto host_send_control_end;
00678             }
00679             if(Is_host_stall())
00680             {
00681                c=CONTROL_STALL;
00682                Host_ack_stall();
00683                goto host_send_control_end;
00684             }
00685          }
00686          Host_ack_control_out();
00687       }                                // end of OUT data stage
00688       Host_freeze_pipe();
00689       Host_set_token_in();
00690       Host_unfreeze_pipe();
00691       while(!Is_host_control_in_received())
00692       {
00693          if (Is_host_emergency_exit())
00694          {
00695             c=CONTROL_TIMEOUT;
00696             Host_freeze_pipe();
00697             Host_reset_pipe(0);
00698             goto host_send_control_end;
00699          }
00700   #if (USB_OTG_FEATURE == ENABLED)
00701         if (Is_timeout_bdev_response_overflow())
00702         {
00703            Otg_print_new_failure_message(OTGMSG_DEVICE_NO_RESP,OTG_TEMPO_4SEC);
00704            c=CONTROL_TIMEOUT;
00705            Host_freeze_pipe();
00706            Host_reset_pipe(0);
00707            goto host_send_control_end;
00708         }
00709   #endif
00710          if(Is_host_pipe_error())
00711          {
00712             c = Host_error_status();
00713             Host_ack_all_errors();
00714             goto host_send_control_end;
00715          }
00716          if(Is_host_stall())
00717          {
00718             c=CONTROL_STALL;
00719             Host_ack_stall();
00720             goto host_send_control_end;
00721          }
00722       }
00723       Host_ack_control_in();
00724       Host_freeze_pipe();
00725       Host_send_control_in();
00726       c=(CONTROL_GOOD);
00727       goto host_send_control_end;
00728    }
00729 host_send_control_end:
00730    return ((U8)c);
00731 }

U8 host_check_VID_PID ( void   ) 

host_check_VID_PIDThis function checks if the VID and the PID are supported (if the VID/PID belongs to the VID_PID table)

Parameters:
none 
Returns:
status

Definition at line 102 of file usb_host_enum.c.

References c, data_stage, device_PID, device_VID, HOST_FALSE, HOST_TRUE, LSB, MSB, OFFSET_FIELD_LSB_PID, OFFSET_FIELD_LSB_VID, OFFSET_FIELD_MSB_PID, OFFSET_FIELD_MSB_VID, and registered_VID_PID.

Referenced by usb_host_task().

00103 {
00104 U8  c,d;
00105 
00106    // Rebuild VID PID from data stage
00107    LSB(device_VID) = data_stage[OFFSET_FIELD_LSB_VID];
00108    MSB(device_VID) = data_stage[OFFSET_FIELD_MSB_VID];
00109    LSB(device_PID) = data_stage[OFFSET_FIELD_LSB_PID];
00110    MSB(device_PID) = data_stage[OFFSET_FIELD_MSB_PID];
00111 
00112    // Compare detected VID PID with supported table
00113    c=0;
00114 
00115    while (c< sizeof(registered_VID_PID)/2)   // /2 because registered_VID_PID table is U16...
00116    {
00117       if (registered_VID_PID[c] == device_VID)   // VID is correct
00118       {
00119          d = (U8)registered_VID_PID[c+1];    // store nb of PID for this VID
00120          while (d != 0)
00121          {
00122             if (registered_VID_PID[c+d+1] == device_PID)
00123             {
00124                return HOST_TRUE;
00125             }
00126             d--;
00127          }
00128       }
00129       c+=registered_VID_PID[c+1]+2;
00130    }
00131    return HOST_FALSE;
00132 }

U8 host_check_OTG_features ( void   ) 

host_check_OTG_featuresThis function checks if the OTG descriptor has been received and indicates which features are supported

Parameters:
none 
Returns:
status

Definition at line 144 of file usb_host_enum.c.

References data_stage, HOST_FALSE, HOST_TRUE, OFFSET_DESCRIPTOR_LENGHT, OFFSET_FIELD_DESCRIPTOR_TYPE, OFFSET_FIELD_OTG_FEATURES, OFFSET_FIELD_TOTAL_LENGHT, OTG_DESCRIPTOR, OTG_DESCRIPTOR_bLength, otg_features_supported, Peripheral_is_not_otg_device, and Peripheral_is_otg_device.

Referenced by usb_host_task().

00145 {
00146   U8 index;     // variable offset used to search the OTG descriptor
00147   U8 nb_bytes;  // number of bytes of the config descriptor
00148 
00149   Peripheral_is_not_otg_device();  // init
00150   otg_features_supported = 0;
00151 
00152   nb_bytes = data_stage[OFFSET_FIELD_TOTAL_LENGHT];
00153   index = 0;
00154   if (nb_bytes > 0x09)   // check this is not a reduced/uncomplete config descriptor
00155   {
00156     while (index < nb_bytes)  // search in the descriptors
00157     {
00158       if (data_stage[index+OFFSET_FIELD_DESCRIPTOR_TYPE] != OTG_DESCRIPTOR)   // IS the pointed descriptor THE OTG DESCRIPTOR ?
00159       {
00160         index += data_stage[index+OFFSET_DESCRIPTOR_LENGHT];    // NO, skip to next descriptor
00161       }
00162       else
00163       {
00164         if (data_stage[index+OFFSET_DESCRIPTOR_LENGHT] == OTG_DESCRIPTOR_bLength)   // YES, check descriptor length
00165         {
00166           Peripheral_is_otg_device();   // an OTG descriptor has been found
00167           otg_features_supported = data_stage[index+OFFSET_FIELD_OTG_FEATURES];    // load otg features supported
00168           return HOST_TRUE;
00169         }
00170         else
00171         {
00172           return HOST_FALSE;    // bad descriptor length
00173         }
00174       }
00175     }
00176   }
00177   else
00178   {
00179     return HOST_FALSE;    // this was only a reduced/uncomplete configuration descriptor
00180   }
00181   return HOST_TRUE;
00182 }

U8 host_check_class ( void   ) 

host_check_classThis function checks if the device class is supported. The function looks in all interface declared in the received dewcriptors, if one of them match with the CLASS/SUB_CLASS/PROTOCOL table

Parameters:
none 
Returns:
status

Definition at line 197 of file usb_host_enum.c.

References S_interface::altset_nb, bmattributes, c, S_interface::class, CONFIGURATION_DESCRIPTOR, data_stage, HOST_FALSE, HOST_TRUE, INTERFACE_DESCRIPTOR, S_interface::interface_nb, interface_supported, LSB, MAX_INTERFACE_SUPPORTED, maxpower, MSB, S_interface::nb_ep, nb_interface_supported, OFFSET_FIELD_ALT, OFFSET_FIELD_BMATTRIBUTES, OFFSET_FIELD_CLASS, OFFSET_FIELD_DESCRIPTOR_TYPE, OFFSET_FIELD_INTERFACE_NB, OFFSET_FIELD_MAXPOWER, OFFSET_FIELD_PROTOCOL, OFFSET_FIELD_SUB_CLASS, OFFSET_FIELD_TOTAL_LENGHT, OFFSET_FIELS_NB_OF_EP, S_interface::protocol, registered_class, SIZEOF_DATA_STAGE, S_interface::subclass, and T_DESC_OFFSET.

Referenced by usb_host_task().

00198 {
00199 U8  c;
00200 T_DESC_OFFSET  descriptor_offset;
00201 T_DESC_OFFSET  conf_offset_end;
00202 U16  config_size;
00203 U8  device_class;
00204 U8  device_subclass;
00205 U8  device_protocol;
00206 
00207    nb_interface_supported=0;   //First asumes ,no interface is supported!
00208    if (data_stage[OFFSET_FIELD_DESCRIPTOR_TYPE] != CONFIGURATION_DESCRIPTOR)           // check if configuration descriptor
00209    { return HOST_FALSE;}
00210    LSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT];
00211    MSB(config_size) = data_stage[OFFSET_FIELD_TOTAL_LENGHT+1];
00212    bmattributes = data_stage[OFFSET_FIELD_BMATTRIBUTES];
00213    maxpower = data_stage[OFFSET_FIELD_MAXPOWER];
00214    descriptor_offset = 0;
00215    conf_offset_end = descriptor_offset + config_size;
00216 
00217    // Look in all interfaces declared in the configuration
00218    while(descriptor_offset < conf_offset_end)
00219    {
00220       // Find next interface descriptor
00221       while (data_stage[descriptor_offset+OFFSET_FIELD_DESCRIPTOR_TYPE] != INTERFACE_DESCRIPTOR)
00222       {
00223          descriptor_offset += data_stage[descriptor_offset];
00224          if(descriptor_offset >= conf_offset_end)
00225          {
00226             if(nb_interface_supported)
00227             {return HOST_TRUE;}
00228             else return HOST_FALSE;
00229          }
00230       }
00231       // Found an interface descriptor
00232       // Get charateristics of this interface
00233       device_class    = data_stage[descriptor_offset + OFFSET_FIELD_CLASS];
00234       device_subclass = data_stage[descriptor_offset + OFFSET_FIELD_SUB_CLASS];
00235       device_protocol = data_stage[descriptor_offset + OFFSET_FIELD_PROTOCOL];
00236       // Look in registered class table for match
00237       c=0;
00238       while (c< sizeof(registered_class))
00239       {
00240          if (registered_class[c] == device_class)                 // class is correct!
00241          {
00242             if (registered_class[c+1] == device_subclass)         // sub class is correct!
00243             {
00244                if (registered_class[c+2] == device_protocol)      // protocol is correct!
00245                {
00246                   // Prepare for another item CLASS/SUB_CLASS/PROTOCOL in table
00247                   c+=3;
00248                   // Store this interface as supported interface
00249                   // Memorize its interface nb
00250                   interface_supported[nb_interface_supported].interface_nb=data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB];
00251                   //          its alternate setting
00252                   interface_supported[nb_interface_supported].altset_nb=data_stage[descriptor_offset+OFFSET_FIELD_ALT];
00253                   //          its USB class
00254                   interface_supported[nb_interface_supported].class=device_class;
00255                   //          its USB subclass
00256                   interface_supported[nb_interface_supported].subclass=device_subclass;
00257                   //          its USB protocol
00258                   interface_supported[nb_interface_supported].protocol=device_protocol;
00259                   //          the number of endpoints associated to this interface
00260                   //          Note: The associated endpoints addresses are stored during pipe attribution...
00261                   interface_supported[nb_interface_supported].nb_ep=data_stage[descriptor_offset+OFFSET_FIELS_NB_OF_EP];
00262                   // Update the number of interface supported
00263                   nb_interface_supported++;
00264                   // Check the maximum number of interfaces we can support
00265                   if(nb_interface_supported>=MAX_INTERFACE_SUPPORTED)
00266                   {
00267                      return HOST_TRUE;
00268                   }
00269                }
00270             }
00271          }
00272          c+=3; // Check other item CLASS/SUB_CLASS/PROTOCOL in table
00273       }
00274       descriptor_offset += data_stage[descriptor_offset]; // Next descriptor
00275       if(descriptor_offset > SIZEOF_DATA_STAGE)           // Check overflow
00276       {
00277          if(nb_interface_supported)
00278          {return HOST_TRUE;}
00279          else return HOST_FALSE;
00280       }
00281    }
00282    if(nb_interface_supported)
00283    { return HOST_TRUE; }
00284    else return HOST_FALSE;
00285 }

U8 host_auto_configure_endpoint (  ) 

This function configures the pipe according to the device class of the interface selected.

Returns:
status

Definition at line 293 of file usb_host_enum.c.

References data_stage, ENDPOINT_DESCRIPTOR, S_interface::ep_addr, ep_table, get_interface_descriptor_offset(), Get_pipe_token, host_configure_pipe, host_determine_pipe_size(), Host_disable_pipe, Host_enable_pipe, HOST_FALSE, Host_select_pipe, Host_set_configured, HOST_TRUE, interface_supported, MSK_EP_DIR, nb_interface_supported, OFFSET_DESCRIPTOR_LENGHT, OFFSET_FIELD_DESCRIPTOR_TYPE, OFFSET_FIELD_EP_ADDR, OFFSET_FIELD_EP_INTERVAL, OFFSET_FIELD_EP_SIZE, OFFSET_FIELD_EP_TYPE, OFFSET_FIELS_NB_OF_EP, ONE_BANK, SIZEOF_DATA_STAGE, T_DESC_OFFSET, and Usb_unallocate_memory.

Referenced by usb_host_task().

00294 {
00295 U8  nb_endpoint_to_configure;
00296 T_DESC_OFFSET  descriptor_offset;
00297 U8  physical_pipe=1;   // =1 cause lookup table assumes that physiacl pipe 0 is reserved for control
00298 U8 i;
00299 U8 ep_index;
00300 
00301    // For all interfaces to configure...
00302    for(i=0;i<nb_interface_supported;i++)
00303    {
00304       ep_index=0;
00305       // First look for the target interface descriptor offset
00306       descriptor_offset = get_interface_descriptor_offset(interface_supported[i].interface_nb,interface_supported[i].altset_nb);
00307       // Get the number of endpoint to configure for this interface
00308       nb_endpoint_to_configure = data_stage[descriptor_offset+OFFSET_FIELS_NB_OF_EP];
00309       // Get the first Endpoint descriptor offset to configure
00310       descriptor_offset += data_stage[descriptor_offset+OFFSET_DESCRIPTOR_LENGHT];  // pointing on endpoint descriptor
00311 
00312       // While there is at least one pipe to configure
00313       while (nb_endpoint_to_configure)
00314       {
00315          // Check and look for an Endpoint descriptor
00316          while (data_stage[descriptor_offset+OFFSET_FIELD_DESCRIPTOR_TYPE] != ENDPOINT_DESCRIPTOR)
00317          {
00318             descriptor_offset += data_stage[descriptor_offset];
00319             if(descriptor_offset > SIZEOF_DATA_STAGE)   // No more endpoint descriptor found -> Errror !
00320             {  return HOST_FALSE; }
00321          }
00322 
00323         // Select the new physical pipe to configure and get ride of any previous configuration for this physical pipe
00324          Host_select_pipe(physical_pipe);
00325          Host_disable_pipe();
00326          Usb_unallocate_memory();
00327          Host_enable_pipe();
00328 
00329          // Build the pipe configuration according to the endpoint descriptors fields received
00330          //
00331          // host_configure_pipe(
00332          //    physical_pipe,                                                                    // pipe nb in USB interface
00333          //    data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE],                               // pipe type (interrupt/BULK/ISO)
00334          //    Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]),               // pipe addr
00335          //    (data_stage[descriptor_offset+2] & MSK_EP_DIR),                                   // pipe dir (IN/OUT)
00336          //    host_determine_pipe_size((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE]),// pipe size
00337          //    ONE_BANK,                                                                         // bumber of bank to allocate for pipe
00338          //    data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL]                            // interrupt period (for interrupt pipe)
00339          //  );
00340          host_configure_pipe(                                                          \
00341             physical_pipe,                                                             \
00342             data_stage[descriptor_offset+OFFSET_FIELD_EP_TYPE],                        \
00343             Get_pipe_token(data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR]),        \
00344             (data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR] & MSK_EP_DIR),                            \
00345             host_determine_pipe_size((U16)data_stage[descriptor_offset+OFFSET_FIELD_EP_SIZE]),\
00346             ONE_BANK,                                                                  \
00347             data_stage[descriptor_offset+OFFSET_FIELD_EP_INTERVAL]                     \
00348          );
00349 
00350          // Update Physical Pipe lookup table with device enpoint address
00351          ep_table[physical_pipe]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR];
00352          physical_pipe++;
00353          // Update endpoint addr table in supported interface structure
00354          interface_supported[i].ep_addr[ep_index++]=data_stage[descriptor_offset+OFFSET_FIELD_EP_ADDR];
00355          descriptor_offset += data_stage[descriptor_offset];             // pointing on next descriptor
00356 
00357          // All target endpoints configured ?
00358          nb_endpoint_to_configure--;
00359       } //for(i=0;i<nb_interface_supported;i++)
00360    }
00361    Host_set_configured();
00362    return HOST_TRUE;
00363 }

Here is the call graph for this function:

U8 get_interface_descriptor_offset ( U8  interface,
U8  alt 
)

get_interface_descriptor_offsetThis function returns the offset in data_stage where to find the interface descriptor whose number and alternate setting values are passed as parameters

Parameters:
interface the interface nb to look for offset descriptor
alt the interface alt setting number
Returns:
T_DESC_OFFSET offset in data_stage[]

Definition at line 376 of file usb_host_enum.c.

References data_stage, HOST_FALSE, INTERFACE_DESCRIPTOR, OFFSET_DESCRIPTOR_LENGHT, OFFSET_FIELD_ALT, OFFSET_FIELD_DESCRIPTOR_TYPE, OFFSET_FIELD_INTERFACE_NB, OFFSET_FIELD_NB_INTERFACE, SIZEOF_DATA_STAGE, and T_DESC_OFFSET.

Referenced by host_auto_configure_endpoint().

00377 {
00378    U8 nb_interface;
00379    T_DESC_OFFSET descriptor_offset;
00380 
00381    nb_interface = data_stage[OFFSET_FIELD_NB_INTERFACE];      // Detects the number of interfaces in this configuration
00382    descriptor_offset = data_stage[OFFSET_DESCRIPTOR_LENGHT];  // now pointing on next descriptor
00383 
00384    while(descriptor_offset < SIZEOF_DATA_STAGE)            // Look in all interfaces declared in the configuration
00385    {
00386       while (data_stage[descriptor_offset+OFFSET_FIELD_DESCRIPTOR_TYPE] != INTERFACE_DESCRIPTOR)
00387       {
00388          descriptor_offset += data_stage[descriptor_offset];
00389          if(descriptor_offset > SIZEOF_DATA_STAGE)
00390          {  return HOST_FALSE;  }
00391       }
00392       if (data_stage[descriptor_offset+OFFSET_FIELD_INTERFACE_NB]==interface
00393           && data_stage[descriptor_offset+OFFSET_FIELD_ALT]==alt)
00394       {
00395         return  descriptor_offset;
00396       }
00397       descriptor_offset += data_stage[descriptor_offset];
00398    }
00399    return descriptor_offset;
00400 }

U8 host_get_hwd_pipe_nb ( U8  ep_addr  ) 

This function returns the physical pipe number linked to a logical endpoint address.

Parameters:
ep_addr 
Returns:
physical_pipe_number
Note:
the function returns 0 if no ep_addr is found in the look up table.

Definition at line 412 of file usb_host_enum.c.

References ep_table, and MAX_EP_NB.

Referenced by otg_user_task().

00413 {
00414    U8 i;
00415    for(i=0;i<MAX_EP_NB;i++)
00416    {
00417       if(ep_table[i]==ep_addr)
00418       { return i; }
00419    }
00420    return 0;
00421 }


Variable Documentation

S_usb_setup_data usb_request

For control requests management over pipe 0.

Definition at line 193 of file usb_host_task.c.

U8 data_stage[SIZEOF_DATA_STAGE]

Public : U8 data_stage[SIZEOF_DATA_STAGE]; Internal RAM buffer for USB data stage content This buffer is required to setup host enumeration process Its contains the device descriptors received.

Depending on the device descriptors lenght, its size can be optimized with the SIZEOF_DATA_STAGE define of conf_usb.h file

/

Definition at line 204 of file usb_host_task.c.

Referenced by get_interface_descriptor_offset(), host_auto_configure_endpoint(), host_check_class(), host_check_OTG_features(), host_check_VID_PID(), and usb_host_task().

U8 device_status

Definition at line 206 of file usb_host_task.c.

U8 nb_interface_supported

The number of interface the host is able to support in the device connected.

Definition at line 77 of file usb_host_enum.c.

Referenced by host_auto_configure_endpoint(), host_check_class(), and usb_host_task().

S_interface interface_supported[MAX_INTERFACE_SUPPORTED]

Definition at line 79 of file usb_host_enum.c.

Referenced by host_auto_configure_endpoint(), and host_check_class().

U16 device_PID

PID of device connected.

Definition at line 82 of file usb_host_enum.c.

Referenced by host_check_VID_PID().

U16 device_VID

VID of device connected.

Definition at line 84 of file usb_host_enum.c.

Referenced by host_check_VID_PID().

U8 bmattributes

bmAttributes byte of the connected device

Definition at line 86 of file usb_host_enum.c.

Referenced by host_check_class().

U8 maxpower

maxpower byte of the connected device (Caution, unit is 2mA)

Definition at line 88 of file usb_host_enum.c.

Referenced by host_check_class().


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