| Line 3... |
Line 3... |
| 3 |
* Author: Christian Starkjohann
|
3 |
* Author: Christian Starkjohann
|
| 4 |
* Creation Date: 2004-12-29
|
4 |
* Creation Date: 2004-12-29
|
| 5 |
* Tabsize: 4
|
5 |
* Tabsize: 4
|
| 6 |
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
6 |
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
| 7 |
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
7 |
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
| 8 |
* This Revision: $Id$
|
- |
|
| 9 |
*/
|
8 |
*/
|
| 10 |
|
9 |
|
| 11 |
#ifndef __usbdrv_h_included__
|
10 |
#ifndef __usbdrv_h_included__
|
| 12 |
#define __usbdrv_h_included__
|
11 |
#define __usbdrv_h_included__
|
| 13 |
#include "usbconfig.h"
|
12 |
#include "usbconfig.h"
|
| Line 120... |
Line 119... |
| 120 |
|
119 |
|
| 121 |
/* ------------------------------------------------------------------------- */
|
120 |
/* ------------------------------------------------------------------------- */
|
| 122 |
/* --------------------------- Module Interface ---------------------------- */
|
121 |
/* --------------------------- Module Interface ---------------------------- */
|
| 123 |
/* ------------------------------------------------------------------------- */
|
122 |
/* ------------------------------------------------------------------------- */
|
| 124 |
|
123 |
|
| 125 |
#define USBDRV_VERSION 20120109
|
124 |
#define USBDRV_VERSION 20121206
|
| 126 |
/* This define uniquely identifies a driver version. It is a decimal number
|
125 |
/* This define uniquely identifies a driver version. It is a decimal number
|
| 127 |
* constructed from the driver's release date in the form YYYYMMDD. If the
|
126 |
* constructed from the driver's release date in the form YYYYMMDD. If the
|
| 128 |
* driver's behavior or interface changes, you can use this constant to
|
127 |
* driver's behavior or interface changes, you can use this constant to
|
| 129 |
* distinguish versions. If it is not defined, the driver's release date is
|
128 |
* distinguish versions. If it is not defined, the driver's release date is
|
| 130 |
* older than 2006-01-25.
|
129 |
* older than 2006-01-25.
|
| Line 161... |
Line 160... |
| 161 |
* a 16 bit data type is used, allowing up to 16384 bytes (the rest is used
|
160 |
* a 16 bit data type is used, allowing up to 16384 bytes (the rest is used
|
| 162 |
* for flags in the descriptor configuration).
|
161 |
* for flags in the descriptor configuration).
|
| 163 |
*/
|
162 |
*/
|
| 164 |
#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */
|
163 |
#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */
|
| 165 |
|
164 |
|
| - |
|
165 |
#ifndef usbMsgPtr_t
|
| - |
|
166 |
#define usbMsgPtr_t uchar *
|
| - |
|
167 |
#endif
|
| - |
|
168 |
/* Making usbMsgPtr_t a define allows the user of this library to define it to
|
| - |
|
169 |
* an 8 bit type on tiny devices. This reduces code size, especially if the
|
| - |
|
170 |
* compiler supports a tiny memory model.
|
| - |
|
171 |
* The type can be a pointer or scalar type, casts are made where necessary.
|
| - |
|
172 |
* Although it's paradoxical, Gcc 4 generates slightly better code for scalar
|
| - |
|
173 |
* types than for pointers.
|
| - |
|
174 |
*/
|
| - |
|
175 |
|
| 166 |
struct usbRequest; /* forward declaration */
|
176 |
struct usbRequest; /* forward declaration */
|
| 167 |
|
177 |
|
| 168 |
USB_PUBLIC void usbInit(void);
|
178 |
USB_PUBLIC void usbInit(void);
|
| 169 |
/* This function must be called before interrupts are enabled and the main
|
179 |
/* This function must be called before interrupts are enabled and the main
|
| 170 |
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
|
180 |
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
|
| Line 176... |
Line 186... |
| 176 |
* Maximum delay between calls is somewhat less than 50ms (USB timeout for
|
186 |
* Maximum delay between calls is somewhat less than 50ms (USB timeout for
|
| 177 |
* accepting a Setup message). Otherwise the device will not be recognized.
|
187 |
* accepting a Setup message). Otherwise the device will not be recognized.
|
| 178 |
* Please note that debug outputs through the UART take ~ 0.5ms per byte
|
188 |
* Please note that debug outputs through the UART take ~ 0.5ms per byte
|
| 179 |
* at 19200 bps.
|
189 |
* at 19200 bps.
|
| 180 |
*/
|
190 |
*/
|
| 181 |
extern uchar *usbMsgPtr;
|
191 |
extern usbMsgPtr_t usbMsgPtr;
|
| 182 |
/* This variable may be used to pass transmit data to the driver from the
|
192 |
/* This variable may be used to pass transmit data to the driver from the
|
| 183 |
* implementation of usbFunctionWrite(). It is also used internally by the
|
193 |
* implementation of usbFunctionWrite(). It is also used internally by the
|
| 184 |
* driver for standard control requests.
|
194 |
* driver for standard control requests.
|
| 185 |
*/
|
195 |
*/
|
| 186 |
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]);
|
196 |
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]);
|
| Line 388... |
Line 398... |
| 388 |
/* ------------------------------------------------------------------------- */
|
398 |
/* ------------------------------------------------------------------------- */
|
| 389 |
/* This is advanced stuff. See usbconfig-prototype.h for more information
|
399 |
/* This is advanced stuff. See usbconfig-prototype.h for more information
|
| 390 |
* about the various methods to define USB descriptors. If you do nothing,
|
400 |
* about the various methods to define USB descriptors. If you do nothing,
|
| 391 |
* the default descriptors will be used.
|
401 |
* the default descriptors will be used.
|
| 392 |
*/
|
402 |
*/
|
| 393 |
#define USB_PROP_IS_DYNAMIC (1 << 14)
|
403 |
#define USB_PROP_IS_DYNAMIC (1u << 14)
|
| 394 |
/* If this property is set for a descriptor, usbFunctionDescriptor() will be
|
404 |
/* If this property is set for a descriptor, usbFunctionDescriptor() will be
|
| 395 |
* used to obtain the particular descriptor. Data directly returned via
|
405 |
* used to obtain the particular descriptor. Data directly returned via
|
| 396 |
* usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to
|
406 |
* usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to
|
| 397 |
* return RAM data.
|
407 |
* return RAM data.
|
| 398 |
*/
|
408 |
*/
|
| 399 |
#define USB_PROP_IS_RAM (1 << 15)
|
409 |
#define USB_PROP_IS_RAM (1u << 15)
|
| 400 |
/* If this property is set for a descriptor, the data is read from RAM
|
410 |
/* If this property is set for a descriptor, the data is read from RAM
|
| 401 |
* memory instead of Flash. The property is used for all methods to provide
|
411 |
* memory instead of Flash. The property is used for all methods to provide
|
| 402 |
* external descriptors.
|
412 |
* external descriptors.
|
| 403 |
*/
|
413 |
*/
|
| 404 |
#define USB_PROP_LENGTH(len) ((len) & 0x3fff)
|
414 |
#define USB_PROP_LENGTH(len) ((len) & 0x3fff)
|
| Line 448... |
Line 458... |
| 448 |
* arrays as declared below:
|
458 |
* arrays as declared below:
|
| 449 |
*/
|
459 |
*/
|
| 450 |
#ifndef __ASSEMBLER__
|
460 |
#ifndef __ASSEMBLER__
|
| 451 |
extern
|
461 |
extern
|
| 452 |
#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
|
462 |
#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
|
| 453 |
PROGMEM
|
463 |
PROGMEM const
|
| 454 |
#endif
|
464 |
#endif
|
| 455 |
char usbDescriptorDevice[];
|
465 |
char usbDescriptorDevice[];
|
| 456 |
|
466 |
|
| 457 |
extern
|
467 |
extern
|
| 458 |
#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
|
468 |
#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
|
| 459 |
PROGMEM
|
469 |
PROGMEM const
|
| 460 |
#endif
|
470 |
#endif
|
| 461 |
char usbDescriptorConfiguration[];
|
471 |
char usbDescriptorConfiguration[];
|
| 462 |
|
472 |
|
| 463 |
extern
|
473 |
extern
|
| 464 |
#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
|
474 |
#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
|
| 465 |
PROGMEM
|
475 |
PROGMEM const
|
| 466 |
#endif
|
476 |
#endif
|
| 467 |
char usbDescriptorHidReport[];
|
477 |
char usbDescriptorHidReport[];
|
| 468 |
|
478 |
|
| 469 |
extern
|
479 |
extern
|
| 470 |
#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
|
480 |
#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
|
| 471 |
PROGMEM
|
481 |
PROGMEM const
|
| 472 |
#endif
|
482 |
#endif
|
| 473 |
char usbDescriptorString0[];
|
483 |
char usbDescriptorString0[];
|
| 474 |
|
484 |
|
| 475 |
extern
|
485 |
extern
|
| 476 |
#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
|
486 |
#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
|
| 477 |
PROGMEM
|
487 |
PROGMEM const
|
| 478 |
#endif
|
488 |
#endif
|
| 479 |
int usbDescriptorStringVendor[];
|
489 |
int usbDescriptorStringVendor[];
|
| 480 |
|
490 |
|
| 481 |
extern
|
491 |
extern
|
| 482 |
#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
|
492 |
#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
|
| 483 |
PROGMEM
|
493 |
PROGMEM const
|
| 484 |
#endif
|
494 |
#endif
|
| 485 |
int usbDescriptorStringDevice[];
|
495 |
int usbDescriptorStringDevice[];
|
| 486 |
|
496 |
|
| 487 |
extern
|
497 |
extern
|
| 488 |
#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
|
498 |
#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
|
| 489 |
PROGMEM
|
499 |
PROGMEM const
|
| 490 |
#endif
|
500 |
#endif
|
| 491 |
int usbDescriptorStringSerialNumber[];
|
501 |
int usbDescriptorStringSerialNumber[];
|
| 492 |
|
502 |
|
| 493 |
#endif /* __ASSEMBLER__ */
|
503 |
#endif /* __ASSEMBLER__ */
|
| 494 |
|
504 |
|