Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB host enumeration functions module

Data Structures

struct  S_interface
 Interface. More...
 
struct  S_usb_setup_data
 USB Setup Data. More...
 

Macros

#define CONTROL_CRC16   0x10
 
#define CONTROL_DATA_PID   0x02
 
#define CONTROL_DATA_TOGGLE   0x01
 
#define CONTROL_GOOD   0x00
 
#define CONTROL_NO_DEVICE   0x40
 
#define CONTROL_PID   0x04
 
#define CONTROL_STALL   0x20
 
#define CONTROL_TIMEOUT   0x08
 
#define Get_altset_nb(s_interface)   (interface_supported[(s_interface)].altset_nb)
 Number of alternate settings associated with a supported interface. More...
 
#define Get_class(s_interface)   (interface_supported[(s_interface)].uclass)
 USB class associated with the supported interface. More...
 
#define Get_ep_nbr(s_interface, n_ep)   (Host_get_pipe_endpoint_number(Get_ep_pipe(s_interface, n_ep)))
 Endpoint number associated with the supported interface. More...
 
#define Get_ep_pipe(s_interface, n_ep)   (interface_supported[(s_interface)].ep_pipe[(n_ep)])
 Endpoint pipe associated with the supported interface. More...
 
#define Get_ep_type(s_interface, n_ep)   (Host_get_pipe_type(Get_ep_pipe(s_interface, n_ep)))
 Endpoint type associated with the supported interface. More...
 
#define Get_interface_number(s_interface)   (interface_supported[(s_interface)].interface_nb)
 Number of interfaces associated with a supported interface. More...
 
#define Get_maxpower()   (maxpower)
 Maximal power consumption ot the connected device (unit is 2 mA) More...
 
#define Get_nb_ep(s_interface)   (interface_supported[(s_interface)].nb_ep)
 Number of endpoints associated with a supported interface. More...
 
#define Get_nb_supported_interface()   (nb_interface_supported)
 Number of supported interfaces in the connected device. More...
 
#define Get_PID()   (device_PID)
 PID of the connected device. More...
 
#define Get_pipe_token(ep_addr)   ((Get_desc_ep_dir(ep_addr)) ? TOKEN_IN : TOKEN_OUT)
 Extract token information from endpoint address. More...
 
#define Get_protocol(s_interface)   (interface_supported[(s_interface)].protocol)
 USB protocol associated with the supported interface. More...
 
#define Get_subclass(s_interface)   (interface_supported[(s_interface)].subclass)
 USB subclass associated with the supported interface. More...
 
#define Get_VID()   (device_VID)
 VID of the connected device. More...
 
#define host_clear_endpoint_feature(ep)
 Send a "clear endpoint feature" request. More...
 
#define host_get_configuration()
 Send a "get configuration" request. More...
 
#define host_get_configuration_descriptor(cfg_ix)
 Send a "get device configuration descriptor" request The configuration descriptor received is stored in the data_stage array. More...
 
#define host_get_device_descriptor()
 Send a "get device descriptor" request The descriptor received is stored in the data_stage array. More...
 
#define host_get_device_descriptor_incomplete()
 Send an incomplete "get device descriptor" request The descriptor received is stored in the data_stage array. More...
 
#define host_ms_get_max_lun()
 Send the mass-storage specific request "get max LUN". More...
 
#define host_set_address(addr)
 Send a "set address" request. More...
 
#define host_set_configuration(cfg_nb)
 Send a "set configuration" request. More...
 
#define host_set_feature_remote_wakeup()
 Send a "set feature" "device remote wake-up". More...
 
#define host_set_interface(interface_nb, alt_setting)
 Send a "set interface" request to specify an alternate setting for an interface. More...
 
#define Is_device_self_powered()   (Tst_bits(bmattributes, SELF_POWERED_MASK))
 true if the connected device is self-powered More...
 
#define Is_device_supports_remote_wakeup()   (Tst_bits(bmattributes, REMOTE_WAKEUP_MASK))
 true if the connected device supports remote wake-up More...
 
