summaryrefslogtreecommitdiffstats
path: root/firmware/usbdrv
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2013-11-04 13:57:24 +0100
committercpldcpu <cpldcpu@gmail.com>2013-11-04 13:57:24 +0100
commit0a4f48c2cbcf20f93fc9531b3f57974cb4b6364d (patch)
tree2a831c2c1ec1f8ac21427bf87c2955eae391d171 /firmware/usbdrv
parentd7360925c1170acbc3a7b98c50e48350ac80fbc7 (diff)
downloadmicronucleus-0a4f48c2cbcf20f93fc9531b3f57974cb4b6364d.tar.gz
micronucleus-0a4f48c2cbcf20f93fc9531b3f57974cb4b6364d.tar.bz2
micronucleus-0a4f48c2cbcf20f93fc9531b3f57974cb4b6364d.zip
source code clean up
Diffstat (limited to 'firmware/usbdrv')
-rw-r--r--firmware/usbdrv/usbdrvasm.S195
1 files changed, 1 insertions, 194 deletions
diff --git a/firmware/usbdrv/usbdrvasm.S b/firmware/usbdrv/usbdrvasm.S
index 29c634a..32ce8ef 100644
--- a/firmware/usbdrv/usbdrvasm.S
+++ b/firmware/usbdrv/usbdrvasm.S
@@ -282,7 +282,7 @@ usbCrc16Append:
#undef scratch
-#if USB_CFG_HAVE_MEASURE_FRAME_LENGTHx
+#if USB_CFG_HAVE_MEASURE_FRAME_LENGTH
#ifdef __IAR_SYSTEMS_ASM__
/* Register assignments for usbMeasureFrameLength on IAR cc */
/* Calling conventions on IAR:
@@ -355,199 +355,6 @@ usbMFTimeout:
#endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */
-
-#if USB_CFG_HAVE_MEASURE_FRAME_LENGTHx
-#ifdef __IAR_SYSTEMS_ASM__
-/* Register assignments for usbMeasureFrameLengthDecreasing on IAR cc */
-/* Calling conventions on IAR:
- * First parameter passed in r16/r17, second in r18/r19 and so on.
- * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer)
- * Result is passed in r16/r17
- * In case of the "tiny" memory model, pointers are only 8 bit with no
- * padding. We therefore pass argument 1 as "16 bit unsigned".
- */
-# define resL r16
-# define resH r17
-# define cnt16L r30
-# define cnt16H r31
-# define cntH r18
-
-#else /* __IAR_SYSTEMS_ASM__ */
-/* Register assignments for usbMeasureFrameLength on gcc */
-/* Calling conventions on gcc:
- * First parameter passed in r24/r25, second in r22/23 and so on.
- * Callee must preserve r1-r17, r28/r29
- * Result is passed in r24/r25
- */
-# define resL r24
-# define resH r25
-# define cnt16L r24
-# define cnt16H r25
-# define cntH r26
-#endif
-# define cnt16 cnt16L
-
-; extern int usbMeasurePacketLengthDecreasing(int);
-; input: timer start value
-; return: counts down time between two idle strobes in multiples of 5 CPU clocks
-.global usbMeasureFrameLengthDecreasing
-usbMeasureFrameLengthDecreasing:
-
-#if resL != cnt16L
- mov cnt16L, resL
- mov cnt16H, resH
-#endif
-
-usbDFWaitStrobe: ; first wait for D- == 0 (idle strobe)
- sbic USBIN, USBMINUS ;
- rjmp usbDFWaitStrobe ;
-usbDFWaitIdle: ; then wait until idle again
- sbis USBIN, USBMINUS ;1 wait for D- == 1
- rjmp usbDFWaitIdle ;2
-usbDFWaitLoop:
- sbiw cnt16,1 ;[0] [5]
- sbic USBIN, USBMINUS ;[2]
- rjmp usbDFWaitLoop ;[3]
-
-#if resL != cnt16L
- mov resL, cnt16L
- mov resH, cnt16H
-#endif
- ret
-
-#undef resL
-#undef resH
-#undef cnt16
-#undef cnt16L
-#undef cnt16H
-#undef cntH
-
-#endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */
-
-
-
-#if USB_CFG_HAVE_MEASURE_FRAME_LENGTH
-#ifdef __IAR_SYSTEMS_ASM__
-/* Register assignments for usbMeasureFrameLengthDecreasing on IAR cc */
-/* Calling conventions on IAR:
- * First parameter passed in r16/r17, second in r18/r19 and so on.
- * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer)
- * Result is passed in r16/r17
- * In case of the "tiny" memory model, pointers are only 8 bit with no
- * padding. We therefore pass argument 1 as "16 bit unsigned".
- */
-
-# define resL r16
-# define resH r17
-# define cnt16L r30
-# define cnt16H r31
-# define cntH r18
-
-#else /* __IAR_SYSTEMS_ASM__ */
-/* Register assignments for usbMeasureFrameLength on gcc */
-/* Calling conventions on gcc:
- * First parameter passed in r24/r25, second in r22/23 and so on.
- * Callee must preserve r1-r17, r28/r29
- * Result is passed in r24/r25
- */
-
-# define i r20
-# define opV r19
-# define opD r18
-# define try r27
-# define stp r26
-# define cnt16L r24
-# define cnt16H r25
-#endif
-# define cnt16 cnt16L
-
-; extern void calibrateOscillatorASM(void);
-
-.global calibrateOscillatorASM
-calibrateOscillatorASM:
-
- cli
- ldi i, 10 ; 10 iterations
-
- ldi opD, 255
-
- ldi try, 128 ; calibration start value
- ldi stp, 64 ; initial step width
-
-usbCOloop:
-
- out OSCCAL, try
- nop
-
- ; Delay values = F_CPU * 999e-6 / 5 + 0.5
-
-#if (F_CPU == 16500000)
- ldi cnt16L, lo8(3297)
- ldi cnt16H, hi8(3297)
-#define usbok
-#endif
-
-#if (F_CPU == 12800000)
- ldi cnt16L, lo8(2557)
- ldi cnt16H, hi8(2557)
-#define usbok
-#endif
-
-#ifndef usbok
- #error "calibrateOscillatorASM: no delayvalues defined for this F_CPU setting"
-#endif
-#undef usbok
-
-usbCOWaitStrobe: ; first wait for D- == 0 (idle strobe)
- sbic USBIN, USBMINUS ;
- rjmp usbCOWaitStrobe ;
-usbCOWaitIdle: ; then wait until idle again
- sbis USBIN, USBMINUS ;1 wait for D- == 1
- rjmp usbCOWaitIdle ;2
-usbCOWaitLoop:
- sbiw cnt16,1 ;[0] [5]
- sbic USBIN, USBMINUS ;[2]
- rjmp usbCOWaitLoop ;[3]
-
- sbrs cnt16H, 7 ;delay overflow?
- rjmp usbCOclocktoolow
- sub try, stp
- neg cnt16L
- rjmp usbCOclocktoohigh
-usbCOclocktoolow:
- add try, stp
-usbCOclocktoohigh:
- lsr stp
- brne usbCOstepnotzero
- cp opD, cnt16L
- brcs usbCOnoimprovement
- in opV, OSCCAL
- mov opD, cnt16L
-usbCOnoimprovement:
- ldi stp, 1
-usbCOstepnotzero:
- subi i, 1
- brne usbCOloop
-
- out OSCCAL, opV
- nop
- sei
- ret
-
-#undef i
-#undef opV
-#undef opD
-#undef try
-#undef stp
-#undef cnt16
-#undef cnt16L
-#undef cnt16H
-
-
-#endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */
-
-
-
;----------------------------------------------------------------------------
; Now include the clock rate specific code
;----------------------------------------------------------------------------