summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2013-11-18 11:26:03 +0100
committercpldcpu <cpldcpu@gmail.com>2013-11-18 11:26:03 +0100
commita9c9f4d6329df9b958e5b78d25edfa1c6ea292f4 (patch)
tree1e63528e74c7e6bf1b9c89ed3275212b30d28246
parent086906f916b0e6faf5a41656fba70fa29986b906 (diff)
downloadmicronucleus-a9c9f4d6329df9b958e5b78d25edfa1c6ea292f4.tar.gz
micronucleus-a9c9f4d6329df9b958e5b78d25edfa1c6ea292f4.tar.bz2
micronucleus-a9c9f4d6329df9b958e5b78d25edfa1c6ea292f4.zip
Fix: re-introduce testing for magic byte
-rw-r--r--firmware/usbdrv/usbdrvasm165.inc43
1 files changed, 37 insertions, 6 deletions
diff --git a/firmware/usbdrv/usbdrvasm165.inc b/firmware/usbdrv/usbdrvasm165.inc
index ae91588..450d2fd 100644
--- a/firmware/usbdrv/usbdrvasm165.inc
+++ b/firmware/usbdrv/usbdrvasm165.inc
@@ -4,7 +4,9 @@
* Creation Date: 2007-04-22
* Tabsize: 4
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
+ * Portions Copyright: (c) 2012 Louis Beaudoin
* 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
@@ -34,12 +36,41 @@ of CPU cycles, but even an exact number of cycles!
; Numbers in brackets are clocks counted from center of last sync bit
; when instruction starts
+; the code enabled by TINY85MODE is inteded only for use with the tiny85-compatible USBaspLoader
+; project.
+; with TINY85MODE set, the beginning of the ISR checks for a magic word "B007" at the very bottom of the stack
+; and jumps to the application's ISR if the magic word isn't present
+; the max allowable interrupt latency is lower given this additional code before getting to the
+; USB-specific portion of the ISR.
USB_INTR_VECTOR:
;order of registers pushed: YL, SREG [sofError], r0, YH, shift, x1, x2, x3, x4, cnt
- push YL ;[-23] push only what is necessary to sync with edge ASAP
- in YL, SREG ;[-21]
- push YL ;[-20]
+ push YL ; push only what is necessary to sync with edge ASAP
+ in YL, SREG ;
+ push YL ;
+
+#ifdef TINY85MODE
+; look for magic word "B007" at the bottom of the stack
+ lds YL, RAMEND
+ cpi YL, 0xB0
+ brne cleanupAndJumpToApp
+
+ lds YL, RAMEND-1
+ cpi YL, 0x07
+ breq cleanupBootloaderIntStack
+
+cleanupAndJumpToApp:
+; magic word was not found, put registers back to where they were before this ISR ran, and jump to application ISR
+ pop YL
+ out SREG, YL
+ pop YL
+
+ rjmp __vectors - TINYVECTOR_USBPLUS_OFFSET
+
+cleanupBootloaderIntStack:
+; magic word was found, put registers
+ CLR YL ; [-19] ensure we meet below requirements for YL < 0x80
+#endif
;----------------------------------------------------------------------------
; Synchronize with sync pattern:
;----------------------------------------------------------------------------
@@ -49,9 +80,9 @@ USB_INTR_VECTOR:
;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
+ inc YL ; [-18]
+ sbis USBIN, USBMINUS ; [-17]
+ brne waitForJ ; [-16] just make sure we have ANY timeout
waitForK:
;The following code results in a sampling window of < 1/4 bit which meets the spec.
sbis USBIN, USBMINUS ;[-15]