#define Is_ep_in(s_interface, n_ep)   (Host_get_pipe_token(Get_ep_pipe(s_interface, n_ep)) == TOKEN_IN)
 true if the endpoint direction associated with the supported interface is IN More...
 
#define OFFSET_DESCRIPTOR_LENGTH   0
 Offsets common to all descriptor types. More...
 
#define OFFSET_FIELD_ALT   3
 
#define OFFSET_FIELD_BMATTRIBUTES   7
 
#define OFFSET_FIELD_CLASS   5
 
#define OFFSET_FIELD_CONFIGURATION_NB   5
 
#define OFFSET_FIELD_DESCRIPTOR_TYPE   1
 
#define OFFSET_FIELD_EP_ADDR   2
 Offsets in endpoint descriptors. More...
 
#define OFFSET_FIELD_EP_INTERVAL   6
 
#define OFFSET_FIELD_EP_SIZE   4
 
#define OFFSET_FIELD_EP_TYPE   3
 
#define OFFSET_FIELD_INTERFACE_NB   2
 Offsets in interface descriptors. More...
 
#define OFFSET_FIELD_MAXPACKETSIZE   7
 Offsets in device descriptors. More...
 
#define OFFSET_FIELD_MAXPOWER   8
 
#define OFFSET_FIELD_NB_CONFIGURATION   17
 
#define OFFSET_FIELD_NB_INTERFACE   4
 
#define OFFSET_FIELD_NB_OF_EP   4
 
#define OFFSET_FIELD_PID   10
 
#define OFFSET_FIELD_PROTOCOL   7
 
#define OFFSET_FIELD_SUB_CLASS   6
 
#define OFFSET_FIELD_TOTAL_LENGTH   2
 Offsets in configuration descriptors. More...
 
#define OFFSET_FIELD_VID   8
 
#define REMOTE_WAKEUP_BIT   5
 
#define REMOTE_WAKEUP_MASK   (1 << REMOTE_WAKEUP_BIT)
 
#define SELF_POWERED_BIT   6
 
#define SELF_POWERED_MASK   (1 << SELF_POWERED_BIT)
 

Functions

bool host_check_class (void)
 
bool host_check_VID_PID (void)
 
Status_t host_transfer_control (void *data_pointer)
 

Variables

volatile U8 bmattributes
 
volatile U16 device_PID
 
volatile U16 device_VID
 
volatile S_interface interface_supported [MAX_INTERFACE_SUPPORTED]
 
volatile U8 maxpower
 
volatile U8 nb_interface_supported
 

#define CONTROL_CRC16   0x10
#define CONTROL_DATA_PID   0x02
#define CONTROL_DATA_TOGGLE   0x01
#define CONTROL_GOOD   0x00
#define CONTROL_NO_DEVICE   0x40
#define CONTROL_PID   0x04
#define CONTROL_STALL   0x20
#define CONTROL_TIMEOUT   0x08
#define Get_altset_nb (   s_interface)    (interface_supported[(s_interface)].altset_nb)

Number of alternate settings associated with a supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: Number of alternate settings
#define Get_class (   s_interface)    (interface_supported[(s_interface)].uclass)

USB class associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: Class
#define Get_ep_nbr (   s_interface,
  n_ep 
)    (Host_get_pipe_endpoint_number(Get_ep_pipe(s_interface, n_ep)))

Endpoint number associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
n_epU8: The endpoint number in this interface
Returns
U8: Endpoint number
#define Get_ep_pipe (   s_interface,
  n_ep 
)    (interface_supported[(s_interface)].ep_pipe[(n_ep)])

Endpoint pipe associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
n_epU8: The endpoint number in this interface
Returns
U8: Endpoint pipe
#define Get_ep_type (   s_interface,
  n_ep 
)    (Host_get_pipe_type(Get_ep_pipe(s_interface, n_ep)))

Endpoint type associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
n_epU8: The endpoint number in this interface
Returns
U8: Endpoint type
#define Get_interface_number (   s_interface)    (interface_supported[(s_interface)].interface_nb)

