1 /*******************************************************************
2 Copyright (C) 2008 FreakLabs
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 Please post support questions to the FreakLabs forum.
19 *******************************************************************/
24 /*******************************************************************/
26 #include <avr/pgmspace.h>
28 U8 dev_desc
[] PROGMEM
=
31 DEV_DESCR
, // bDescriptorType
33 0x02, // bcdUSB: 0200 (2.0)
34 0x02, // bDeviceClass: CDC
35 0x00, // bDeviceSubClass: Get from cfg descr
36 0x00, // bDeviceProtocol: Get from cfg descr
37 MAX_BUF_SZ
, // bMaxPacketSize: MAX_BUF_SZ
39 0x03, // idVendor: 0x03EB (use Atmel's VID for now)
41 0x20, // idProduct: 0x2018 (use Atmel's PID for now)
43 0x01, // bcdDevice: 0100 (v1.00)
44 1, // Index of string descriptor describing manufacturer
45 2, // Index of string descriptor describing product
46 3, // Index of string descriptor describing the device's serial number
47 0x01 // bNumConfigurations
51 U8 cfg_desc
[] PROGMEM
=
54 0x09, // bLength: cfg desc len
55 CFG_DESCR
, // bDescriptorType: Configuration
56 0x43, // wTotalLength: 0x43 (67 bytes = total size of cfg + sub descriptors)
58 0x02, // bNumInterfaces: 2 interface
59 0x01, // bConfigurationValue: Configuration value
60 0x00, // iConfiguration: Index of string descriptor describing the configuration
61 0xA0, // bmAttributes: bus powered
62 0x32, // MaxPower 100 mA
65 0x09, // bLength: Interface Descriptor size
66 INTF_DESCR
, // bDescriptorType: Interface
67 0x00, // bInterfaceNumber: Number of Interface
68 0x00, // bAlternateSetting: Alternate setting
69 0x01, // bNumEndpoints: One endpoints used
70 0x02, // bInterfaceClass: Communication Interface Class
71 0x02, // bInterfaceSubClass: Abstract Control Model
72 0x01, // bInterfaceProtocol: Common AT commands
75 // hdr functional descr
76 0x05, // bLength: Endpoint Descriptor size
77 0x24, // bDescriptorType: CS_INTERFACE
78 0x00, // bDescriptorSubtype: Header Func Desc
79 0x10, // bcdCDC: spec release number 0110 (1.1)
82 // call mgmt functional descriptors
83 0x05, // bFunctionLength
84 0x24, // bDescriptorType: CS_INTERFACE
85 0x01, // bDescriptorSubtype: Call Management Func Desc
86 0x00, // bmCapabilities: D0+D1
87 0x01, // bDataInterface: 1
89 // acm functional descr
90 0x04, // bFunctionLength
91 0x24, // bDescriptorType: CS_INTERFACE
92 0x02, // bDescriptorSubtype: Abstract Control Management desc
93 0x02, // bmCapabilities
95 // union functional descr
96 0x05, // bFunctionLength
97 0x24, // bDescriptorType: CS_INTERFACE
98 0x06, // bDescriptorSubtype: Union func desc
99 0x00, // bMasterInterface: Communication class interface
100 0x01, // bSlaveInterface0: Data Class Interface
103 0x07, // bLength: Endpoint Descriptor size
104 EP_DESCR
, // bDescriptorType: Endpoint
105 0x82, // bEndpointAddress: (IN2)
106 0x03, // bmAttributes: Interrupt
107 0x08, // wMaxPacketSize:
109 0xff, // bInterval: 255 msec
110 // not really using this endpoint for anything so just set
111 // it to a fucking long interval
113 // data class intf descr
114 0x09, // bLength: Interface Descriptor size
115 INTF_DESCR
, // bDescriptorType: interface descriptor
116 0x01, // bInterfaceNumber: Number of Interface
117 0x00, // bAlternateSetting: Alternate setting
118 0x02, // bNumEndpoints: Two endpoints used
119 0x0A, // bInterfaceClass: CDC
120 0x00, // bInterfaceSubClass:
121 0x00, // bInterfaceProtocol:
125 0x07, // bLength: Endpoint Descriptor size
126 EP_DESCR
, // bDescriptorType: Endpoint
127 0x03, // bEndpointAddress: (OUT3)
128 0x02, // bmAttributes: Bulk
129 MAX_BUF_SZ
, // wMaxPacketSize: MAX_BUF_SZ
131 0x00, // bInterval: ignore for Bulk transfer
134 0x07, // bLength: Endpoint Descriptor size
135 EP_DESCR
, // bDescriptorType: Endpoint
136 0x81, // bEndpointAddress: (IN1)
137 0x02, // bmAttributes: Bulk
138 MAX_BUF_SZ
, // wMaxPacketSize: MAX_BUF_SZ
140 0x00 // bInterval: ignore for Bulk transfer
143 U8 dev_qualifier_desc
[] PROGMEM
=
146 0x06, // bDescriptorType: Device Qualifier
148 0x02, // bcdUSB Spec Version: 0200 (2.0)
149 0x02, // bDeviceClass: CDC
150 0x00, // bDeviceSubClass: Get from cfg descr
151 0x00, // bDeviceProtocol: Get from cfg descr
152 MAX_BUF_SZ
, // bMaxPacketSize: MAX_BUF_SZ
153 0x01, // bNumConfigurations: 1
154 0x00 // bReserved: Don't touch this or the device explodes
157 U8 lang_str_desc
[] PROGMEM
=
160 STR_DESCR
, // bDescriptorType: String
165 U8 vendor_str_desc
[] PROGMEM
=
168 STR_DESCR
, // bDescriptorType: String
169 // Manufacturer: "FreakLabs"
170 'F',0, 'r',0, 'e',0, 'a',0, 'k',0, 'L',0, 'a',0, 'b',0,
174 U8 prod_str_desc
[] PROGMEM
=
176 0x4A, // bLength: 0x3E (62 bytes = sizeof str fields + string)
177 STR_DESCR
, // bDescriptorType: String
178 // Product name: "FreakLabs RP AVRUSB Virtual COM Port"
180 'F',0, 'r',0, 'e',0, 'a',0, 'k',0, 'L',0, 'a',0, 'b',0,
181 's',0, ' ',0, 'R',0, 'P',0, ' ',0, 'A',0, 'V',0, 'R',0,
182 'U',0, 'S',0, 'B',0, ' ',0, 'V',0, 'i',0, 'r',0, 't',0,
183 'u',0, 'a',0, 'l',0, ' ',0, 'C',0, 'O',0, 'M',0, ' ',0,
184 'P',0, 'o',0, 'r',0, 't',0,
187 U8 serial_str_desc
[] PROGMEM
=
189 0x14, // bLength: 0x14 (20 bytes = sizeof str fields + string)
190 STR_DESCR
, // bDescriptorType: String
192 'B',0, 'e',0, 't',0, 'a',0, ' ',0, '0',0, '.',0, '5',0,
196 /**************************************************************************/
198 Return a pointer to the device descriptor.
200 /**************************************************************************/
206 /**************************************************************************/
208 Return the length of the device descriptor. The length is stored in the
209 first byte of the device descriptor.
211 /**************************************************************************/
212 U8
desc_dev_get_len()
214 return pgm_read_byte(dev_desc
);
217 /**************************************************************************/
219 Return a pointer to the configuration descriptor.
221 /**************************************************************************/
227 /**************************************************************************/
229 Return the length of the configuration descriptor. The length of the complete
230 configuration descriptor is stored in the third byte of the config
233 /**************************************************************************/
234 U8
desc_cfg_get_len()
236 return pgm_read_byte(cfg_desc
+ 2);
239 /**************************************************************************/
241 Return a pointer to the device qualifier.
243 /**************************************************************************/
244 U8
*desc_dev_qual_get()
246 return dev_qualifier_desc
;
249 /**************************************************************************/
251 Return the length of the device qualifier. The length is stored in the
252 first byte of the qualifier.
254 /**************************************************************************/
255 U8
desc_dev_qual_get_len()
257 return pgm_read_byte(dev_qualifier_desc
);
260 /**************************************************************************/
262 Return a pointer to the specified string descriptor.
264 /**************************************************************************/
265 U8
*desc_str_get(U8 index
)
270 return (U8
*)lang_str_desc
;
272 return (U8
*)vendor_str_desc
;
274 return (U8
*)prod_str_desc
;
275 case SERIAL_DESC_IDX
:
276 return (U8
*)serial_str_desc
;
282 /**************************************************************************/
284 Return the length of the specified string descriptor.
286 /**************************************************************************/
287 U8
desc_str_get_len(U8 index
)
292 return pgm_read_byte(lang_str_desc
);
294 return pgm_read_byte(vendor_str_desc
);
296 return pgm_read_byte(prod_str_desc
);
297 case SERIAL_DESC_IDX
:
298 return pgm_read_byte(serial_str_desc
);