/* Name: usbdrvasm165.inc * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers * 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) * 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 16.5 MHz version of the USB driver. It is intended for the ATTiny45 and similar controllers running on 16.5 MHz internal RC oscillator. This version contains a phase locked loop in the receiver routine to cope with slight clock rate deviations of up to +/- 1%. 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! ,----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: 59 cycles -> max 52 cycles interrupt disable ;max stack usage: [ret(2), r0, SREG, YL, YH, shift, x1, x2, x3, x4, cnt] = 12 bytes ;nominal frequency: 16.5 MHz -> 11 cycles per bit ; 16.3125 MHz < F_CPU < 16.6875 MHz (+/- 1.1%) ; Numbers in brackets are clocks counted from center of last sync bit ; when instruction starts USB_INTR_VECTOR: ;order of registers pushed: YL, SREG [sofError], r0, YH, shift, x1, x2, x3, x4, cnt #if USB_CFG_TINYAVR_SERIES == 1 push YL ;[-23] push only what is necessary to sync with edge ASAP ldi YL, (1<