Number of interfaces associated with a supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: Number of interfaces
#define Get_maxpower ( )    (maxpower)

Maximal power consumption ot the connected device (unit is 2 mA)

Returns
U8: Maximal power
#define Get_nb_ep (   s_interface)    (interface_supported[(s_interface)].nb_ep)

Number of endpoints associated with a supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: Number of endpoints
#define Get_nb_supported_interface ( )    (nb_interface_supported)

Number of supported interfaces in the connected device.

Returns
U8: Number of supported interfaces
#define Get_PID ( )    (device_PID)

PID of the connected device.

Returns
U16: PID
#define Get_pipe_token (   ep_addr)    ((Get_desc_ep_dir(ep_addr)) ? TOKEN_IN : TOKEN_OUT)

Extract token information from endpoint address.

Parameters
ep_addrU8: Endpoint address
Returns
TOKEN_IN/TOKEN_OUT: Pipe token
#define Get_protocol (   s_interface)    (interface_supported[(s_interface)].protocol)

USB protocol associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: protocol
#define Get_subclass (   s_interface)    (interface_supported[(s_interface)].subclass)

USB subclass associated with the supported interface.

Parameters
s_interfaceU8: The supported interface number
Returns
U8: Subclass
#define Get_VID ( )    (device_VID)

VID of the connected device.

