nRF5 SDK v17.1.0
Data Structures | Macros | Enumerations
USB HID class types

nRF52840 only: Module with types and definitions used by HID modules. More...

Data Structures

union  app_usbd_hid_descriptor_t
 HID descriptor, binary layout. More...
 

Macros

#define APP_USBD_HID_CLASS   0x03
 HID class definition in interface descriptor. More...
 
#define APP_USBD_HID_REPORT_ITEM(size)   APP_USBD_HID_DESCRIPTOR_REPORT, ((size) & 0xFF), ((size) / 256)
 HID report descriptor entry at the end of HID descriptor. More...
 
#define APP_USBD_HID_PHYSICAL_ITEM(size)   APP_USBD_HID_DESCRIPTOR_PHYSICAL, ((size) & 0xFF), ((size) / 256)
 HID physical descriptor entry at the end of HID descriptor. More...
 
#define APP_USBD_HID_BCD_VER   APP_USBD_BCD_VER_MAKE(1, 1, 1)
 Hid version BCD value definition. More...
 
#define APP_USBD_HID_BCD_VER_BYTES   LSB_16(APP_USBD_HID_BCD_VER), MSB_16(APP_USBD_HID_BCD_VER)
 HID version BCD value definition distributed into bytes. More...
 
#define APP_USBD_HID_INTERFACE_DSC(interface_number, endpoints_num, subclass, protocol)
 Initializer of interface descriptor for HID classes. More...
 
#define APP_USBD_HID_HID_DSC(...)
 Initializer of HID descriptor for HID classes. More...
 
#define APP_USBD_HID_EP_DSC(endpoint, ep_size, ep_interval)
 Initializer of endpoint descriptor for HID classes. More...
 

Enumerations

enum  app_usbd_hid_subclass_t {
  APP_USBD_HID_SUBCLASS_NONE = 0x00,
  APP_USBD_HID_SUBCLASS_BOOT = 0x01
}
 HID subclass definition. More...
 
enum  app_usbd_hid_protocol_select_t {
  APP_USBD_HID_PROTO_BOOT = 0x00,
  APP_USBD_HID_PROTO_REPORT = 0x01
}
 HID selected protocol. More...
 
enum  app_usbd_hid_protocol_t {
  APP_USBD_HID_PROTO_GENERIC = 0x00,
  APP_USBD_HID_PROTO_KEYBOARD = 0x01,
  APP_USBD_HID_PROTO_MOUSE = 0x02,
  APP_USBD_HID_PROTO_MULTITOUCH = 0x03
}
 HID protocol types defined by specification. More...
 
enum  app_usbd_hid_country_code_t {
  APP_USBD_HID_COUNTRY_NOT_SUPPORTED = 0,
  APP_USBD_HID_COUNTRY_ARABIC = 1,
  APP_USBD_HID_COUNTRY_BELGIAN = 2,
  APP_USBD_HID_COUNTRY_CANADIAN_BILINGUAL = 3,
  APP_USBD_HID_COUNTRY_CANADIAN_FRENCH = 4,
  APP_USBD_HID_COUNTRY_CZECH_REPUBLIC = 5,
  APP_USBD_HID_COUNTRY_DANISH = 6,
  APP_USBD_HID_COUNTRY_FINNISH = 7,
  APP_USBD_HID_COUNTRY_FRENCH = 8,
  APP_USBD_HID_COUNTRY_GERMAN = 9,
  APP_USBD_HID_COUNTRY_GREEK = 10,
  APP_USBD_HID_COUNTRY_HEBREW = 11,
  APP_USBD_HID_COUNTRY_HUNGARY = 12,
  APP_USBD_HID_COUNTRY_INTERNATIONAL_ISO = 13,
  APP_USBD_HID_COUNTRY_ITALIAN = 14,
  APP_USBD_HID_COUNTRY_JAPAN_KATAKANA = 15,
  APP_USBD_HID_COUNTRY_KOREAN = 16,
  APP_USBD_HID_COUNTRY_LATIN_AMERICAN = 17,
  APP_USBD_HID_COUNTRY_NETHERLANDS_DUTCH = 18,
  APP_USBD_HID_COUNTRY_NORWEGIAN = 19,
  APP_USBD_HID_COUNTRY_PERSIAN_FARSI = 20,
  APP_USBD_HID_COUNTRY_POLAND = 21,
  APP_USBD_HID_COUNTRY_PORTUGUESE = 22,
  APP_USBD_HID_COUNTRY_RUSSIA = 23,
  APP_USBD_HID_COUNTRY_SLOVAKIA = 24,
  APP_USBD_HID_COUNTRY_SPANISH = 25,
  APP_USBD_HID_COUNTRY_SWEDISH = 26,
  APP_USBD_HID_COUNTRY_SWISS_FRENCH = 27,
  APP_USBD_HID_COUNTRY_SWISS_GERMAN = 28,
  APP_USBD_HID_COUNTRY_SWITZERLAND = 29,
  APP_USBD_HID_COUNTRY_TAIWAN = 30,
  APP_USBD_HID_COUNTRY_TURKISH_Q = 31,
  APP_USBD_HID_COUNTRY_UK = 32,
  APP_USBD_HID_COUNTRY_US = 33,
  APP_USBD_HID_COUNTRY_YUGOSLAVIA = 34,
  APP_USBD_HID_COUNTRY_TURKISH_F = 35
}
 HID country code ID. More...
 
