/* Name: usbdrvasm12.inc * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers * 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) * TinyAvr1 TinyAvr0 code port by: 12oClocker */ /* Do not link this file! Link usbdrvasm.S instead, which includes the * appropriate implementation! */ /* General Description: This file is the 12 MHz version of the asssembler part of the USB driver. It requires a 12 MHz crystal (not a ceramic resonator and not a calibrated RC oscillator). See usbdrv.h for a description of the entire driver. Since almost all of this code is timing critical, don't change unless you really know what you are doing! Many parts require not only a maximum number of CPU cycles, but even an exact number of cycles! Timing constraints according to spec (in bit times): timing subject min max CPUcycles --------------------------------------------------------------------------- EOP of OUT/SETUP to sync pattern of DATA0 (both rx) 2 16 16-128 EOP of IN to sync pattern of DATA0 (rx, then tx) 2 7.5 16-60 DATAx (rx) to ACK/NAK/STALL (tx) 2 7.5 16-60 ,----Likely to cause the most issues with TinyAvr0 TinyAvr1 series... | --AVR---|--TinyAvr-- CPU cycle differences for opcodes X push 2 push 1 X cbi 2 cbi 1 X sbi 2 sbi 1 X st 2 st 1,2 1 cycles for SRAM, 2 cycles for FLASH or EEPROM X std 2 std 1,2 1 cycles for SRAM, 2 cycles for FLASH or EEPROM sts 2 sts 2,3 only different if NOT reading from SRAM X lds 2 lds 3,4 3 cycles for SRAM, 4 cycles for FLASH or EEPROM ld 2 ld 2,3 only different if NOT reading from SRAM ldd 2 ldd 2,3 only different if NOT reading from SRAM ret 4 ret 4,5 only different if NOT reading from SRAM reti 4 reti 4,5 only different if NOT reading from SRAM icall 3 icall 2,3 rcall 3 rcall 2,3 */ ;Software-receiver engine. Strict timing! Don't change unless you can preserve timing! ;interrupt response time: 4 cycles + insn running = 7 max if interrupts always enabled ;max allowable interrupt latency: 34 cycles -> max 25 cycles interrupt disable ;max stack usage: [ret(2), YL, SREG, YH, shift, x1, x2, x3, cnt, x4] = 11 bytes ;Numbers in brackets are maximum cycles since SOF. USB_INTR_VECTOR: ;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt #if USB_CFG_TINYAVR_SERIES == 1 push YL ;1 [35] push only what is necessary to sync with edge ASAP ldi YL, (1<