startover again and port fd0's loader to the 644
This commit is contained in:
parent
e45b08a5fb
commit
b2bf789b85
@ -1,7 +1,7 @@
|
||||
|
||||
# microcontroller and project specific settings
|
||||
TARGET = bootloader
|
||||
F_CPU = 20000000
|
||||
F_CPU = 20000000UL
|
||||
MCU = atmega644
|
||||
|
||||
SRC = bootloader.c
|
||||
@ -11,7 +11,7 @@ OBJECTS += $(patsubst %.S,%.o,${ASRC})
|
||||
HEADERS += $(shell echo *.h)
|
||||
# CFLAGS += -Werror
|
||||
LDFLAGS += -L/usr/local/avr/avr/lib
|
||||
CFLAGS += -Iusbdrv -I. -Os
|
||||
CFLAGS += -Iusbdrv -I.
|
||||
CFLAGS += -DHARDWARE_REV=$(HARDWARE_REV)
|
||||
ASFLAGS += -x assembler-with-cpp
|
||||
ASFLAGS += -Iusbdrv -I.
|
||||
@ -36,10 +36,7 @@ else ifeq ($(MCU),atmega88)
|
||||
# bootloader section starts at 0xc00 (word-address) == 0x1800 (byte-address)
|
||||
BOOT_SECTION_START = 0x1800
|
||||
else ifeq ($(MCU),atmega644)
|
||||
# atmega88 with 1024 words bootloader:
|
||||
# bootloader section starts at 0x7c00 (word-address) == 0xF800 (byte-address)
|
||||
|
||||
# atmega88 with 2024 words bootloader:
|
||||
# atmega88 with 2048 words bootloader:
|
||||
# bootloader section starts at 0x7800 (word-address) == 0xF000 (byte-address)
|
||||
BOOT_SECTION_START = 0xf000
|
||||
endif
|
||||
@ -57,59 +54,23 @@ all: $(TARGET).hex $(TARGET).lss
|
||||
@echo "$(TARGET) compiled for: $(MCU)"
|
||||
@echo -n "size is: "
|
||||
@$(SIZE) -A $(TARGET).hex | grep "\.sec1" | tr -s " " | cut -d" " -f2
|
||||
@echo "max size:4096 bytes"
|
||||
@echo "==============================="
|
||||
|
||||
$(TARGET): $(OBJECTS) $(TARGET).o
|
||||
|
||||
%.o: $(HEADERS)
|
||||
|
||||
.PHONY: install lock fuses-atmega168-unzap bootstrap
|
||||
.PHONY: clean clean-$(TARGET)
|
||||
|
||||
# install: program-serial-$(TARGET) program-serial-eeprom-$(TARGET)
|
||||
install: program-isp-$(TARGET)
|
||||
|
||||
lock:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U lock:w:0x2f:m
|
||||
|
||||
fuses-atmega168-unzap:
|
||||
echo "sck 5" | $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -F -u -t
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U lfuse:w:0xe7:m -U hfuse:w:0xd5:m -U efuse:w:0x00:m
|
||||
echo "sck 0.2" | $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -F -u -t
|
||||
|
||||
fuses-atmega168-rumpus:
|
||||
echo "sck 5" | $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -F -u -t
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U lfuse:w:0xe7:m -U efuse:w:0x00:m
|
||||
echo "sck 0.2" | $(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -F -u -t
|
||||
|
||||
bootstrap: fuses-atmega168-unzap install lock
|
||||
|
||||
.PHONY: clean clean-$(TARGET) clean-uploadtest
|
||||
|
||||
clean: clean-$(TARGET) clean-uploadtest
|
||||
clean: clean-$(TARGET)
|
||||
|
||||
clean-$(TARGET):
|
||||
$(RM) $(TARGET) $(OBJECTS)
|
||||
|
||||
clean-uploadtest:
|
||||
rm -f datatestfile{512,14k}.raw
|
||||
|
||||
.PHONY: depend test uploadtest
|
||||
.PHONY: depend test
|
||||
|
||||
depend:
|
||||
$(CC) $(CFLAGS) -M $(CDEFS) $(CINCS) $(SRC) >> $(MAKEFILE).dep
|
||||
|
||||
datatestfile14k.raw:
|
||||
dd if=/dev/urandom of=datatestfile14k.raw bs=1 count=14336
|
||||
|
||||
datatestfile512.raw:
|
||||
dd if=/dev/urandom of=datatestfile512.raw bs=1 count=512
|
||||
|
||||
test/test.hex:
|
||||
$(MAKE) -C test test.hex
|
||||
|
||||
uploadtest: datatestfile14k.raw datatestfile512.raw
|
||||
$(AVRDUDE) -p $(AVRDUDE_MCU) -c usbasp -P usb -U flash:w:datatestfile14k.raw -U eeprom:w:datatestfile512.raw
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U flash:v:datatestfile14k.raw -U eeprom:v:datatestfile512.raw
|
||||
|
||||
-include $(MAKEFILE).dep
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Programmer used for In System Programming
|
||||
ISP_PROG = usbasp
|
||||
# device the ISP programmer is connected to
|
||||
ISP_DEV = /dev/tty.PL2303-00002126
|
||||
ISP_DEV =
|
||||
# Programmer used for serial programming (using the bootloader)
|
||||
SERIAL_PROG = avr109
|
||||
# device the serial programmer is connected to
|
||||
@ -38,7 +38,6 @@ ifeq ($(MCU),atmega644)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
AVRDUDE_FLAGS += -p $(AVRDUDE_MCU)
|
||||
|
||||
# flags for the compiler
|
||||
@ -67,27 +66,14 @@ $(OBJECTS):
|
||||
clean:
|
||||
$(RM) *.hex *.eep.hex *.o *.lst *.lss
|
||||
|
||||
interactive-isp:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -t
|
||||
|
||||
interactive-serial:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(SERIAL_PROG) -P $(SERIAL_DEV) -t
|
||||
|
||||
|
||||
.PHONY: all clean interactive-isp interactive-serial launch-bootloader
|
||||
|
||||
flash: bootloader.hex
|
||||
flash:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -U flash:w:$<
|
||||
|
||||
program-isp-eeprom-%: %.eep.hex
|
||||
flash-eeprom-%: %.eep.hex
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(ISP_PROG) -P $(ISP_DEV) -U eeprom:w:$<
|
||||
|
||||
program-serial-%: %.hex
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(SERIAL_PROG) -P $(SERIAL_DEV) -U flash:w:$<
|
||||
|
||||
program-serial-eeprom-%: %.eep.hex launch-bootloader
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -c $(SERIAL_PROG) -P $(SERIAL_DEV) -U eeprom:w:$<
|
||||
|
||||
%.hex: %
|
||||
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
||||
|
||||
@ -99,6 +85,3 @@ program-serial-eeprom-%: %.eep.hex launch-bootloader
|
||||
|
||||
%-size: %.hex
|
||||
$(SIZE) $<
|
||||
|
||||
launch-bootloader:
|
||||
launch-bootloader $(SERIAL_DEV) $(AVRDUDE_BAUDRATE)
|
||||
|
||||
@ -85,7 +85,7 @@ static const uint8_t signature[4] = {
|
||||
#elif defined (__AVR_ATmega328P__)
|
||||
0x1e, 0x95, 0x0f, 0
|
||||
#elif defined (__AVR_ATmega644__)
|
||||
0x1e, 0x96, 0x06, 0
|
||||
0x1e, 0x96, 0x09, 0
|
||||
#else
|
||||
# error "Device signature is not known, please edit config.h!"
|
||||
#endif
|
||||
@ -109,7 +109,7 @@ static __attribute__ (( __noinline__ )) void putc(uint8_t data) {
|
||||
* which turn the interrupt on and off at the right times,
|
||||
* and prevent the execution of an interrupt while the pullup resistor
|
||||
* is switched off */
|
||||
/*
|
||||
|
||||
#ifdef USB_CFG_PULLUP_IOPORTNAME
|
||||
#undef usbDeviceConnect
|
||||
#define usbDeviceConnect() do { \
|
||||
@ -124,7 +124,7 @@ static __attribute__ (( __noinline__ )) void putc(uint8_t data) {
|
||||
USB_PULLUP_OUT &= ~(1<<USB_CFG_PULLUP_BIT); \
|
||||
} while(0);
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* prototypes */
|
||||
void __attribute__ (( __noreturn__, __noinline__, __naked__ )) leave_bootloader(void);
|
||||
|
||||
@ -341,19 +341,18 @@ int __attribute__ ((noreturn,OS_main)) main(void)
|
||||
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
|
||||
UCSR0B = _BV(TXEN0);
|
||||
#endif
|
||||
putc('a');
|
||||
putc('0');
|
||||
|
||||
|
||||
wdt_disable();
|
||||
|
||||
uint8_t reset = MCUSR;
|
||||
reset=0;
|
||||
uint16_t delay =0;
|
||||
timeout = TIMEOUT;
|
||||
|
||||
|
||||
/* if power-on reset, quit bootloader via watchdog reset */
|
||||
if (reset & _BV(PORF)){
|
||||
putc('p');
|
||||
putc('P');
|
||||
MCUSR = 0;
|
||||
leave_bootloader();
|
||||
}
|
||||
@ -361,19 +360,20 @@ int __attribute__ ((noreturn,OS_main)) main(void)
|
||||
else if(reset & _BV(WDRF)){
|
||||
|
||||
MCUSR = 0;
|
||||
//WDTCSR |= (1<<WDCE);
|
||||
//WDTCSR &= ~((1<<WDIE) | (1<<WDE));
|
||||
wdt_disable();
|
||||
putc('r');
|
||||
while(1);
|
||||
putc('W');
|
||||
|
||||
DLED_TGL;
|
||||
_delay_ms(500);
|
||||
DLED_TGL;
|
||||
_delay_ms(500);
|
||||
|
||||
jump_to_app();
|
||||
}
|
||||
|
||||
while(1);
|
||||
|
||||
/* else: enter programming mode */
|
||||
|
||||
putc('u');
|
||||
|
||||
/* clear external reset flags */
|
||||
MCUSR = 0;
|
||||
@ -386,10 +386,13 @@ int __attribute__ ((noreturn,OS_main)) main(void)
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
cli();
|
||||
/* enable interrupts */
|
||||
sei();
|
||||
|
||||
/* initialize usb pins */
|
||||
usbInit();
|
||||
|
||||
|
||||
/* disconnect for ~500ms, so that the host re-enumerates this device */
|
||||
putc('d');
|
||||
usbDeviceDisconnect();
|
||||
@ -398,12 +401,12 @@ int __attribute__ ((noreturn,OS_main)) main(void)
|
||||
usbDeviceConnect();
|
||||
putc('c');
|
||||
|
||||
/* enable interrupts */
|
||||
sei();
|
||||
|
||||
|
||||
|
||||
while(1) {
|
||||
//wdt_reset();
|
||||
usbPoll();
|
||||
|
||||
delay++;
|
||||
|
||||
/* do some led blinking, so that it is visible that the bootloader is still running */
|
||||
@ -419,8 +422,7 @@ int __attribute__ ((noreturn,OS_main)) main(void)
|
||||
_delay_ms(10);
|
||||
leave_bootloader();
|
||||
}
|
||||
}
|
||||
putc('l');
|
||||
|
||||
leave_bootloader();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,5 +5,5 @@
|
||||
/* micro-jumptable, we are using just reset and int0 vectors */
|
||||
exit:
|
||||
__vector_default:
|
||||
rjmp __init
|
||||
rjmp __vector_1
|
||||
jmp __init
|
||||
jmp __vector_1
|
||||
|
||||
@ -231,47 +231,3 @@ Scroll down to the bottom to see the most recent changes.
|
||||
- Added 20 MHz module contributed by Jeroen Benschop.
|
||||
|
||||
* Release 2008-05-13
|
||||
|
||||
- Fixed bug in libs-host/hiddata.c function usbhidGetReport(): length
|
||||
was not incremented, pointer to length was incremented instead.
|
||||
- Added code to command line tool(s) which claims an interface. This code
|
||||
is disabled by default, but may be necessary on newer Linux kernels.
|
||||
- Added usbconfig.h option "USB_CFG_CHECK_DATA_TOGGLING".
|
||||
- New header "usbportability.h" prepares ports to other development
|
||||
environments.
|
||||
- Long transfers (above 254 bytes) did not work when usbFunctionRead() was
|
||||
used to supply the data. Fixed this bug. [Thanks to Alexander Neumann!]
|
||||
- In hiddata.c (example code for sending/receiving data over HID), use
|
||||
USB_RECIP_DEVICE instead of USB_RECIP_INTERFACE for control transfers so
|
||||
that we need not claim the interface.
|
||||
- in usbPoll() loop 20 times polling for RESET state instead of 10 times.
|
||||
This accounts for the higher clock rates we now support.
|
||||
- Added a module for 12.8 MHz RC oscillator with PLL in receiver loop.
|
||||
- Added hook to SOF code so that oscillator can be tuned to USB frame clock.
|
||||
- Added timeout to waitForJ loop. Helps preventing unexpected hangs.
|
||||
- Added example code for oscillator tuning to libs-device (thanks to
|
||||
Henrik Haftmann for the idea to this routine).
|
||||
- Implemented option USB_CFG_SUPPRESS_INTR_CODE.
|
||||
|
||||
* Release 2008-10-22
|
||||
|
||||
- Fixed libs-device/osctune.h: OSCCAL is memory address on ATMega88 and
|
||||
similar, not offset of 0x20 needs to be added.
|
||||
- Allow distribution under GPLv3 for those who have to link against other
|
||||
code distributed under GPLv3.
|
||||
|
||||
* Release 2008-11-26
|
||||
|
||||
- Removed libusb-win32 dependency for hid-data example in Makefile.windows.
|
||||
It was never required and confused many people.
|
||||
- Added extern uchar usbRxToken to usbdrv.h.
|
||||
- Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser.
|
||||
|
||||
* Release 2009-03-23
|
||||
|
||||
- Hid-mouse example used settings from hid-data example, fixed that.
|
||||
- Renamed project to V-USB due to a trademark issue with Atmel(r).
|
||||
- Changed CommercialLicense.txt and USBID-License.txt to make the
|
||||
background of USB ID registration clearer.
|
||||
|
||||
* Release 2009-04-15
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
V-USB Driver Software License Agreement
|
||||
Version 2009-04-14
|
||||
AVR-USB Driver Software License Agreement
|
||||
Version 2008-04-15
|
||||
|
||||
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
|
||||
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
|
||||
@ -13,8 +13,8 @@ Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA.
|
||||
|
||||
1.2 "You" shall mean the Licensee.
|
||||
|
||||
1.3 "V-USB" shall mean all files included in the package distributed under
|
||||
the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/)
|
||||
1.3 "AVR-USB" shall mean all files included in the package distributed under
|
||||
the name "avrusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/avrusb/)
|
||||
unless otherwise noted. This includes the firmware-only USB device
|
||||
implementation for Atmel AVR microcontrollers, some simple device examples
|
||||
and host side software examples and libraries.
|
||||
@ -23,22 +23,21 @@ and host side software examples and libraries.
|
||||
2 LICENSE GRANTS
|
||||
|
||||
2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source
|
||||
code of V-USB.
|
||||
code of AVR-USB.
|
||||
|
||||
2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the
|
||||
non-exclusive right to use, copy and distribute V-USB with your hardware
|
||||
non-exclusive right to use and distribute AVR-USB with your hardware
|
||||
product(s), restricted by the limitations in section 3 below.
|
||||
|
||||
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
||||
the source code and your copy of V-USB according to your needs.
|
||||
your copy of AVR-USB according to your needs.
|
||||
|
||||
2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB Product
|
||||
ID(s), sent to you in e-mail. These Product IDs are reserved exclusively for
|
||||
you. They have been obtained from Wouter van Ooijen (www.voti.nl), who has
|
||||
reserved the Vendor ID 5824 (decimal) at the USB Implementers Forum, Inc.
|
||||
(www.usb.org). This mechanism ensures that there are no Product ID conflicts,
|
||||
but you cannot become USB certified (enter into the USB-IF Trademark License
|
||||
Agreement) as you would need your own Vendor ID for that.
|
||||
2.4 USB IDs. OBJECTIVE DEVELOPMENT grants you the exclusive rights to use
|
||||
USB Product ID(s) sent to you in e-mail after receiving your payment in
|
||||
conjunction with USB Vendor ID 5824. OBJECTIVE DEVELOPMENT has acquired an
|
||||
exclusive license for this pair of USB identifiers from Wouter van Ooijen
|
||||
(www.voti.nl), who has licensed the VID from the USB Implementers Forum,
|
||||
Inc. (www.usb.org).
|
||||
|
||||
|
||||
3 LICENSE RESTRICTIONS
|
||||
@ -47,21 +46,21 @@ Agreement) as you would need your own Vendor ID for that.
|
||||
applicable. Which one is determined by the amount you pay to OBJECTIVE
|
||||
DEVELOPMENT, see section 4 ("Payment") below.
|
||||
|
||||
Hobby License: You may use V-USB according to section 2 above in no more
|
||||
Hobby License: You may use AVR-USB according to section 2 above in no more
|
||||
than 5 hardware units. These units must not be sold for profit.
|
||||
|
||||
Entry Level License: You may use V-USB according to section 2 above in no
|
||||
Entry Level License: You may use AVR-USB according to section 2 above in no
|
||||
more than 150 hardware units.
|
||||
|
||||
Professional License: You may use V-USB according to section 2 above in
|
||||
Professional License: You may use AVR-USB according to section 2 above in
|
||||
any number of hardware units, except for large scale production ("unlimited
|
||||
fair use"). Quantities below 10,000 units are not considered large scale
|
||||
production. If your reach quantities which are obviously large scale
|
||||
production, you must pay a license fee of 0.10 EUR per unit for all units
|
||||
above 10,000.
|
||||
|
||||
3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber
|
||||
any copy of V-USB, or any of the rights granted herein.
|
||||
3.2 Rental. You may not rent, lease, or lend AVR-USB or otherwise encumber
|
||||
any copy of AVR-USB, or any of the rights granted herein.
|
||||
|
||||
3.3 Transfer. You may not transfer your rights under this Agreement to
|
||||
another party without OBJECTIVE DEVELOPMENT's prior written consent. If
|
||||
@ -79,7 +78,7 @@ non-exclusive.
|
||||
by third parties. In particular, you are not allowed to use the USB logo or
|
||||
other trademarks owned by the USB Implementers Forum, Inc. without their
|
||||
consent. Since such consent depends on USB certification, it should be
|
||||
noted that V-USB will not pass certification because it does not
|
||||
noted that AVR-USB will not pass certification because it does not
|
||||
implement checksum verification and the microcontroller ports do not meet
|
||||
the electrical specifications.
|
||||
|
||||
@ -89,15 +88,15 @@ the electrical specifications.
|
||||
The payment amount depends on the variation of this agreement (according to
|
||||
section 3.1) into which you want to enter. Concrete prices are listed on
|
||||
OBJECTIVE DEVELOPMENT's web site, usually at
|
||||
http://www.obdev.at/vusb/license.html. You agree to pay the amount listed
|
||||
http://www.obdev.at/avrusb/license.html. You agree to pay the amount listed
|
||||
there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor
|
||||
or reseller.
|
||||
|
||||
|
||||
5 COPYRIGHT AND OWNERSHIP
|
||||
|
||||
V-USB is protected by copyright laws and international copyright
|
||||
treaties, as well as other intellectual property laws and treaties. V-USB
|
||||
AVR-USB is protected by copyright laws and international copyright
|
||||
treaties, as well as other intellectual property laws and treaties. AVR-USB
|
||||
is licensed, not sold.
|
||||
|
||||
|
||||
@ -113,12 +112,12 @@ and limitation of liability shall survive termination of this agreement.
|
||||
|
||||
7 DISCLAIMER OF WARRANTY AND LIABILITY
|
||||
|
||||
LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
LIMITED WARRANTY. AVR-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE
|
||||
DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
||||
NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE
|
||||
NON-INFRINGEMENT, WITH REGARD TO AVR-USB, AND THE PROVISION OF OR FAILURE
|
||||
TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
|
||||
RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO
|
||||
STATE/JURISDICTION.
|
||||
@ -128,11 +127,11 @@ IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY
|
||||
SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
||||
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
||||
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
||||
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE
|
||||
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE AVR-USB OR THE
|
||||
PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE
|
||||
DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
|
||||
CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS
|
||||
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB.
|
||||
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR AVR-USB.
|
||||
|
||||
|
||||
8 MISCELLANEOUS TERMS
|
||||
|
||||
@ -1,18 +1,16 @@
|
||||
OBJECTIVE DEVELOPMENT GmbH's V-USB driver software is distributed under the
|
||||
terms and conditions of the GNU GPL version 2 or the GNU GPL version 3. It is
|
||||
your choice whether you apply the terms of version 2 or version 3. The full
|
||||
text of GPLv2 is included below. In addition to the requirements in the GPL,
|
||||
we STRONGLY ENCOURAGE you to do the following:
|
||||
OBJECTIVE DEVELOPMENT GmbH's AVR-USB driver software is distributed under the
|
||||
terms and conditions of the GNU GPL version 2, see the text below. In addition
|
||||
to the requirements in the GPL, we STRONGLY ENCOURAGE you to do the following:
|
||||
|
||||
(1) Publish your entire project on a web site and drop us a note with the URL.
|
||||
Use the form at http://www.obdev.at/vusb/feedback.html for your submission.
|
||||
Use the form at http://www.obdev.at/avrusb/feedback.html for your submission.
|
||||
|
||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||
- a circuit diagram in PDF, PNG or GIF format
|
||||
- full source code for the host software
|
||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
||||
project and what can be found in which directories and which files
|
||||
- a reference to http://www.obdev.at/vusb/
|
||||
- a reference to http://www.obdev.at/avrusb/
|
||||
|
||||
(3) If you improve the driver firmware itself, please give us a free license
|
||||
to your modifications for our commercial license offerings.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
This is the Readme file to Objective Development's firmware-only USB driver
|
||||
for Atmel AVR microcontrollers. For more information please visit
|
||||
http://www.obdev.at/vusb/
|
||||
http://www.obdev.at/avrusb/
|
||||
|
||||
This directory contains the USB firmware only. Copy it as-is to your own
|
||||
project and add all .c and .S files to your project (these files are marked
|
||||
@ -33,7 +33,7 @@ The driver consists of the following files:
|
||||
defined to a value greater than 0. Link this module
|
||||
to your code!
|
||||
oddebug.h .............. Interface definitions of the debug module.
|
||||
usbportability.h ....... Header with compiler-dependent stuff.
|
||||
iarcompat.h ............ Compatibility definitions for IAR C-compiler.
|
||||
usbdrvasm.asm .......... Compatibility stub for IAR-C-compiler. Use this
|
||||
module instead of usbdrvasm.S when you assembler
|
||||
with IAR's tools.
|
||||
@ -47,13 +47,12 @@ The driver consists of the following files:
|
||||
|
||||
CPU CORE CLOCK FREQUENCY
|
||||
========================
|
||||
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
|
||||
actual clock rate must be configured in usbdrv.h unless you use the default
|
||||
12 MHz.
|
||||
We supply assembler modules for clock frequencies of 12 MHz, 15 MHz, 16 MHz and
|
||||
16.5 MHz. Other clock rates are not supported. The actual clock rate must be
|
||||
configured in usbdrv.h unless you use the default 12 MHz.
|
||||
|
||||
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 AVR-USB because it's the lowest clock
|
||||
rate where the timing constraints of the USB spec can be met.
|
||||
|
||||
15 MHz Clock
|
||||
@ -68,29 +67,19 @@ if you need the slightly higher clock rate for performance reasons. Since
|
||||
16 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code
|
||||
is somewhat tricky and has to insert a leap cycle every third byte.
|
||||
|
||||
12.8 MHz and 16.5 MHz Clock
|
||||
The assembler modules for these clock rates differ from the other modules
|
||||
because they have been built for an RC oscillator with only 1% precision. The
|
||||
receiver code inserts leap cycles to compensate for clock deviations. 1% is
|
||||
also the precision which can be achieved by calibrating the internal RC
|
||||
oscillator of the AVR. Please note that only AVRs with internal 64 MHz PLL
|
||||
oscillator can reach 16.5 MHz with the RC oscillator. This includes the very
|
||||
popular ATTiny25, ATTiny45, ATTiny85 series as well as the ATTiny26. Almost
|
||||
all AVRs can reach 12.8 MHz, although this is outside the specified range.
|
||||
16.5 MHz Clock
|
||||
The assembler module for this clock rate differs from the other modules because
|
||||
it has been built for an RC oscillator with only 1% precision. The receiver
|
||||
code inserts leap cycles to compensate for clock deviations. 1% is also the
|
||||
precision which can be achieved by calibrating the internal RC oscillator of
|
||||
the AVR. Please note that only AVRs with internal 64 MHz PLL oscillator can be
|
||||
used since the 8 MHz RC oscillator cannot be trimmed up to 16.5 MHz. This
|
||||
includes the very popular ATTiny25, ATTiny45, ATTiny85 series as well as the
|
||||
ATTiny26.
|
||||
|
||||
See the EasyLogger example at http://www.obdev.at/vusb/easylogger.html for
|
||||
See the EasyLogger example at http://www.obdev.at/avrusb/easylogger.html for
|
||||
code which calibrates the RC oscillator based on the USB frame clock.
|
||||
|
||||
18 MHz Clock
|
||||
This module is closer to the USB specification because it performs an on the
|
||||
fly CRC check for incoming packets. Packets with invalid checksum are
|
||||
discarded as required by the spec. If you also implement checks for data
|
||||
PID toggling on application level (see option USB_CFG_CHECK_DATA_TOGGLING
|
||||
in usbconfig.h for more info), this ensures data integrity. Due to the CRC
|
||||
tables and alignment requirements, this code is bigger than modules for other
|
||||
clock rates. To activate this module, you must define USB_CFG_CHECK_CRC to 1
|
||||
and USB_CFG_CLOCK_KHZ to 18000 in usbconfig.h.
|
||||
|
||||
20 MHz Clock
|
||||
This module is for people who won't do it with less than the maximum. Since
|
||||
20 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code
|
||||
@ -108,14 +97,14 @@ and hobbyists, we provide some VID/PID pairs for free. See the file
|
||||
USBID-License.txt for details.
|
||||
|
||||
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/avrusb/ for details.
|
||||
|
||||
|
||||
DEVELOPMENT SYSTEM
|
||||
==================
|
||||
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
|
||||
that you use the GNU compiler suite because it is freely available. V-USB
|
||||
that you use the GNU compiler suite because it is freely available. AVR-USB
|
||||
has also been ported to the IAR compiler and assembler. It has been tested
|
||||
with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the "small" and "tiny"
|
||||
memory model. Not every release is tested with IAR CC and the driver may
|
||||
@ -123,36 +112,35 @@ therefore fail to compile with IAR. Please note that gcc is more efficient for
|
||||
usbdrv.c because this module has been deliberately optimized for gcc.
|
||||
|
||||
|
||||
USING V-USB FOR FREE
|
||||
====================
|
||||
USING AVR-USB FOR FREE
|
||||
======================
|
||||
The AVR firmware driver is published under the GNU General Public License
|
||||
Version 2 (GPL2) and the GNU General Public License Version 3 (GPL3). It is
|
||||
your choice whether you apply the terms of version 2 or version 3.
|
||||
Version 2 (GPL2). See the file "License.txt" for details.
|
||||
|
||||
If you decide for the free GPL2 or GPL3, we STRONGLY ENCOURAGE you to do the
|
||||
following things IN ADDITION to the obligations from the GPL:
|
||||
If you decide for the free GPL2, we STRONGLY ENCOURAGE you to do the following
|
||||
things IN ADDITION to the obligations from the GPL2:
|
||||
|
||||
(1) Publish your entire project on a web site and drop us a note with the URL.
|
||||
Use the form at http://www.obdev.at/vusb/feedback.html for your submission.
|
||||
Use the form at http://www.obdev.at/avrusb/feedback.html for your submission.
|
||||
If you don't have a web site, you can publish the project in obdev's
|
||||
documentation wiki at
|
||||
http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects.
|
||||
http://www.obdev.at/goto.php?t=avrusb-wiki&p=hosted-projects.
|
||||
|
||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||
- a circuit diagram in PDF, PNG or GIF format
|
||||
- full source code for the host software
|
||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
||||
project and what can be found in which directories and which files
|
||||
- a reference to http://www.obdev.at/vusb/
|
||||
- a reference to http://www.obdev.at/avrusb/
|
||||
|
||||
(3) If you improve the driver firmware itself, please give us a free license
|
||||
to your modifications for our commercial license offerings.
|
||||
|
||||
|
||||
COMMERCIAL LICENSES FOR V-USB
|
||||
=============================
|
||||
If you don't want to publish your source code under the terms of the GPL,
|
||||
you can simply pay money for V-USB. As an additional benefit you get
|
||||
USB PIDs for free, reserved exclusively to you. See the file
|
||||
COMMERCIAL LICENSES FOR AVR-USB
|
||||
===============================
|
||||
If you don't want to publish your source code under the terms of the GPL2,
|
||||
you can simply pay money for AVR-USB. As an additional benefit you get
|
||||
USB PIDs for free, licensed exclusively to you. See the file
|
||||
"CommercialLicense.txt" for details.
|
||||
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
Royalty-Free Non-Exclusive Use of USB Product-IDs
|
||||
Royalty-Free Non-Exclusive License USB Product-ID
|
||||
=================================================
|
||||
|
||||
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.
|
||||
|
||||
Version 2008-04-07
|
||||
|
||||
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
||||
right to use four USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
||||
right to use three USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
||||
products based on Objective Development's firmware-only USB driver for
|
||||
Atmel AVR microcontrollers:
|
||||
|
||||
@ -34,11 +27,10 @@ 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".
|
||||
OBJECTIVE DEVELOPMENT Software GmbH has licensed these VID/PID pairs from
|
||||
Wouter van Ooijen (see www.voti.nl), who has licensed 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
|
||||
@ -52,7 +44,7 @@ MUST be available at least in USB language 0x0409 (English/US).
|
||||
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/".
|
||||
Development http://www.obdev.at/avrusb/".
|
||||
|
||||
(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.
|
||||
@ -150,5 +142,5 @@ 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
|
||||
Development's commercial licenses for AVR-USB include a PID for
|
||||
unrestricted exclusive use.
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Name: asmcommon.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-11-05
|
||||
* Tabsize: 4
|
||||
* 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) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id$
|
||||
*/
|
||||
|
||||
@ -103,11 +103,8 @@ sofError:
|
||||
reti
|
||||
|
||||
handleData:
|
||||
#if USB_CFG_CHECK_CRC
|
||||
CRC_CLEANUP_AND_CHECK ; jumps to ignorePacket if CRC error
|
||||
#endif
|
||||
lds shift, usbCurrentTok;[18]
|
||||
tst shift ;[20]
|
||||
lds token, usbCurrentTok;[18]
|
||||
tst token ;[20]
|
||||
breq doReturn ;[21]
|
||||
lds x2, usbRxLen ;[22]
|
||||
tst x2 ;[24]
|
||||
@ -116,11 +113,8 @@ handleData:
|
||||
; recognized if usbPoll() was called less frequently than once every 4 ms.
|
||||
cpi cnt, 4 ;[26] zero sized data packets are status phase only -- ignore and ack
|
||||
brmi sendAckAndReti ;[27] keep rx buffer clean -- we must not NAK next SETUP
|
||||
#if USB_CFG_CHECK_DATA_TOGGLING
|
||||
sts usbCurrentDataToken, token ; store for checking by C code
|
||||
#endif
|
||||
sts usbRxLen, cnt ;[28] store received data, swap buffers
|
||||
sts usbRxToken, shift ;[30]
|
||||
sts usbRxToken, token ;[30]
|
||||
lds x2, usbInputBufOffset;[32] swap buffers
|
||||
ldi cnt, USB_BUFSIZE ;[34]
|
||||
sub cnt, x2 ;[35]
|
||||
@ -137,11 +131,7 @@ handleIn:
|
||||
ldi x1, USBPID_NAK ;[34] prepare value for usbTxLen
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
andi x3, 0xf ;[35] x3 contains endpoint
|
||||
#if USB_CFG_SUPPRESS_INTR_CODE
|
||||
brne sendNakAndReti ;[36]
|
||||
#else
|
||||
brne handleIn1 ;[36]
|
||||
#endif
|
||||
#endif
|
||||
lds cnt, usbTxLen ;[37]
|
||||
sbrc cnt, 4 ;[39] all handshake tokens have bit 4 set
|
||||
@ -160,7 +150,7 @@ handleIn:
|
||||
; RAM this way and avoid potential problems with endless retries. The rest of
|
||||
; the driver assumes error-free transfers anyway.
|
||||
|
||||
#if !USB_CFG_SUPPRESS_INTR_CODE && USB_CFG_HAVE_INTRIN_ENDPOINT /* placed here due to relative jump range */
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT /* placed here due to relative jump range */
|
||||
handleIn1: ;[38]
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
; 2006-06-10 as suggested by O.Tamura: support second INTR IN / BULK IN endpoint
|
||||
@ -174,8 +164,9 @@ handleIn1: ;[38]
|
||||
ldi YL, lo8(usbTxBuf1) ;[46]
|
||||
ldi YH, hi8(usbTxBuf1) ;[47]
|
||||
rjmp usbSendAndReti ;[48] 50 + 12 = 62 until SOP
|
||||
#endif
|
||||
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT && USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
handleIn3:
|
||||
lds cnt, usbTxLen3 ;[41]
|
||||
sbrc cnt, 4 ;[43]
|
||||
@ -185,4 +176,3 @@ handleIn3:
|
||||
ldi YH, hi8(usbTxBuf3) ;[48]
|
||||
rjmp usbSendAndReti ;[49] 51 + 12 = 63 until SOP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
* Creation Date: 2006-03-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: Proprietary, free under certain conditions. See Documentation.
|
||||
* This Revision: $Id$
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: iarcompat.h 533 2008-02-28 15:35:25Z cs $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -33,11 +33,6 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
|
||||
#endif
|
||||
|
||||
#define __attribute__(arg)
|
||||
#define IAR_SECTION(section) @ section
|
||||
|
||||
#ifndef USB_BUFFER_SECTION
|
||||
# define USB_BUFFER_SECTION "TINY_Z" /* if user has not selected a named section */
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ASM__
|
||||
# define __ASSEMBLER__
|
||||
@ -58,6 +53,13 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
|
||||
#define sei() __enable_interrupt()
|
||||
#define wdt_reset() __watchdog_reset()
|
||||
|
||||
/* Depending on the device you use, you may get problems with the way usbdrv.h
|
||||
* handles the differences between devices. Since IAR does not use #defines
|
||||
* for MCU registers, we can't check for the existence of a particular
|
||||
* register with an #ifdef. If the autodetection mechanism fails, include
|
||||
* definitions for the required USB_INTR_* macros in your usbconfig.h. See
|
||||
* usbconfig-prototype.h and usbdrv.h for details.
|
||||
*/
|
||||
|
||||
#endif /* defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ */
|
||||
#endif /* __iarcompat_h_INCLUDED__ */
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
* Creation Date: 2005-01-16
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: oddebug.c 275 2007-03-20 09:58:28Z cs $
|
||||
*/
|
||||
|
||||
#include "oddebug.h"
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
* Creation Date: 2005-01-16
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: oddebug.h 275 2007-03-20 09:58:28Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __oddebug_h_included__
|
||||
@ -29,7 +29,10 @@ the output and a memory block to dump in hex ('data' and 'len').
|
||||
#endif
|
||||
|
||||
/* make sure we have the UART defines: */
|
||||
#include "usbportability.h"
|
||||
#include "iarcompat.h"
|
||||
#ifndef __IAR_SYSTEMS_ICC__
|
||||
# include <avr/io.h>
|
||||
#endif
|
||||
|
||||
#ifndef uchar
|
||||
# define uchar unsigned char
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbconfig-prototype.h 600 2008-05-13 10:34:56Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
@ -14,7 +14,7 @@
|
||||
/*
|
||||
General Description:
|
||||
This file is an example configuration (with inline documentation) for the USB
|
||||
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
|
||||
driver. It configures AVR-USB for USB D+ connected to Port D bit 2 (which is
|
||||
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
|
||||
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
|
||||
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
@ -44,18 +44,12 @@ section at the end of this file).
|
||||
* markers every millisecond.]
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* 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
|
||||
* crystal, they tolerate +/- 1% deviation from the nominal frequency. All
|
||||
* other rates require a precision of 2000 ppm and thus a crystal!
|
||||
/* Clock rate of the AVR in MHz. Legal values are 12000, 15000, 16000, 16500
|
||||
* and 20000. The 16.5 MHz version of the code requires no crystal, it
|
||||
* tolerates +/- 1% deviation from the nominal frequency. All other rates
|
||||
* require a precision of 2000 ppm and thus a crystal!
|
||||
* Default if not specified: 12 MHz
|
||||
*/
|
||||
#define USB_CFG_CHECK_CRC 0
|
||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
|
||||
* currently only available for 18 MHz crystal clock. You must choose
|
||||
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
|
||||
@ -100,14 +94,6 @@ section at the end of this file).
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 0
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 10
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
@ -170,33 +156,6 @@ section at the end of this file).
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* 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.
|
||||
@ -284,9 +243,7 @@ section at the end of this file).
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* at runtime via usbFunctionDescriptor().
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
@ -318,12 +275,6 @@ section at the end of this file).
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
#define USB_CFG_DESCR_PROPS_DEVICE 0
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
/* Name: usbdrv.c
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2004-12-29
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbdrv.c 591 2008-05-03 20:21:19Z cs $
|
||||
*/
|
||||
|
||||
#include "usbportability.h"
|
||||
#include "iarcompat.h"
|
||||
#ifndef __IAR_SYSTEMS_ICC__
|
||||
# include <avr/io.h>
|
||||
# include <avr/pgmspace.h>
|
||||
#endif
|
||||
#include "usbdrv.h"
|
||||
#include "oddebug.h"
|
||||
|
||||
@ -34,15 +38,12 @@ uchar usbTxBuf[USB_BUFSIZE];/* data to transmit with next IN, free if usbT
|
||||
#if USB_COUNT_SOF
|
||||
volatile uchar usbSofCount; /* incremented by assembler module every SOF */
|
||||
#endif
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
usbTxStatus_t usbTxStatus1;
|
||||
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
usbTxStatus_t usbTxStatus3;
|
||||
# endif
|
||||
#endif
|
||||
#if USB_CFG_CHECK_DATA_TOGGLING
|
||||
uchar usbCurrentDataToken;/* when we check data toggling to ignore duplicate packets */
|
||||
#endif
|
||||
|
||||
/* USB status registers / not shared with asm code */
|
||||
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
|
||||
@ -55,7 +56,7 @@ static uchar usbMsgFlags; /* flag values see below */
|
||||
/*
|
||||
optimizing hints:
|
||||
- do not post/pre inc/dec integer values in operations
|
||||
- assign value of USB_READ_FLASH() to register variables and don't use side effects in arg
|
||||
- assign value of PRG_RDB() to register variables and don't use side effects in arg
|
||||
- use narrow scope for variables which should be in X/Y/Z register
|
||||
- assign char sized expressions to variables to force 8 bit arithmetics
|
||||
*/
|
||||
@ -194,9 +195,18 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* We don't use prog_int or prog_int16_t for compatibility with various libc
|
||||
* versions. Here's an other compatibility hack:
|
||||
*/
|
||||
#ifndef PRG_RDB
|
||||
#define PRG_RDB(addr) pgm_read_byte(addr)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static inline void usbResetDataToggling(void)
|
||||
{
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
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 */
|
||||
@ -216,7 +226,6 @@ static inline void usbResetStall(void)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if !USB_CFG_SUPPRESS_INTR_CODE
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
static void usbGenericSetInterrupt(uchar *data, uchar len, usbTxStatus_t *txStatus)
|
||||
{
|
||||
@ -254,7 +263,6 @@ USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len)
|
||||
usbGenericSetInterrupt(data, len, &usbTxStatus3);
|
||||
}
|
||||
#endif
|
||||
#endif /* USB_CFG_SUPPRESS_INTR_CODE */
|
||||
|
||||
/* ------------------ utilities for code following below ------------------- */
|
||||
|
||||
@ -400,7 +408,7 @@ uchar index = rq->wIndex.bytes[0];
|
||||
usbResetStall();
|
||||
SWITCH_CASE(USBRQ_GET_INTERFACE) /* 10 */
|
||||
len = 1;
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
SWITCH_CASE(USBRQ_SET_INTERFACE) /* 11 */
|
||||
usbResetDataToggling();
|
||||
usbResetStall();
|
||||
@ -428,7 +436,7 @@ usbRequest_t *rq = (void *)data;
|
||||
* 0xe1 11100001 (USBPID_OUT: data phase of setup transfer)
|
||||
* 0...0x0f for OUT on endpoint X
|
||||
*/
|
||||
DBG2(0x10 + (usbRxToken & 0xf), data, len + 2); /* SETUP=1d, SETUP-DATA=11, OUTx=1x */
|
||||
DBG2(0x10 + (usbRxToken & 0xf), data, len); /* SETUP=1d, SETUP-DATA=11, OUTx=1x */
|
||||
USB_RX_USER_HOOK(data, len)
|
||||
#if USB_CFG_IMPLEMENT_FN_WRITEOUT
|
||||
if(usbRxToken < 0x10){ /* OUT to endpoint != 0: endpoint number in usbRxToken */
|
||||
@ -451,13 +459,9 @@ usbRequest_t *rq = (void *)data;
|
||||
}
|
||||
#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE
|
||||
if(replyLen == USB_NO_MSG){ /* use user-supplied read/write function */
|
||||
/* do some conditioning on replyLen, but on IN transfers only */
|
||||
/* do some conditioning on replyLen */
|
||||
if((rq->bmRequestType & USBRQ_DIR_MASK) != USBRQ_DIR_HOST_TO_DEVICE){
|
||||
if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */
|
||||
replyLen = rq->wLength.bytes[0];
|
||||
}else{
|
||||
replyLen = rq->wLength.word;
|
||||
}
|
||||
replyLen = rq->wLength.bytes[0]; /* IN transfers only */
|
||||
}
|
||||
usbMsgFlags = USB_FLG_USE_USER_RW;
|
||||
}else /* The 'else' prevents that we limit a replyLen of USB_NO_MSG to the maximum transfer len. */
|
||||
@ -501,7 +505,7 @@ static uchar usbDeviceRead(uchar *data, uchar len)
|
||||
uchar i = len, *r = usbMsgPtr;
|
||||
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
|
||||
do{
|
||||
uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */
|
||||
uchar c = PRG_RDB(r); /* assign to char size variable to enforce byte ops */
|
||||
*data++ = c;
|
||||
r++;
|
||||
}while(--i);
|
||||
@ -588,17 +592,17 @@ uchar i;
|
||||
usbBuildTxBlock();
|
||||
}
|
||||
}
|
||||
for(i = 20; i > 0; i--){
|
||||
for(i = 10; i > 0; i--){
|
||||
uchar usbLineStatus = USBIN & USBMASK;
|
||||
if(usbLineStatus != 0) /* SE0 has ended */
|
||||
goto isNotReset;
|
||||
break;
|
||||
}
|
||||
/* RESET condition, called multiple times during reset */
|
||||
if(i == 0){ /* RESET condition, called multiple times during reset */
|
||||
usbNewDeviceAddr = 0;
|
||||
usbDeviceAddr = 0;
|
||||
usbResetStall();
|
||||
DBG1(0xff, 0, 0);
|
||||
isNotReset:
|
||||
}
|
||||
usbHandleResetHook(i);
|
||||
}
|
||||
|
||||
@ -614,7 +618,7 @@ USB_PUBLIC void usbInit(void)
|
||||
#endif
|
||||
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
|
||||
usbResetDataToggling();
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
usbTxLen1 = USBPID_NAK;
|
||||
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
usbTxLen3 = USBPID_NAK;
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
/* Name: usbdrv.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2004-12-29
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbdrv.h 607 2008-05-13 15:57:28Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbdrv_h_included__
|
||||
#define __usbdrv_h_included__
|
||||
#include "usbconfig.h"
|
||||
#include "usbportability.h"
|
||||
#include "iarcompat.h"
|
||||
|
||||
/*
|
||||
Hardware Prerequisites:
|
||||
@ -34,8 +34,8 @@ usbDeviceConnect() and usbDeviceDisconnect() further down in this file.
|
||||
|
||||
Please adapt the values in usbconfig.h according to your hardware!
|
||||
|
||||
The device MUST be clocked at exactly 12 MHz, 15 MHz, 16 MHz or 20 MHz
|
||||
or at 12.8 MHz resp. 16.5 MHz +/- 1%. See usbconfig-prototype.h for details.
|
||||
The device MUST be clocked at exactly 12 MHz, 15 MHz or 16 MHz
|
||||
or at 16.5 MHz +/- 1%. See usbconfig-prototype.h for details.
|
||||
|
||||
|
||||
Limitations:
|
||||
@ -122,7 +122,7 @@ USB messages, even if they address another (low-speed) device on the same bus.
|
||||
/* --------------------------- Module Interface ---------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define USBDRV_VERSION 20090415
|
||||
#define USBDRV_VERSION 20080513
|
||||
/* 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
|
||||
* driver's behavior or interface changes, you can use this constant to
|
||||
@ -273,8 +273,6 @@ USB_PUBLIC uchar usbFunctionRead(uchar *data, uchar len);
|
||||
* to 1 in usbconfig.h and return 0xff in usbFunctionSetup()..
|
||||
*/
|
||||
#endif /* USB_CFG_IMPLEMENT_FN_READ */
|
||||
|
||||
extern uchar usbRxToken; /* may be used in usbFunctionWriteOut() below */
|
||||
#if USB_CFG_IMPLEMENT_FN_WRITEOUT
|
||||
USB_PUBLIC void usbFunctionWriteOut(uchar *data, uchar len);
|
||||
/* This function is called by the driver when data is received on an interrupt-
|
||||
@ -341,12 +339,6 @@ extern volatile uchar usbSofCount;
|
||||
* the macro USB_COUNT_SOF is defined to a value != 0.
|
||||
*/
|
||||
#endif
|
||||
#if USB_CFG_CHECK_DATA_TOGGLING
|
||||
extern uchar usbCurrentDataToken;
|
||||
/* This variable can be checked in usbFunctionWrite() and usbFunctionWriteOut()
|
||||
* to ignore duplicate packets.
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define USB_STRING_DESCRIPTOR_HEADER(stringLength) ((2*(stringLength)+2) | (3<<8))
|
||||
/* This macro builds a descriptor header for a string descriptor given the
|
||||
@ -390,9 +382,7 @@ extern volatile schar usbRxLen;
|
||||
*/
|
||||
#define USB_PROP_IS_DYNAMIC (1 << 14)
|
||||
/* If this property is set for a descriptor, usbFunctionDescriptor() will be
|
||||
* used to obtain the particular descriptor. Data directly returned via
|
||||
* usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to
|
||||
* return RAM data.
|
||||
* used to obtain the particular descriptor.
|
||||
*/
|
||||
#define USB_PROP_IS_RAM (1 << 15)
|
||||
/* If this property is set for a descriptor, the data is read from RAM
|
||||
@ -556,10 +546,6 @@ int usbDescriptorStringSerialNumber[];
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
#endif
|
||||
|
||||
#ifndef USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
|
||||
#endif
|
||||
|
||||
#define USB_BUFSIZE 11 /* PID, 8 bytes data, 2 bytes CRC */
|
||||
|
||||
/* ----- Try to find registers and bits responsible for ext interrupt 0 ----- */
|
||||
@ -572,14 +558,7 @@ int usbDescriptorStringSerialNumber[];
|
||||
# endif
|
||||
#endif
|
||||
#ifndef USB_INTR_CFG_SET /* allow user to override our default */
|
||||
# if defined(USB_COUNT_SOF) || defined(USB_SOF_HOOK)
|
||||
# define USB_INTR_CFG_SET (1 << ISC01) /* cfg for falling edge */
|
||||
/* If any SOF logic is used, the interrupt must be wired to D- where
|
||||
* we better trigger on falling edge
|
||||
*/
|
||||
# else
|
||||
# define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) /* cfg for rising edge */
|
||||
# endif
|
||||
#endif
|
||||
#ifndef USB_INTR_CFG_CLR /* allow user to override our default */
|
||||
# define USB_INTR_CFG_CLR 0 /* no bits to clear */
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbdrvasm.S
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-06-13
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -15,8 +15,15 @@ general code (preprocessor acrobatics and CRC computation) and then includes
|
||||
the file appropriate for the given clock rate.
|
||||
*/
|
||||
|
||||
#define __SFR_OFFSET 0 /* used by avr-libc's register definitions */
|
||||
#include "usbportability.h"
|
||||
#include "iarcompat.h"
|
||||
#ifndef __IAR_SYSTEMS_ASM__
|
||||
/* configs for io.h */
|
||||
# define __SFR_OFFSET 0
|
||||
# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
|
||||
# include <avr/io.h> /* for CPU I/O register definitions and vectors */
|
||||
# define macro .macro /* GNU Assembler macro definition */
|
||||
# define endm .endm /* End of GNU Assembler macro definition */
|
||||
#endif /* __IAR_SYSTEMS_ASM__ */
|
||||
#include "usbdrv.h" /* for common defs */
|
||||
|
||||
/* register names */
|
||||
@ -26,14 +33,24 @@ the file appropriate for the given clock rate.
|
||||
#define cnt r19
|
||||
#define x3 r20
|
||||
#define x4 r21
|
||||
#define x5 r22
|
||||
#define bitcnt x5
|
||||
#define bitcnt r22
|
||||
#define phase x4
|
||||
#define leap x4
|
||||
|
||||
/* Some assembler dependent definitions and declarations: */
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ASM__
|
||||
|
||||
# define nop2 rjmp $+2 /* jump to next instruction */
|
||||
# define XL r26
|
||||
# define XH r27
|
||||
# define YL r28
|
||||
# define YH r29
|
||||
# define ZL r30
|
||||
# define ZH r31
|
||||
# define lo8(x) LOW(x)
|
||||
# define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
|
||||
|
||||
extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset
|
||||
extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen
|
||||
extern usbTxBuf, usbTxStatus1, usbTxStatus3
|
||||
@ -56,6 +73,8 @@ the file appropriate for the given clock rate.
|
||||
|
||||
#else /* __IAR_SYSTEMS_ASM__ */
|
||||
|
||||
# define nop2 rjmp .+0 /* jump to next instruction */
|
||||
|
||||
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
|
||||
# define USB_INTR_VECTOR SIG_INTERRUPT0
|
||||
# endif
|
||||
@ -280,26 +299,16 @@ usbMFTimeout:
|
||||
# define USB_CFG_CLOCK_KHZ 12000
|
||||
#endif
|
||||
|
||||
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
|
||||
# if USB_CFG_CLOCK_KHZ == 18000
|
||||
# include "usbdrvasm18-crc.inc"
|
||||
# else
|
||||
# error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!"
|
||||
# endif
|
||||
#else /* USB_CFG_CHECK_CRC */
|
||||
# if USB_CFG_CLOCK_KHZ == 12000
|
||||
#if USB_CFG_CLOCK_KHZ == 12000
|
||||
# include "usbdrvasm12.inc"
|
||||
# elif USB_CFG_CLOCK_KHZ == 12800
|
||||
# include "usbdrvasm128.inc"
|
||||
# elif USB_CFG_CLOCK_KHZ == 15000
|
||||
#elif USB_CFG_CLOCK_KHZ == 15000
|
||||
# include "usbdrvasm15.inc"
|
||||
# elif USB_CFG_CLOCK_KHZ == 16000
|
||||
#elif USB_CFG_CLOCK_KHZ == 16000
|
||||
# include "usbdrvasm16.inc"
|
||||
# elif USB_CFG_CLOCK_KHZ == 16500
|
||||
#elif USB_CFG_CLOCK_KHZ == 16500
|
||||
# include "usbdrvasm165.inc"
|
||||
# elif USB_CFG_CLOCK_KHZ == 20000
|
||||
#elif USB_CFG_CLOCK_KHZ == 20000
|
||||
# include "usbdrvasm20.inc"
|
||||
# else
|
||||
# error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!"
|
||||
# endif
|
||||
#endif /* USB_CFG_CHECK_CRC */
|
||||
#else
|
||||
# error "USB_CFG_CLOCK_KHZ is not one of the supported rates!"
|
||||
#endif
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Name: usbdrvasm.asm
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2006-03-01
|
||||
* Tabsize: 4
|
||||
* 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) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id$
|
||||
*/
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbdrvasm12.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2004-12-29
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbdrvasm12.inc 483 2008-02-05 15:05:32Z cs $
|
||||
*/
|
||||
|
||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||
@ -48,13 +48,10 @@ USB_INTR_VECTOR:
|
||||
;----------------------------------------------------------------------------
|
||||
;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
|
||||
;sync up with J to K edge during sync pattern -- use fastest possible loops
|
||||
;The first part waits at most 1 bit long since we must be in sync pattern.
|
||||
;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to
|
||||
;waitForJ, ensure that this prerequisite is met.
|
||||
;first part has no timeout because it waits for IDLE or SE1 (== disconnected)
|
||||
waitForJ:
|
||||
inc YL
|
||||
sbis USBIN, USBMINUS
|
||||
brne waitForJ ; just make sure we have ANY timeout
|
||||
sbis USBIN, USBMINUS ;1 [40] wait for D- == 1
|
||||
rjmp waitForJ ;2
|
||||
waitForK:
|
||||
;The following code results in a sampling window of 1/4 bit which meets the spec.
|
||||
sbis USBIN, USBMINUS
|
||||
@ -72,9 +69,6 @@ waitForK:
|
||||
inc YL
|
||||
sts usbSofCount, YL
|
||||
#endif /* USB_COUNT_SOF */
|
||||
#ifdef USB_SOF_HOOK
|
||||
USB_SOF_HOOK
|
||||
#endif
|
||||
rjmp sofError
|
||||
foundK:
|
||||
;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling]
|
||||
@ -256,12 +250,12 @@ macro POP_STANDARD ; 12 cycles
|
||||
pop x1
|
||||
pop shift
|
||||
pop YH
|
||||
endm
|
||||
endm
|
||||
macro POP_RETI ; 5 cycles
|
||||
pop YL
|
||||
out SREG, YL
|
||||
pop YL
|
||||
endm
|
||||
endm
|
||||
|
||||
#include "asmcommon.inc"
|
||||
|
||||
@ -269,16 +263,25 @@ macro POP_RETI ; 5 cycles
|
||||
; Transmitting data
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
txByteLoop:
|
||||
txBitloop:
|
||||
stuffN1Delay: ; [03]
|
||||
ror shift ;[-5] [11] [59]
|
||||
brcc doExorN1 ;[-4] [60]
|
||||
subi x4, 1 ;[-3]
|
||||
brne commonN1 ;[-2]
|
||||
lsl shift ;[-1] compensate ror after rjmp stuffDelay
|
||||
nop ;[00] stuffing consists of just waiting 8 cycles
|
||||
rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear
|
||||
bitstuff0: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
ldi x2, 0 ;1
|
||||
out USBOUT, x1 ;1 <-- out
|
||||
rjmp didStuff0 ;2 branch back 2 cycles earlier
|
||||
bitstuff1: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff1 ;2 we know that C is clear, jump back to do OUT and ror 0 into x2
|
||||
bitstuff2: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff2 ;2 jump back 4 cycles earlier and do out and ror 0 into x2
|
||||
bitstuff3: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff3 ;2 jump back earlier and ror 0 into x2
|
||||
bitstuff4: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
ldi x2, 0 ;1
|
||||
out USBOUT, x1 ;1 <-- out
|
||||
rjmp didStuff4 ;2 jump back 2 cycles earlier
|
||||
|
||||
sendNakAndReti: ;0 [-19] 19 cycles until SOP
|
||||
ldi x3, USBPID_NAK ;1 [-18]
|
||||
@ -303,91 +306,122 @@ usbSendX3: ;0 [-16]
|
||||
;usbSend:
|
||||
;pointer to data in 'Y'
|
||||
;number of bytes in 'cnt' -- including sync byte
|
||||
;uses: x1...x2, x4, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x4 = bitstuff cnt]
|
||||
;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction)
|
||||
usbSendAndReti:
|
||||
in x2, USBDDR ;[-12] 12 cycles until SOP
|
||||
ori x2, USBMASK ;[-11]
|
||||
sbi USBOUT, USBMINUS ;[-10] prepare idle state; D+ and D- must have been 0 (no pullups)
|
||||
out USBDDR, x2 ;[-8] <--- acquire bus
|
||||
in x1, USBOUT ;[-7] port mirror for tx loop
|
||||
ldi shift, 0x40 ;[-6] sync byte is first byte sent (we enter loop after ror)
|
||||
ldi x2, USBMASK ;[-5]
|
||||
push x4 ;[-4]
|
||||
doExorN1:
|
||||
eor x1, x2 ;[-2] [06] [62]
|
||||
ldi x4, 6 ;[-1] [07] [63]
|
||||
commonN1:
|
||||
stuffN2Delay:
|
||||
out USBOUT, x1 ;[00] [08] [64] <--- set bit
|
||||
ror shift ;[01]
|
||||
brcc doExorN2 ;[02]
|
||||
subi x4, 1 ;[03]
|
||||
brne commonN2 ;[04]
|
||||
lsl shift ;[05] compensate ror after rjmp stuffDelay
|
||||
rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear
|
||||
doExorN2:
|
||||
eor x1, x2 ;[04] [12]
|
||||
ldi x4, 6 ;[05] [13]
|
||||
commonN2:
|
||||
nop ;[06] [14]
|
||||
subi cnt, 171 ;[07] [15] trick: (3 * 171) & 0xff = 1
|
||||
out USBOUT, x1 ;[08] [16] <--- set bit
|
||||
brcs txBitloop ;[09] [25] [41]
|
||||
|
||||
stuff6Delay:
|
||||
ror shift ;[42] [50]
|
||||
brcc doExor6 ;[43]
|
||||
subi x4, 1 ;[44]
|
||||
brne common6 ;[45]
|
||||
lsl shift ;[46] compensate ror after rjmp stuffDelay
|
||||
nop ;[47] stuffing consists of just waiting 8 cycles
|
||||
rjmp stuff6Delay ;[48] after ror, C bit is reliably clear
|
||||
doExor6:
|
||||
eor x1, x2 ;[45] [53]
|
||||
ldi x4, 6 ;[46]
|
||||
common6:
|
||||
stuff7Delay:
|
||||
ror shift ;[47] [55]
|
||||
out USBOUT, x1 ;[48] <--- set bit
|
||||
brcc doExor7 ;[49]
|
||||
subi x4, 1 ;[50]
|
||||
brne common7 ;[51]
|
||||
lsl shift ;[52] compensate ror after rjmp stuffDelay
|
||||
rjmp stuff7Delay ;[53] after ror, C bit is reliably clear
|
||||
doExor7:
|
||||
eor x1, x2 ;[51] [59]
|
||||
ldi x4, 6 ;[52]
|
||||
common7:
|
||||
ld shift, y+ ;[53]
|
||||
tst cnt ;[55]
|
||||
out USBOUT, x1 ;[56] <--- set bit
|
||||
brne txByteLoop ;[57]
|
||||
|
||||
;uses: x1...x4, shift, cnt, Y
|
||||
;Numbers in brackets are time since first bit of sync pattern is sent
|
||||
usbSendAndReti: ;0 [-13] timing: 13 cycles until SOP
|
||||
in x2, USBDDR ;1 [-12]
|
||||
ori x2, USBMASK ;1 [-11]
|
||||
sbi USBOUT, USBMINUS;2 [-9] prepare idle state; D+ and D- must have been 0 (no pullups)
|
||||
in x1, USBOUT ;1 [-8] port mirror for tx loop
|
||||
out USBDDR, x2 ;1 [-7] <- acquire bus
|
||||
; need not init x2 (bitstuff history) because sync starts with 0
|
||||
push x4 ;2 [-5]
|
||||
ldi x4, USBMASK ;1 [-4] exor mask
|
||||
ldi shift, 0x80 ;1 [-3] sync byte is first byte sent
|
||||
txLoop: ; [62]
|
||||
sbrs shift, 0 ;1 [-2] [62]
|
||||
eor x1, x4 ;1 [-1] [63]
|
||||
out USBOUT, x1 ;1 [0] <-- out bit 0
|
||||
ror shift ;1 [1]
|
||||
ror x2 ;1 [2]
|
||||
didStuff0:
|
||||
cpi x2, 0xfc ;1 [3]
|
||||
brsh bitstuff0 ;1 [4]
|
||||
sbrs shift, 0 ;1 [5]
|
||||
eor x1, x4 ;1 [6]
|
||||
ror shift ;1 [7]
|
||||
didStuff1:
|
||||
out USBOUT, x1 ;1 [8] <-- out bit 1
|
||||
ror x2 ;1 [9]
|
||||
cpi x2, 0xfc ;1 [10]
|
||||
brsh bitstuff1 ;1 [11]
|
||||
sbrs shift, 0 ;1 [12]
|
||||
eor x1, x4 ;1 [13]
|
||||
ror shift ;1 [14]
|
||||
didStuff2:
|
||||
ror x2 ;1 [15]
|
||||
out USBOUT, x1 ;1 [16] <-- out bit 2
|
||||
cpi x2, 0xfc ;1 [17]
|
||||
brsh bitstuff2 ;1 [18]
|
||||
sbrs shift, 0 ;1 [19]
|
||||
eor x1, x4 ;1 [20]
|
||||
ror shift ;1 [21]
|
||||
didStuff3:
|
||||
ror x2 ;1 [22]
|
||||
cpi x2, 0xfc ;1 [23]
|
||||
out USBOUT, x1 ;1 [24] <-- out bit 3
|
||||
brsh bitstuff3 ;1 [25]
|
||||
nop2 ;2 [27]
|
||||
ld x3, y+ ;2 [29]
|
||||
sbrs shift, 0 ;1 [30]
|
||||
eor x1, x4 ;1 [31]
|
||||
out USBOUT, x1 ;1 [32] <-- out bit 4
|
||||
ror shift ;1 [33]
|
||||
ror x2 ;1 [34]
|
||||
didStuff4:
|
||||
cpi x2, 0xfc ;1 [35]
|
||||
brsh bitstuff4 ;1 [36]
|
||||
sbrs shift, 0 ;1 [37]
|
||||
eor x1, x4 ;1 [38]
|
||||
ror shift ;1 [39]
|
||||
didStuff5:
|
||||
out USBOUT, x1 ;1 [40] <-- out bit 5
|
||||
ror x2 ;1 [41]
|
||||
cpi x2, 0xfc ;1 [42]
|
||||
brsh bitstuff5 ;1 [43]
|
||||
sbrs shift, 0 ;1 [44]
|
||||
eor x1, x4 ;1 [45]
|
||||
ror shift ;1 [46]
|
||||
didStuff6:
|
||||
ror x2 ;1 [47]
|
||||
out USBOUT, x1 ;1 [48] <-- out bit 6
|
||||
cpi x2, 0xfc ;1 [49]
|
||||
brsh bitstuff6 ;1 [50]
|
||||
sbrs shift, 0 ;1 [51]
|
||||
eor x1, x4 ;1 [52]
|
||||
ror shift ;1 [53]
|
||||
didStuff7:
|
||||
ror x2 ;1 [54]
|
||||
cpi x2, 0xfc ;1 [55]
|
||||
out USBOUT, x1 ;1 [56] <-- out bit 7
|
||||
brsh bitstuff7 ;1 [57]
|
||||
mov shift, x3 ;1 [58]
|
||||
dec cnt ;1 [59]
|
||||
brne txLoop ;1/2 [60/61]
|
||||
;make SE0:
|
||||
cbr x1, USBMASK ;[58] prepare SE0 [spec says EOP may be 15 to 18 cycles]
|
||||
lds x2, usbNewDeviceAddr;[59]
|
||||
lsl x2 ;[61] we compare with left shifted address
|
||||
subi YL, 2 + 20 ;[62] Only assign address on data packets, not ACK/NAK in x3
|
||||
sbci YH, 0 ;[63]
|
||||
out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle
|
||||
cbr x1, USBMASK ;1 [61] prepare SE0 [spec says EOP may be 15 to 18 cycles]
|
||||
pop x4 ;2 [63]
|
||||
;brackets are cycles from start of SE0 now
|
||||
out USBOUT, x1 ;1 [0] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle
|
||||
;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm:
|
||||
;set address only after data packet was sent, not after handshake
|
||||
breq skipAddrAssign ;[01]
|
||||
sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer
|
||||
lds x2, usbNewDeviceAddr;2 [2]
|
||||
lsl x2; ;1 [3] we compare with left shifted address
|
||||
subi YL, 20 + 2 ;1 [4] Only assign address on data packets, not ACK/NAK in x3
|
||||
sbci YH, 0 ;1 [5]
|
||||
breq skipAddrAssign ;2 [7]
|
||||
sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer
|
||||
skipAddrAssign:
|
||||
;end of usbDeviceAddress transfer
|
||||
ldi x2, 1<<USB_INTR_PENDING_BIT;[03] int0 occurred during TX -- clear pending flag
|
||||
USB_STORE_PENDING(x2) ;[04]
|
||||
ori x1, USBIDLE ;[05]
|
||||
in x2, USBDDR ;[06]
|
||||
cbr x2, USBMASK ;[07] set both pins to input
|
||||
mov x3, x1 ;[08]
|
||||
cbr x3, USBMASK ;[09] configure no pullup on both pins
|
||||
pop x4 ;[10]
|
||||
nop2 ;[12]
|
||||
nop2 ;[14]
|
||||
out USBOUT, x1 ;[16] <-- out J (idle) -- end of SE0 (EOP signal)
|
||||
out USBDDR, x2 ;[17] <-- release bus now
|
||||
out USBOUT, x3 ;[18] <-- ensure no pull-up resistors are active
|
||||
ldi x2, 1<<USB_INTR_PENDING_BIT;1 [8] int0 occurred during TX -- clear pending flag
|
||||
USB_STORE_PENDING(x2) ;1 [9]
|
||||
ori x1, USBIDLE ;1 [10]
|
||||
in x2, USBDDR ;1 [11]
|
||||
cbr x2, USBMASK ;1 [12] set both pins to input
|
||||
mov x3, x1 ;1 [13]
|
||||
cbr x3, USBMASK ;1 [14] configure no pullup on both pins
|
||||
out USBOUT, x1 ;1 [15] <-- out J (idle) -- end of SE0 (EOP signal)
|
||||
out USBDDR, x2 ;1 [16] <-- release bus now
|
||||
out USBOUT, x3 ;1 [17] <-- ensure no pull-up resistors are active
|
||||
rjmp doReturn
|
||||
|
||||
bitstuff5: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff5 ;2 same trick as in bitstuff1...
|
||||
bitstuff6: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff6 ;2 same trick as above...
|
||||
bitstuff7: ;1 (for branch taken)
|
||||
eor x1, x4 ;1
|
||||
rjmp didStuff7 ;2 same trick as above...
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbdrvasm15.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: contributed by V. Bosch
|
||||
* Creation Date: 2007-08-06
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id: usbdrvasm15.inc 607 2008-05-13 15:57:28Z cs $
|
||||
*/
|
||||
|
||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||
@ -43,13 +43,11 @@ USB_INTR_VECTOR:
|
||||
;
|
||||
; sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
|
||||
; sync up with J to K edge during sync pattern -- use fastest possible loops
|
||||
;The first part waits at most 1 bit long since we must be in sync pattern.
|
||||
;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to
|
||||
;waitForJ, ensure that this prerequisite is met.
|
||||
waitForJ:
|
||||
inc YL
|
||||
sbis USBIN, USBMINUS
|
||||
brne waitForJ ; just make sure we have ANY timeout
|
||||
; first part has no timeout because it waits for IDLE or SE1 (== disconnected)
|
||||
;-------------------------------------------------------------------------------
|
||||
waitForJ: ;-
|
||||
sbis USBIN, USBMINUS ;1 <-- sample: wait for D- == 1
|
||||
rjmp waitForJ ;2
|
||||
;-------------------------------------------------------------------------------
|
||||
; The following code results in a sampling window of < 1/4 bit
|
||||
; which meets the spec.
|
||||
@ -72,9 +70,6 @@ waitForK: ;-
|
||||
inc YL
|
||||
sts usbSofCount, YL
|
||||
#endif /* USB_COUNT_SOF */
|
||||
#ifdef USB_SOF_HOOK
|
||||
USB_SOF_HOOK
|
||||
#endif
|
||||
rjmp sofError
|
||||
;------------------------------------------------------------------------------
|
||||
; {3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for
|
||||
@ -294,12 +289,12 @@ macro POP_STANDARD ; 16 cycles
|
||||
pop x1
|
||||
pop shift
|
||||
pop YH
|
||||
endm
|
||||
endm
|
||||
macro POP_RETI ; 5 cycles
|
||||
pop YL
|
||||
out SREG, YL
|
||||
pop YL
|
||||
endm
|
||||
endm
|
||||
|
||||
#include "asmcommon.inc"
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbdrvasm16.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-06-15
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id: usbdrvasm16.inc 607 2008-05-13 15:57:28Z cs $
|
||||
*/
|
||||
|
||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||
@ -41,13 +41,10 @@ USB_INTR_VECTOR:
|
||||
;----------------------------------------------------------------------------
|
||||
;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
|
||||
;sync up with J to K edge during sync pattern -- use fastest possible loops
|
||||
;The first part waits at most 1 bit long since we must be in sync pattern.
|
||||
;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to
|
||||
;waitForJ, ensure that this prerequisite is met.
|
||||
;first part has no timeout because it waits for IDLE or SE1 (== disconnected)
|
||||
waitForJ:
|
||||
inc YL
|
||||
sbis USBIN, USBMINUS
|
||||
brne waitForJ ; just make sure we have ANY timeout
|
||||
sbis USBIN, USBMINUS ;[-18] wait for D- == 1
|
||||
rjmp waitForJ
|
||||
waitForK:
|
||||
;The following code results in a sampling window of < 1/4 bit which meets the spec.
|
||||
sbis USBIN, USBMINUS ;[-15]
|
||||
@ -67,9 +64,6 @@ waitForK:
|
||||
inc YL
|
||||
sts usbSofCount, YL
|
||||
#endif /* USB_COUNT_SOF */
|
||||
#ifdef USB_SOF_HOOK
|
||||
USB_SOF_HOOK
|
||||
#endif
|
||||
rjmp sofError
|
||||
foundK: ;[-12]
|
||||
;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling]
|
||||
@ -214,13 +208,13 @@ macro POP_STANDARD ; 14 cycles
|
||||
pop x1
|
||||
pop shift
|
||||
pop bitcnt
|
||||
endm
|
||||
endm
|
||||
macro POP_RETI ; 7 cycles
|
||||
pop YH
|
||||
pop YL
|
||||
out SREG, YL
|
||||
pop YL
|
||||
endm
|
||||
endm
|
||||
|
||||
#include "asmcommon.inc"
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Name: usbdrvasm165.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-04-22
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* 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 $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id: usbdrvasm165.inc 607 2008-05-13 15:57:28Z cs $
|
||||
*/
|
||||
|
||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||
@ -46,13 +46,10 @@ USB_INTR_VECTOR:
|
||||
;----------------------------------------------------------------------------
|
||||
;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
|
||||
;sync up with J to K edge during sync pattern -- use fastest possible loops
|
||||
;The first part waits at most 1 bit long since we must be in sync pattern.
|
||||
;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to
|
||||
;waitForJ, ensure that this prerequisite is met.
|
||||
;first part has no timeout because it waits for IDLE or SE1 (== disconnected)
|
||||
waitForJ:
|
||||
inc YL
|
||||
sbis USBIN, USBMINUS
|
||||
brne waitForJ ; just make sure we have ANY timeout
|
||||
sbis USBIN, USBMINUS ;[-18] wait for D- == 1
|
||||
rjmp waitForJ
|
||||
waitForK:
|
||||
;The following code results in a sampling window of < 1/4 bit which meets the spec.
|
||||
sbis USBIN, USBMINUS ;[-15]
|
||||
@ -72,9 +69,6 @@ waitForK:
|
||||
inc YL
|
||||
sts usbSofCount, YL
|
||||
#endif /* USB_COUNT_SOF */
|
||||
#ifdef USB_SOF_HOOK
|
||||
USB_SOF_HOOK
|
||||
#endif
|
||||
rjmp sofError
|
||||
foundK: ;[-12]
|
||||
;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling]
|
||||
@ -340,12 +334,12 @@ macro POP_STANDARD ; 16 cycles
|
||||
pop shift
|
||||
pop YH
|
||||
pop r0
|
||||
endm
|
||||
endm
|
||||
macro POP_RETI ; 5 cycles
|
||||
pop YL
|
||||
out SREG, YL
|
||||
pop YL
|
||||
endm
|
||||
endm
|
||||
|
||||
#include "asmcommon.inc"
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/* Name: usbdrvasm20.inc
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Project: AVR USB driver
|
||||
* Author: Jeroen Benschop
|
||||
* Based on usbdrvasm16.inc from Christian Starkjohann
|
||||
* Creation Date: 2008-03-05
|
||||
* Tabsize: 4
|
||||
* 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)
|
||||
* Revision: $Id: usbdrvasm20.inc 740 2009-04-13 18:23:31Z cs $
|
||||
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
|
||||
* Revision: $Id: usbdrvasm20.inc 607 2008-05-13 15:57:28Z cs $
|
||||
*/
|
||||
|
||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||
@ -57,13 +57,10 @@ USB_INTR_VECTOR:
|
||||
;----------------------------------------------------------------------------
|
||||
;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
|
||||
;sync up with J to K edge during sync pattern -- use fastest possible loops
|
||||
;The first part waits at most 1 bit long since we must be in sync pattern.
|
||||
;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to
|
||||
;waitForJ, ensure that this prerequisite is met.
|
||||
;first part has no timeout because it waits for IDLE or SE1 (== disconnected)
|
||||
waitForJ:
|
||||
inc YL
|
||||
sbis USBIN, USBMINUS
|
||||
brne waitForJ ; just make sure we have ANY timeout
|
||||
sbis USBIN, USBMINUS ;[-21] wait for D- == 1
|
||||
rjmp waitForJ
|
||||
waitForK:
|
||||
;The following code results in a sampling window of < 1/4 bit which meets the spec.
|
||||
sbis USBIN, USBMINUS ;[-19]
|
||||
@ -89,9 +86,6 @@ waitForK:
|
||||
inc YL
|
||||
sts usbSofCount, YL
|
||||
#endif /* USB_COUNT_SOF */
|
||||
#ifdef USB_SOF_HOOK
|
||||
USB_SOF_HOOK
|
||||
#endif
|
||||
rjmp sofError
|
||||
foundK: ;[-16]
|
||||
;{3, 5} after falling D- edge, average delay: 4 cycles
|
||||
@ -238,13 +232,13 @@ macro POP_STANDARD ; 14 cycles
|
||||
pop x1
|
||||
pop shift
|
||||
pop bitcnt
|
||||
endm
|
||||
endm
|
||||
macro POP_RETI ; 7 cycles
|
||||
pop YH
|
||||
pop YL
|
||||
out SREG, YL
|
||||
pop YL
|
||||
endm
|
||||
endm
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user