Rev Author Line No. Line
3331 kaklik 1 /* Name: usbconfig.h
2 * Project: AVR USB driver
3 * Author: Christian Starkjohann
4 * Creation Date: 2005-04-01
5 * Tabsize: 4
6 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
7 * License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
8 * This Revision: $Id: usbconfig-prototype.h 275 2007-03-20 09:58:28Z cs $
9 */
10  
11 #ifndef __usbconfig_h_included__
12 #define __usbconfig_h_included__
13  
14 /*
15 General Description:
16 This file is an example configuration (with inline documentation) for the USB
17 driver. It configures AVR-USB for an ATMega8 with USB D+ connected to Port D
18 bit 2 (which is also hardware interrupt 0) and USB D- to Port D bit 0. You may
19 wire the lines to any other port, as long as D+ is also wired to INT0.
20 To create your own usbconfig.h file, copy this file to the directory
21 containing "usbdrv" (that is your project firmware source directory) and
22 rename it to "usbconfig.h". Then edit it accordingly.
23 */
24  
25 /* ---------------------------- Hardware Config ---------------------------- */
26  
27 #define USB_CFG_IOPORTNAME D
28 /* This is the port where the USB bus is connected. When you configure it to
29 * "B", the registers PORTB, PINB and DDRB will be used.
30 */
31 #define USB_CFG_DMINUS_BIT 0
32 /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
33 * This may be any bit in the port.
34 */
35 #define USB_CFG_DPLUS_BIT 2
36 /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
37 * This may be any bit in the port. Please note that D+ must also be connected
38 * to interrupt pin INT0!
39 */
40  
41 /* ----------------------- Optional Hardware Config ------------------------ */
42  
43 /* #define USB_CFG_PULLUP_IOPORTNAME D */
44 /* If you connect the 1.5k pullup resistor from D- to a port pin instead of
45 * V+, you can connect and disconnect the device from firmware by calling
46 * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
47 * This constant defines the port on which the pullup resistor is connected.
48 */
49 /* #define USB_CFG_PULLUP_BIT 4 */
50 /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
51 * above) where the 1.5k pullup resistor is connected. See description
52 * above for details.
53 */
54  
55 /* --------------------------- Functional Range ---------------------------- */
56  
57 #define USB_CFG_HAVE_INTRIN_ENDPOINT 1
58 /* Define this to 1 if you want to compile a version with two endpoints: The
59 * default control endpoint 0 and an interrupt-in endpoint 1.
60 */
61 #define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
62 /* Define this to 1 if you want to compile a version with three endpoints: The
63 * default control endpoint 0, an interrupt-in endpoint 1 and an interrupt-in
64 * endpoint 3. You must also enable endpoint 1 above.
65 */
66 #define USB_CFG_IMPLEMENT_HALT 0
67 /* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
68 * for endpoint 1 (interrupt endpoint). Although you may not need this feature,
69 * it is required by the standard. We have made it a config option because it
70 * bloats the code considerably.
71 */
72 #define USB_CFG_INTR_POLL_INTERVAL 20
73 /* If you compile a version with endpoint 1 (interrupt-in), this is the poll
74 * interval. The value is in milliseconds and must not be less than 10 ms for
75 * low speed devices.
76 */
77 #define USB_CFG_IS_SELF_POWERED 0
78 /* Define this to 1 if the device has its own power supply. Set it to 0 if the
79 * device is powered from the USB bus.
80 */
81 #define USB_CFG_MAX_BUS_POWER 100
82 /* Set this variable to the maximum USB bus power consumption of your device.
83 * The value is in milliamperes. [It will be divided by two since USB
84 * communicates power requirements in units of 2 mA.]
85 */
86 #define USB_CFG_IMPLEMENT_FN_WRITE 0
87 /* Set this to 1 if you want usbFunctionWrite() to be called for control-out
88 * transfers. Set it to 0 if you don't need it and want to save a couple of
89 * bytes.
90 */
91 #define USB_CFG_IMPLEMENT_FN_READ 0
92 /* Set this to 1 if you need to send control replies which are generated
93 * "on the fly" when usbFunctionRead() is called. If you only want to send
94 * data from a static buffer, set it to 0 and return the data from
95 * usbFunctionSetup(). This saves a couple of bytes.
96 */
97 #define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
98 /* Define this to 1 if you want to use interrupt-out (or bulk out) endpoint 1.
99 * You must implement the function usbFunctionWriteOut() which receives all
100 * interrupt/bulk data sent to endpoint 1.
101 */
102 #define USB_CFG_HAVE_FLOWCONTROL 0
103 /* Define this to 1 if you want flowcontrol over USB data. See the definition
104 * of the macros usbDisableAllRequests() and usbEnableAllRequests() in
105 * usbdrv.h.
106 */
107  
108 /* -------------------------- Device Description --------------------------- */
109  
110 #define USB_CFG_VENDOR_ID 0xc0, 0x16
111 /* USB vendor ID for the device, low byte first. If you have registered your
112 * own Vendor ID, define it here. Otherwise you use obdev's free shared
113 * VID/PID pair. Be sure to read USBID-License.txt for rules!
114 * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df.
115 * Use this VID/PID pair ONLY if you understand the implications!
116 */
117 #define USB_CFG_DEVICE_ID 0xdf, 0x05
118 /* This is the ID of the product, low byte first. It is interpreted in the
119 * scope of the vendor ID. If you have registered your own VID with usb.org
120 * or if you have licensed a PID from somebody else, define it here. Otherwise
121 * you use obdev's free shared VID/PID pair. Be sure to read the rules in
122 * USBID-License.txt!
123 * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df.
124 * Use this VID/PID pair ONLY if you understand the implications!
125 */
126 #define USB_CFG_DEVICE_VERSION 0x00, 0x01
127 /* Version number of the device: Minor number first, then major number.
128 */
129 #define USB_CFG_VENDOR_NAME 'w', 'w', 'w', '.', 'o', 'b', 'd', 'e', 'v', '.', 'a', 't'
130 #define USB_CFG_VENDOR_NAME_LEN 12
131 /* These two values define the vendor name returned by the USB device. The name
132 * must be given as a list of characters under single quotes. The characters
133 * are interpreted as Unicode (UTF-16) entities.
134 * If you don't want a vendor name string, undefine these macros.
135 * ALWAYS define a vendor name containing your Internet domain name if you use
136 * obdev's free shared VID/PID pair. See the file USBID-License.txt for
137 * details.
138 */
139 #define USB_CFG_DEVICE_NAME 'T', 'e', 'm', 'p', 'l', 'a', 't', 'e'
140 #define USB_CFG_DEVICE_NAME_LEN 8
141 /* Same as above for the device name. If you don't want a device name, undefine
142 * the macros. See the file USBID-License.txt before you assign a name if you
143 * use a shared VID/PID.
144 */
145 /*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
146 /*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
147 /* Same as above for the serial number. If you don't want a serial number,
148 * undefine the macros.
149 * It may be useful to provide the serial number through other means than at
150 * compile time. See the section about descriptor properties below for how
151 * to fine tune control over USB descriptors such as the string descriptor
152 * for the serial number.
153 */
154 #define USB_CFG_DEVICE_CLASS 0
155 #define USB_CFG_DEVICE_SUBCLASS 0
156 /* See USB specification if you want to conform to an existing device class.
157 */
158 #define USB_CFG_INTERFACE_CLASS 3 /* HID */
159 #define USB_CFG_INTERFACE_SUBCLASS 0
160 #define USB_CFG_INTERFACE_PROTOCOL 0
161 /* See USB specification if you want to conform to an existing device class or
162 * protocol.
163 * This template defines a HID class device. If you implement a vendor class
164 * device, set USB_CFG_INTERFACE_CLASS to 0 and USB_CFG_DEVICE_CLASS to 0xff.
165 */
166 #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 42 /* total length of report descriptor */
167 /* Define this to the length of the HID report descriptor, if you implement
168 * an HID device. Otherwise don't define it or define it to 0.
169 * Since this template defines a HID device, it must also specify a HID
170 * report descriptor length. You must add a PROGMEM character array named
171 * "usbHidReportDescriptor" to your code which contains the report descriptor.
172 * Don't forget to keep the array and this define in sync!
173 */
174  
175 /* ------------------- Fine Control over USB Descriptors ------------------- */
176 /* If you don't want to use the driver's default USB descriptors, you can
177 * provide our own. These can be provided as (1) fixed length static data in
178 * flash memory, (2) fixed length static data in RAM or (3) dynamically at
179 * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
180 * information about this function.
181 * Descriptor handling is configured through the descriptor's properties. If
182 * no properties are defined or if they are 0, the default descriptor is used.
183 * Possible properties are:
184 * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
185 * at runtime via usbFunctionDescriptor().
186 * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
187 * in static memory is in RAM, not in flash memory.
188 * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
189 * the driver must know the descriptor's length. The descriptor itself is
190 * found at the address of a well known identifier (see below).
191 * List of static descriptor names (must be declared PROGMEM if in flash):
192 * char usbDescriptorDevice[];
193 * char usbDescriptorConfiguration[];
194 * char usbDescriptorHidReport[];
195 * char usbDescriptorString0[];
196 * int usbDescriptorStringVendor[];
197 * int usbDescriptorStringDevice[];
198 * int usbDescriptorStringSerialNumber[];
199 * Other descriptors can't be provided statically, they must be provided
200 * dynamically at runtime.
201 *
202 * Descriptor properties are or-ed or added together, e.g.:
203 * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
204 *
205 * The following descriptors are defined:
206 * USB_CFG_DESCR_PROPS_DEVICE
207 * USB_CFG_DESCR_PROPS_CONFIGURATION
208 * USB_CFG_DESCR_PROPS_STRINGS
209 * USB_CFG_DESCR_PROPS_STRING_0
210 * USB_CFG_DESCR_PROPS_STRING_VENDOR
211 * USB_CFG_DESCR_PROPS_STRING_PRODUCT
212 * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
213 * USB_CFG_DESCR_PROPS_HID
214 * USB_CFG_DESCR_PROPS_HID_REPORT
215 * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
216 *
217 */
218  
219 #define USB_CFG_DESCR_PROPS_DEVICE 0
220 #define USB_CFG_DESCR_PROPS_CONFIGURATION 0
221 #define USB_CFG_DESCR_PROPS_STRINGS 0
222 #define USB_CFG_DESCR_PROPS_STRING_0 0
223 #define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
224 #define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
225 #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
226 #define USB_CFG_DESCR_PROPS_HID 0
227 #define USB_CFG_DESCR_PROPS_HID_REPORT 0
228 #define USB_CFG_DESCR_PROPS_UNKNOWN 0
229  
230 /* ----------------------- Optional MCU Description ------------------------ */
231  
232 /* The following configurations have working defaults in usbdrv.h. You
233 * usually don't need to set them explicitly. Only if you want to run
234 * the driver on a device which is not yet supported or with a compiler
235 * which is not fully supported (such as IAR C) or if you use a differnt
236 * interrupt than INT0, you may have to define some of these.
237 */
238 /* #define USB_INTR_CFG MCUCR */
239 /* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
240 /* #define USB_INTR_CFG_CLR 0 */
241 /* #define USB_INTR_ENABLE GIMSK */
242 /* #define USB_INTR_ENABLE_BIT INT0 */
243 /* #define USB_INTR_PENDING GIFR */
244 /* #define USB_INTR_PENDING_BIT INTF0 */
245  
246 #endif /* __usbconfig_h_included__ */