Update the usbdrv lib

This commit is contained in:
Aaron Mueller 2014-05-13 22:20:30 +02:00
parent e9ea7fb763
commit b04518168e
20 changed files with 126 additions and 106 deletions

View file

@ -306,3 +306,24 @@ Scroll down to the bottom to see the most recent changes.
endpoint now. endpoint now.
* Release 2010-07-15 * Release 2010-07-15
- Fixed bug in usbDriverSetup() which prevented descriptor sizes above 255
bytes.
- Avoid a compiler warning for unused parameter in usbHandleResetHook() when
compiler option -Wextra is enabled.
- Fixed wrong hex value for some IDs in USB-IDs-for-free.txt.
- Keep a define for USBATTR_BUSPOWER, although the flag does not exist
in USB 1.1 any more. Set it to 0. This is for backward compatibility.
* Release 2012-01-09
- Define a separate (defined) type for usbMsgPtr so that projects using a
tiny memory model can define it to an 8 bit type in usbconfig.h. This
change also saves a couple of bytes when using a scalar 16 bit type.
- Inserted "const" keyword for all PROGMEM declarations because new GCC
requires it.
- Fixed problem with dependence of usbportability.h on usbconfig.h. This
problem occurred with IAR CC only.
- Prepared repository for github.com.
* Release 2012-12-06

View file

