2602
|
1 IFEQ H6309-1
|
2576
|
2
|
2574
|
3 *******************************************************
|
|
4 *
|
2576
|
5 * DWWrite - 6309 native Turbo Edition 115k / 230k
|
|
6 * Send a packet to the DriveWire server.
|
|
7 * Serial data format: 8-N-2
|
|
8 *
|
|
9 * Entry:
|
|
10 * X = address of the data to be sent
|
|
11 * Y = number of bytes to send
|
|
12 *
|
|
13 * Exit:
|
|
14 * X = address of last byte sent + 1
|
|
15 * Y = 0
|
|
16 * All others preserved
|
|
17 *
|
|
18 BBOUT equ $FF20 ; bit banger output port
|
|
19
|
|
20 DWWrite pshs u,d,cc ; preserve registers
|
|
21 orcc #$50 ; mask interrupts
|
|
22 ldu #BBOUT ; point U to output port
|
|
23 aim #$F7,3,u ; disable sound output
|
|
24
|
|
25 * Wait for serial input line to become idle
|
|
26 wait1 lda 2,u ; sample input
|
|
27 ldb #$80 ; setup ACCB as a shift counter
|
|
28 wait2 eora 2,u ; look for changing input
|
|
29 lsra ; shift 'changed' bit into Carry
|
|
30 lda 2,u ; sample input
|
|
31 rorb ; rotate 'changed' bit into ACCB
|
|
32 bcc wait2 ; loop for 8 samples
|
|
33 bne wait1 ; try again if changes seen in the input
|
|
34
|
|
35 * Byte transmitter loop
|
|
36 incb ; ACCB = 1 (start bit / byte incrementor)
|
|
37 txByte lda ,x ; get data byte
|
|
38 stb ,u ; send start bit
|
|
39 asla ; move bit 0 into position
|
|
40 abx ; increment data ptr
|
|
41 sta ,u++ ; bit 0
|
|
42 rora
|
|
43 nop
|
|
44 sta ,--u ; bit 1
|
|
45 lsra
|
|
46 sta ,u++ ; bit 2
|
|
47 lsra
|
|
48 nop
|
|
49 sta ,--u ; bit 3
|
|
50 lsra
|
|
51 nop
|
|
52 sta ,u++ ; bit 4
|
|
53 lsra
|
|
54 nop
|
|
55 sta ,--u ; bit 5
|
|
56 lsra
|
|
57 sta ,u++ ; bit 6
|
|
58 lsra
|
|
59 aslb ; ACCB = 2 (stop bit)
|
|
60 sta ,--u ; bit 7
|
|
61 leau ,u
|
|
62 stb ,u ; send stop bit
|
|
63 lsrb ; ACCB = 1 (start bit / byte incrementor)
|
|
64 leay -1,y ; decrement counter
|
|
65 bne txByte ; loop if more bytes to send
|
|
66
|
|
67 puls cc,d,u,pc ; restore registers and return
|
|
68
|
|
69 ELSE
|
|
70
|
|
71 *******************************************************
|
|
72 *
|
|
73 * DWWrite - 6809 Turbo Edition 115k / 230k
|
2574
|
74 * Send a packet to the DriveWire server.
|
|
75 * Serial data format: 8-N-2
|
|
76 *
|
|
77 * Entry:
|
|
78 * X = address of the data to be sent
|
|
79 * Y = number of bytes to send
|
|
80 *
|
|
81 * Exit:
|
|
82 * X = address of last byte sent + 1
|
|
83 * Y = 0
|
|
84 * All others preserved
|
|
85 *
|
|
86 *BBOUT equ $FF20 ; bit banger output port
|
|
87
|
|
88 DWWrite pshs u,d,cc ; preserve registers
|
|
89 orcc #$50 ; mask interrupts
|
|
90 ldu #BBOUT ; point U to output port
|
|
91 lda 3,u ; read PIA 1-B control register
|
|
92 anda #$F7 ; clear sound enable bit
|
|
93 sta 3,u ; disable sound output
|
|
94
|
|
95 * Wait for serial input line to become idle
|
|
96 wait1 lda 2,u ; sample input
|
|
97 ldb #$80 ; setup ACCB as a shift counter
|
|
98 wait2 eora 2,u ; look for changing input
|
|
99 lsra ; shift 'changed' bit into Carry
|
|
100 lda 2,u ; sample input
|
|
101 rorb ; rotate 'changed' bit into ACCB
|
|
102 bcc wait2 ; loop for 8 samples
|
|
103 bne wait1 ; try again if changes seen in the input
|
|
104
|
|
105 * Byte transmitter loop
|
|
106 ldb #2
|
|
107 lda ,x ; retrieve first byte from buffer
|
|
108 txByte decb ; ACCB = 1 (start bit / byte incrementor)
|
|
109 abx ; increment data ptr
|
|
110 stb ,u ; send start bit
|
|
111 asla ; move bit 0 into position
|
|
112 nop
|
|
113 sta ,u ; bit 0
|
|
114 rora
|
|
115 sta ,u+ ; bit 1
|
|
116 lsra
|
|
117 sta -1,u ; bit 2
|
|
118 lsra
|
|
119 sta ,-u ; bit 3
|
|
120 lsra
|
|
121 incb ; ACCB = 2 (stop bit)
|
|
122 sta ,u ; bit 4
|
|
123 lsra
|
|
124 sta ,u+ ; bit 5
|
|
125 lsra
|
|
126 sta -1,u ; bit 6
|
|
127 lsra
|
|
128 sta ,-u ; bit 7
|
|
129 lda ,x ; fetch next byte
|
|
130 stb ,u ; send stop bit
|
|
131 leay -1,y ; decrement counter
|
|
132 bne txByte ; loop if more bytes to send
|
|
133
|
|
134 puls cc,d,u,pc ; restore registers and return
|
|
135
|
2576
|
136 ENDC
|