Switch to new vusb
This commit is contained in:
parent
08b4654b5c
commit
c8d91b4bbf
@ -275,3 +275,55 @@ Scroll down to the bottom to see the most recent changes.
|
|||||||
background of USB ID registration clearer.
|
background of USB ID registration clearer.
|
||||||
|
|
||||||
* Release 2009-04-15
|
* Release 2009-04-15
|
||||||
|
|
||||||
|
- Changed CommercialLicense.txt to reflect the new range of PIDs from
|
||||||
|
Jason Kotzin.
|
||||||
|
- Removed USBID-License.txt in favor of USB-IDs-for-free.txt and
|
||||||
|
USB-ID-FAQ.txt
|
||||||
|
- Fixed a bug in the 12.8 MHz module: End Of Packet decection was made in
|
||||||
|
the center between bit 0 and 1 of each byte. This is where the data lines
|
||||||
|
are expected to change and the sampled data may therefore be nonsense.
|
||||||
|
We therefore check EOP ONLY if bits 0 AND 1 have both been read as 0 on D-.
|
||||||
|
- Fixed a bitstuffing problem in the 16 MHz module: If bit 6 was stuffed,
|
||||||
|
the unstuffing code in the receiver routine was 1 cycle too long. If
|
||||||
|
multiple bytes had the unstuffing in bit 6, the error summed up until the
|
||||||
|
receiver was out of sync.
|
||||||
|
- Included option for faster CRC routine.
|
||||||
|
Thanks to Slawomir Fras (BoskiDialer) for this code!
|
||||||
|
- Updated bits in Configuration Descriptor's bmAttributes according to
|
||||||
|
USB 1.1 (in particular bit 7, it is a must-be-set bit now).
|
||||||
|
|
||||||
|
* Release 2009-08-22
|
||||||
|
|
||||||
|
- Moved first DBG1() after odDebugInit() in all examples.
|
||||||
|
- Use vector INT0_vect instead of SIG_INTERRUPT0 if defined. This makes
|
||||||
|
V-USB compatible with the new "p" suffix devices (e.g. ATMega328p).
|
||||||
|
- USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any
|
||||||
|
more).
|
||||||
|
- New option USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with
|
||||||
|
more than 64 kB flash.
|
||||||
|
- Built-in configuration descriptor allows custom definition for second
|
||||||
|
endpoint now.
|
||||||
|
|
||||||
|
* 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
|
||||||
@ -1,5 +1,5 @@
|
|||||||
V-USB Driver Software License Agreement
|
V-USB Driver Software License Agreement
|
||||||
Version 2009-04-14
|
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
|
||||||
@ -32,13 +32,22 @@ product(s), restricted by the limitations in section 3 below.
|
|||||||
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
||||||
the source code and your copy of V-USB according to your needs.
|
the source code and your copy of V-USB according to your needs.
|
||||||
|
|
||||||
2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB Product
|
2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB
|
||||||
ID(s), sent to you in e-mail. These Product IDs are reserved exclusively for
|
Product ID(s), sent to you in e-mail. These Product IDs are reserved
|
||||||
you. They have been obtained from Wouter van Ooijen (www.voti.nl), who has
|
exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID
|
||||||
reserved the Vendor ID 5824 (decimal) at the USB Implementers Forum, Inc.
|
ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen
|
||||||
(www.usb.org). This mechanism ensures that there are no Product ID conflicts,
|
Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from
|
||||||
but you cannot become USB certified (enter into the USB-IF Trademark License
|
Jason Kotzin (now flirc.tv, Inc.). Both owners of the Vendor IDs have
|
||||||
Agreement) as you would need your own Vendor ID for that.
|
obtained these IDs from the USB Implementers Forum, Inc. (www.usb.org).
|
||||||
|
OBJECTIVE DEVELOPMENT disclaims all liability which might arise from the
|
||||||
|
assignment of USB IDs.
|
||||||
|
|
||||||
|
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
|
||||||
|
Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't
|
||||||
|
meet the electrical specifications required by the USB specification and
|
||||||
|
the USB Implementers Forum certifies only members who bought a Vendor ID of
|
||||||
|
their own.
|
||||||
|
|
||||||
|
|
||||||
3 LICENSE RESTRICTIONS
|
3 LICENSE RESTRICTIONS
|
||||||
|
|||||||
@ -39,8 +39,8 @@ The driver consists of the following files:
|
|||||||
with IAR's tools.
|
with IAR's tools.
|
||||||
License.txt ............ Open Source license for this driver.
|
License.txt ............ Open Source license for this driver.
|
||||||
CommercialLicense.txt .. Optional commercial license for this driver.
|
CommercialLicense.txt .. Optional commercial license for this driver.
|
||||||
USBID-License.txt ...... Terms and conditions for using particular USB ID
|
USB-ID-FAQ.txt ......... General infos about USB Product- and Vendor-IDs.
|
||||||
values for particular purposes.
|
USB-IDs-for-free.txt ... List and terms of use for free shared PIDs.
|
||||||
|
|
||||||
(*) ... These files should be linked to your project.
|
(*) ... These files should be linked to your project.
|
||||||
|
|
||||||
@ -49,8 +49,7 @@ CPU CORE CLOCK FREQUENCY
|
|||||||
========================
|
========================
|
||||||
We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz,
|
We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz,
|
||||||
16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The
|
16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The
|
||||||
actual clock rate must be configured in usbdrv.h unless you use the default
|
actual clock rate must be configured in usbconfig.h.
|
||||||
12 MHz.
|
|
||||||
|
|
||||||
12 MHz Clock
|
12 MHz Clock
|
||||||
This is the traditional clock rate of V-USB because it's the lowest clock
|
This is the traditional clock rate of V-USB because it's the lowest clock
|
||||||
@ -105,7 +104,7 @@ can assign PIDs at will.
|
|||||||
|
|
||||||
Since an entry level cost of 1,500 USD is too high for most small companies
|
Since an entry level cost of 1,500 USD is too high for most small companies
|
||||||
and hobbyists, we provide some VID/PID pairs for free. See the file
|
and hobbyists, we provide some VID/PID pairs for free. See the file
|
||||||
USBID-License.txt for details.
|
USB-IDs-for-free.txt for details.
|
||||||
|
|
||||||
Objective Development also has some license offerings which include product
|
Objective Development also has some license offerings which include product
|
||||||
IDs. See http://www.obdev.at/vusb/ for details.
|
IDs. See http://www.obdev.at/vusb/ for details.
|
||||||
@ -114,13 +113,28 @@ IDs. See http://www.obdev.at/vusb/ for details.
|
|||||||
DEVELOPMENT SYSTEM
|
DEVELOPMENT SYSTEM
|
||||||
==================
|
==================
|
||||||
This driver has been developed and optimized for the GNU compiler version 3
|
This driver has been developed and optimized for the GNU compiler version 3
|
||||||
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
|
and 4. We recommend that you use the GNU compiler suite because it is freely
|
||||||
that you use the GNU compiler suite because it is freely available. V-USB
|
available. V-USB has also been ported to the IAR compiler and assembler. It
|
||||||
has also been ported to the IAR compiler and assembler. It has been tested
|
has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the
|
||||||
with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the "small" and "tiny"
|
"small" and "tiny" memory model. Not every release is tested with IAR CC and
|
||||||
memory model. Not every release is tested with IAR CC and the driver may
|
the driver may therefore fail to compile with IAR. Please note that gcc is
|
||||||
therefore fail to compile with IAR. Please note that gcc is more efficient for
|
more efficient for usbdrv.c because this module has been deliberately
|
||||||
usbdrv.c because this module has been deliberately optimized for gcc.
|
optimized for gcc.
|
||||||
|
|
||||||
|
Gcc version 3 produces smaller code than version 4 due to new optimizing
|
||||||
|
capabilities which don't always improve things on 8 bit CPUs. The code size
|
||||||
|
generated by gcc 4 can be reduced with the compiler options
|
||||||
|
-fno-move-loop-invariants, -fno-tree-scev-cprop and
|
||||||
|
-fno-inline-small-functions in addition to -Os. On devices with more than
|
||||||
|
8k of flash memory, we also recommend the linker option --relax (written as
|
||||||
|
-Wl,--relax for gcc) to convert absolute calls into relative where possible.
|
||||||
|
|
||||||
|
For more information about optimizing options see:
|
||||||
|
|
||||||
|
http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html
|
||||||
|
|
||||||
|
These optimizations are good for gcc 4.x. Version 3.x of gcc does not support
|
||||||
|
most of these options and produces good code anyway.
|
||||||
|
|
||||||
|
|
||||||
USING V-USB FOR FREE
|
USING V-USB FOR FREE
|
||||||
|
|||||||
@ -1,154 +0,0 @@
|
|||||||
Royalty-Free Non-Exclusive Use of USB Product-IDs
|
|
||||||
=================================================
|
|
||||||
|
|
||||||
Version 2009-04-13
|
|
||||||
|
|
||||||
Strictly speaking, this is not a license. You can't give a license to use
|
|
||||||
a simple number (such as e.g. 1500) for any purpose. This is a set of rules
|
|
||||||
which should make it possible to build USB devices without the requirement
|
|
||||||
for individual USB IDs. If you break one of the rules, you will run into
|
|
||||||
technical problems sooner or later, but you don't risk legal trouble.
|
|
||||||
|
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
|
||||||
right to use four USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
|
||||||
products based on Objective Development's firmware-only USB driver for
|
|
||||||
Atmel AVR microcontrollers:
|
|
||||||
|
|
||||||
* VID = 5824 (=0x16c0) / PID = 1500 (=0x5dc) for devices implementing no
|
|
||||||
USB device class (vendor-class devices with USB class = 0xff). Devices
|
|
||||||
using this pair will be referred to as "VENDOR CLASS" devices.
|
|
||||||
|
|
||||||
* VID = 5824 (=0x16c0) / PID = 1503 (=0x5df) for HID class devices
|
|
||||||
(excluding mice and keyboards). Devices using this pair will be referred
|
|
||||||
to as "HID CLASS" devices.
|
|
||||||
|
|
||||||
* VID = 5824 (=0x16c0) / PID = 1505 (=0x5e1) for CDC class modem devices
|
|
||||||
Devices using this pair will be referred to as "CDC-ACM CLASS" devices.
|
|
||||||
|
|
||||||
* VID = 5824 (=0x16c0) / PID = 1508 (=0x5e4) for MIDI class devices
|
|
||||||
Devices using this pair will be referred to as "MIDI CLASS" devices.
|
|
||||||
|
|
||||||
Since the granted right is non-exclusive, the same VID/PID pairs may be
|
|
||||||
used by many companies and individuals for different products. To avoid
|
|
||||||
conflicts, your device and host driver software MUST adhere to the rules
|
|
||||||
outlined below.
|
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH has obtained these VID/PID pairs from
|
|
||||||
Wouter van Ooijen (see www.voti.nl) for exclusive disposition. Wouter van
|
|
||||||
Ooijen has obtained the VID from the USB Implementers Forum, Inc.
|
|
||||||
(see www.usb.org). The VID is registered for the company name
|
|
||||||
"Van Ooijen Technische Informatica".
|
|
||||||
|
|
||||||
|
|
||||||
RULES AND RESTRICTIONS
|
|
||||||
======================
|
|
||||||
|
|
||||||
(1) The USB device MUST provide a textual representation of the
|
|
||||||
manufacturer and product identification. The manufacturer identification
|
|
||||||
MUST be available at least in USB language 0x0409 (English/US).
|
|
||||||
|
|
||||||
(2) The textual manufacturer identification MUST contain either an Internet
|
|
||||||
domain name (e.g. "mycompany.com") registered and owned by you, or an
|
|
||||||
e-mail address under your control (e.g. "myname@gmx.net"). You can embed
|
|
||||||
the domain name or e-mail address in any string you like, e.g. "Objective
|
|
||||||
Development http://www.obdev.at/vusb/".
|
|
||||||
|
|
||||||
(3) You are responsible for retaining ownership of the domain or e-mail
|
|
||||||
address for as long as any of your products are in use.
|
|
||||||
|
|
||||||
(4) You may choose any string for the textual product identification, as
|
|
||||||
long as this string is unique within the scope of your textual manufacturer
|
|
||||||
identification.
|
|
||||||
|
|
||||||
(5) Matching of device-specific drivers MUST be based on the textual
|
|
||||||
manufacturer and product identification in addition to the usual VID/PID
|
|
||||||
matching. This means that operating system features which are based on
|
|
||||||
VID/PID matching only (e.g. Windows kernel level drivers, automatic actions
|
|
||||||
when the device is plugged in etc) MUST NOT be used. The driver matching
|
|
||||||
MUST be a comparison of the entire strings, NOT a sub-string match. For
|
|
||||||
CDC-ACM CLASS and MIDI CLASS devices, a generic class driver should be used
|
|
||||||
and the matching is based on the USB device class.
|
|
||||||
|
|
||||||
(6) The extent to which VID/PID matching is allowed for non device-specific
|
|
||||||
drivers or features depends on the operating system and particular VID/PID
|
|
||||||
pair used:
|
|
||||||
|
|
||||||
* Mac OS X, Linux, FreeBSD and other Unixes: No VID/PID matching is
|
|
||||||
required and hence no VID/PID-only matching is allowed at all.
|
|
||||||
|
|
||||||
* Windows: The operating system performs VID/PID matching for the kernel
|
|
||||||
level driver. You are REQUIRED to use libusb-win32 (see
|
|
||||||
http://libusb-win32.sourceforge.net/) as the kernel level driver for
|
|
||||||
VENDOR CLASS devices. HID CLASS devices all use the generic HID class
|
|
||||||
driver shipped with Windows, except mice and keyboards. You therefore
|
|
||||||
MUST NOT use any of the shared VID/PID pairs for mice or keyboards.
|
|
||||||
CDC-ACM CLASS devices require a ".inf" file which matches on the VID/PID
|
|
||||||
pair. This ".inf" file MUST load the "usbser" driver to configure the
|
|
||||||
device as modem (COM-port).
|
|
||||||
|
|
||||||
(7) OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any
|
|
||||||
problems which are caused by the shared use of these VID/PID pairs. You
|
|
||||||
have been warned that the sharing of VID/PID pairs may cause problems. If
|
|
||||||
you want to avoid them, get your own VID/PID pair for exclusive use.
|
|
||||||
|
|
||||||
|
|
||||||
HOW TO IMPLEMENT THESE RULES
|
|
||||||
============================
|
|
||||||
|
|
||||||
The following rules are for VENDOR CLASS and HID CLASS devices. CDC-ACM
|
|
||||||
CLASS and MIDI CLASS devices use the operating system's class driver and
|
|
||||||
don't need a custom driver.
|
|
||||||
|
|
||||||
The host driver MUST iterate over all devices with the given VID/PID
|
|
||||||
numbers in their device descriptors and query the string representation for
|
|
||||||
the manufacturer name in USB language 0x0409 (English/US). It MUST compare
|
|
||||||
the ENTIRE string with your textual manufacturer identification chosen in
|
|
||||||
(2) above. A substring search for your domain or e-mail address is NOT
|
|
||||||
acceptable. The driver MUST NOT touch the device (other than querying the
|
|
||||||
descriptors) unless the strings match.
|
|
||||||
|
|
||||||
For all USB devices with matching VID/PID and textual manufacturer
|
|
||||||
identification, the host driver must query the textual product
|
|
||||||
identification and string-compare it with the name of the product it can
|
|
||||||
control. It may only initialize the device if the product matches exactly.
|
|
||||||
|
|
||||||
Objective Development provides examples for these matching rules with the
|
|
||||||
"PowerSwitch" project (using libusb) and with the "Automator" project
|
|
||||||
(using Windows calls on Windows and libusb on Unix).
|
|
||||||
|
|
||||||
|
|
||||||
Technical Notes:
|
|
||||||
================
|
|
||||||
|
|
||||||
Sharing the same VID/PID pair among devices is possible as long as ALL
|
|
||||||
drivers which match the VID/PID also perform matching on the textual
|
|
||||||
identification strings. This is easy on all operating systems except
|
|
||||||
Windows, since Windows establishes a static connection between the VID/PID
|
|
||||||
pair and a kernel level driver. All devices with the same VID/PID pair must
|
|
||||||
therefore use THE SAME kernel level driver.
|
|
||||||
|
|
||||||
We therefore demand that you use libusb-win32 for VENDOR CLASS devices.
|
|
||||||
This is a generic kernel level driver which allows all types of USB access
|
|
||||||
for user space applications. This is only a partial solution of the
|
|
||||||
problem, though, because different device drivers may come with different
|
|
||||||
versions of libusb-win32 and they may not work with the libusb version of
|
|
||||||
the respective other driver. You are therefore encouraged to test your
|
|
||||||
driver against a broad range of libusb-win32 versions. Do not use new
|
|
||||||
features in new versions, or check for their existence before you use them.
|
|
||||||
When a new libusb-win32 becomes available, make sure that your driver is
|
|
||||||
compatible with it.
|
|
||||||
|
|
||||||
For HID CLASS devices it is necessary that all those devices bind to the
|
|
||||||
same kernel driver: Microsoft's generic USB HID driver. This is true for
|
|
||||||
all HID devices except those with a specialized driver. Currently, the only
|
|
||||||
HIDs with specialized drivers are mice and keyboards. You therefore MUST
|
|
||||||
NOT use a shared VID/PID with mouse and keyboard devices.
|
|
||||||
|
|
||||||
Sharing the same VID/PID among different products is unusual and probably
|
|
||||||
violates the USB specification. If you do it, you do it at your own risk.
|
|
||||||
|
|
||||||
To avoid possible incompatibilities, we highly recommend that you get your
|
|
||||||
own VID/PID pair if you intend to sell your product. Objective
|
|
||||||
Development's commercial licenses for V-USB include a PID for
|
|
||||||
unrestricted exclusive use.
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
@ -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__
|
||||||
|
|||||||
@ -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 740 2009-04-13 18:23:31Z cs $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbconfig_h_included__
|
#ifndef __usbconfig_h_included__
|
||||||
@ -45,10 +44,12 @@ section at the end of this file).
|
|||||||
*/
|
*/
|
||||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||||
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
||||||
* 16500 and 20000. The 12.8 MHz and 16.5 MHz versions of the code require no
|
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
|
||||||
* crystal, they tolerate +/- 1% deviation from the nominal frequency. All
|
* require no crystal, they tolerate +/- 1% deviation from the nominal
|
||||||
* other rates require a precision of 2000 ppm and thus a crystal!
|
* frequency. All other rates require a precision of 2000 ppm and thus a
|
||||||
* Default if not specified: 12 MHz
|
* crystal!
|
||||||
|
* Since F_CPU should be defined to your actual clock rate anyway, you should
|
||||||
|
* not need to modify this setting.
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_CHECK_CRC 0
|
#define USB_CFG_CHECK_CRC 0
|
||||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||||
@ -144,6 +145,11 @@ section at the end of this file).
|
|||||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||||
* usbdrv.h.
|
* usbdrv.h.
|
||||||
*/
|
*/
|
||||||
|
#define USB_CFG_DRIVER_FLASH_PAGE 0
|
||||||
|
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
|
||||||
|
* where the driver's constants (descriptors) are located. Or in other words:
|
||||||
|
* Define this to 1 for boot loaders on the ATMega128.
|
||||||
|
*/
|
||||||
#define USB_CFG_LONG_TRANSFERS 0
|
#define USB_CFG_LONG_TRANSFERS 0
|
||||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||||
* in a single control-in or control-out transfer. Note that the capability
|
* in a single control-in or control-out transfer. Note that the capability
|
||||||
@ -201,24 +207,36 @@ section at the end of this file).
|
|||||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||||
*/
|
*/
|
||||||
|
#define USB_USE_FAST_CRC 0
|
||||||
|
/* The assembler module has two implementations for the CRC algorithm. One is
|
||||||
|
* faster, the other is smaller. This CRC routine is only used for transmitted
|
||||||
|
* messages where timing is not critical. The faster routine needs 31 cycles
|
||||||
|
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
|
||||||
|
* may be worth the 32 bytes bigger code size if you transmit lots of data and
|
||||||
|
* run the AVR close to its limit.
|
||||||
|
*/
|
||||||
|
|
||||||
/* -------------------------- Device Description --------------------------- */
|
/* -------------------------- Device Description --------------------------- */
|
||||||
|
|
||||||
#define USB_CFG_VENDOR_ID 0xc0, 0x16
|
#define USB_CFG_VENDOR_ID 0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */
|
||||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||||
* own Vendor ID, define it here. Otherwise you use one of obdev's free shared
|
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
|
||||||
* VID/PID pairs. Be sure to read USBID-License.txt for rules!
|
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
|
||||||
* + This template uses obdev's shared VID/PID pair: 0x16c0/0x5dc.
|
* *** IMPORTANT NOTE ***
|
||||||
* + Use this VID/PID pair ONLY if you understand the implications!
|
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||||
|
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||||
|
* the implications!
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_DEVICE_ID 0xdc, 0x05
|
#define USB_CFG_DEVICE_ID 0xdc, 0x05 /* = 0x05dc = 1500 */
|
||||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||||
* you use obdev's free shared VID/PID pair. Be sure to read the rules in
|
* you may use one of obdev's free shared VID/PID pairs. See the file
|
||||||
* USBID-License.txt!
|
* USB-IDs-for-free.txt for details!
|
||||||
* + This template uses obdev's shared VID/PID pair: 0x16c0/0x5dc.
|
* *** IMPORTANT NOTE ***
|
||||||
* + Use this VID/PID pair ONLY if you understand the implications!
|
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||||
|
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||||
|
* the implications!
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||||
/* Version number of the device: Minor number first, then major number.
|
/* Version number of the device: Minor number first, then major number.
|
||||||
@ -230,14 +248,14 @@ section at the end of this file).
|
|||||||
* are interpreted as Unicode (UTF-16) entities.
|
* are interpreted as Unicode (UTF-16) entities.
|
||||||
* If you don't want a vendor name string, undefine these macros.
|
* If you don't want a vendor name string, undefine these macros.
|
||||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||||
* obdev's free shared VID/PID pair. See the file USBID-License.txt for
|
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||||
* details.
|
* details.
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_DEVICE_NAME 'T', 'e', 'm', 'p', 'l', 'a', 't', 'e'
|
#define USB_CFG_DEVICE_NAME 'T', 'e', 'm', 'p', 'l', 'a', 't', 'e'
|
||||||
#define USB_CFG_DEVICE_NAME_LEN 8
|
#define USB_CFG_DEVICE_NAME_LEN 8
|
||||||
/* Same as above for the device name. If you don't want a device name, undefine
|
/* Same as above for the device name. If you don't want a device name, undefine
|
||||||
* the macros. See the file USBID-License.txt before you assign a name if you
|
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||||
* use a shared VID/PID.
|
* you use a shared VID/PID.
|
||||||
*/
|
*/
|
||||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||||
@ -337,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
|
||||||
@ -352,6 +379,6 @@ section at the end of this file).
|
|||||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||||
/* #define USB_INTR_PENDING GIFR */
|
/* #define USB_INTR_PENDING GIFR */
|
||||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||||
/* #define USB_INTR_VECTOR SIG_INTERRUPT0 */
|
/* #define USB_INTR_VECTOR INT0_vect */
|
||||||
|
|
||||||
#endif /* __usbconfig_h_included__ */
|
#endif /* __usbconfig_h_included__ */
|
||||||
|
|||||||
@ -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 740 2009-04-13 18:23:31Z cs $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "usbportability.h"
|
|
||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
#include "oddebug.h"
|
#include "oddebug.h"
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ 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 */
|
||||||
static uchar usbMsgFlags; /* flag values see below */
|
static uchar usbMsgFlags; /* flag values see below */
|
||||||
|
|
||||||
@ -67,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) */
|
||||||
@ -77,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
|
||||||
};
|
};
|
||||||
@ -86,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
|
||||||
};
|
};
|
||||||
@ -95,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
|
||||||
};
|
};
|
||||||
@ -108,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 */
|
||||||
@ -139,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 +
|
||||||
@ -149,9 +147,9 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
|
|||||||
1, /* index of this configuration */
|
1, /* index of this configuration */
|
||||||
0, /* configuration name string index */
|
0, /* configuration name string index */
|
||||||
#if USB_CFG_IS_SELF_POWERED
|
#if USB_CFG_IS_SELF_POWERED
|
||||||
USBATTR_SELFPOWER, /* attributes */
|
(1 << 7) | USBATTR_SELFPOWER, /* attributes */
|
||||||
#else
|
#else
|
||||||
(char)USBATTR_BUSPOWER, /* attributes */
|
(1 << 7), /* attributes */
|
||||||
#endif
|
#endif
|
||||||
USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
|
USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
|
||||||
/* interface descriptor follows inline: */
|
/* interface descriptor follows inline: */
|
||||||
@ -184,7 +182,7 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
|
|||||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
|
#if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
|
||||||
7, /* sizeof(usbDescrEndpoint) */
|
7, /* sizeof(usbDescrEndpoint) */
|
||||||
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
|
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
|
||||||
(char)0x83, /* IN endpoint number 1 */
|
(char)(0x80 | USB_CFG_EP3_NUMBER), /* IN endpoint number 3 */
|
||||||
0x03, /* attrib: Interrupt endpoint */
|
0x03, /* attrib: Interrupt endpoint */
|
||||||
8, 0, /* maximum packet size */
|
8, 0, /* maximum packet size */
|
||||||
USB_CFG_INTR_POLL_INTERVAL, /* in ms */
|
USB_CFG_INTR_POLL_INTERVAL, /* in ms */
|
||||||
@ -301,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); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,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];
|
||||||
@ -408,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;
|
||||||
}
|
}
|
||||||
@ -498,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 */
|
||||||
@ -507,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;
|
||||||
@ -557,6 +558,8 @@ uchar isReset = !notResetState;
|
|||||||
USB_RESET_HOOK(isReset);
|
USB_RESET_HOOK(isReset);
|
||||||
wasReset = isReset;
|
wasReset = isReset;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
notResetState = notResetState; // avoid compiler warning
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 748 2009-04-15 15:05:07Z cs $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbdrv_h_included__
|
#ifndef __usbdrv_h_included__
|
||||||
@ -105,9 +104,9 @@ interrupt routine.
|
|||||||
Interrupt latency:
|
Interrupt latency:
|
||||||
The application must ensure that the USB interrupt is not disabled for more
|
The application must ensure that the USB interrupt is not disabled for more
|
||||||
than 25 cycles (this is for 12 MHz, faster clocks allow longer latency).
|
than 25 cycles (this is for 12 MHz, faster clocks allow longer latency).
|
||||||
This implies that all interrupt routines must either be declared as "INTERRUPT"
|
This implies that all interrupt routines must either have the "ISR_NOBLOCK"
|
||||||
instead of "SIGNAL" (see "avr/signal.h") or that they are written in assembler
|
attribute set (see "avr/interrupt.h") or be written in assembler with "sei"
|
||||||
with "sei" as the first instruction.
|
as the first instruction.
|
||||||
|
|
||||||
Maximum interrupt duration / CPU cycle consumption:
|
Maximum interrupt duration / CPU cycle consumption:
|
||||||
The driver handles all USB communication during the interrupt service
|
The driver handles all USB communication during the interrupt service
|
||||||
@ -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 20090415
|
#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,11 +162,24 @@ 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);
|
USB_PUBLIC void usbInit(void);
|
||||||
/* This function must be called before interrupts are enabled and the main
|
/* This function must be called before interrupts are enabled and the main
|
||||||
* loop is entered.
|
* 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.
|
||||||
@ -176,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.
|
||||||
@ -388,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.
|
||||||
@ -448,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[];
|
||||||
|
|
||||||
@ -511,22 +523,22 @@ int usbDescriptorStringSerialNumber[];
|
|||||||
#if !defined __ASSEMBLER__ && (!defined USB_CFG_VENDOR_ID || !defined USB_CFG_DEVICE_ID)
|
#if !defined __ASSEMBLER__ && (!defined USB_CFG_VENDOR_ID || !defined USB_CFG_DEVICE_ID)
|
||||||
#warning "You should define USB_CFG_VENDOR_ID and USB_CFG_DEVICE_ID in usbconfig.h"
|
#warning "You should define USB_CFG_VENDOR_ID and USB_CFG_DEVICE_ID in usbconfig.h"
|
||||||
/* If the user has not defined IDs, we default to obdev's free IDs.
|
/* If the user has not defined IDs, we default to obdev's free IDs.
|
||||||
* See USBID-License.txt for details.
|
* See USB-IDs-for-free.txt for details.
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* make sure we have a VID and PID defined, byte order is lowbyte, highbyte */
|
/* make sure we have a VID and PID defined, byte order is lowbyte, highbyte */
|
||||||
#ifndef USB_CFG_VENDOR_ID
|
#ifndef USB_CFG_VENDOR_ID
|
||||||
# define USB_CFG_VENDOR_ID 0xc0, 0x16 /* 5824 in dec, stands for VOTI */
|
# define USB_CFG_VENDOR_ID 0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USB_CFG_DEVICE_ID
|
#ifndef USB_CFG_DEVICE_ID
|
||||||
# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH
|
# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH
|
||||||
# define USB_CFG_DEVICE_ID 0xdf, 0x05 /* 1503 in dec, shared PID for HIDs */
|
# define USB_CFG_DEVICE_ID 0xdf, 0x05 /* = 0x5df = 1503, shared PID for HIDs */
|
||||||
# elif USB_CFG_INTERFACE_CLASS == 2
|
# elif USB_CFG_INTERFACE_CLASS == 2
|
||||||
# define USB_CFG_DEVICE_ID 0xe1, 0x05 /* 1505 in dec, shared PID for CDC Modems */
|
# define USB_CFG_DEVICE_ID 0xe1, 0x05 /* = 0x5e1 = 1505, shared PID for CDC Modems */
|
||||||
# else
|
# else
|
||||||
# define USB_CFG_DEVICE_ID 0xdc, 0x05 /* 1500 in dec, obdev's free PID */
|
# define USB_CFG_DEVICE_ID 0xdc, 0x05 /* = 0x5dc = 1500, obdev's free PID */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -716,7 +728,8 @@ typedef struct usbRequest{
|
|||||||
#define USBDESCR_HID_REPORT 0x22
|
#define USBDESCR_HID_REPORT 0x22
|
||||||
#define USBDESCR_HID_PHYS 0x23
|
#define USBDESCR_HID_PHYS 0x23
|
||||||
|
|
||||||
#define USBATTR_BUSPOWER 0x80
|
//#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
|
||||||
|
|
||||||
|
|||||||
@ -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 740 2009-04-13 18:23:31Z cs $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -57,7 +56,11 @@ the file appropriate for the given clock rate.
|
|||||||
#else /* __IAR_SYSTEMS_ASM__ */
|
#else /* __IAR_SYSTEMS_ASM__ */
|
||||||
|
|
||||||
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
|
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
|
||||||
# define USB_INTR_VECTOR SIG_INTERRUPT0
|
# ifdef INT0_vect
|
||||||
|
# define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector
|
||||||
|
# else
|
||||||
|
# define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
.text
|
.text
|
||||||
.global USB_INTR_VECTOR
|
.global USB_INTR_VECTOR
|
||||||
@ -139,16 +142,93 @@ RTMODEL "__rt_version", "3"
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
; extern unsigned usbCrc16(unsigned char *data, unsigned char len);
|
#if USB_USE_FAST_CRC
|
||||||
; data: r24/25
|
|
||||||
; len: r22
|
; This implementation is faster, but has bigger code size
|
||||||
|
; Thanks to Slawomir Fras (BoskiDialer) for this code!
|
||||||
|
; It implements the following C pseudo-code:
|
||||||
|
; unsigned table(unsigned char x)
|
||||||
|
; {
|
||||||
|
; unsigned value;
|
||||||
|
;
|
||||||
|
; value = (unsigned)x << 6;
|
||||||
|
; value ^= (unsigned)x << 7;
|
||||||
|
; if(parity(x))
|
||||||
|
; value ^= 0xc001;
|
||||||
|
; return value;
|
||||||
|
; }
|
||||||
|
; unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen)
|
||||||
|
; {
|
||||||
|
; unsigned crc = 0xffff;
|
||||||
|
;
|
||||||
|
; while(argLen--)
|
||||||
|
; crc = table(lo8(crc) ^ *argPtr++) ^ hi8(crc);
|
||||||
|
; return ~crc;
|
||||||
|
; }
|
||||||
|
|
||||||
|
; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen);
|
||||||
|
; argPtr r24+25 / r16+r17
|
||||||
|
; argLen r22 / r18
|
||||||
; temp variables:
|
; temp variables:
|
||||||
; r18: data byte
|
; byte r18 / r22
|
||||||
; r19: bit counter
|
; scratch r23
|
||||||
; r20/21: polynomial
|
; resCrc r24+r25 / r16+r17
|
||||||
; r23: scratch
|
; ptr X / Z
|
||||||
; r24/25: crc-sum
|
usbCrc16:
|
||||||
; r26/27=X: ptr
|
mov ptrL, argPtrL
|
||||||
|
mov ptrH, argPtrH
|
||||||
|
ldi resCrcL, 0xFF
|
||||||
|
ldi resCrcH, 0xFF
|
||||||
|
rjmp usbCrc16LoopTest
|
||||||
|
usbCrc16ByteLoop:
|
||||||
|
ld byte, ptr+
|
||||||
|
eor resCrcL, byte ; resCrcL is now 'x' in table()
|
||||||
|
mov byte, resCrcL ; compute parity of 'x'
|
||||||
|
swap byte
|
||||||
|
eor byte, resCrcL
|
||||||
|
mov scratch, byte
|
||||||
|
lsr byte
|
||||||
|
lsr byte
|
||||||
|
eor byte, scratch
|
||||||
|
inc byte
|
||||||
|
lsr byte
|
||||||
|
andi byte, 1 ; byte is now parity(x)
|
||||||
|
mov scratch, resCrcL
|
||||||
|
mov resCrcL, resCrcH
|
||||||
|
eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001;
|
||||||
|
neg byte
|
||||||
|
andi byte, 0xc0
|
||||||
|
mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001;
|
||||||
|
clr byte
|
||||||
|
lsr scratch
|
||||||
|
ror byte
|
||||||
|
eor resCrcH, scratch
|
||||||
|
eor resCrcL, byte
|
||||||
|
lsr scratch
|
||||||
|
ror byte
|
||||||
|
eor resCrcH, scratch
|
||||||
|
eor resCrcL, byte
|
||||||
|
usbCrc16LoopTest:
|
||||||
|
subi argLen, 1
|
||||||
|
brsh usbCrc16ByteLoop
|
||||||
|
com resCrcL
|
||||||
|
com resCrcH
|
||||||
|
ret
|
||||||
|
|
||||||
|
#else /* USB_USE_FAST_CRC */
|
||||||
|
|
||||||
|
; This implementation is slower, but has less code size
|
||||||
|
;
|
||||||
|
; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen);
|
||||||
|
; argPtr r24+25 / r16+r17
|
||||||
|
; argLen r22 / r18
|
||||||
|
; temp variables:
|
||||||
|
; byte r18 / r22
|
||||||
|
; bitCnt r19
|
||||||
|
; poly r20+r21
|
||||||
|
; scratch r23
|
||||||
|
; resCrc r24+r25 / r16+r17
|
||||||
|
; ptr X / Z
|
||||||
usbCrc16:
|
usbCrc16:
|
||||||
mov ptrL, argPtrL
|
mov ptrL, argPtrL
|
||||||
mov ptrH, argPtrH
|
mov ptrH, argPtrH
|
||||||
@ -156,27 +236,30 @@ usbCrc16:
|
|||||||
ldi resCrcH, 0
|
ldi resCrcH, 0
|
||||||
ldi polyL, lo8(0xa001)
|
ldi polyL, lo8(0xa001)
|
||||||
ldi polyH, hi8(0xa001)
|
ldi polyH, hi8(0xa001)
|
||||||
com argLen ; argLen = -argLen - 1
|
com argLen ; argLen = -argLen - 1: modified loop to ensure that carry is set
|
||||||
crcByteLoop:
|
ldi bitCnt, 0 ; loop counter with starnd condition = end condition
|
||||||
subi argLen, -1
|
rjmp usbCrcLoopEntry
|
||||||
brcc crcReady ; modified loop to ensure that carry is set below
|
usbCrcByteLoop:
|
||||||
ld byte, ptr+
|
ld byte, ptr+
|
||||||
ldi bitCnt, -8 ; strange loop counter to ensure that carry is set where we need it
|
|
||||||
eor resCrcL, byte
|
eor resCrcL, byte
|
||||||
crcBitLoop:
|
usbCrcBitLoop:
|
||||||
ror resCrcH ; carry is always set here
|
ror resCrcH ; carry is always set here (see brcs jumps to here)
|
||||||
ror resCrcL
|
ror resCrcL
|
||||||
brcs crcNoXor
|
brcs usbCrcNoXor
|
||||||
eor resCrcL, polyL
|
eor resCrcL, polyL
|
||||||
eor resCrcH, polyH
|
eor resCrcH, polyH
|
||||||
crcNoXor:
|
usbCrcNoXor:
|
||||||
subi bitCnt, -1
|
subi bitCnt, 224 ; (8 * 224) % 256 = 0; this loop iterates 8 times
|
||||||
brcs crcBitLoop
|
brcs usbCrcBitLoop
|
||||||
rjmp crcByteLoop
|
usbCrcLoopEntry:
|
||||||
crcReady:
|
subi argLen, -1
|
||||||
|
brcs usbCrcByteLoop
|
||||||
|
usbCrcReady:
|
||||||
ret
|
ret
|
||||||
; Thanks to Reimar Doeffinger for optimizing this CRC routine!
|
; Thanks to Reimar Doeffinger for optimizing this CRC routine!
|
||||||
|
|
||||||
|
#endif /* USB_USE_FAST_CRC */
|
||||||
|
|
||||||
; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len);
|
; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len);
|
||||||
usbCrc16Append:
|
usbCrc16Append:
|
||||||
rcall usbCrc16
|
rcall usbCrc16
|
||||||
@ -277,7 +360,11 @@ usbMFTimeout:
|
|||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef USB_CFG_CLOCK_KHZ
|
#ifndef USB_CFG_CLOCK_KHZ
|
||||||
# define USB_CFG_CLOCK_KHZ 12000
|
# ifdef F_CPU
|
||||||
|
# define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||||
|
# else
|
||||||
|
# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
|
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
|
||||||
|
|||||||
@ -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$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 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
|
||||||
@ -31,8 +30,9 @@ limitations:
|
|||||||
They typical range is 14.5 MHz and most AVRs can actually reach this rate.
|
They typical range is 14.5 MHz and most AVRs can actually reach this rate.
|
||||||
(2) Writing EEPROM and Flash may be unreliable (short data lifetime) since
|
(2) Writing EEPROM and Flash may be unreliable (short data lifetime) since
|
||||||
the write procedure is timed from the RC oscillator.
|
the write procedure is timed from the RC oscillator.
|
||||||
(3) End Of Packet detection is between bit 0 and bit 1 where the EOP condition
|
(3) End Of Packet detection (SE0) should be in bit 1, bit it is only checked
|
||||||
may not be reliable when a hub is used. It should be in bit 1.
|
if bits 0 and 1 both read as 0 on D- and D+ read as 0 in the middle. This may
|
||||||
|
cause problems with old hubs which delay SE0 by up to one cycle.
|
||||||
(4) Code size is much larger than that of the other modules.
|
(4) Code size is much larger than that of the other modules.
|
||||||
|
|
||||||
Since almost all of this code is timing critical, don't change unless you
|
Since almost all of this code is timing critical, don't change unless you
|
||||||
@ -217,8 +217,10 @@ unstuff0s:
|
|||||||
ifioclr USBIN, USBMINUS ;[00]
|
ifioclr USBIN, USBMINUS ;[00]
|
||||||
ifioset USBIN, USBPLUS ;[01]
|
ifioset USBIN, USBPLUS ;[01]
|
||||||
rjmp bit0IsClr ;[02] executed if first expr false or second true
|
rjmp bit0IsClr ;[02] executed if first expr false or second true
|
||||||
jumpToSe0AndStore:
|
se0AndStore: ; executed only if both bits 0
|
||||||
rjmp se0AndStore ;[03] executed only if both bits 0
|
st y+, x1 ;[15/17] cycles after start of byte
|
||||||
|
rjmp se0 ;[17/19]
|
||||||
|
|
||||||
bit0IsClr:
|
bit0IsClr:
|
||||||
ifrset phase, USBMINUS ;[04] check phase only if D- changed
|
ifrset phase, USBMINUS ;[04] check phase only if D- changed
|
||||||
lpm ;[05]
|
lpm ;[05]
|
||||||
@ -228,7 +230,7 @@ bit1AfterClr:
|
|||||||
andi phase, USBMASK ;[08]
|
andi phase, USBMASK ;[08]
|
||||||
ifioset USBIN, USBMINUS ;[09] <--- sample 1
|
ifioset USBIN, USBMINUS ;[09] <--- sample 1
|
||||||
rjmp bit1IsSet ;[10]
|
rjmp bit1IsSet ;[10]
|
||||||
breq jumpToSe0AndStore ;[11]
|
breq se0AndStore ;[11] if D- was 0 in bits 0 AND 1 and D+ was 0 in between, we have SE0
|
||||||
andi shift, ~(7 << 1) ;[12]
|
andi shift, ~(7 << 1) ;[12]
|
||||||
in phase, USBIN ;[13] <- phase
|
in phase, USBIN ;[13] <- phase
|
||||||
breq unstuff1c ;[14]
|
breq unstuff1c ;[14]
|
||||||
@ -355,10 +357,6 @@ unstuff7c:
|
|||||||
nop ;[59]
|
nop ;[59]
|
||||||
rjmp bit7IsSet ;[60]
|
rjmp bit7IsSet ;[60]
|
||||||
|
|
||||||
se0AndStore:
|
|
||||||
st y+, x1 ;[15/17] cycles after start of byte
|
|
||||||
rjmp se0 ;[17/19]
|
|
||||||
|
|
||||||
bit7IsClr:
|
bit7IsClr:
|
||||||
ifrset phase, USBMINUS ;[62] check phase only if D- changed
|
ifrset phase, USBMINUS ;[62] check phase only if D- changed
|
||||||
lpm ;[63]
|
lpm ;[63]
|
||||||
@ -391,25 +389,24 @@ bit0IsSet:
|
|||||||
in phase, USBIN ;[06] <- phase (one cycle too late)
|
in phase, USBIN ;[06] <- phase (one cycle too late)
|
||||||
ori shift, 1 << 0 ;[07]
|
ori shift, 1 << 0 ;[07]
|
||||||
bit1AfterSet:
|
bit1AfterSet:
|
||||||
andi phase, USBMASK ;[08]
|
andi shift, ~(7 << 1) ;[08] compensated by "ori shift, 1<<1" if bit1IsClr
|
||||||
ifioclr USBIN, USBMINUS ;[09] <--- sample 1
|
ifioclr USBIN, USBMINUS ;[09] <--- sample 1
|
||||||
rjmp bit1IsClr ;[10]
|
rjmp bit1IsClr ;[10]
|
||||||
andi shift, ~(7 << 1) ;[11]
|
breq unstuff1s ;[11]
|
||||||
breq unstuff1s ;[12]
|
nop2 ;[12] do not check for SE0 if bit 0 was 1
|
||||||
in phase, USBIN ;[13] <- phase
|
in phase, USBIN ;[14] <- phase (one cycle too late)
|
||||||
nop ;[14]
|
|
||||||
rjmp bit2AfterSet ;[15]
|
rjmp bit2AfterSet ;[15]
|
||||||
unstuff1s:
|
unstuff1s:
|
||||||
in phase, USBIN ;[14] <- phase (one cycle too late)
|
in phase, USBIN ;[13] <- phase
|
||||||
andi fix, ~(1 << 1) ;[15]
|
andi fix, ~(1 << 1) ;[14]
|
||||||
nop2 ;[08]
|
lpm ;[07]
|
||||||
nop2 ;[10]
|
nop2 ;[10]
|
||||||
bit1IsClr:
|
bit1IsClr:
|
||||||
ifrset phase, USBMINUS ;[12] check phase only if D- changed
|
ifrset phase, USBMINUS ;[12] check phase only if D- changed
|
||||||
lpm ;[13]
|
lpm ;[13]
|
||||||
in phase, USBIN ;[14] <- phase (one cycle too late)
|
in phase, USBIN ;[14] <- phase (one cycle too late)
|
||||||
breq se0AndStore ;[15] if we come from unstuff1s, Z bit is never set
|
ori shift, 1 << 1 ;[15]
|
||||||
ori shift, 1 << 1 ;[16]
|
nop ;[16]
|
||||||
bit2AfterClr:
|
bit2AfterClr:
|
||||||
ifioset USBIN, USBMINUS ;[17] <--- sample 2
|
ifioset USBIN, USBMINUS ;[17] <--- sample 2
|
||||||
rjmp bit2IsSet ;[18]
|
rjmp bit2IsSet ;[18]
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 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
|
||||||
@ -117,12 +116,15 @@ haveTwoBitsK:
|
|||||||
; Receiver loop (numbers in brackets are cycles within byte after instr)
|
; Receiver loop (numbers in brackets are cycles within byte after instr)
|
||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap"
|
||||||
|
; accordingly to approximate this value in the long run.
|
||||||
|
|
||||||
unstuff6:
|
unstuff6:
|
||||||
andi x2, USBMASK ;[03]
|
andi x2, USBMASK ;[03]
|
||||||
ori x3, 1<<6 ;[04] will not be shifted any more
|
ori x3, 1<<6 ;[04] will not be shifted any more
|
||||||
andi shift, ~0x80;[05]
|
andi shift, ~0x80;[05]
|
||||||
mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6
|
mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6
|
||||||
subi leap, 3 ;[07] since this is a short (10 cycle) bit, enforce leap bit
|
subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3
|
||||||
rjmp didUnstuff6 ;[08]
|
rjmp didUnstuff6 ;[08]
|
||||||
|
|
||||||
unstuff7:
|
unstuff7:
|
||||||
@ -130,7 +132,7 @@ unstuff7:
|
|||||||
in x2, USBIN ;[00] [10] re-sample bit 7
|
in x2, USBIN ;[00] [10] re-sample bit 7
|
||||||
andi x2, USBMASK ;[01]
|
andi x2, USBMASK ;[01]
|
||||||
andi shift, ~0x80;[02]
|
andi shift, ~0x80;[02]
|
||||||
subi leap, 3 ;[03] since this is a short (10 cycle) bit, enforce leap bit
|
subi leap, 2 ;[03] total duration = 10 bits -> add 1/3
|
||||||
rjmp didUnstuff7 ;[04]
|
rjmp didUnstuff7 ;[04]
|
||||||
|
|
||||||
unstuffEven:
|
unstuffEven:
|
||||||
@ -139,8 +141,8 @@ unstuffEven:
|
|||||||
andi shift, ~0x80;[01]
|
andi shift, ~0x80;[01]
|
||||||
andi x1, USBMASK ;[02]
|
andi x1, USBMASK ;[02]
|
||||||
breq se0 ;[03]
|
breq se0 ;[03]
|
||||||
subi leap, 3 ;[04] since this is a short (10 cycle) bit, enforce leap bit
|
subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3
|
||||||
nop ;[05]
|
nop2 ;[05]
|
||||||
rjmp didUnstuffE ;[06]
|
rjmp didUnstuffE ;[06]
|
||||||
|
|
||||||
unstuffOdd:
|
unstuffOdd:
|
||||||
@ -149,8 +151,8 @@ unstuffOdd:
|
|||||||
andi shift, ~0x80;[01]
|
andi shift, ~0x80;[01]
|
||||||
andi x2, USBMASK ;[02]
|
andi x2, USBMASK ;[02]
|
||||||
breq se0 ;[03]
|
breq se0 ;[03]
|
||||||
subi leap, 3 ;[04] since this is a short (10 cycle) bit, enforce leap bit
|
subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3
|
||||||
nop ;[05]
|
nop2 ;[05]
|
||||||
rjmp didUnstuffO ;[06]
|
rjmp didUnstuffO ;[06]
|
||||||
|
|
||||||
rxByteLoop:
|
rxByteLoop:
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 740 2009-04-13 18:23:31Z cs $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -125,7 +124,11 @@ static inline void sei(void)
|
|||||||
# include <avr/pgmspace.h>
|
# include <avr/pgmspace.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if USB_CFG_DRIVER_FLASH_PAGE
|
||||||
|
# define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr))
|
||||||
|
#else
|
||||||
# define USB_READ_FLASH(addr) pgm_read_byte(addr)
|
# define USB_READ_FLASH(addr) pgm_read_byte(addr)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define macro .macro
|
#define macro .macro
|
||||||
#define endm .endm
|
#define endm .endm
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user