# HG changeset patch # User boisy # Date 1239562104 0 # Node ID 27f07aa0bca0d34afa5016377d4553c5f9bd06ca # Parent 236cbc2d2dc84d05c2a37b88dccf2773fee9ed75 Updated modules to use Darren Atkinson's latest changes to low level read/write routines diff -r 236cbc2d2dc8 -r 27f07aa0bca0 level1/modules/boot_dw3.asm --- a/level1/modules/boot_dw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/boot_dw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -97,22 +97,20 @@ lbsr DWWrite send it to server * Get 256 bytes of sector data ldx blockloc,u - lda #255 + ldy #256 bsr DWRead read bytes from server bcs ReadEr branch if framing error - cmpd #256 - bne ReadEr2 + bne ReadEr2 * Send two byte checksum pshs y leax ,s ldy #2 lbsr DWWrite - lda #255 + ldy #1 bsr DWRead leas 2,s bcs ReadEx - cmpd #1 bne ReadEr2 ldb ,s beq ReadEx diff -r 236cbc2d2dc8 -r 27f07aa0bca0 level1/modules/clock2_dw3.asm --- a/level1/modules/clock2_dw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/clock2_dw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -51,9 +51,8 @@ jsr 6,u puls a * Consider the following optimization -* ldx #D.Year - leax D.Year,y Note: Y = 0 after returning from XMT56K - lda #255 + ldx #D.Year + ldy #$0005 jsr 3,u UpdLeave puls x,y,u,pc diff -r 236cbc2d2dc8 -r 27f07aa0bca0 level1/modules/dwdefs.d --- a/level1/modules/dwdefs.d Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/dwdefs.d Sun Apr 12 18:48:24 2009 +0000 @@ -10,6 +10,10 @@ nam dwdefs ttl DriveWire Definitions File +* Addresses +BBOUT equ $FF20 +BBIN equ $FF22 + * Opcodes OP_NOP equ $00 No-Op OP_RESET1 equ $FE Server Reset diff -r 236cbc2d2dc8 -r 27f07aa0bca0 level1/modules/dwread.asm --- a/level1/modules/dwread.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/dwread.asm Sun Apr 12 18:48:24 2009 +0000 @@ -1,293 +1,244 @@ - IFNE BAUD38400 - -****************************************************************************** -* COCO 38400 BAUD BIT-BANGER RECEIVER -****************************************************************************** +******************************************************* +* +* DWRead +* Receive a response from the DriveWire server. +* Times out if serial port goes idle for more than 1.4 (0.7) seconds. +* Serial data format: 1-8-N-1 +* 4/12/2009 by Darren Atkinson * -* WAITS FOR A SPECIFIED TIMEOUT PERIOD UNTIL A START-BIT APPEARS ON THE -* BIT-BANGER INPUT. DATA RECEPTION IS INITIATED IF A START-BIT APPEARS -* BEFORE THE TIMEOUT PERIOD EXPIRES. THE SERIAL DATA FORMAT MUST BE: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1..2 STOP BITS. +* Entry: +* X = starting address where data is to be stored +* Y = number of bytes expected +* +* Exit: +* CC = carry set on framing error, Z set if all bytes received +* X = starting address of data received +* Y = checksum +* U is preserved. All accumulators are clobbered * -* DATA RECPEPTION TERMINATES WHEN: -* - A PERIOD OF 4 MS ELLAPSES WITHOUT A NEW START BIT -* - A FRAMING ERROR IS DETECTED. -* -* ON ENTRY: -* X = ADDRESS FOR DATA STORAGE -* A = TIMEOUT VALUE (125 = APPROX ONE SECOND) -* -* ON EXIT: -* Y = DATA CHECKSUM -* D = NUMBER OF BYTES RECEIVED -* X AND U ARE PRESERVED -* CC.CARRY IS SET ONLY IF A FRAMING ERROR WAS DETECTED -* -****************************************************************************** -BBIN EQU $FF22 ; BIT-BANGER INPUT ADDRESS -BUFBAS EQU 1 ; OFFSET TO STORAGE ADDRESS ON STACK + + + IFNE BAUD38400 +******************************************************* +* 38400 bps using 6809 code and timimg +******************************************************* + +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 + orcc #$50 ; mask interrupts + tfr a,dp ; set direct page to $FFxx + setdp $ff + leau ,x ; U = storage ptr + ldx #0 ; initialize checksum + adda #2 ; A = $01 (serial in mask), set Carry -DWRead -RCV38K CLRB ; CLEAR CARRY FLAG (NO FRAMING ERROR) - PSHS U,X,CC ; PRESERVE REGISTERS - ORCC #$50 ; MASK INTERRUPTS - TFR D,Y ; SET Y TO INITIAL TIMEOUT COUNTER - LEAU ,X ; POINT U TO STORAGE BUFFER - LDX #0 ; INITIALIZE CHECKSUM - LDA #1 ; A = SERIAL INPUT MASK - -WAIT1 LEAY ,Y ; TEST TIMEOUT COUNTER - BEQ FINISH ; BRANCH IF TIMEOUT HAS EXPIRED -WAIT2 BITA BBIN ; CHECK FOR START BIT - BEQ BSTART ; BRANCH IF START BIT DETECTED - LEAY -1,Y ; DECREMENT TIMEOUT COUNTER - BITA BBIN ; CHECK FOR START BIT - BNE WAIT1 ; LOOP IF STILL NO START BIT +* Wait for a start bit or timeout +rx0010 bcc rxExit ; exit if timeout expired + ldb #$ff ; init timeout lsb +rx0020 bita CARRY .. BIT 0->B.1 .. '0'->B.0 - ROLB ; BIT 7 -> B.0 .. BIT 0->B.2 .. '0'->B.1 +DWWrite pshs u,d,cc ; preserve registers + orcc #$50 ; mask interrupts + ldu #BBOUT ; point U to bit banger out register + lda 3,u ; read PIA 1-B control register + anda #$f7 ; clear sound enable bit + sta 3,u ; disable sound output + fcb $8c ; skip next instruction -WRLOOP STB ,U++ ; TRANSMIT A BIT (BUMPING U) - TST ,--U ; 9 CYCLE DELAY (RESTORES BUMPED U) - RORB ; MOVE NEXT BIT INTO POSITION - DECA ; DECREMENT LOOP COUNTER - BNE WRLOOP ; LOOP UNTIL BIT 6 HAS BEEN TRANSMITTED +txByte stb ,--u ; send stop bit + leau ,u+ + lda #8 ; counter for start bit and 7 data bits + ldb ,x+ ; get a byte to transmit + lslb ; left rotate the byte two positions.. + rolb ; ..placing a zero (start bit) in bit 1 +tx0010 stb ,u++ ; send bit + tst ,--u + rorb ; move next bit into position + deca ; decrement loop counter + bne tx0010 ; loop until 7th data bit has been sent + leau ,u + stb ,u ; send bit 7 + lda ,u++ + ldb #$02 ; value for stop bit (MARK) + leay -1,y ; decrement byte counter + bne txByte ; loop if more to send - LEAU ,U ; 4 CYCLE DELAY - STB ,U ; TRANSMIT BIT 7 - LDA ,U++ ; 7 CYCLE DELAY (BUMPING U) - LDB #$02 ; PREPARE VALUE FOR STOP BIT - LEAY -1,Y ; DECREMENT BYTES REMAINING COUNTER - BNE OUTBYT ; LOOP IF MORE TO TRANSMIT + stb ,--u ; leave bit banger output at MARK + puls cc,d,u,pc ; restore registers and return - STB ,--U ; TRANSMIT STOP BIT - PULS CC,D,U,PC ; RESTORE REGISTERS AND RETURN ELSE IFNE H6309-1 +******************************************************* +* 57600 (115200) bps using 6809 code and timimg +******************************************************* -** -** Rev 3 Notes: -** -** For CoCo 1,2 or 3 -** 6809 Timing -** No Read Count in Receiver -** +DWWrite pshs dp,d,cc ; preserve registers + orcc #$50 ; mask interrupts + ldd #$04ff ; A = loop counter, B = $ff + tfr b,dp ; set direct page to $FFxx + setdp $ff + ldb <$ff23 ; read PIA 1-B control register + andb #$f7 ; clear sound enable bit + stb <$ff23 ; disable sound output + fcb $8c ; skip next instruction + +txByte stb CARRY .. BIT 0->B.1 ..'0'->B.0 - ROLB 2 / ; BIT 7 -> B.0 .. BIT 0->B.2 ..'0'->B.1 - -ODDBIT STB CARRY .. BIT 0->B.1 ..'0'->B.0 - ROLB 1 | ; BIT 7 -> B.0 .. BIT 0->B.2 ..'0'->B.1 - LDA #8 2 | ; BIT COUNT (START BIT, DATA BITS 0-6) - BRA BSEND 3 / ; ENTER THE LOOP +tx0020 bita #1 ; even or odd bit number ? + beq tx0040 ; branch if even (15 cycles) +tx0030 nop ; extra (16th) cycle +tx0040 stb -1,u ; send bit + rorb ; move next bit into position + deca ; decrement loop counter + bne tx0020 ; loop until 7th data bit has been sent + leau ,u+ + stb -1,u ; send bit 7 + ldd #$0802 ; A = loop counter, B = MARK value + leay -1,y ; decrement byte counter + bne txByte ; loop if more to send -XLOOP BITA #1 2 ; BIT COUNTER EVEN OR ODD? - BEQ BSEND 3 ; BRANCH IF EVEN (15-CYCLE BIT) - NOP 1 ; ONE MORE FOR A 16-CYCLE BIT -BSEND STB ,U 4 \ ; BIT OUTPUT - RORB 1 | ; ROTATE NEXT BIT INTO POSITION - NOP 1 | 10 ; DELAY CYCLE - DECA 1 | ; DECREMENT BIT COUNTER - BNE XLOOP 3 / ; LOOP UNTIL BIT 6 HAS BEEN SAMPLED - LEAU ,U++ 6 ; CONSUME 6 CYCLES (16 TOTAL FOR BIT 6) + stb -1,u ; final stop bit + puls cc,d,u,pc ; restore registers and return - STB ,U 4 \ ; BIT 7 OUTPUT - LDB #2 2 | ; PREPARE STOP BIT - NOP 1 | 15 ; DELAY CYCLE - LEAY -1,Y 5 | ; DECREMENT BYTES REMAINING COUNT - BNE OUTBYT 3 / ; LOOP IF MORE TO TRANSMIT - - STB ,U ; FINAL STOP BIT - PULS CC,D,U,PC ; RESTORE REGISTERS AND RETURN ENDC ENDC + + diff -r 236cbc2d2dc8 -r 27f07aa0bca0 level1/modules/rbdw3.asm --- a/level1/modules/rbdw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/rbdw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -211,10 +211,9 @@ * Get 256 bytes of sector data ldx 5,s ldx PD.BUF,x get buffer pointer into X - lda #255 + ldy #$0100 jsr 3,u bcs ReadEr1 - cmpd #256 bne ReadEr1 pshs y leax ,s @@ -223,10 +222,9 @@ * Get error code byte leax ,s - lda #255 + ldy #$0001 jsr 3,u bcs ReadEr0 branch if we timed out - cmpd #0001 bne ReadEr0 puls d tfr a,b transfer byte to B (in case of error) @@ -300,12 +298,10 @@ jsr 6,u * Await acknowledgement from server on receipt of sector -* ldy #$0001 - lda #255 leax ,s + ldy #$0001 jsr 3,u read ack byte from server bcs WritEx0 - cmpd #$0001 bne WritEx0 puls d tsta