enum  app_usbd_hid_descriptor_type_t {
  APP_USBD_HID_DESCRIPTOR_HID = 0x21,
  APP_USBD_HID_DESCRIPTOR_REPORT = 0x22,
  APP_USBD_HID_DESCRIPTOR_PHYSICAL = 0x23
}
 HID descriptor types. More...
 
enum  app_usbd_hid_req_t {
  APP_USBD_HID_REQ_GET_REPORT = 0x01,
  APP_USBD_HID_REQ_GET_IDLE = 0x02,
  APP_USBD_HID_REQ_GET_PROTOCOL = 0x03,
  APP_USBD_HID_REQ_SET_REPORT = 0x09,
  APP_USBD_HID_REQ_SET_IDLE = 0x0A,
  APP_USBD_HID_REQ_SET_PROTOCOL = 0x0B
}
 HID requests defined by specification. More...
 
enum  app_usbd_hid_report_type_t {
  APP_USBD_HID_REPORT_TYPE_INPUT = 0x01,
  APP_USBD_HID_REPORT_TYPE_OUTPUT = 0x02,
  APP_USBD_HID_REPORT_TYPE_FEATURE = 0x03
}
 HID report type. More...
 

Detailed Description

nRF52840 only: Module with types and definitions used by HID modules.

Macro Definition Documentation

#define APP_USBD_HID_BCD_VER   APP_USBD_BCD_VER_MAKE(1, 1, 1)

Hid version BCD value definition.

The version of the HID descriptors used.

#define APP_USBD_HID_BCD_VER_BYTES   LSB_16(APP_USBD_HID_BCD_VER), MSB_16(APP_USBD_HID_BCD_VER)

HID version BCD value definition distributed into bytes.

This is a value written directly into app_usbd_hid_descriptor_t::bcdHID.

See Also
APP_USBD_HID_BCD_VER
#define APP_USBD_HID_CLASS   0x03

HID class definition in interface descriptor.

app_usbd_descriptor_iface_t::bInterfaceClass

#define APP_USBD_HID_EP_DSC (   endpoint,
  ep_size,
  ep_interval 
)
Value:
/*.bLength = */ sizeof(app_usbd_descriptor_ep_t), \
/*.bDescriptorType = */ APP_USBD_DESCRIPTOR_ENDPOINT, \
/*.bEndpointAddress = */ endpoint, \
/*.bmAttributes = */ APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT, \
/*.wMaxPacketSize = */ APP_USBD_U16_TO_RAW_DSC(ep_size), \
/*.bInterval = */ ep_interval, \

Initializer of endpoint descriptor for HID classes.

