USB standard requests

nRF5 SDK v15.2.0

nRF52840 only: Module with types definitions used for standard requests processing. More...

Data Structures

union app_usbd_setup_w_t
Universal way to access 16 bit values and its parts. More...
struct app_usbd_setup_t
Internal redefinition of setup structure. More...

Macros

#define APP_USBD_SETUP_REQ_BF_REC BF_CX (5, 0)
Recipient bit-field in request type. More...
#define APP_USBD_SETUP_REQ_BF_TYP BF_CX (2, 5)
Type bit-field in request type. More...
#define APP_USBD_SETUP_REQ_BF_DIR BF_CX (1, 7)
Direction bit-field in request type. More...

Functions

static app_usbd_setup_reqrec_t app_usbd_setup_req_rec (uint8_t bmRequestType)
Extract recipient from request type. More...
static app_usbd_setup_reqtype_t app_usbd_setup_req_typ (uint8_t bmRequestType)
Extract type from request type. More...
static app_usbd_setup_reqdir_t app_usbd_setup_req_dir (uint8_t bmRequestType)
Extract direction from request type. More...
static uint8_t app_usbd_setup_req_val ( app_usbd_setup_reqrec_t rec, app_usbd_setup_reqtype_t typ, app_usbd_setup_reqdir_t dir)
Make request type value. More...

Variables

ANON_UNIONS_DISABLE

Detailed Description

nRF52840 only: Module with types definitions used for standard requests processing.

Macro Definition Documentation

#define APP_USBD_SETUP_REQ_BF_DIR BF_CX (1, 7)

Direction bit-field in request type.

Bit 7

#define APP_USBD_SETUP_REQ_BF_REC BF_CX (5, 0)

Recipient bit-field in request type.

Bits 4...0

#define APP_USBD_SETUP_REQ_BF_TYP BF_CX (2, 5)

Type bit-field in request type.

Bits 6...5

Enumeration Type Documentation

Direction of setup command.

Note
It is part of app_usbd_setup_reqtype_t variable type.
Enumerator
APP_USBD_SETUP_REQDIR_OUT

Host to device

APP_USBD_SETUP_REQDIR_IN

Device to host

Recipient enumerator.

Note
It is part of app_usbd_setup_reqtype_t variable type.
Enumerator
APP_USBD_SETUP_REQREC_DEVICE

The whole device is a request target

APP_USBD_SETUP_REQREC_INTERFACE

Selected interface is a request target

APP_USBD_SETUP_REQREC_ENDPOINT

Selected endpoint is a request target

APP_USBD_SETUP_REQREC_OTHER

Other element is a request target

Request type enumerator.

Note
It is part of app_usbd_setup_reqtype_t variable type.
Enumerator
APP_USBD_SETUP_REQTYPE_STD

Standard request

APP_USBD_SETUP_REQTYPE_CLASS

Class specific request

APP_USBD_SETUP_REQTYPE_VENDOR

Vendor specific request

Standard feature selectors.

Standard features that may be disabled or enabled by APP_USBD_SETUP_STDREQ_CLEAR_FEATURE or APP_USBD_SETUP_STDREQ_SET_FEATURE

Enumerator
APP_USBD_SETUP_STDFEATURE_DEVICE_REMOTE_WAKEUP

Remote wakeup feature. Target: Device only

APP_USBD_SETUP_STDFEATURE_ENDPOINT_HALT

Stall or clear the endpoint. Target: Endpoint different than default (0)

APP_USBD_SETUP_STDFEATURE_TEST_MODE

Upstream port test mode. Power has to be cycled to exit test mode. This feature cannot be cleared.

Target: Device only

Note
It should only be supported by HighSpeed capable devices. Not supported in this library.

Standard requests.

Enumerator for standard requests values.

Enumerator
APP_USBD_SETUP_STDREQ_GET_STATUS

Targets: Device, Interface, Endpoint Expected SETUP frame format:

  • wValue: Zero
  • wIndex: Zero, (lb): Interface or Endpoint
  • wLength: 2
  • Data:2 bytes of data, depending on targets
    • Device:
      • D15..D2: Reserved (Reset to zero)
      • D1: Remove Wakeup
      • D0: Self Powered
    • Interface:
      • D15..D0: Reserved (Reset to zero)
    • Endpoint:
      • D15..D1: Reserved (Reset to zero)
      • D0: Halt
APP_USBD_SETUP_STDREQ_CLEAR_FEATURE

Targets: Device, Interface, Endpoint Expected SETUP frame format:

APP_USBD_SETUP_STDREQ_SET_FEATURE

Targets: Device, Interface, Endpoint Expected SETUP frame format:

APP_USBD_SETUP_STDREQ_SET_ADDRESS
Note
This SETUP request is processed in hardware. Use it only to mark current USB state.

Targets: Device Expected SETUP frame format:

  • wValue: New device address
  • wIndex: 0
  • wLength: 0
  • Data: None
APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR

Targets: Device

  • wValue: (hb): Descriptor Type and (lb): Descriptor Index
  • wIndex: Zero of Language ID
  • wLength: Descriptor Length
  • Data: Descriptor
APP_USBD_SETUP_STDREQ_SET_DESCRIPTOR

Not supported - Stall when called.

APP_USBD_SETUP_STDREQ_GET_CONFIGURATION

Target: Device Expected SETUP frame format:

  • wValue: 0
  • wIndex: 0
  • wLength: 1
  • Data: Configuration value
APP_USBD_SETUP_STDREQ_SET_CONFIGURATION

Target: Device Expected SETUP frame format:

  • wValue: (lb): Configuration value
  • wIndex: 0
  • wLength: 0
  • Data: None
APP_USBD_SETUP_STDREQ_GET_INTERFACE

Target: Interface Expected SETUP frame format:

  • wValue: 0
  • wIndex: Interface
  • wLength: 1
  • Data: Alternate setting
APP_USBD_SETUP_STDREQ_SET_INTERFACE

Target: Interface Expected SETUP frame format:

  • wValue: Alternate setting
  • wIndex: Interface
  • wLength: 0
  • Data: None
APP_USBD_SETUP_STDREQ_SYNCH_FRAME

Target: Endpoint Expected SETUP frame format:

  • wValue: 0
  • wIndex: Endpoint
  • wLength: 2
  • Data: Frame Number
Note
This request is used only in connection with isochronous endpoints. This is rarely used and probably we would not need to support it.

Function Documentation

static app_usbd_setup_reqdir_t app_usbd_setup_req_dir ( uint8_t bmRequestType )
inline static

Extract direction from request type.

Parameters
[in] bmRequestType
Returns
Extracted direction field from request type value.
static app_usbd_setup_reqrec_t app_usbd_setup_req_rec ( uint8_t bmRequestType )
inline static

Extract recipient from request type.

Parameters
[in] bmRequestType
Returns
Extracted recipient field from request type value.
static app_usbd_setup_reqtype_t app_usbd_setup_req_typ ( uint8_t bmRequestType )
inline static

Extract type from request type.

Parameters
[in] bmRequestType
Returns
Extracted type field from request type value.
static uint8_t app_usbd_setup_req_val ( app_usbd_setup_reqrec_t rec ,
app_usbd_setup_reqtype_t typ ,
app_usbd_setup_reqdir_t dir
)
inline static

Make request type value.

Parameters
[in] rec Recipient.
[in] typ Request type.
[in] dir Direction.
Returns
Assembled request type value.