Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/dwread.asm @ 2725:c2112f93923a lwtools-port
o dwio for Atari now uses routines in ROM, so dwread/dwrite stripped of Atari
o Added NMI code (as a conditional) to clock
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Tue, 31 Jul 2012 11:54:02 -0500 |
parents | 22bdfbe8bc68 |
children | bfe3de781ddf |
rev | line source |
---|---|
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
1 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
2 * |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
3 * DWRead |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
4 * Receive a response from the DriveWire server. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
5 * Times out if serial port goes idle for more than 1.4 (0.7) seconds. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
6 * Serial data format: 1-8-N-1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
7 * 4/12/2009 by Darren Atkinson |
2182 | 8 * |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
9 * Entry: |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
10 * X = starting address where data is to be stored |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
11 * Y = number of bytes expected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
12 * |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
13 * Exit: |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
14 * CC = carry set on framing error, Z set if all bytes received |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
15 * X = starting address of data received |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
16 * Y = checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
17 * U is preserved. All accumulators are clobbered |
2182 | 18 * |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
19 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
20 |
2546 | 21 IFNE BECKER |
2711
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
22 |
2551 | 23 * NOTE: There is no timeout currently on here... |
24 DWRead pshs cc,d,x,u | |
25 leau ,x | |
26 ldx #$0000 | |
27 orcc #IntMasks | |
28 loop@ ldb $FF41 | |
29 bitb #$02 | |
30 beq loop@ | |
31 ldb $FF42 | |
32 stb ,u+ | |
33 abx | |
34 leay -1,y | |
35 bne loop@ | |
2546 | 36 |
2551 | 37 tfr x,y |
38 puls cc | |
39 andcc #^Carry | |
40 orcc #Zero | |
41 puls d,x,u,pc | |
2546 | 42 |
43 ELSE | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
44 IFNE BAUD38400 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
45 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
46 * 38400 bps using 6809 code and timimg |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
47 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
48 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
49 DWRead clra ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
50 deca ; clear Z flag, A = timeout msb ($ff) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
51 tfr cc,b |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
52 pshs u,x,dp,b,a ; preserve registers, push timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
53 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
54 tfr a,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
55 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
56 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
57 ldx #0 ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
58 adda #2 ; A = $01 (serial in mask), set Carry |
2182 | 59 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
60 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
61 rx0010 bcc rxExit ; exit if timeout expired |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
62 ldb #$ff ; init timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
63 rx0020 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
64 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
65 subb #1 ; decrement timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
66 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
67 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
68 bcc rx0020 ; loop until timeout lsb rolls under |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
69 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
70 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
71 addb ,s ; B = timeout msb - 1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
72 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
73 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
74 stb ,s ; store decremented timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
75 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
76 bne rx0010 ; loop if still no start bit |
2182 | 77 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
78 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
79 rxByte leay ,-y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
80 ldd #$ff80 ; A = timeout msb, B = shift counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
81 sta ,s ; reset timeout msb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
82 rx0030 exg a,a |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
83 nop |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
84 lda <BBIN ; read data bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
85 lsra ; shift into carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
86 rorb ; rotate into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
87 lda #$01 ; prep stop bit mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
88 bcc rx0030 ; loop until all 8 bits read |
2182 | 89 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
90 stb ,u+ ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
91 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
92 ldb #$ff ; set timeout lsb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
93 anda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
94 beq rxExit ; exit if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
95 leay ,y ; test request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
96 bne rx0020 ; loop if another byte wanted |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
97 lda #$03 ; setup to return SUCCESS |
2182 | 98 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
99 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
100 rxExit leas 1,s ; remove timeout msb from stack |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
101 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
102 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
103 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
104 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
105 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
106 setdp $00 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
107 |
2182 | 108 |
109 ELSE | |
110 IFNE H6309-1 | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
111 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
112 * 57600 (115200) bps using 6809 code and timimg |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
113 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
114 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
115 DWRead clra ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
116 deca ; clear Z flag, A = timeout msb ($ff) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
117 tfr cc,b |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
118 pshs u,x,dp,b,a ; preserve registers, push timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
119 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
120 tfr a,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
121 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
122 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
123 ldx #0 ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
124 lda #$01 ; A = serial in mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
125 bra rx0030 ; go wait for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
126 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
127 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
128 rxByte leau 1,u ; bump storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
129 leay ,-y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
130 lda <BBIN ; read bit 0 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
131 lsra ; move bit 0 into Carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
132 ldd #$ff20 ; A = timeout msb, B = shift counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
133 sta ,s ; reset timeout msb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
134 rorb ; rotate bit 0 into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
135 rx0010 lda <BBIN ; read bit (d1, d3, d5) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
136 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
137 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
138 bita 1,s ; 5 cycle delay |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
139 bcs rx0020 ; exit loop after reading bit 5 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
140 lda <BBIN ; read bit (d2, d4) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
141 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
142 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
143 leau ,u |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
144 bra rx0010 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
145 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
146 rx0020 lda <BBIN ; read bit 6 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
147 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
148 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
149 leay ,y ; test request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
150 beq rx0050 ; branch if final byte of request |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
151 lda <BBIN ; read bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
152 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
153 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
154 stb -1,u ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
155 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
156 lda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
157 anda #$01 ; mask out other bits |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
158 beq rxExit ; exit if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
159 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
160 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
161 rx0030 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
162 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
163 bita <BBIN ; again |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
164 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
165 ldb #$ff ; init timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
166 rx0040 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
167 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
168 subb #1 ; decrement timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
169 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
170 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
171 bcc rx0040 ; loop until timeout lsb rolls under |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
172 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
173 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
174 addb ,s ; B = timeout msb - 1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
175 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
176 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
177 stb ,s ; store decremented timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
178 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
179 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
180 bcs rx0030 ; loop if timeout hasn't expired |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
181 bra rxExit ; exit due to timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
182 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
183 rx0050 lda <BBIN ; read bit 7 of final byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
184 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
185 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
186 stb -1,u ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
187 abx ; calculate final checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
188 lda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
189 anda #$01 ; mask out other bits |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
190 ora #$02 ; return SUCCESS if no framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
191 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
192 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
193 rxExit leas 1,s ; remove timeout msb from stack |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
194 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
195 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
196 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
197 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
198 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
199 setdp $00 |
2180 | 200 |
201 | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
202 ELSE |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
203 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
204 * 57600 (115200) bps using 6309 native mode |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
205 ******************************************************* |
2180 | 206 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
207 DWRead clrb ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
208 decb ; clear Z flag, B = $FF |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
209 pshs u,x,dp,cc ; preserve registers |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
210 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
211 * ldmd #1 ; requires 6309 native mode |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
212 tfr b,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
213 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
214 leay -1,y ; adjust request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
215 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
216 tfr 0,x ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
217 lda #$01 ; A = serial in mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
218 bra rx0030 ; go wait for start bit |
2180 | 219 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
220 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
221 rxByte sexw ; 4 cycle delay |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
222 ldw #$006a ; shift counter and timing flags |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
223 clra ; clear carry so next will branch |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
224 rx0010 bcc rx0020 ; branch if even bit number (15 cycles) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
225 nop ; extra (16th) cycle |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
226 rx0020 lda <BBIN ; read bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
227 lsra ; move bit into carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
228 rorb ; rotate bit into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
229 lda #0 ; prep A for 8th data bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
230 lsrw ; bump shift count, timing bit to carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
231 bne rx0010 ; loop until 7th data bit has been read |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
232 incw ; W = 1 for subtraction from Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
233 inca ; A = 1 for reading bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
234 anda <BBIN ; read bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
235 lsra ; move bit 7 into carry, A = 0 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
236 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
237 stb ,u+ ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
238 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
239 subr w,y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
240 inca ; A = 1 for reading stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
241 anda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
242 bls rxExit ; exit if completed or framing error |
2180 | 243 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
244 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
245 rx0030 clrw ; initialize timeout counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
246 rx0040 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
247 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
248 addw #1 ; bump timeout counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
249 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
250 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
251 bcc rx0040 ; loop until timeout rolls over |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
252 lda #$03 ; setup to return TIMEOUT status |
2180 | 253 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
254 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
255 rxExit beq rx0050 ; branch if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
256 eora #$02 ; toggle SUCCESS flag |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
257 rx0050 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
258 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
259 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
260 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
261 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
262 setdp $00 |
2180 | 263 |
2182 | 264 ENDC |
265 ENDC | |
2546 | 266 ENDC |