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