Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

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