Minor updates to the Benito programmer - remove redundant PORT register manipulations.
[pub/USBasp.git] / Bootloaders / CDC / Descriptors.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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 disclaim 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 /* Macros: */
43 #if defined(__AVR_AT90USB1286__)
44 #define AVR_SIGNATURE_1 0x1E
45 #define AVR_SIGNATURE_2 0x97
46 #define AVR_SIGNATURE_3 0x82
47 #elif defined(__AVR_AT90USB1287__)
48 #define AVR_SIGNATURE_1 0x1E
49 #define AVR_SIGNATURE_2 0x97
50 #define AVR_SIGNATURE_3 0x82
51 #elif defined(__AVR_AT90USB646__)
52 #define AVR_SIGNATURE_1 0x1E
53 #define AVR_SIGNATURE_2 0x96
54 #define AVR_SIGNATURE_3 0x82
55 #elif defined(__AVR_AT90USB647__)
56 #define AVR_SIGNATURE_1 0x1E
57 #define AVR_SIGNATURE_2 0x96
58 #define AVR_SIGNATURE_3 0x82
59 #elif defined(__AVR_AT90USB162__)
60 #define AVR_SIGNATURE_1 0x1E
61 #define AVR_SIGNATURE_2 0x94
62 #define AVR_SIGNATURE_3 0x82
63 #elif defined(__AVR_AT90USB82__)
64 #define AVR_SIGNATURE_1 0x1E
65 #define AVR_SIGNATURE_2 0x94
66 #define AVR_SIGNATURE_3 0x82
67 #elif defined(__AVR_ATmega32U6__)
68 #define AVR_SIGNATURE_1 0x1E
69 #define AVR_SIGNATURE_2 0x95
70 #define AVR_SIGNATURE_3 0x88
71 #elif defined(__AVR_ATmega32U4__)
72 #define AVR_SIGNATURE_1 0x1E
73 #define AVR_SIGNATURE_2 0x95
74 #define AVR_SIGNATURE_3 0x87
75 #elif defined(__AVR_ATmega16U4__)
76 #define AVR_SIGNATURE_1 0x1E
77 #define AVR_SIGNATURE_2 0x94
78 #define AVR_SIGNATURE_3 0x88
79 #else
80 #error The selected AVR part is not currently supported by this bootloader.
81 #endif
82
83 /** Structure for a CDC class Functional descriptor, with a given data size. This is used instead of a
84 * type define so that the same macro can be used for functional descriptors of varying data lengths,
85 * while allowing the sizeof() operator to return correct results.
86 *
87 * \param[in] DataSize Size of the functional descriptor's data payload, in bytes
88 */
89 #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \
90 struct \
91 { \
92 USB_Descriptor_Header_t Header; \
93 uint8_t SubType; \
94 uint8_t Data[DataSize]; \
95 }
96
97 /** Endpoint number for the CDC control interface event notification endpoint. */
98 #define CDC_NOTIFICATION_EPNUM 3
99
100 /** Size of the CDC control interface notification endpoint bank, in bytes */
101 #define CDC_NOTIFICATION_EPSIZE 8
102
103 /** Endpoint number for the CDC data interface TX (data IN) endpoint */
104 #define CDC_TX_EPNUM 1
105
106 /** Endpoint number for the CDC data interface RX (data OUT) endpoint */
107 #define CDC_RX_EPNUM 2
108
109 /** Size of the CDC data interface TX and RX data endpoint banks, in bytes */
110 #define CDC_TXRX_EPSIZE 16
111
112 /* Type Defines: */
113 /** Type define for the device configuration descriptor structure. This must be defined in the
114 * application code, as the configuration descriptor contains several sub-descriptors which
115 * vary between devices, and which describe the device's usage to the host.
116 */
117 typedef struct
118 {
119 USB_Descriptor_Configuration_Header_t Config;
120 USB_Descriptor_Interface_t CCI_Interface;
121 CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader;
122 CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_CallManagement;
123 CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement;
124 CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union;
125 USB_Descriptor_Endpoint_t ManagementEndpoint;
126 USB_Descriptor_Interface_t DCI_Interface;
127 USB_Descriptor_Endpoint_t DataOutEndpoint;
128 USB_Descriptor_Endpoint_t DataInEndpoint;
129 } USB_Descriptor_Configuration_t;
130
131 /* Function Prototypes: */
132 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
133 ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
134
135 #endif