@ -1,5 +1,5 @@
V-USB Driver Software License Agreement V-USB Driver Software License Agreement
Version 2009-08-03 Version 2012-07-09
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
@ -37,10 +37,10 @@ Product ID(s), sent to you in e-mail. These Product IDs are reserved
exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID
ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen
Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from
Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs Jason Kotzin (now flirc.tv, Inc.). Both owners of the Vendor IDs have
have obtained these IDs from the USB Implementers Forum, Inc. obtained these IDs from the USB Implementers Forum, Inc. (www.usb.org).
(www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might OBJECTIVE DEVELOPMENT disclaims all liability which might arise from the
arise from the assignment of USB IDs. assignment of USB IDs.
2.5 USB Certification. Although not part of this agreement, we want to make 2.5 USB Certification. Although not part of this agreement, we want to make
it clear that you cannot become USB certified when you use V-USB or a USB it clear that you cannot become USB certified when you use V-USB or a USB

View file

@ -1,4 +1,4 @@
Version 2009-08-22 Version 2012-07-09
========================== ==========================
WHY DO WE NEED THESE IDs? WHY DO WE NEED THESE IDs?
@ -107,8 +107,8 @@ WHO IS THE OWNER OF THE VENDOR-ID?
Objective Development has obtained ranges of USB Product-IDs under two Objective Development has obtained ranges of USB Product-IDs under two
Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen
Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason
Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their Kotzin (now flirc.tv, Inc.). Both VID owners have received their Vendor-ID
Vendor-ID directly from usb.org. directly from usb.org.
========================================================================= =========================================================================

View file

@ -86,8 +86,9 @@ If you use one of the IDs listed below, your device and host-side software
must conform to these rules: must conform to these rules:
(1) The USB device MUST provide a textual representation of the serial (1) The USB device MUST provide a textual representation of the serial
number. The serial number string MUST be available at least in USB language number, unless ONLY the operating system's default class driver is used.
0x0409 (English/US). The serial number string MUST be available at least in USB language 0x0409
(English/US).
(2) The serial number MUST start with either an Internet domain name (e.g. (2) The serial number MUST start with either an Internet domain name (e.g.
"mycompany.com") registered and owned by you, or an e-mail address under your "mycompany.com") registered and owned by you, or an e-mail address under your
@ -108,6 +109,11 @@ driver for Vendor Class devices is needed, this driver must be libusb or
libusb-win32 (see http://libusb.org/ and libusb-win32 (see http://libusb.org/ and
http://libusb-win32.sourceforge.net/). http://libusb-win32.sourceforge.net/).
(7) If ONLY the operating system's default class driver is used, e.g. for
mice, keyboards, joysticks, CDC or MIDI devices and no discrimination by an
application is needed, the serial number may be omitted.
Table if IDs for discrimination by serial number string: Table if IDs for discrimination by serial number string:
PID dec (hex) | VID dec (hex) | Description of use PID dec (hex) | VID dec (hex) | Description of use
@ -121,11 +127,11 @@ PID dec (hex) | VID dec (hex) | Description of use
---------------+---------------+------------------------------------------- ---------------+---------------+-------------------------------------------
10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards
---------------+---------------+------------------------------------------- ---------------+---------------+-------------------------------------------
10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks 10204 (0x27dc) | 5824 (0x16c0) | For USB Joysticks
---------------+---------------+------------------------------------------- ---------------+---------------+-------------------------------------------
10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 10205 (0x27dd) | 5824 (0x16c0) | For CDC-ACM class devices (modems)
---------------+---------------+------------------------------------------- ---------------+---------------+-------------------------------------------
10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices 10206 (0x27de) | 5824 (0x16c0) | For MIDI class devices
---------------+---------------+------------------------------------------- ---------------+---------------+-------------------------------------------

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id$
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: oddebug.c 692 2008-11-07 15:07:40Z cs $
*/ */
#include "oddebug.h" #include "oddebug.h"

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: oddebug.h 692 2008-11-07 15:07:40Z cs $
*/ */
#ifndef __oddebug_h_included__ #ifndef __oddebug_h_included__

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
*/ */
#ifndef __usbconfig_h_included__ #ifndef __usbconfig_h_included__
@ -356,6 +355,15 @@ section at the end of this file).
#define USB_CFG_DESCR_PROPS_HID_REPORT 0 #define USB_CFG_DESCR_PROPS_HID_REPORT 0
#define USB_CFG_DESCR_PROPS_UNKNOWN 0 #define USB_CFG_DESCR_PROPS_UNKNOWN 0
#define usbMsgPtr_t unsigned short
/* If usbMsgPtr_t is not defined, it defaults to 'uchar *'. We define it to
* a scalar type here because gcc generates slightly shorter code for scalar
* arithmetics than for pointer arithmetics. Remove this define for backward
* type compatibility or define it to an 8 bit type if you use data in RAM only
* and all RAM is below 256 bytes (tiny memory model in IAR CC).
*/
/* ----------------------- Optional MCU Description ------------------------ */ /* ----------------------- Optional MCU Description ------------------------ */
/* The following configurations have working defaults in usbdrv.h. You /* The following configurations have working defaults in usbdrv.h. You

View file

@ -5,10 +5,8 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbdrv.c 791 2010-07-15 15:56:13Z cs $
*/ */
#include "usbportability.h"
#include "usbdrv.h" #include "usbdrv.h"
#include "oddebug.h" #include "oddebug.h"
@ -45,14 +43,9 @@ uchar usbCurrentDataToken;/* when we check data toggling to ignore duplica
#endif #endif
/* USB status registers / not shared with asm code */ /* USB status registers / not shared with asm code */
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */ usbMsgPtr_t usbMsgPtr; /* data to transmit next -- ROM or RAM address */
static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */ static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */
#ifdef USB_CFG_USE_GPIOR
# define usbMsgFlags (*((uchar*)&GPIOR0))
#else
static uchar usbMsgFlags; /* flag values see below */ static uchar usbMsgFlags; /* flag values see below */
#endif
#define USB_FLG_MSGPTR_IS_ROM (1<<6) #define USB_FLG_MSGPTR_IS_ROM (1<<6)
#define USB_FLG_USE_USER_RW (1<<7) #define USB_FLG_USE_USER_RW (1<<7)
@ -72,7 +65,7 @@ optimizing hints:
#if USB_CFG_DESCR_PROPS_STRING_0 == 0 #if USB_CFG_DESCR_PROPS_STRING_0 == 0
#undef USB_CFG_DESCR_PROPS_STRING_0 #undef USB_CFG_DESCR_PROPS_STRING_0
#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0) #define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
PROGMEM char usbDescriptorString0[] = { /* language descriptor */ PROGMEM const char usbDescriptorString0[] = { /* language descriptor */
4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */ 4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
3, /* descriptor type */ 3, /* descriptor type */
0x09, 0x04, /* language index (0x0409 = US-English) */ 0x09, 0x04, /* language index (0x0409 = US-English) */
@ -82,7 +75,7 @@ PROGMEM char usbDescriptorString0[] = { /* language descriptor */
#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN #if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_VENDOR #undef USB_CFG_DESCR_PROPS_STRING_VENDOR
#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor) #define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
PROGMEM int usbDescriptorStringVendor[] = { PROGMEM const int usbDescriptorStringVendor[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN), USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
USB_CFG_VENDOR_NAME USB_CFG_VENDOR_NAME
}; };
@ -91,7 +84,7 @@ PROGMEM int usbDescriptorStringVendor[] = {
#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN #if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT #undef USB_CFG_DESCR_PROPS_STRING_PRODUCT
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice) #define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice)
PROGMEM int usbDescriptorStringDevice[] = { PROGMEM const int usbDescriptorStringDevice[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN), USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
USB_CFG_DEVICE_NAME USB_CFG_DEVICE_NAME
}; };
@ -100,7 +93,7 @@ PROGMEM int usbDescriptorStringDevice[] = {
#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN #if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN
#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER #undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber) #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber)
PROGMEM int usbDescriptorStringSerialNumber[] = { PROGMEM const int usbDescriptorStringSerialNumber[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN), USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),
USB_CFG_SERIAL_NUMBER USB_CFG_SERIAL_NUMBER
}; };
@ -113,7 +106,7 @@ PROGMEM int usbDescriptorStringSerialNumber[] = {
#if USB_CFG_DESCR_PROPS_DEVICE == 0 #if USB_CFG_DESCR_PROPS_DEVICE == 0
#undef USB_CFG_DESCR_PROPS_DEVICE #undef USB_CFG_DESCR_PROPS_DEVICE
#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice) #define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */ PROGMEM const char usbDescriptorDevice[] = { /* USB device descriptor */
18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */ 18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
USBDESCR_DEVICE, /* descriptor type */ USBDESCR_DEVICE, /* descriptor type */
0x10, 0x01, /* USB version supported */ 0x10, 0x01, /* USB version supported */
@ -144,7 +137,7 @@ PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0 #if USB_CFG_DESCR_PROPS_CONFIGURATION == 0
#undef USB_CFG_DESCR_PROPS_CONFIGURATION #undef USB_CFG_DESCR_PROPS_CONFIGURATION
#define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration) #define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration)
PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */ USBDESCR_CONFIG, /* descriptor type */
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 +
@ -199,6 +192,16 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
static inline void usbResetDataToggling(void)
{
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
#endif
}
static inline void usbResetStall(void) static inline void usbResetStall(void)
{ {
#if USB_CFG_IMPLEMENT_HALT && USB_CFG_HAVE_INTRIN_ENDPOINT #if USB_CFG_IMPLEMENT_HALT && USB_CFG_HAVE_INTRIN_ENDPOINT
@ -296,7 +299,7 @@ USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len)
len = usbFunctionDescriptor(rq); \ len = usbFunctionDescriptor(rq); \
}else{ \ }else{ \
len = USB_PROP_LENGTH(cfgProp); \ len = USB_PROP_LENGTH(cfgProp); \
usbMsgPtr = (uchar *)(staticName); \ usbMsgPtr = (usbMsgPtr_t)(staticName); \
} \ } \
} }
@ -356,7 +359,8 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM;
*/ */
static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq) static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq)
{ {
uchar len = 0, *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */ usbMsgLen_t len = 0;
uchar *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */
uchar value = rq->wValue.bytes[0]; uchar value = rq->wValue.bytes[0];
#if USB_CFG_IMPLEMENT_HALT #if USB_CFG_IMPLEMENT_HALT
uchar index = rq->wIndex.bytes[0]; uchar index = rq->wIndex.bytes[0];
@ -403,7 +407,7 @@ uchar index = rq->wIndex.bytes[0];
SWITCH_DEFAULT /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */ SWITCH_DEFAULT /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */
/* Should we add an optional hook here? */ /* Should we add an optional hook here? */
SWITCH_END SWITCH_END
usbMsgPtr = dataPtr; usbMsgPtr = (usbMsgPtr_t)dataPtr;
skipMsgPtrAssignment: skipMsgPtrAssignment:
return len; return len;
} }
@ -493,7 +497,8 @@ static uchar usbDeviceRead(uchar *data, uchar len)
}else }else
#endif #endif
{ {
uchar i = len, *r = usbMsgPtr; uchar i = len;
usbMsgPtr_t r = usbMsgPtr;
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */ if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
do{ do{
uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */ uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */
@ -502,7 +507,8 @@ static uchar usbDeviceRead(uchar *data, uchar len)
}while(--i); }while(--i);
}else{ /* RAM data */ }else{ /* RAM data */
do{ do{
*data++ = *r++; *data++ = *((uchar *)r);
r++;
}while(--i); }while(--i);
} }
usbMsgPtr = r; usbMsgPtr = r;
@ -542,9 +548,9 @@ uchar len;
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#ifdef USB_RESET_HOOK
static inline void usbHandleResetHook(uchar notResetState) static inline void usbHandleResetHook(uchar notResetState)
{ {
#ifdef USB_RESET_HOOK
static uchar wasReset; static uchar wasReset;
uchar isReset = !notResetState; uchar isReset = !notResetState;
@ -552,8 +558,10 @@ uchar isReset = !notResetState;
USB_RESET_HOOK(isReset); USB_RESET_HOOK(isReset);
wasReset = isReset; wasReset = isReset;
} }
} #else
notResetState = notResetState; // avoid compiler warning
#endif #endif
}
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -586,22 +594,35 @@ uchar i;
for(i = 20; i > 0; i--){ for(i = 20; i > 0; i--){
uchar usbLineStatus = USBIN & USBMASK; uchar usbLineStatus = USBIN & USBMASK;
if(usbLineStatus != 0) /* SE0 has ended */ if(usbLineStatus != 0) /* SE0 has ended */
#ifdef USB_RESET_HOOK
goto isNotReset; goto isNotReset;
#else
return;
#endif
} }
/* RESET condition, called multiple times during reset */ /* RESET condition, called multiple times during reset */
usbNewDeviceAddr = 0; usbNewDeviceAddr = 0;
usbDeviceAddr = 0; usbDeviceAddr = 0;
usbResetStall(); usbResetStall();
DBG1(0xff, 0, 0); DBG1(0xff, 0, 0);
#ifdef USB_RESET_HOOK
isNotReset: isNotReset:
usbHandleResetHook(i); usbHandleResetHook(i);
#endif
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
USB_PUBLIC void usbInit(void)
{
#if USB_INTR_CFG_SET != 0
USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
usbResetDataToggling();
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
usbTxLen1 = USBPID_NAK;
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
usbTxLen3 = USBPID_NAK;
#endif
#endif
}
/* ------------------------------------------------------------------------- */

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbdrv.h 793 2010-07-15 15:58:11Z cs $
*/ */
#ifndef __usbdrv_h_included__ #ifndef __usbdrv_h_included__
@ -122,7 +121,7 @@ USB messages, even if they address another (low-speed) device on the same bus.
/* --------------------------- Module Interface ---------------------------- */ /* --------------------------- Module Interface ---------------------------- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#define USBDRV_VERSION 20100715 #define USBDRV_VERSION 20121206
/* This define uniquely identifies a driver version. It is a decimal number /* This define uniquely identifies a driver version. It is a decimal number
* constructed from the driver's release date in the form YYYYMMDD. If the * constructed from the driver's release date in the form YYYYMMDD. If the
* driver's behavior or interface changes, you can use this constant to * driver's behavior or interface changes, you can use this constant to
@ -163,8 +162,25 @@ USB messages, even if they address another (low-speed) device on the same bus.
*/ */
#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */ #define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */
#ifndef usbMsgPtr_t
#define usbMsgPtr_t uchar *
#endif
/* Making usbMsgPtr_t a define allows the user of this library to define it to
* an 8 bit type on tiny devices. This reduces code size, especially if the
* compiler supports a tiny memory model.
* The type can be a pointer or scalar type, casts are made where necessary.
* Although it's paradoxical, Gcc 4 generates slightly better code for scalar
* types than for pointers.
*/
struct usbRequest; /* forward declaration */ struct usbRequest; /* forward declaration */
USB_PUBLIC void usbInit(void);
/* This function must be called before interrupts are enabled and the main
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
* not been changed from their default status (which is 0). If you have changed
* them, set both back to 0 (configure them as input with no internal pull-up).
*/
USB_PUBLIC void usbPoll(void); USB_PUBLIC void usbPoll(void);
/* This function must be called at regular intervals from the main loop. /* This function must be called at regular intervals from the main loop.
* Maximum delay between calls is somewhat less than 50ms (USB timeout for * Maximum delay between calls is somewhat less than 50ms (USB timeout for
@ -172,7 +188,7 @@ USB_PUBLIC void usbPoll(void);
* Please note that debug outputs through the UART take ~ 0.5ms per byte * Please note that debug outputs through the UART take ~ 0.5ms per byte
* at 19200 bps. * at 19200 bps.
*/ */
extern uchar *usbMsgPtr; extern usbMsgPtr_t usbMsgPtr;
/* This variable may be used to pass transmit data to the driver from the /* This variable may be used to pass transmit data to the driver from the
* implementation of usbFunctionWrite(). It is also used internally by the * implementation of usbFunctionWrite(). It is also used internally by the
* driver for standard control requests. * driver for standard control requests.
@ -384,13 +400,13 @@ extern volatile schar usbRxLen;
* about the various methods to define USB descriptors. If you do nothing, * about the various methods to define USB descriptors. If you do nothing,
* the default descriptors will be used. * the default descriptors will be used.
*/ */
#define USB_PROP_IS_DYNAMIC (1 << 14) #define USB_PROP_IS_DYNAMIC (1u << 14)
/* If this property is set for a descriptor, usbFunctionDescriptor() will be /* If this property is set for a descriptor, usbFunctionDescriptor() will be
* used to obtain the particular descriptor. Data directly returned via * used to obtain the particular descriptor. Data directly returned via
* usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to * usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to
* return RAM data. * return RAM data.
*/ */
#define USB_PROP_IS_RAM (1 << 15) #define USB_PROP_IS_RAM (1u << 15)
/* If this property is set for a descriptor, the data is read from RAM /* If this property is set for a descriptor, the data is read from RAM
* memory instead of Flash. The property is used for all methods to provide * memory instead of Flash. The property is used for all methods to provide
* external descriptors. * external descriptors.
@ -444,43 +460,43 @@ extern volatile schar usbRxLen;
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__
extern extern
#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
char usbDescriptorDevice[]; char usbDescriptorDevice[];
extern extern
#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
char usbDescriptorConfiguration[]; char usbDescriptorConfiguration[];
extern extern
#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
char usbDescriptorHidReport[]; char usbDescriptorHidReport[];
extern extern
#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
char usbDescriptorString0[]; char usbDescriptorString0[];
extern extern
#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
int usbDescriptorStringVendor[]; int usbDescriptorStringVendor[];
extern extern
#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
int usbDescriptorStringDevice[]; int usbDescriptorStringDevice[];
extern extern
#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM) #if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
PROGMEM PROGMEM const
#endif #endif
int usbDescriptorStringSerialNumber[]; int usbDescriptorStringSerialNumber[];
@ -713,6 +729,7 @@ typedef struct usbRequest{
#define USBDESCR_HID_PHYS 0x23 #define USBDESCR_HID_PHYS 0x23
//#define USBATTR_BUSPOWER 0x80 // USB 1.1 does not define this value any more //#define USBATTR_BUSPOWER 0x80 // USB 1.1 does not define this value any more
#define USBATTR_BUSPOWER 0
#define USBATTR_SELFPOWER 0x40 #define USBATTR_SELFPOWER 0x40
#define USBATTR_REMOTEWAKE 0x20 #define USBATTR_REMOTEWAKE 0x20
@ -726,40 +743,4 @@ typedef struct usbRequest{
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#ifndef __ASSEMBLER__
static inline void usbResetDataToggling(void)
{
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
#endif
}
static inline void usbInit(void)
{
#if USB_INTR_CFG_SET != 0
USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
usbResetDataToggling();
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
usbTxLen1 = USBPID_NAK;
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
usbTxLen3 = USBPID_NAK;
#endif
#endif
}
/* This function must be called before interrupts are enabled and the main
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
* not been changed from their default status (which is 0). If you have changed
* them, set both back to 0 (configure them as input with no internal pull-up).
*/
#endif /* __ASSEMBLER */
#endif /* __usbdrv_h_included__ */ #endif /* __usbdrv_h_included__ */

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm.S 785 2010-05-30 17:57:07Z cs $
*/ */
/* /*
@ -368,10 +367,6 @@ usbMFTimeout:
# endif # endif
#endif #endif
/* place the interrupt routine in .vectors, after the jump to __init.
Warning: This depends on correct linking order. Link crt0 before usbdrasm! */
.section .vectors
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ #if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
# if USB_CFG_CLOCK_KHZ == 18000 # if USB_CFG_CLOCK_KHZ == 18000
# include "usbdrvasm18-crc.inc" # include "usbdrvasm18-crc.inc"

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id$
*/ */
/* /*

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbdrvasm12.inc 740 2009-04-13 18:23:31Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbdrvasm128.inc 758 2009-08-06 10:12:54Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm16.inc 760 2009-08-09 18:59:43Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm165.inc 740 2009-04-13 18:23:31Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm18-crc.inc 740 2009-04-13 18:23:31Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -6,7 +6,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2008 by Jeroen Benschop and OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2008 by Jeroen Benschop and OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* Revision: $Id: usbdrvasm20.inc 740 2009-04-13 18:23:31Z cs $
*/ */
/* Do not link this file! Link usbdrvasm.S instead, which includes the /* Do not link this file! Link usbdrvasm.S instead, which includes the

View file

@ -5,7 +5,6 @@
* Tabsize: 4 * Tabsize: 4
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbportability.h 785 2010-05-30 17:57:07Z cs $
*/ */
/* /*