]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c
Massdrop keyboard support (#3780)
[qmk_firmware.git] / tmk_core / protocol / arm_atsam / usb / udi_hid_kbd_desc.c
1 /**
2  * \file
3  *
4  * \brief Default descriptors for a USB Device
5  * with a single interface HID keyboard
6  *
7  * Copyright (c) 2009-2016 Atmel Corporation. All rights reserved.
8  *
9  * \asf_license_start
10  *
11  * \page License
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions are met:
15  *
16  * 1. Redistributions of source code must retain the above copyright notice,
17  *    this list of conditions and the following disclaimer.
18  *
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.
22  *
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.
25  *
26  * 4. This software may only be redistributed and used in connection with an
27  *    Atmel microcontroller product.
28  *
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.
40  *
41  * \asf_license_stop
42  *
43  */
44 /*
45  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
46  */
47
48 #include "conf_usb.h"
49 #include "usb_protocol.h"
50 #include "udc_desc.h"
51 #include "udi_device_conf.h"
52 #include "udi_hid_kbd.h"
53 #include "udi_cdc.h"
54
55 /**
56  * \ingroup udi_hid_keyboard_group
57  * \defgroup udi_hid_keyboard_group_single_desc USB device descriptors for a single interface
58  *
59  * The following structures provide the USB device descriptors required
60  * for USB Device with a single interface HID keyboard.
61  *
62  * It is ready to use and do not require more definition.
63  * @{
64  */
65
66 //! USB Device Descriptor
67 COMPILER_WORD_ALIGNED
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
80     .iManufacturer             = 1,
81 #else
82     .iManufacturer             = 0,  // No manufacture string
83 #endif
84 #ifdef USB_DEVICE_PRODUCT_NAME
85     .iProduct                  = 2,
86 #else
87     .iProduct                  = 0,  // No product string
88 #endif
89 #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
90     .iSerialNumber             = 3,
91 #else
92     .iSerialNumber             = 0,  // No serial string
93 #endif
94     .bNumConfigurations        = 1
95 };
96
97 #if 0
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),
105     .bDeviceClass              = 0,
106     .bDeviceSubClass           = 0,
107     .bDeviceProtocol           = 0,
108     .bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
109     .bNumConfigurations        = 1
110 };
111 #endif
112 #endif
113
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),
125 #ifdef KBD
126     .hid_kbd                   = UDI_HID_KBD_DESC,
127 #endif
128 #ifdef RAW
129     .hid_raw                   = UDI_HID_RAW_DESC,
130 #endif
131 #ifdef MOU
132     .hid_mou                   = UDI_HID_MOU_DESC,
133 #endif
134 #ifdef EXK
135   .hid_exk                   = UDI_HID_EXK_DESC,
136 #endif
137 #ifdef NKRO
138   .hid_nkro                  = UDI_HID_NKRO_DESC,
139 #endif
140 #ifdef CDC
141   .cdc_serial                = CDC_DESCRIPTOR,
142 #endif
143 };
144
145 UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
146   #ifdef KBD
147     &udi_api_hid_kbd,
148   #endif
149   #ifdef RAW
150     &udi_api_hid_raw,
151   #endif
152   #ifdef MOU
153     &udi_api_hid_mou,
154   #endif
155   #ifdef EXK
156     &udi_api_hid_exk,
157   #endif
158   #ifdef NKRO
159     &udi_api_hid_nkro,
160   #endif
161   #ifdef CDC
162   &udi_api_cdc_comm, &udi_api_cdc_data,
163   #endif
164 };
165
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,
170 }};
171
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,
176 };
177
178 //@}
179 //@}