From 0a4f48c2cbcf20f93fc9531b3f57974cb4b6364d Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Mon, 4 Nov 2013 13:57:24 +0100 Subject: source code clean up --- firmware/usbdrv/usbdrvasm.S | 195 +------------------------------------------- 1 file changed, 1 insertion(+), 194 deletions(-) (limited to 'firmware/usbdrv') 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 ;---------------------------------------------------------------------------- -- cgit v1.2.3