Returns
U16: VID
#define host_clear_endpoint_feature (   ep)
Value:
(\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
#define FEATURE_ENDPOINT_HALT
Definition: usb_task.h:134
Status_t host_transfer_control(void *data_pointer)
#define CLEAR_FEATURE
Definition: usb_task.h:101
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "clear endpoint feature" request.

Parameters
epU8: Target endpoint
Returns
Status
#define host_get_configuration ( )
Value:
(\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
#define GET_CONFIGURATION
Definition: usb_task.h:107
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "get configuration" request.

Returns
Status
#define host_get_configuration_descriptor (   cfg_ix)
Value:
(\
usb_request.wLength = SIZEOF_DATA_STAGE,\
)
#define GET_DESCRIPTOR
Definition: usb_task.h:105
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
#define CONFIGURATION_DESCRIPTOR
Definition: usb_task.h:125
Status_t host_transfer_control(void *data_pointer)
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "get device configuration descriptor" request The configuration descriptor received is stored in the data_stage array.

Parameters
cfg_ixU8: Index of the configuration descriptor to get
Returns
Status
#define host_get_device_descriptor ( )
Value:
(\
)
#define GET_DESCRIPTOR
Definition: usb_task.h:105
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
#define DEVICE_DESCRIPTOR
Definition: usb_task.h:124
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "get device descriptor" request The descriptor received is stored in the data_stage array.

Returns
Status
#define host_get_device_descriptor_incomplete ( )
Value:
(\
)
#define GET_DESCRIPTOR
Definition: usb_task.h:105
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
#define DEVICE_DESCRIPTOR
Definition: usb_task.h:124
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send an incomplete "get device descriptor" request The descriptor received is stored in the data_stage array.

The received descriptors are limited to the length of the control pipe.

Returns
Status
#define host_ms_get_max_lun ( )
Value:
(\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
#define MS_GET_MAX_LUN
Definition: host_mem.h:57
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send the mass-storage specific request "get max LUN".

Returns
Status
#define host_set_address (   addr)
Value:
(\
usb_request.wValue = (addr),\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
#define SET_ADDRESS
Definition: usb_task.h:104
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "set address" request.

Parameters
addrU8: Address assigned to the device
Returns
Status
#define host_set_configuration (   cfg_nb)
Value:
(\
usb_request.wValue = (cfg_nb),\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
#define SET_CONFIGURATION
Definition: usb_task.h:108
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "set configuration" request.

Parameters
cfg_nbU8: Configuration to activate
Returns
Status
#define host_set_feature_remote_wakeup ( )
Value:
(\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
#define SET_FEATURE
Definition: usb_task.h:103
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "set feature" "device remote wake-up".

Returns
Status
#define host_set_interface (   interface_nb,
  alt_setting 
)
Value:
(\
usb_request.wValue = (alt_setting),\
usb_request.wIndex = (interface_nb),\
)
U8 bmRequestType
Characteristics of the request.
Definition: usb_host_enum.h:73
U8 bRequest
Specific request.
Definition: usb_host_enum.h:74
#define SET_INTERFACE
Definition: usb_task.h:110
U16 wValue
Field that varies according to request.
Definition: usb_host_enum.h:75
volatile S_usb_setup_data usb_request
Status_t host_transfer_control(void *data_pointer)
U16 wLength
Number of bytes to transfer if Data.
Definition: usb_host_enum.h:77
bool incomplete_read
true: only one read
Definition: usb_host_enum.h:78
U8 data_stage[SIZEOF_DATA_STAGE]
U16 wIndex
Field that varies according to request.
Definition: usb_host_enum.h:76

Send a "set interface" request to specify an alternate setting for an interface.

Parameters
interface_nbU8: Interface
alt_settingU8: Alternate setting
Returns
Status
#define Is_device_self_powered ( )    (Tst_bits(bmattributes, SELF_POWERED_MASK))

true if the connected device is self-powered

Returns
bool: Self-powered?
#define Is_device_supports_remote_wakeup ( )    (Tst_bits(bmattributes, REMOTE_WAKEUP_MASK))

true if the connected device supports remote wake-up

Returns
bool: Remote wake-up supported?
#define Is_ep_in (   s_interface,
  n_ep 
)    (Host_get_pipe_token(Get_ep_pipe(s_interface, n_ep)) == TOKEN_IN)

true if the endpoint direction associated with the supported interface is IN

Parameters
s_interfaceU8: The supported interface number
n_epU8: The endpoint number in this interface
Returns
bool: Endpoint direction IN?
#define OFFSET_DESCRIPTOR_LENGTH   0

Offsets common to all descriptor types.

#define OFFSET_FIELD_ALT   3
#define OFFSET_FIELD_BMATTRIBUTES   7
#define OFFSET_FIELD_CLASS   5
#define OFFSET_FIELD_CONFIGURATION_NB   5
#define OFFSET_FIELD_DESCRIPTOR_TYPE   1
#define OFFSET_FIELD_EP_ADDR   2

Offsets in endpoint descriptors.

#define OFFSET_FIELD_EP_INTERVAL   6
#define OFFSET_FIELD_EP_SIZE   4
#define OFFSET_FIELD_EP_TYPE   3
#define OFFSET_FIELD_INTERFACE_NB   2

Offsets in interface descriptors.

#define OFFSET_FIELD_MAXPACKETSIZE   7

Offsets in device descriptors.

#define OFFSET_FIELD_MAXPOWER   8
#define OFFSET_FIELD_NB_CONFIGURATION   17
#define OFFSET_FIELD_NB_INTERFACE   4
#define OFFSET_FIELD_NB_OF_EP   4
#define OFFSET_FIELD_PID   10
#define OFFSET_FIELD_PROTOCOL   7
#define OFFSET_FIELD_SUB_CLASS   6
#define OFFSET_FIELD_TOTAL_LENGTH   2

Offsets in configuration descriptors.

#define OFFSET_FIELD_VID   8
#define REMOTE_WAKEUP_BIT   5
#define REMOTE_WAKEUP_MASK   (1 << REMOTE_WAKEUP_BIT)
#define SELF_POWERED_BIT   6
#define SELF_POWERED_MASK   (1 << SELF_POWERED_BIT)

bool host_check_class ( void  )
bool host_check_VID_PID ( void  )
Status_t host_transfer_control ( void *  data_pointer)

volatile U8 bmattributes
volatile U16 device_PID
volatile U16 device_VID
volatile S_interface interface_supported[MAX_INTERFACE_SUPPORTED]
volatile U8 maxpower
volatile U8 nb_interface_supported