diff options
author | Shay Green <gblargg@gmail.com> | 2014-07-14 17:04:12 -0500 |
---|---|---|
committer | Shay Green <gblargg@gmail.com> | 2014-07-14 17:04:12 -0500 |
commit | 044d47585ce3459ecbf7ce2bb87ea35992d0cdae (patch) | |
tree | 10adec2635436a012296807b6607408f818481eb /firmware | |
parent | 902b613ad809ac76e07301f4a4193e8de2e6250c (diff) | |
download | micronucleus-044d47585ce3459ecbf7ce2bb87ea35992d0cdae.tar.gz micronucleus-044d47585ce3459ecbf7ce2bb87ea35992d0cdae.tar.bz2 micronucleus-044d47585ce3459ecbf7ce2bb87ea35992d0cdae.zip |
firmware: osccalASM.S fixed to tolerate USB traffic, e.g. when on hub
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/osccalASM.S | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/firmware/osccalASM.S b/firmware/osccalASM.S index e8e174e..6484350 100644 --- a/firmware/osccalASM.S +++ b/firmware/osccalASM.S @@ -113,6 +113,8 @@ usbCOloop: #endif nop +usbCOLoopNoCal: + ; Delay values = F_CPU * 999e-6 / 5 + 0.5 #if (F_CPU == 16500000) @@ -145,6 +147,22 @@ usbCOWaitLoop: sbic USBIN, USBMINUS ;[2] rjmp usbCOWaitLoop ;[3] + sbis USBIN, USBPLUS ; ignore frame if data is present + rjmp usbCOnotdata + +usbCOWaitNoData: + in cnt16H, USBIN ; wait for SE0 state (both lines low) + andi cnt16H, (1<<USBPLUS)|(1<<USBMINUS) + brne usbCOWaitNoData + in cnt16H, USBIN ; be sure SE0 state wasn't a glitch + andi cnt16H, (1<<USBPLUS)|(1<<USBMINUS) + brne usbCOWaitNoData +usbCOWaitNoData2: + sbis USBIN, USBMINUS ; wait for D- go to high + rjmp usbCOWaitNoData2 + rjmp usbCOLoopNoCal + +usbCOnotdata: sbrs cnt16H, 7 ;delay overflow? rjmp usbCOclocktoolow sub try, stp |