- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# USB device standard requests decoding

## Defines
#define | ATTACHED 0
#define | POWERED 1
#define | DEFAULT 2
#define | ADDRESSED 3
#define | CONFIGURED 4
#define | SUSPENDED 5
#define | USB_REMOTE_WAKEUP 1
#define | OTG_B_HNP_ENABLE 3
#define | OTG_A_HNP_SUPPORT 4
#define | OTG_A_ALT_HNP_SUPPORT 5
#define | Is_device_enumerated() ((usb_configuration_nb!=0) ? TRUE : FALSE)
#define | Is_device_not_enumerated() ((usb_configuration_nb!=0) ? FALSE : TRUE)
## Functions
void | usb_process_request (void)
void | usb_generate_remote_wakeup (void)
| This function manages the remote wake up generation.
## Variables
U8 | usb_configuration_nb
| Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /.
U8 | remote_wakeup_feature
U8 | f_get_serial_string

## Define Documentation

#define ATTACHED 0

Definition at line 67 of file usb_standard_request.h.

#define POWERED 1

Definition at line 68 of file usb_standard_request.h.

#define DEFAULT 2

Definition at line 69 of file usb_standard_request.h.

#define ADDRESSED 3

Definition at line 70 of file usb_standard_request.h.

#define CONFIGURED 4

Definition at line 71 of file usb_standard_request.h.

#define SUSPENDED 5

Definition at line 72 of file usb_standard_request.h.

#define USB_REMOTE_WAKEUP 1

Definition at line 74 of file usb_standard_request.h.

Referenced by usb_set_feature().

#define OTG_B_HNP_ENABLE 3

Definition at line 75 of file usb_standard_request.h.

Referenced by usb_set_feature().

#define OTG_A_HNP_SUPPORT 4

Definition at line 76 of file usb_standard_request.h.

Referenced by usb_set_feature().

#define OTG_A_ALT_HNP_SUPPORT 5

Definition at line 77 of file usb_standard_request.h.

Referenced by usb_set_feature().

#define Is_device_enumerated | ( |  | ) | ((usb_configuration_nb!=0) ? TRUE : FALSE)

Returns true when device connected and correctly enumerated with an host. The device high level application should tests this before performing any applicative requests

Definition at line 84 of file usb_standard_request.h.

Referenced by storage_task().

#define Is_device_not_enumerated | ( |  | ) | ((usb_configuration_nb!=0) ? FALSE : TRUE)

Definition at line 85 of file usb_standard_request.h.

## Function Documentation

void usb_process_request | ( | void |  | ) |

This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. When exiting of the usb_read_request function, the device is ready to manage the next request.

If the received request is not supported or a none USB standard request, the function will call for custom decoding function in usb_specific_request module.

Parameters:

  | none |

Returns:
  none

Note:
  list of supported requests: SETUP_GET_DESCRIPTOR SETUP_GET_CONFIGURATION SETUP_SET_ADDRESS SETUP_SET_CONFIGURATION SETUP_CLEAR_FEATURE SETUP_SET_FEATURE SETUP_GET_STATUS

This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. When exiting of the usb_read_request function, the device is ready to manage the next request.

Definition at line 106 of file usb_standard_request.c.