Parameters
endpointEndpoint number.
ep_sizeEndpoint size.
ep_intervalEndpoint interval (milliseconds).
#define APP_USBD_HID_HID_DSC (   ...)
Value:
/*.bLength = */ sizeof(app_usbd_hid_descriptor_t) + 3 * (NUM_VA_ARGS(__VA_ARGS__)), \
/*.bDescriptorType = */ APP_USBD_HID_DESCRIPTOR_HID, \
/*.bcdHID = */ APP_USBD_HID_BCD_VER_BYTES, \
/*.bCountryCode = */ APP_USBD_HID_COUNTRY_NOT_SUPPORTED, \
/*.bNumDescriptors = */ (NUM_VA_ARGS(__VA_ARGS__)), \
/*.bRDescriptorType = */ APP_USBD_HID_REPORT_ITEM(sizeof(GET_VA_ARG_1_(__VA_ARGS__))), \
/*.wDescriptorLength = */

Initializer of HID descriptor for HID classes.

Parameters
...Report/physical item list.
#define APP_USBD_HID_INTERFACE_DSC (   interface_number,
  endpoints_num,
  subclass,
  protocol 
)
Value:
/*.bLength = */ sizeof(app_usbd_descriptor_iface_t), \
/*.bDescriptorType = */ APP_USBD_DESCRIPTOR_INTERFACE, \
/*.bInterfaceNumber = */ interface_number, \
/*.bAlternateSetting = */ 0x00, \
/*.bNumEndpoints = */ endpoints_num, \
/*.bInterfaceClass = */ APP_USBD_HID_CLASS, \
/*.bInterfaceSubClass = */ subclass, \
/*.bInterfaceProtocol = */ protocol, \
/*.iInterface = 0, */ 0x00, \

Initializer of interface descriptor for HID classes.

Parameters
interface_numberInterface number.
endpoints_numNumber of endpoints.
subclassSubclass type app_usbd_hid_subclass_t.
protocolProtocol type app_usbd_hid_protocol_t.
#define APP_USBD_HID_PHYSICAL_ITEM (   size)    APP_USBD_HID_DESCRIPTOR_PHYSICAL, ((size) & 0xFF), ((size) / 256)

HID physical descriptor entry at the end of HID descriptor.

Parameters
sizePhysical descriptor size.
#define APP_USBD_HID_REPORT_ITEM (   size)    APP_USBD_HID_DESCRIPTOR_REPORT, ((size) & 0xFF), ((size) / 256)

HID report descriptor entry at the end of HID descriptor.

Parameters
sizeReport descriptor size.

Enumeration Type Documentation

HID country code ID.

Look into app_usbd_hid_descriptor_t::bCountryCode.

Enumerator
APP_USBD_HID_COUNTRY_NOT_SUPPORTED 

NOT_SUPPORTED

APP_USBD_HID_COUNTRY_ARABIC 

ARABIC

APP_USBD_HID_COUNTRY_BELGIAN 

BELGIAN

APP_USBD_HID_COUNTRY_CANADIAN_BILINGUAL 

CANADIAN_BILINGUAL

APP_USBD_HID_COUNTRY_CANADIAN_FRENCH 

CANADIAN_FRENCH

APP_USBD_HID_COUNTRY_CZECH_REPUBLIC 

CZECH_REPUBLIC

APP_USBD_HID_COUNTRY_DANISH 

DANISH

APP_USBD_HID_COUNTRY_FINNISH 

FINNISH

APP_USBD_HID_COUNTRY_FRENCH 

FRENCH

APP_USBD_HID_COUNTRY_GERMAN 

GERMAN

APP_USBD_HID_COUNTRY_GREEK 

GREEK

APP_USBD_HID_COUNTRY_HEBREW 

HEBREW

APP_USBD_HID_COUNTRY_HUNGARY 

HUNGARY

APP_USBD_HID_COUNTRY_INTERNATIONAL_ISO 

INTERNATIONAL_ISO

APP_USBD_HID_COUNTRY_ITALIAN 

ITALIAN

APP_USBD_HID_COUNTRY_JAPAN_KATAKANA 

JAPAN_KATAKANA

APP_USBD_HID_COUNTRY_KOREAN 

KOREAN

APP_USBD_HID_COUNTRY_LATIN_AMERICAN 

LATIN_AMERICAN

APP_USBD_HID_COUNTRY_NETHERLANDS_DUTCH 

NETHERLANDS_DUTCH

APP_USBD_HID_COUNTRY_NORWEGIAN 

NORWEGIAN

APP_USBD_HID_COUNTRY_PERSIAN_FARSI 

