123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- USB_INTR_VECTOR:
- push YL
- in YL, SREG
- push YL
- waitForJ:
- inc YL
- sbis USBIN, USBMINUS
- brne waitForJ
- waitForK:
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- lds YL, usbSofCount
- inc YL
- sts usbSofCount, YL
- USB_SOF_HOOK
- rjmp sofError
- foundK:
- push YH
- lds YL, usbInputBufOffset
- clr YH
- subi YL, lo8(-(usbRxBuf))
- sbci YH, hi8(-(usbRxBuf))
- sbis USBIN, USBMINUS
- rjmp haveTwoBitsK
- pop YH
- rjmp waitForK
- haveTwoBitsK:
- push shift
- push x1
- push x2
- ldi shift, 0x80
- ifioset USBIN, USBMINUS
- ori shift, 1<<0
- push x3
- push cnt
- push r0
- ifioset USBIN, USBMINUS
- ori shift, 1<<1
- ser fix
- ldi cnt, USB_BUFSIZE
- mov data, shift
- lsl shift
- nop2
- ifioset USBIN, USBMINUS
- ori data, 3<<2
- eor shift, data
- andi data, 1<<3
- in phase, USBIN
- brne jumpToEntryAfterSet
- nop
- rjmp entryAfterClr
- jumpToEntryAfterSet:
- rjmp entryAfterSet
- bit7IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 7
- nop
- bit0AfterSet:
- eor fix, shift
- ifioclr USBIN, USBMINUS
- rjmp bit0IsClr
- andi shift, ~(7 << 0)
- breq unstuff0s
- in phase, USBIN
- rjmp bit1AfterSet
- unstuff0s:
- in phase, USBIN
- andi fix, ~(1 << 0)
- ifioclr USBIN, USBMINUS
- ifioset USBIN, USBPLUS
- rjmp bit0IsClr
- se0AndStore:
- st y+, x1
- rjmp se0
- bit0IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 0
- bit1AfterClr:
- andi phase, USBMASK
- ifioset USBIN, USBMINUS
- rjmp bit1IsSet
- breq se0AndStore
- andi shift, ~(7 << 1)
- in phase, USBIN
- breq unstuff1c
- rjmp bit2AfterClr
- unstuff1c:
- andi fix, ~(1 << 1)
- nop2
- nop2
- bit1IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 1
- nop
- bit2AfterSet:
- ifioclr USBIN, USBMINUS
- rjmp bit2IsClr
- andi shift, ~(7 << 2)
- breq unstuff2s
- in phase, USBIN
- rjmp bit3AfterSet
- unstuff2s:
- in phase, USBIN
- andi fix, ~(1 << 2)
- nop2
- nop2
- bit2IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 2
- bit3AfterClr:
- st y+, data
- entryAfterClr:
- ifioset USBIN, USBMINUS
- rjmp bit3IsSet
- andi shift, ~(7 << 3)
- breq unstuff3c
- in phase, USBIN
- rjmp bit4AfterClr
- unstuff3c:
- in phase, USBIN
- andi fix, ~(1 << 3)
- nop2
- nop2
- bit3IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 3
- bit4AfterSet:
- mov data, fix
- ifioclr USBIN, USBMINUS
- rjmp bit4IsClr
- andi shift, ~(7 << 4)
- breq unstuff4s
- in phase, USBIN
- rjmp bit5AfterSet
- unstuff4s:
- in phase, USBIN
- andi fix, ~(1 << 4)
- nop2
- nop2
- bit4IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 4
- bit5AfterClr:
- ser data
- ifioset USBIN, USBMINUS
- rjmp bit5IsSet
- andi shift, ~(7 << 5)
- breq unstuff5c
- in phase, USBIN
- rjmp bit6AfterClr
- unstuff5c:
- in phase, USBIN
- andi fix, ~(1 << 5)
- nop2
- nop2
- bit5IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 5
- bit6AfterSet:
- subi cnt, 1
- brcs jumpToOverflow
- ifioclr USBIN, USBMINUS
- rjmp bit6IsClr
- andi shift, ~(3 << 6)
- cpi shift, 2
- in phase, USBIN
- brlt unstuff6s
- rjmp bit7AfterSet
- jumpToOverflow:
- rjmp overflow
- unstuff6s:
- andi fix, ~(1 << 6)
- lpm
- bit6IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 6
- nop
- bit7AfterClr:
- ifioset USBIN, USBMINUS
- rjmp bit7IsSet
- andi shift, ~(1 << 7)
- cpi shift, 4
- in phase, USBIN
- brlt unstuff7c
- rjmp bit0AfterClr
- unstuff7c:
- andi fix, ~(1 << 7)
- nop
- rjmp bit7IsSet
- bit7IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 7
- nop
- bit0AfterClr:
- eor fix, shift
- ifioset USBIN, USBMINUS
- rjmp bit0IsSet
- andi shift, ~(7 << 0)
- breq unstuff0c
- in phase, USBIN
- rjmp bit1AfterClr
- unstuff0c:
- in phase, USBIN
- andi fix, ~(1 << 0)
- ifioclr USBIN, USBMINUS
- ifioset USBIN, USBPLUS
- rjmp bit0IsSet
- rjmp se0AndStore
- bit0IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 0
- bit1AfterSet:
- andi shift, ~(7 << 1)
- ifioclr USBIN, USBMINUS
- rjmp bit1IsClr
- breq unstuff1s
- nop2
- in phase, USBIN
- rjmp bit2AfterSet
- unstuff1s:
- in phase, USBIN
- andi fix, ~(1 << 1)
- lpm
- nop2
- bit1IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 1
- nop
- bit2AfterClr:
- ifioset USBIN, USBMINUS
- rjmp bit2IsSet
- andi shift, ~(7 << 2)
- breq unstuff2c
- in phase, USBIN
- rjmp bit3AfterClr
- unstuff2c:
- in phase, USBIN
- andi fix, ~(1 << 2)
- nop2
- nop2
- bit2IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 2
- bit3AfterSet:
- st y+, data
- entryAfterSet:
- ifioclr USBIN, USBMINUS
- rjmp bit3IsClr
- andi shift, ~(7 << 3)
- breq unstuff3s
- in phase, USBIN
- rjmp bit4AfterSet
- unstuff3s:
- in phase, USBIN
- andi fix, ~(1 << 3)
- nop2
- nop2
- bit3IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 3
- bit4AfterClr:
- mov data, fix
- ifioset USBIN, USBMINUS
- rjmp bit4IsSet
- andi shift, ~(7 << 4)
- breq unstuff4c
- in phase, USBIN
- rjmp bit5AfterClr
- unstuff4c:
- in phase, USBIN
- andi fix, ~(1 << 4)
- nop2
- nop2
- bit4IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 4
- bit5AfterSet:
- ser data
- ifioclr USBIN, USBMINUS
- rjmp bit5IsClr
- andi shift, ~(7 << 5)
- breq unstuff5s
- in phase, USBIN
- rjmp bit6AfterSet
- unstuff5s:
- in phase, USBIN
- andi fix, ~(1 << 5)
- nop2
- nop2
- bit5IsClr:
- ifrset phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 5
- bit6AfterClr:
- subi cnt, 1
- brcs overflow
- ifioset USBIN, USBMINUS
- rjmp bit6IsSet
- andi shift, ~(3 << 6)
- cpi shift, 2
- in phase, USBIN
- brlt unstuff6c
- rjmp bit7AfterClr
- unstuff6c:
- andi fix, ~(1 << 6)
- lpm
- bit6IsSet:
- ifrclr phase, USBMINUS
- lpm
- in phase, USBIN
- ori shift, 1 << 6
- bit7AfterSet:
- ifioclr USBIN, USBMINUS
- rjmp bit7IsClr
- andi shift, ~(1 << 7)
- cpi shift, 4
- in phase, USBIN
- brlt unstuff7s
- rjmp bit0AfterSet
- unstuff7s:
- andi fix, ~(1 << 7)
- nop
- rjmp bit7IsClr
- macro POP_STANDARD
- pop r0
- pop cnt
- pop x3
- pop x2
- pop x1
- pop shift
- pop YH
- endm
- macro POP_RETI
- pop YL
- out SREG, YL
- pop YL
- endm
- txByteLoop:
- txBitloop:
- stuffN1Delay:
- ror shift
- brcc doExorN1
- subi x3, 1
- brne commonN1
- lsl shift
- nop
- rjmp stuffN1Delay
- sendNakAndReti:
- ldi cnt, USBPID_NAK
- rjmp sendCntAndReti
- sendAckAndReti:
- ldi cnt, USBPID_ACK
- sendCntAndReti:
- mov r0, cnt
- ldi YL, 0
- ldi YH, 0
- ldi cnt, 2
- usbSendAndReti:
- in x2, USBDDR
- ori x2, USBMASK
- sbi USBOUT, USBMINUS
- out USBDDR, x2
- in x1, USBOUT
- ldi shift, 0x40
- ldi x2, USBMASK
- doExorN1:
- eor x1, x2
- ldi x3, 6
- commonN1:
- stuffN2Delay:
- out USBOUT, x1
- ror shift
- brcc doExorN2
- subi x3, 1
- brne commonN2
- lsl shift
- rjmp stuffN2Delay
- doExorN2:
- eor x1, x2
- ldi x3, 6
- commonN2:
- nop2
- subi cnt, 171
- out USBOUT, x1
- brcs txBitloop
- stuff6Delay:
- ror shift
- brcc doExor6
- subi x3, 1
- brne common6
- lsl shift
- nop
- rjmp stuff6Delay
- doExor6:
- eor x1, x2
- ldi x3, 6
- common6:
- stuff7Delay:
- ror shift
- out USBOUT, x1
- brcc doExor7
- subi x3, 1
- brne common7
- lsl shift
- rjmp stuff7Delay
- doExor7:
- eor x1, x2
- ldi x3, 6
- common7:
- ld shift, y+
- nop
- tst cnt
- out USBOUT, x1
- brne txByteLoop
- cbr x1, USBMASK
- lds x2, usbNewDeviceAddr
- lsl x2
- subi YL, 2 + 0
- sbci YH, 0
- out USBOUT, x1
- breq skipAddrAssign
- sts usbDeviceAddr, x2
- skipAddrAssign:
- ldi x2, 1<<USB_INTR_PENDING_BIT
- USB_STORE_PENDING(x2)
- ori x1, USBIDLE
- in x2, USBDDR
- cbr x2, USBMASK
- mov x3, x1
- cbr x3, USBMASK
- lpm
- lpm
- out USBOUT, x1
- out USBDDR, x2
- out USBOUT, x3
- rjmp doReturn
|