Hanna
Sourcecode Kontrollplatine
Descriptors.c
gehe zur Dokumentation dieser Datei
1 
19 #include "usb_defaults.h"
20 #include "Descriptors.h"
21 
27 const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
28 { .Header =
29  { .Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device },
30 
31  .USBSpecification = VERSION_BCD( 01.10 ),
32  .Class = CDC_CSCP_CDCClass,
33  .SubClass = CDC_CSCP_NoSpecificSubclass,
34  .Protocol = CDC_CSCP_NoSpecificProtocol,
35 
36  .Endpoint0Size = USB_DEF_EP0_SIZE,
37 
38  .VendorID = USB_DEF_VID,
39  .ProductID = USB_DEF_PID,
40  .ReleaseNumber = VERSION_BCD( 00.01 ),
41 
42  .ManufacturerStrIndex = 0x01,
43  .ProductStrIndex = 0x02,
44  .SerialNumStrIndex = USE_INTERNAL_SERIAL,
45 
46  .NumberOfConfigurations = 1 };
47 
54 { .Config =
55  { .Header =
56  { .Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration },
57 
58  .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
59  .TotalInterfaces = 2,
60 
61  .ConfigurationNumber = 1,
62  .ConfigurationStrIndex = NO_DESCRIPTOR,
63 
64  .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
65 
66  .MaxPowerConsumption = USB_CONFIG_POWER_MA( 100 ) },
67 
68  .CDC_CCI_Interface =
69  { .Header =
70  { .Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface },
71 
72  .InterfaceNumber = 0,
73  .AlternateSetting = 0,
74 
75  .TotalEndpoints = 1,
76 
77  .Class = CDC_CSCP_CDCClass,
78  .SubClass = CDC_CSCP_ACMSubclass,
79  .Protocol = CDC_CSCP_ATCommandProtocol,
80 
81  .InterfaceStrIndex = NO_DESCRIPTOR },
82 
83  .CDC_Functional_Header =
84  { .Header =
85  { .Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface },
87 
88  .CDCSpecification = VERSION_BCD( 01.10 ), },
89 
90  .CDC_Functional_ACM =
91  { .Header =
92  { .Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface },
94 
95  .Capabilities = 0x06, },
96 
97  .CDC_Functional_Union =
98  { .Header =
99  { .Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface },
101 
102  .MasterInterfaceNumber = 0, .SlaveInterfaceNumber = 1, },
103 
104  .CDC_NotificationEndpoint =
105  { .Header =
106  { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint },
107 
108  .EndpointAddress = CDC_NOTIFICATION_EPADDR,
109  .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
110  .EndpointSize = CDC_NOTIFICATION_EPSIZE, .PollingIntervalMS = 0xFF },
111 
112  .CDC_DCI_Interface =
113  { .Header =
114  { .Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface },
115 
116  .InterfaceNumber = 1,
117  .AlternateSetting = 0,
118 
119  .TotalEndpoints = 2,
120 
121  .Class = CDC_CSCP_CDCDataClass,
122  .SubClass = CDC_CSCP_NoDataSubclass,
123  .Protocol = CDC_CSCP_NoDataProtocol,
124 
125  .InterfaceStrIndex = NO_DESCRIPTOR },
126 
127  .CDC_DataOutEndpoint =
128  { .Header =
129  { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint },
130 
131  .EndpointAddress = CDC_RX_EPADDR,
132  .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
133  .EndpointSize = CDC_TXRX_EPSIZE,
134  .PollingIntervalMS = 0x01 },
135 
136  .CDC_DataInEndpoint =
137  { .Header =
138  { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint },
139 
140  .EndpointAddress = CDC_TX_EPADDR,
141  .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
142  .EndpointSize = CDC_TXRX_EPSIZE,
143  .PollingIntervalMS = 0x01 } };
144 
149 const USB_Descriptor_String_t PROGMEM LanguageString =
150 { .Header =
151 { .Size = USB_STRING_LEN( 1 ), .Type = DTYPE_String },
152 
153 .UnicodeString =
154 { LANGUAGE_ID_ENG } };
155 
160 const USB_Descriptor_String_t PROGMEM ManufacturerString =
161 { .Header =
162 { .Size = USB_STRING_LEN( 6 ), .Type = DTYPE_String },
163 
164 .UnicodeString = L"woodym" };
165 
170 const USB_Descriptor_String_t PROGMEM ProductString =
171 { .Header =
172 { .Size = USB_STRING_LEN( 14 ), .Type = DTYPE_String },
173 
174 .UnicodeString = L"CNC Controller" };
175 
182 uint16_t CALLBACK_USB_GetDescriptor ( const uint16_t wValue,
183  const uint8_t wIndex, const void** const DescriptorAddress )
184 {
185  const uint8_t DescriptorType = (wValue >> 8);
186  const uint8_t DescriptorNumber = (wValue & 0xFF);
187 
188  const void* Address = NULL;
189  uint16_t Size = NO_DESCRIPTOR;
190 
191  switch (DescriptorType)
192  {
193  case DTYPE_Device:
194  Address = &DeviceDescriptor;
195  Size = sizeof(USB_Descriptor_Device_t);
196  break;
197  case DTYPE_Configuration:
198  Address = &ConfigurationDescriptor;
199  Size = sizeof(USB_Descriptor_Configuration_t);
200  break;
201  case DTYPE_String:
202  switch (DescriptorNumber)
203  {
204  case 0x00:
205  Address = &LanguageString;
206  Size = pgm_read_byte( &LanguageString.Header.Size );
207  break;
208  case 0x01:
209  Address = &ManufacturerString;
210  Size = pgm_read_byte( &ManufacturerString.Header.Size );
211  break;
212  case 0x02:
213  Address = &ProductString;
214  Size = pgm_read_byte( &ProductString.Header.Size );
215  break;
216  }
217 
218  break;
219  }
220 
221  *DescriptorAddress = Address;
222  return Size;
223 }
224 
Bibliothek zur USB-Kommunikation von Jürgen W.
#define CDC_RX_EPADDR
Definition: Descriptors.h:61
#define CDC_TXRX_EPSIZE
Definition: Descriptors.h:67
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor
Definition: Descriptors.c:53
const USB_Descriptor_String_t PROGMEM ProductString
Definition: Descriptors.c:170
#define CDC_TX_EPADDR
Definition: Descriptors.h:58
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor
Definition: Descriptors.c:27
const USB_Descriptor_String_t PROGMEM LanguageString
Definition: Descriptors.c:149
#define CDC_NOTIFICATION_EPSIZE
Definition: Descriptors.h:64
#define CDC_NOTIFICATION_EPADDR
Definition: Descriptors.h:55
const USB_Descriptor_String_t PROGMEM ManufacturerString
Definition: Descriptors.c:160
Bibliothek zur USB-Kommunikation von Jürgen W.
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void **const DescriptorAddress)
Definition: Descriptors.c:182