]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h
Merge commit 'f6d56675f9f981c5464f0ca7a1fbb0162154e8c5'
[qmk_firmware.git] / tmk_core / protocol / lufa / LUFA-git / Bootloaders / CDC / Descriptors.h
1 /*
2              LUFA Library
3      Copyright (C) Dean Camera, 2014.
4
5   dean [at] fourwalledcubicle [dot] com
6            www.lufa-lib.org
7 */
8
9 /*
10   Copyright 2014  Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12   Permission to use, copy, modify, distribute, and sell this
13   software and its documentation for any purpose is hereby granted
14   without fee, provided that the above copyright notice appear in
15   all copies and that both that the copyright notice and this
16   permission notice and warranty disclaimer appear in supporting
17   documentation, and that the name of the author not be used in
18   advertising or publicity pertaining to distribution of the
19   software without specific, written prior permission.
20
21   The author disclaims all warranties with regard to this
22   software, including all implied warranties of merchantability
23   and fitness.  In no event shall the author be liable for any
24   special, indirect or consequential damages or any damages
25   whatsoever resulting from loss of use, data or profits, whether
26   in an action of contract, negligence or other tortious action,
27   arising out of or in connection with the use or performance of
28   this software.
29 */
30
31 /** \file
32  *
33  *  Header file for Descriptors.c.
34  */
35
36 #ifndef _DESCRIPTORS_H_
37 #define _DESCRIPTORS_H_
38
39         /* Includes: */
40                 #include <LUFA/Drivers/USB/USB.h>
41
42                 #include "Config/AppConfig.h"
43
44         /* Macros: */
45                 #if defined(__AVR_AT90USB1287__)
46                         #define AVR_SIGNATURE_1               0x1E
47                         #define AVR_SIGNATURE_2               0x97
48                         #define AVR_SIGNATURE_3               0x82
49                 #elif defined(__AVR_AT90USB647__)
50                         #define AVR_SIGNATURE_1               0x1E
51                         #define AVR_SIGNATURE_2               0x96
52                         #define AVR_SIGNATURE_3               0x82
53                 #elif defined(__AVR_AT90USB1286__)
54                         #define AVR_SIGNATURE_1               0x1E
55                         #define AVR_SIGNATURE_2               0x97
56                         #define AVR_SIGNATURE_3               0x82
57                 #elif defined(__AVR_AT90USB646__)
58                         #define AVR_SIGNATURE_1               0x1E
59                         #define AVR_SIGNATURE_2               0x96
60                         #define AVR_SIGNATURE_3               0x82
61                 #elif defined(__AVR_ATmega32U4__)
62                         #define AVR_SIGNATURE_1               0x1E
63                         #define AVR_SIGNATURE_2               0x95
64                         #define AVR_SIGNATURE_3               0x87
65                 #elif defined(__AVR_ATmega16U4__)
66                         #define AVR_SIGNATURE_1               0x1E
67                         #define AVR_SIGNATURE_2               0x94
68                         #define AVR_SIGNATURE_3               0x88
69                 #elif defined(__AVR_ATmega32U2__)
70                         #define AVR_SIGNATURE_1               0x1E
71                         #define AVR_SIGNATURE_2               0x95
72                         #define AVR_SIGNATURE_3               0x8A
73                 #elif defined(__AVR_ATmega16U2__)
74                         #define AVR_SIGNATURE_1               0x1E
75                         #define AVR_SIGNATURE_2               0x94
76                         #define AVR_SIGNATURE_3               0x89
77                 #elif defined(__AVR_AT90USB162__)
78                         #define AVR_SIGNATURE_1               0x1E
79                         #define AVR_SIGNATURE_2               0x94
80                         #define AVR_SIGNATURE_3               0x82
81                 #elif defined(__AVR_ATmega8U2__)
82                         #define AVR_SIGNATURE_1               0x1E
83                         #define AVR_SIGNATURE_2               0x93
84                         #define AVR_SIGNATURE_3               0x89
85                 #elif defined(__AVR_AT90USB82__)
86                         #define AVR_SIGNATURE_1               0x1E
87                         #define AVR_SIGNATURE_2               0x94
88                         #define AVR_SIGNATURE_3               0x82
89                 #else
90                         #error The selected AVR part is not currently supported by this bootloader.
91                 #endif
92
93                 /** Endpoint address for the CDC control interface event notification endpoint. */
94                 #define CDC_NOTIFICATION_EPADDR        (ENDPOINT_DIR_IN | 2)
95
96                 /** Endpoint address for the CDC data interface TX (data IN) endpoint. */
97                 #define CDC_TX_EPADDR                  (ENDPOINT_DIR_IN | 3)
98
99                 /** Endpoint address for the CDC data interface RX (data OUT) endpoint. */
100                 #define CDC_RX_EPADDR                  (ENDPOINT_DIR_OUT | 4)
101
102                 /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */
103                 #define CDC_TXRX_EPSIZE                16
104
105                 /** Size of the CDC control interface notification endpoint bank, in bytes. */
106                 #define CDC_NOTIFICATION_EPSIZE        8
107
108         /* Type Defines: */
109                 /** Type define for the device configuration descriptor structure. This must be defined in the
110                  *  application code, as the configuration descriptor contains several sub-descriptors which
111                  *  vary between devices, and which describe the device's usage to the host.
112                  */
113                 typedef struct
114                 {
115                         USB_Descriptor_Configuration_Header_t    Config;
116
117                         // CDC Control Interface
118                         USB_Descriptor_Interface_t               CDC_CCI_Interface;
119                         USB_CDC_Descriptor_FunctionalHeader_t    CDC_Functional_Header;
120                         USB_CDC_Descriptor_FunctionalACM_t       CDC_Functional_ACM;
121                         USB_CDC_Descriptor_FunctionalUnion_t     CDC_Functional_Union;
122                         USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint;
123
124                         // CDC Data Interface
125                         USB_Descriptor_Interface_t               CDC_DCI_Interface;
126                         USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint;
127                         USB_Descriptor_Endpoint_t                CDC_DataInEndpoint;
128                 } USB_Descriptor_Configuration_t;
129
130                 /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
131                  *  should have a unique ID index associated with it, which can be used to refer to the
132                  *  interface from other descriptors.
133                  */
134                 enum InterfaceDescriptors_t
135                 {
136                         INTERFACE_ID_CDC_CCI = 0, /**< CDC CCI interface descriptor ID */
137                         INTERFACE_ID_CDC_DCI = 1, /**< CDC DCI interface descriptor ID */
138                 };
139
140                 /** Enum for the device string descriptor IDs within the device. Each string descriptor should
141                  *  have a unique ID index associated with it, which can be used to refer to the string from
142                  *  other descriptors.
143                  */
144                 enum StringDescriptors_t
145                 {
146                         STRING_ID_Language     = 0, /**< Supported Languages string descriptor ID (must be zero) */
147                         STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
148                         STRING_ID_Product      = 2, /**< Product string ID */
149                 };
150
151         /* Function Prototypes: */
152                 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
153                                                     const uint8_t wIndex,
154                                                     const void** const DescriptorAddress)
155                                                     ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
156
157 #endif
158