# HG changeset patch # User Boisy Pitre # Date 1358903928 21600 # Node ID 8b2df903334ceadb5c5dfd654fa17e82ef214ed5 # Parent 863cf7feafa6276a047017810a661b98806a39ad Merged in dwread/dwwrite Arduino changes diff -r 863cf7feafa6 -r 8b2df903334c level1/modules/dwread.asm --- a/level1/modules/dwread.asm Fri Jan 18 21:52:41 2013 -0600 +++ b/level1/modules/dwread.asm Tue Jan 22 19:18:48 2013 -0600 @@ -17,10 +17,60 @@ * U is preserved. All accumulators are clobbered * + IFNE ARDUINO +* Note: this is an optimistic routine. It presumes that the server will always be there, and +* has NO timeout fallback. It is also very short and quick. +DWRead clra ; clear Carry (no framing error) + pshs u,x,cc ; preserve registers + leau ,x + ldx #$0000 +loop@ tst $FF51 ; check for CA1 bit (1=Arduino has byte ready) + bpl loop@ ; loop if not set + ldb $FF50 ; clear CA1 bit in status register + stb ,u+ ; save off acquired byte + abx ; update checksum + leay ,-y + bne loop@ + leay ,x ; return checksum in Y + puls cc,x,u,pc ; restore registers and return + + ELSE + + IFNE JMCPBCK +* NOTE: There is no timeout currently on here... +DWRead clra ; clear Carry (no framing error) + deca ; clear Z flag, A = timeout msb ($ff) + tfr cc,b + pshs u,x,dp,b,a ; preserve registers, push timeout msb + leau ,x + ldx #$0000 + orcc #IntMasks +loop@ ldb $FF4C + bitb #$02 + beq loop@ + ldb $FF44 + stb ,u+ + abx + leay ,-y + bne loop@ + + tfr x,y + ldb #0 + lda #3 + leas 1,s ; remove timeout msb from stack + inca ; A = status to be returned in C and Z + ora ,s ; place status information into the.. + sta ,s ; ..C and Z bits of the preserved CC + leay ,x ; return checksum in Y + puls cc,dp,x,u,pc ; restore registers and return + ELSE IFNE BECKER * NOTE: There is no timeout currently on here... -DWRead pshs cc,d,x,u +DWRead clra ; clear Carry (no framing error) + deca ; clear Z flag, A = timeout msb ($ff) + tfr cc,b + pshs u,x,dp,b,a ; preserve registers, push timeout msb leau ,x ldx #$0000 orcc #IntMasks @@ -30,16 +80,22 @@ ldb $FF42 stb ,u+ abx - leay -1,y + leay ,-y bne loop@ tfr x,y - puls cc - andcc #^Carry - orcc #Zero - puls d,x,u,pc + ldb #0 + lda #3 + leas 1,s ; remove timeout msb from stack + inca ; A = status to be returned in C and Z + ora ,s ; place status information into the.. + sta ,s ; ..C and Z bits of the preserved CC + leay ,x ; return checksum in Y + puls cc,dp,x,u,pc ; restore registers and return + ENDC + ENDC - ELSE + IFEQ BECKER+JMCPBCK+ARDUINO IFNE BAUD38400 ******************************************************* * 38400 bps using 6809 code and timimg @@ -106,70 +162,7 @@ ELSE - IFNE H6309 -******************************************************* -* 57600 (115200) bps using 6309 native mode -******************************************************* - -DWRead clrb ; clear Carry (no framing error) - decb ; clear Z flag, B = $FF - pshs u,x,dp,cc ; preserve registers - orcc #$50 ; mask interrupts -* ldmd #1 ; requires 6309 native mode - tfr b,dp ; set direct page to $FFxx - setdp $ff - leay -1,y ; adjust request count - leau ,x ; U = storage ptr - tfr 0,x ; initialize checksum - lda #$01 ; A = serial in mask - bra rx0030 ; go wait for start bit - -* Read a byte -rxByte sexw ; 4 cycle delay - ldw #$006a ; shift counter and timing flags - clra ; clear carry so next will branch -rx0010 bcc rx0020 ; branch if even bit number (15 cycles) - nop ; extra (16th) cycle -rx0020 lda