Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB Device Interface (UDI) for Human Interface Device Keyboard (HID Keyboard)

USB Device Interface (UDI) for Human Interface Device Keyboard (HID keyboard) provides an interface for the configuration and management of USB HID keyboard device.

The outline of this documentation is as follows:

For more details for Atmel® Software Framework (ASF) USB Device Stack and USB Device HID keyboard, refer to following application notes:

API Overview

Data Structures

struct  udi_hid_kbd_desc_t
 Interface descriptor structure for HID keyboard. More...
 
struct  udi_hid_kbd_report_desc_t
 Report descriptor for HID keyboard. More...
 

Interface with USB Device Core (UDC)

Variable required by UDC.

UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd
 Global structure which contains standard UDI API for UDC. More...
 

USB Interface Descriptors

The following structures provide predefined USB interface descriptors.

It must be used to define the final USB descriptors.

#define UDI_HID_KBD_STRING_ID   0
 By default no string associated to this interface. More...
 
#define UDI_HID_KBD_EP_SIZE   8
 HID keyboard endpoints size. More...
 
#define UDI_HID_KBD_DESC
 Content of HID keyboard interface descriptor for all speed. More...
 

USB Device Interface (UDI) for Human Interface Device (HID) Keyboard Class

Common APIs used by high level application to use this USB class.

bool udi_hid_kbd_modifier_up (uint8_t modifier_id)
 Send events key modifier released. More...
 
bool udi_hid_kbd_modifier_down (uint8_t modifier_id)
 Send events key modifier pressed. More...
 
bool udi_hid_kbd_up (uint8_t key_id)
 Send events key released. More...
 
bool udi_hid_kbd_down (uint8_t key_id)
 Send events key pressed. More...
 

#define UDI_HID_KBD_DESC
Value:
{\
.iface.bLength = sizeof(usb_iface_desc_t),\
.iface.bDescriptorType = USB_DT_INTERFACE,\
.iface.bInterfaceNumber = UDI_HID_KBD_IFACE_NUMBER,\
.iface.bAlternateSetting = 0,\
.iface.bNumEndpoints = 1,\
.iface.bInterfaceClass = HID_CLASS,\
.iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
.iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
.iface.iInterface = UDI_HID_KBD_STRING_ID,\
.hid.bLength = sizeof(usb_hid_descriptor_t),\
.hid.bDescriptorType = USB_DT_HID,\
.hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
.hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
.hid.bNumDescriptors = USB_HID_NUM_DESC,\
.hid.bRDescriptorType = USB_DT_HID_REPORT,\
.hid.wDescriptorLength = LE16(sizeof(udi_hid_kbd_report_desc_t)),\
.ep.bLength = sizeof(usb_ep_desc_t),\
.ep.bDescriptorType = USB_DT_ENDPOINT,\
.ep.bEndpointAddress = UDI_HID_KBD_EP_IN,\
.ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
.ep.wMaxPacketSize = LE16(UDI_HID_KBD_EP_SIZE),\
.ep.bInterval = 2,\
}
#define UDI_HID_KBD_EP_IN
USB HID Keyboard low level configuration In standalone these configurations are defined by the HID Ke...
Definition: common/services/usb/class/composite/device/example3/conf_usb.h:166
HID Descriptor.
Definition: usb_protocol_hid.h:116
#define UDI_HID_KBD_STRING_ID
By default no string associated to this interface.
Definition: udi_hid_kbd_doc.h:103
#define UDI_HID_KBD_IFACE_NUMBER
Interface number.
Definition: common/services/usb/class/composite/device/example3/conf_usb.h:169
#define USB_HID_NUM_DESC
Numeric expression specifying the number of class descriptors Note: Always at least one i...
Definition: usb_protocol_hid.h:143
Definition: usb_protocol_hid.h:86
Definition: usb_protocol.h:194
#define HID_SUB_CLASS_NOBOOT
Interface subclass NO support BOOT protocol.
Definition: usb_protocol_hid.h:58
Definition: usb_protocol.h:193
#define USB_HID_NO_COUNTRY_CODE
Definition: usb_protocol_hid.h:147
#define HID_CLASS
Definition: usb_protocol_hid.h:52
Standard USB interface descriptor structure.
Definition: usb_protocol.h:446
#define UDI_HID_KBD_EP_SIZE
HID keyboard endpoints size.
Definition: udi_hid_kbd_doc.h:107
Definition: usb_protocol_hid.h:87
#define USB_HID_BDC_V1_11
Numeric expression identifying the HID Class Specification release (here V1.11)
Definition: usb_protocol_hid.h:140
Report descriptor for HID keyboard.
Definition: udi_hid_kbd.h:75
Standard USB endpoint descriptor structure.
Definition: usb_protocol.h:461
#define LE16(x)
Definition: compiler.h:773
Definition: usb_protocol.h:252
#define HID_PROTOCOL_KEYBOARD
Protocol keyboard standard.
Definition: usb_protocol_hid.h:68

Content of HID keyboard interface descriptor for all speed.

#define UDI_HID_KBD_EP_SIZE   8

HID keyboard endpoints size.

#define UDI_HID_KBD_STRING_ID   0

By default no string associated to this interface.

bool udi_hid_kbd_down ( uint8_t  key_id)

Send events key pressed.

Parameters
[in]key_idID of key
Returns
1 if function was successfully done, otherwise 0.
Parameters
key_idID of key

References cpu_irq_restore(), cpu_irq_save(), i, udi_hid_kbd_b_report_valid, udi_hid_kbd_report, UDI_HID_KBD_REPORT_SIZE, and udi_hid_kbd_send_report().

bool udi_hid_kbd_modifier_down ( uint8_t  modifier_id)

Send events key modifier pressed.

Parameters
[in]modifier_idID of key modifier
Returns
1 if function was successfully done, otherwise 0.
Parameters
modifier_idID of key modifier
Returns
1 if function was successfully done, otherwise 0.

References cpu_irq_restore(), cpu_irq_save(), udi_hid_kbd_b_report_valid, udi_hid_kbd_report, and udi_hid_kbd_send_report().

bool udi_hid_kbd_modifier_up ( uint8_t  modifier_id)

Send events key modifier released.

Parameters
[in]modifier_idID of key modifier
Returns
1 if function was successfully done, otherwise 0.
Parameters
modifier_idID of key modifier
Returns
1 if function was successfully done, otherwise 0.

References cpu_irq_restore(), cpu_irq_save(), udi_hid_kbd_b_report_valid, udi_hid_kbd_report, and udi_hid_kbd_send_report().

bool udi_hid_kbd_up ( uint8_t  key_id)

Send events key released.

Parameters
[in]key_idID of key
Returns
1 if function was successfully done, otherwise 0.
Parameters
key_idID of key
Returns
1 if function was successfully done, otherwise 0.

References cpu_irq_restore(), cpu_irq_save(), i, udi_hid_kbd_b_report_valid, udi_hid_kbd_report, UDI_HID_KBD_REPORT_SIZE, and udi_hid_kbd_send_report().

UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd

Global structure which contains standard UDI API for UDC.

Global structure which contains standard UDI API for UDC.