From aacf677a758f61f273ab8dff5c8a6a92eee4404a Mon Sep 17 00:00:00 2001 From: Christian Starkjohann Date: Mon, 20 Oct 2008 13:18:39 +0000 Subject: - use timeout in waitForJ --- usbdrv/Changelog.txt | 1 + usbdrv/usbdrvasm12.inc | 10 +++++++--- usbdrv/usbdrvasm128.inc | 10 +++++++--- usbdrv/usbdrvasm15.inc | 13 ++++++++----- usbdrv/usbdrvasm16.inc | 10 +++++++--- usbdrv/usbdrvasm165.inc | 10 +++++++--- usbdrv/usbdrvasm20.inc | 10 +++++++--- 7 files changed, 44 insertions(+), 20 deletions(-) diff --git a/usbdrv/Changelog.txt b/usbdrv/Changelog.txt index 339bca6..9d6844d 100644 --- a/usbdrv/Changelog.txt +++ b/usbdrv/Changelog.txt @@ -248,3 +248,4 @@ Scroll down to the bottom to see the most recent changes. This accounts for the higher clock rates we now support. - Added a module for 12.8 MHz RC oscillator with PLL in receiver loop. - Added hook to SOF code so that oscillator can be tuned to USB frame clock. + - Added timeout to waitForJ loop. Helps preventing unexpected hangs. diff --git a/usbdrv/usbdrvasm12.inc b/usbdrv/usbdrvasm12.inc index d9da1dc..f891ab6 100644 --- a/usbdrv/usbdrvasm12.inc +++ b/usbdrv/usbdrvasm12.inc @@ -48,10 +48,14 @@ USB_INTR_VECTOR: ;---------------------------------------------------------------------------- ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ;sync up with J to K edge during sync pattern -- use fastest possible loops -;first part has no timeout because it waits for IDLE or SE1 (== disconnected) +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. waitForJ: - sbis USBIN, USBMINUS ;1 [40] wait for D- == 1 - rjmp waitForJ ;2 + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; 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 diff --git a/usbdrv/usbdrvasm128.inc b/usbdrv/usbdrvasm128.inc index 8b19d69..2dd6fe1 100644 --- a/usbdrv/usbdrvasm128.inc +++ b/usbdrv/usbdrvasm128.inc @@ -107,10 +107,14 @@ USB_INTR_VECTOR: ;---------------------------------------------------------------------------- ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ;sync up with J to K edge during sync pattern -- use fastest possible loops -;first part has no timeout because it waits for IDLE or SE1 (== disconnected) +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. waitForJ: - sbis USBIN, USBMINUS ;1 [40] wait for D- == 1 - rjmp waitForJ ;2 + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; 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 diff --git a/usbdrv/usbdrvasm15.inc b/usbdrv/usbdrvasm15.inc index 689d2a3..a315eae 100644 --- a/usbdrv/usbdrvasm15.inc +++ b/usbdrv/usbdrvasm15.inc @@ -43,11 +43,14 @@ USB_INTR_VECTOR: ; ; sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ; sync up with J to K edge during sync pattern -- use fastest possible loops -; first part has no timeout because it waits for IDLE or SE1 (== disconnected) -;------------------------------------------------------------------------------- -waitForJ: ;- - sbis USBIN, USBMINUS ;1 <-- sample: wait for D- == 1 - rjmp waitForJ ;2 +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; just make sure we have ANY timeout ;------------------------------------------------------------------------------- ; The following code results in a sampling window of < 1/4 bit ; which meets the spec. diff --git a/usbdrv/usbdrvasm16.inc b/usbdrv/usbdrvasm16.inc index 44b00fa..b59f74d 100644 --- a/usbdrv/usbdrvasm16.inc +++ b/usbdrv/usbdrvasm16.inc @@ -41,10 +41,14 @@ USB_INTR_VECTOR: ;---------------------------------------------------------------------------- ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ;sync up with J to K edge during sync pattern -- use fastest possible loops -;first part has no timeout because it waits for IDLE or SE1 (== disconnected) +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. waitForJ: - sbis USBIN, USBMINUS ;[-18] wait for D- == 1 - rjmp waitForJ + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; 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] diff --git a/usbdrv/usbdrvasm165.inc b/usbdrv/usbdrvasm165.inc index b37ac96..acad899 100644 --- a/usbdrv/usbdrvasm165.inc +++ b/usbdrv/usbdrvasm165.inc @@ -46,10 +46,14 @@ USB_INTR_VECTOR: ;---------------------------------------------------------------------------- ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ;sync up with J to K edge during sync pattern -- use fastest possible loops -;first part has no timeout because it waits for IDLE or SE1 (== disconnected) +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. waitForJ: - sbis USBIN, USBMINUS ;[-18] wait for D- == 1 - rjmp waitForJ + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; 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] diff --git a/usbdrv/usbdrvasm20.inc b/usbdrv/usbdrvasm20.inc index 2d4be52..ebe14e2 100644 --- a/usbdrv/usbdrvasm20.inc +++ b/usbdrv/usbdrvasm20.inc @@ -57,10 +57,14 @@ USB_INTR_VECTOR: ;---------------------------------------------------------------------------- ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] ;sync up with J to K edge during sync pattern -- use fastest possible loops -;first part has no timeout because it waits for IDLE or SE1 (== disconnected) +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. waitForJ: - sbis USBIN, USBMINUS ;[-21] wait for D- == 1 - rjmp waitForJ + sbic USBIN, USBMINUS + rjmp waitForK + inc YL + brne waitForJ ; 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 ;[-19] -- cgit v1.2.3