PERSIAN_FARSI

APP_USBD_HID_COUNTRY_POLAND 

POLAND

APP_USBD_HID_COUNTRY_PORTUGUESE 

PORTUGUESE

APP_USBD_HID_COUNTRY_RUSSIA 

RUSSIA

APP_USBD_HID_COUNTRY_SLOVAKIA 

SLOVAKIA

APP_USBD_HID_COUNTRY_SPANISH 

SPANISH

APP_USBD_HID_COUNTRY_SWEDISH 

SWEDISH

APP_USBD_HID_COUNTRY_SWISS_FRENCH 

SWISS_FRENCH

APP_USBD_HID_COUNTRY_SWISS_GERMAN 

SWISS_GERMAN

APP_USBD_HID_COUNTRY_SWITZERLAND 

SWITZERLAND

APP_USBD_HID_COUNTRY_TAIWAN 

TAIWAN

APP_USBD_HID_COUNTRY_TURKISH_Q 

TURKISH_Q

APP_USBD_HID_COUNTRY_UK 

UK

APP_USBD_HID_COUNTRY_US 

US

APP_USBD_HID_COUNTRY_YUGOSLAVIA 

YUGOSLAVIA

APP_USBD_HID_COUNTRY_TURKISH_F 

TURKISH_F

HID descriptor types.

app_usbd_hid_descriptor_t::bRDescriptorType

Enumerator
APP_USBD_HID_DESCRIPTOR_HID 

HID descriptor.

APP_USBD_HID_DESCRIPTOR_REPORT 

REPORT descriptor.

APP_USBD_HID_DESCRIPTOR_PHYSICAL 

PHYSICAL descriptor.

HID selected protocol.

These values are used for Get_Protocol and Set_Protocol requests. Changing protocol is only allowed when protocol type (app_usbd_hid_protocol_t) is set to APP_USBD_HID_PROTO_KEYBOARD or APP_USBD_HID_PROTO_MOUSE and interface uses boot subclass (APP_USBD_HID_SUBCLASS_BOOT).

See Also
HID 1.11 specification: Chapter 7.2.5 Get_Protocol Request and Chapter 7.2.6 Set_Protocol Request.
Enumerator
APP_USBD_HID_PROTO_BOOT 

Boot protocol.

APP_USBD_HID_PROTO_REPORT 

Report protocol.

HID protocol types defined by specification.

Value needs to be filled in interface descriptor. app_usbd_descriptor_iface_t::bInterfaceProtocol

Enumerator
APP_USBD_HID_PROTO_GENERIC 

GENERIC protocol.

APP_USBD_HID_PROTO_KEYBOARD 

KEYBOARD protocol.

APP_USBD_HID_PROTO_MOUSE 

MOUSE protocol.

APP_USBD_HID_PROTO_MULTITOUCH 

MULTITOUCH protocol.

HID report type.

Enumerator
APP_USBD_HID_REPORT_TYPE_INPUT 

INPUT report type

APP_USBD_HID_REPORT_TYPE_OUTPUT 

OUTPUT report type

APP_USBD_HID_REPORT_TYPE_FEATURE 

FEATURE report type

HID requests defined by specification.

Enumerator
APP_USBD_HID_REQ_GET_REPORT 

REPORT: device -> host (required).

APP_USBD_HID_REQ_GET_IDLE 

IDLE: device -> host (not required).

APP_USBD_HID_REQ_GET_PROTOCOL 

PROTOCOL: device -> host (required for boot protocol).

APP_USBD_HID_REQ_SET_REPORT 

REPORT: host -> device (not required).

APP_USBD_HID_REQ_SET_IDLE 

IDLE: no data stage (required for boot protocol).

APP_USBD_HID_REQ_SET_PROTOCOL 

PROTOCOL: no data stage (required for boot protocol).

HID subclass definition.

See Also
HID 1.11 specification: Chapter 4.2 Subclass. app_usbd_descriptor_iface_t::bInterfaceSubClass
Enumerator
APP_USBD_HID_SUBCLASS_NONE 

Undefined subclass.

APP_USBD_HID_SUBCLASS_BOOT 

Boot subclass.


Documentation feedback | Developer Zone | Subscribe | Updated