4 * \brief Default descriptors for a USB Device
5 * with a single interface HID keyboard
7 * Copyright (c) 2009-2016 Atmel Corporation. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
23 * 3. The name of Atmel may not be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * 4. This software may only be redistributed and used in connection with an
27 * Atmel microcontroller product.
29 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
32 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
33 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
45 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
49 #include "usb_protocol.h"
51 #include "udi_device_conf.h"
52 #include "udi_hid_kbd.h"
56 * \ingroup udi_hid_keyboard_group
57 * \defgroup udi_hid_keyboard_group_single_desc USB device descriptors for a single interface
59 * The following structures provide the USB device descriptors required
60 * for USB Device with a single interface HID keyboard.
62 * It is ready to use and do not require more definition.
66 //! USB Device Descriptor
68 UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
69 .bLength = sizeof(usb_dev_desc_t),
70 .bDescriptorType = USB_DT_DEVICE,
71 .bcdUSB = LE16(USB_V2_0),
72 .bDeviceClass = DEVICE_CLASS,
73 .bDeviceSubClass = DEVICE_SUBCLASS,
74 .bDeviceProtocol = DEVICE_PROTOCOL,
75 .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
76 .idVendor = LE16(USB_DEVICE_VENDOR_ID),
77 .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
78 .bcdDevice = LE16(USB_DEVICE_VERSION),
79 #ifdef USB_DEVICE_MANUFACTURE_NAME
82 .iManufacturer = 0, // No manufacture string
84 #ifdef USB_DEVICE_PRODUCT_NAME
87 .iProduct = 0, // No product string
89 #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
92 .iSerialNumber = 0, // No serial string
94 .bNumConfigurations = 1
98 #ifdef USB_DEVICE_HS_SUPPORT
99 //! USB Device Qualifier Descriptor for HS
100 COMPILER_WORD_ALIGNED
101 UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
102 .bLength = sizeof(usb_dev_qual_desc_t),
103 .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
104 .bcdUSB = LE16(USB_V2_0),
106 .bDeviceSubClass = 0,
107 .bDeviceProtocol = 0,
108 .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
109 .bNumConfigurations = 1
114 //! USB Device Configuration Descriptor filled for FS and HS
115 COMPILER_WORD_ALIGNED
116 UDC_DESC_STORAGE udc_desc_t udc_desc = {
117 .conf.bLength = sizeof(usb_conf_desc_t),
118 .conf.bDescriptorType = USB_DT_CONFIGURATION,
119 .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
120 .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
121 .conf.bConfigurationValue = 1,
122 .conf.iConfiguration = 0,
123 .conf.bmAttributes = /* USB_CONFIG_ATTR_MUST_SET | */ USB_DEVICE_ATTR,
124 .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
126 .hid_kbd = UDI_HID_KBD_DESC,
129 .hid_raw = UDI_HID_RAW_DESC,
132 .hid_mou = UDI_HID_MOU_DESC,
135 .hid_exk = UDI_HID_EXK_DESC,
138 .hid_nkro = UDI_HID_NKRO_DESC,
141 .cdc_serial = CDC_DESCRIPTOR,
145 UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
162 &udi_api_cdc_comm, &udi_api_cdc_data,
166 //! Add UDI with USB Descriptors FS & HS
167 UDC_DESC_STORAGE udc_config_speed_t udc_config_fshs[1] = {{
168 .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc,
169 .udi_apis = udi_apis,
172 //! Add all information about USB Device in global structure for UDC
173 UDC_DESC_STORAGE udc_config_t udc_config = {
174 .confdev_lsfs = &udc_device_desc,
175 .conf_lsfs = udc_config_fshs,