1 ;======================================================================
2 ; MAIN PROGRAM AND GLUE
7 ;======================================================================
8 ; COMMON TO MASTER AND SLAVE
10 ;----------------------------------------
13 bs_f RCON, IPEN ; interrupt priorities
17 bt_f_if0 idloc1,idloc1_master
20 bt_f_if1 idloc1,idloc1_master
26 bt_f_if1 idloc1,idloc1_master
27 goto backgroundloop_master
28 bt_f_if1 idloc1,idloc1_boarddet
29 goto backgroundloop_detectors
30 goto backgroundloop_reversers
34 ; called by {master,slave}_init immediately after they've init'd i2c.
38 call points_local_init
39 call polarity_local_init
40 call detect_local_init
43 ;----------------------------------------
50 intrl_handled_routine @
51 mov_ff isr_low_save_stkptr, STKPTR
54 ;======================================================================
57 ;----------------------------------------
59 ; Master-specific initialisation.
65 call polarity_master_init
66 call points_master_init
67 call common_local_init
73 call power_polarising_init
78 ;----------------------------------------
79 master_interrupt_low @
90 call nmra_serialrx_intrl
91 call power_fault_intrl
94 call points_local_intrl
106 ;----------------------------------------------------------------------
107 serialrx_table_section code 0x2000
109 ;--------------------
114 ;--------------------
115 serialrx_generalmsg @
116 ;command_<something> has same calling convention:
118 ; FSR0 -> start of message undefined
119 ; *FSR0 message undefined
122 bra_n serialrx_if_multibyte
123 bra_z command_crashed
126 bra_z command_power_on
128 bra_z command_power_off
130 bra_z command_tellmode
134 serialrx_if_multibyte
135 rr_fw INDF0 ; W = ii MM ww ww ww ww ii ii
136 and_lw 0x3c ; W = zz zz ww ww ww ww zz zz
137 bt_f_if0 PCL, 0 ; always true, but reads PCL
141 goto serialrx_bad ; 1 0000 xxx
142 goto command_ping ; 1 0001 xxx
143 goto command_polarity ; 1 0010 xxx
144 goto command_watchdog ; 1 0011 xxx
145 goto command_point ; 1 0100 xxx
146 goto serialrx_bad ; 1 0101 xxx
147 goto serialrx_bad ; 1 0110 xxx
148 goto serialrx_bad ; 1 0111 xxx
149 goto serialrx_bad ; 1 1000 xxx
150 goto serialrx_bad ; 1 1001 xxx
151 goto serialrx_bad ; 1 1010 xxx
152 goto serialrx_bad ; 1 1011 xxx
153 goto serialrx_bad ; 1 1100 xxx
154 goto serialrx_bad ; 1 1101 xxx
155 goto serialrx_bad ; 1 1110 xxx
156 goto serialrx_bad ; 1 1111 xxx
164 ;--------------------
170 bra_n command_ping_bad
171 goto serial_addbyte_another
173 command_ping_bad panic morse_HP
175 ;======================================================================
178 ;----------------------------------------
180 ; Slave-specific initialisation.
188 call common_local_init
189 call detect_slave_init
192 ;----------------------------------------
193 slave_interrupt_low @
195 call points_local_intrl
198 ;----------------------------------------
203 ;----------------------------------------
208 bra i2csu_write_if_special
210 bra polarity_local_do
217 i2csu_write_if_special
219 bra i2csu_write_if_bad
220 goto panic_crashread_commanded
223 ;======================================================================
224 ; MASTER/SLAVE deviations
228 ; Either transmits the message to the master, or if we are the master,
229 ; handles it as an incoming message from the notional `slave 0'.
230 ; W message unchanged
232 bt_f_if0 idloc1,idloc1_master
233 goto slave_add_short_message
234 goto loopback_read_byte
236 ;======================================================================