Skip to content

Commit

Permalink
Instrument interrupt routines to output more debug information on PO…
Browse files Browse the repository at this point in the history
…RTC.

    - Bit 0 is toggled when V-USB detects a SOF keep-alive pulse.
    - Bit 1 is set while V-USB is in its interrupt routine (i.e. processing and/or transmitting USB traffic).
    - Bit 2 is toggled on/off once at the end of every interrupt routine.
  • Loading branch information
th-in-gs committed May 1, 2023
1 parent 94578ef commit 3ff0194
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ void setup()
DDRB |= 0b00111110;
PORTB &= 0b11000001;

DDRC |= 0b00000001;
PORTB &= 0b11111110;
DDRC |= 0b00000111;
PORTC &= 0b11111000;


Serial.begin(250000);
Expand Down
3 changes: 3 additions & 0 deletions v-usb/usbdrv/asmcommon.inc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ doReturn:
rjmp waitForJ ;[51] save the pops and pushes -- a new interrupt is already pending
sofError:
POP_RETI ;macro call
cbi PORTC, 1
sbi PORTC, 2
cbi PORTC, 2
reti

handleData:
Expand Down
7 changes: 5 additions & 2 deletions v-usb/usbdrv/usbdrvasm16.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ 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:
cbi PORTC, 1
sbi PORTC, 1
waitForJForReal:
inc YL
sbis USBIN, USBMINUS
brne waitForJ ; just make sure we have ANY timeout
brne waitForJForReal ; 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]
Expand Down Expand Up @@ -239,7 +242,7 @@ bitstuffN:
nop ;[9]
out USBOUT, x1 ;[10] <-- out
rjmp didStuffN ;[0]

bitstuff6:
eor x1, x4 ;[5]
ldi x2, 0 ;[6] Carry is zero due to brcc
Expand Down

0 comments on commit 3ff0194

Please sign in to comment.