]>
Commit | Line | Data |
---|---|---|
a16ba2b0 L |
1 | page 255\r |
2 | .z80\r | |
e4c4b148 | 3 | \r |
6a4e9540 L |
4 | ;\r |
5 | ; FIFO channels for communication with stm32\r | |
6 | ;\r | |
a16ba2b0 L |
7 | global f.init,f.in,f.out,f.i.st\r |
8 | \r | |
9 | extrn buf.init\r | |
10 | \r | |
11 | include config.inc\r | |
12 | include z180reg.inc\r | |
13 | \r | |
14 | \r | |
15 | ;--------------------------------------------------------------\r | |
16 | \r | |
17 | dseg\r | |
a16ba2b0 | 18 | \r |
e4c4b148 L |
19 | \r |
20 | mkbuf ci.fifo_id, rx.buf,rx.buf_len\r | |
21 | mkbuf co.fifo_id, tx.buf,tx.buf_len\r | |
a16ba2b0 L |
22 | \r |
23 | \r | |
24 | ;--------------------------------------------------------------\r | |
25 | \r | |
26 | cseg\r | |
6a4e9540 | 27 | \r |
a16ba2b0 L |
28 | ; Init Serial I/O for console input and output\r |
29 | ;\r | |
6a4e9540 | 30 | \r |
a16ba2b0 L |
31 | f.init:\r |
32 | ld ix,rx.buf\r | |
33 | ld a,rx.buf.mask\r | |
34 | call buf.init\r | |
35 | ld ix,tx.buf\r | |
36 | ld a,tx.buf.mask\r | |
37 | jp buf.init\r | |
38 | \r | |
39 | \r | |
40 | f.i.st:\r | |
41 | push ix\r | |
42 | ld ix,rx.buf ;\r | |
43 | \r | |
44 | buf.empty:\r | |
45 | ld a,(ix+o.in_idx) ;\r | |
46 | sub (ix+o.out_idx) ;\r | |
47 | pop ix\r | |
48 | ret z\r | |
49 | or 0ffh\r | |
50 | ret\r | |
e4c4b148 | 51 | \r |
a16ba2b0 L |
52 | \r |
53 | f.in:\r | |
54 | push ix\r | |
55 | ld ix,rx.buf ;\r | |
56 | \r | |
57 | buf.get:\r | |
58 | ld a,(ix+o.out_idx) ;\r | |
59 | bg.wait:\r | |
60 | cp (ix+o.in_idx) ;\r | |
61 | jr z,bg.wait\r | |
62 | \r | |
63 | push hl ;\r | |
64 | push ix\r | |
65 | pop hl\r | |
66 | add a,l\r | |
67 | ld l,a\r | |
68 | jr nc,bg.nc\r | |
69 | inc h\r | |
70 | bg.nc:\r | |
71 | ld l,(hl)\r | |
e4c4b148 | 72 | \r |
a16ba2b0 L |
73 | ld a,(ix+o.out_idx) ;\r |
74 | inc a\r | |
75 | and (ix+o.mask)\r | |
76 | ld (ix+o.out_idx),a\r | |
e4c4b148 | 77 | \r |
a16ba2b0 L |
78 | ld a,l\r |
79 | pop hl\r | |
80 | pop ix\r | |
81 | ret\r | |
82 | \r | |
83 | \r | |
84 | f.o.st:\r | |
85 | push ix\r | |
86 | ld ix,tx.buf ;\r | |
87 | \r | |
88 | buf.full:\r | |
89 | ld a,(ix+o.in_idx) ;\r | |
90 | inc a\r | |
91 | and (ix+o.mask)\r | |
92 | sub (ix+o.out_idx) ;\r | |
93 | pop ix\r | |
94 | ret z\r | |
95 | or 0ffh\r | |
96 | ret\r | |
97 | \r | |
98 | \r | |
99 | f.out:\r | |
100 | push ix\r | |
101 | ld ix,tx.buf ;\r | |
102 | \r | |
103 | buf.put:\r | |
104 | push hl ;\r | |
105 | push bc\r | |
106 | push ix\r | |
107 | pop hl\r | |
108 | ld c,(ix+o.in_idx) ;\r | |
109 | ld b,0\r | |
110 | add hl,bc\r | |
111 | ld b,a\r | |
112 | \r | |
113 | ld a,c ;\r | |
114 | inc a\r | |
115 | and (ix+o.mask)\r | |
116 | bp.wait:\r | |
117 | cp (ix+o.out_idx) ;\r | |
118 | jr z,bp.wait\r | |
119 | ld (hl),b\r | |
120 | ld (ix+o.in_idx),a\r | |
e4c4b148 | 121 | \r |
a16ba2b0 L |
122 | ld a,b\r |
123 | pop bc\r | |
124 | pop hl\r | |
125 | pop ix\r | |
126 | ret\r | |
127 | \r | |
128 | end\r |