References endpoint_status, EP_CONTROL, MSK_EP_DIR, SETUP_CLEAR_FEATURE, SETUP_GET_CONFIGURATION, SETUP_GET_DESCRIPTOR, SETUP_GET_INTERFACE, SETUP_GET_STATUS, SETUP_SET_ADDRESS, SETUP_SET_CONFIGURATION, SETUP_SET_FEATURE, SETUP_SET_INTERFACE, Usb_ack_control_out, Usb_ack_receive_setup, usb_clear_feature(), Usb_enable_stall_handshake, usb_get_configuration(), usb_get_descriptor(), usb_get_interface(), usb_get_status(), Usb_read_byte, usb_set_address(), usb_set_configuration(), usb_set_feature(), usb_set_interface(), USB_SETUP_GET_STAND_DEVICE, USB_SETUP_GET_STAND_INTERFACE, USB_SETUP_SET_STAND_DEVICE, USB_SETUP_SET_STAND_INTERFACE, and usb_user_read_request().

    00107 {
    00108    U8 bmRequestType;
    00109    U8 bmRequest;
    00110
    00111    Usb_ack_control_out();
    00112    bmRequestType = Usb_read_byte();
    00113    bmRequest     = Usb_read_byte();
    00114
    00115    switch (bmRequest)
    00116    {
    00117       case SETUP_GET_DESCRIPTOR:
    00118       if (USB_SETUP_GET_STAND_DEVICE == bmRequestType)
    00119       {
    00120          if( usb_get_descriptor() )
    00121             return;
    00122       }
    00123       break;
    00124
    00125       case SETUP_GET_CONFIGURATION:
    00126       if (USB_SETUP_GET_STAND_DEVICE == bmRequestType)
    00127       {
    00128          usb_get_configuration();
    00129          return;
    00130       }
    00131       break;
    00132
    00133       case SETUP_SET_ADDRESS:
    00134       if (USB_SETUP_SET_STAND_DEVICE == bmRequestType)
    00135       {
    00136          usb_set_address();
    00137          return;
    00138       }
    00139       break;
    00140
    00141       case SETUP_SET_CONFIGURATION:
    00142       if (USB_SETUP_SET_STAND_DEVICE == bmRequestType)
    00143       {
    00144          if( usb_set_configuration() )
    00145             return;
    00146       }
    00147       break;
    00148
    00149       case SETUP_CLEAR_FEATURE:
    00150       if (usb_clear_feature(bmRequestType))
    00151          return;
    00152       break;
    00153
    00154       case SETUP_SET_FEATURE:
    00155       if (usb_set_feature(bmRequestType))
    00156          return;
    00157       break;
    00158
    00159       case SETUP_GET_STATUS:
    00160       if (usb_get_status(bmRequestType))
    00161          return;
    00162       break;
    00163
    00164       case SETUP_GET_INTERFACE:
    00165       if (USB_SETUP_GET_STAND_INTERFACE == bmRequestType)
    00166       {
    00167          if( usb_get_interface() )
    00168             return;
    00169       }
    00170       break;
    00171
    00172       case SETUP_SET_INTERFACE:
    00173       if (bmRequestType == USB_SETUP_SET_STAND_INTERFACE)
    00174       {
    00175          if( usb_set_interface() )
    00176             return;
    00177       }
    00178       break;
    00179
    00180       default:
    00181       break;
    00182    }
    00183
    00184    // un-supported like standard request => call to user read request
    00185    if( !usb_user_read_request(bmRequestType, bmRequest) )
    00186    {
    00187       // Request unknow in the specific request list from interface
    00188       // keep that order (set StallRq/clear RxSetup) or a
    00189       // OUT request following the SETUP may be acknowledged
    00190       Usb_enable_stall_handshake();
    00191       Usb_ack_receive_setup();
    00192       endpoint_status[(EP_CONTROL & MSK_EP_DIR)] = 0x01;
    00193    }
    00194 }

Here is the call graph for this function:

void usb_generate_remote_wakeup | ( | void |  | ) |

This function manages the remote wake up generation.

This function manages the remote wakeup generation to wake up the host controlle.

If the received request is not supported or a none USB standard request, the function will call for custom decoding function in usb_specific_request module.

Parameters:

  | none |

Returns:
  none

Definition at line 642 of file usb_standard_request.c.

References DISABLED, ENABLED, FALSE, Is_pll_ready, remote_wakeup_feature, Usb_initiate_remote_wake_up, Usb_unfreeze_clock, and Wait_pll_ready.

    00643 {
    00644    if(Is_pll_ready()==FALSE)
    00645    {
    00646       Pll_start_auto();
    00647       Wait_pll_ready();
    00648    }
    00649    Usb_unfreeze_clock();
    00650    if (remote_wakeup_feature == ENABLED)
    00651    {
    00652       Usb_initiate_remote_wake_up();
    00653       remote_wakeup_feature = DISABLED;
    00654    }
    00655 }

## Variable Documentation

U8 usb_configuration_nb

Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /.

Definition at line 97 of file usb_standard_request.c.

U8 remote_wakeup_feature

Definition at line 98 of file usb_standard_request.c.

U8 f_get_serial_string

Definition at line 81 of file usb_standard_request.c.