include common.inc
+;----------------------------------------------------------------------
udata_acs
b res 1 ; byte just read
cbyte res 1
; one of the following:
; 0000 0000 we're expecting the first byte
- ;
- ; M0BB 0001 we have rec
- ; M0BB 0001 we have rec
-
- ; MM zz B2 B1 zz zz zz II
- ;
- ; main byte from slave
-; M0BB0000
- ; where M is 1 iff we're expecting an `extra byte'
- ; otherwise NN is the detection byte we're expecting
-
-sc res 1
-sc_extra equ 7 ; we're
+ ; M0B1 0000 we're expecting more detection byte 1
+ ; M010 0000 we're expecting more detection byte 2
+ ; 1000 0000 we're expecting an extra byte
+;----------------------------------------------------------------------
slavetable_section udata 0x280
ste_szln2 equ 3
code
;======================================================================
+; HANDLING OF I2C EVENTS
;----------------------------------------
i2cm_intrl
call i2cm_interrupt_definite
intrl_handled_nostack
+;----------------------------------------
+i2cmu_done panic morse_MD
+
+;----------------------------------------
+i2cmu_write_next_byte
+ panic morse_UI
+
+;======================================================================
+; PROCESSING OF INCOMING BYTES
+
;----------------------------------------
i2cmu_read_got_byte
; Beforehand At call
ior_wff FSR1L ; FSR1L -> detmsgh
return ; to addmsgs_<something>
-;----------
-read_prep_detectbyte
-; W adjusted detbase l
-; cbyte set for next byte to read
-; b received byte
-; FSR1 -> lastd<n>
-; TOS -> goto addmsgs_<something>
-; NOS return address for i2cmu_read_got_byte
- mov_wf t ; t = adj.detbasel
- mov_fw b ; W = ?d??dddd
- xor_wfw INDF1 ; lastd<n> = ?C??CCCC, Z iff same
- bra_nz read_got_detectbyte_something
- xor_wfw INDF1 ; lastd<n> = ?d??dddd
- ; there's nothing to do
- pop
-;...
-;----------------------------------------
-i2c_arrange_next_byte
- tst_f_ifnz cbyte
- goto i2cm_read_another
-;...
-;----------------------------------------
-i2c_arrange_something
-; figure out what to do next - which pic to address, etc.
- panic morse_UG
-
;----------------------------------------
read_got_notfirst
bt_f_if1 cbyte, 4
bt_f_if0 b, 7 ; any more ?
bc_f cbyte, 7
bc_f b, 7
- call process_got_extra
+ rcall process_got_extra
bra i2c_arrange_next_byte
;----------------------------------------
bra_z slave_got_aargh
panic morse_MX
-;========================================
+;----------
+read_prep_detectbyte
+; W adjusted detbase l
+; cbyte set for next byte to read
+; b received byte
+; FSR1 -> lastd<n>
+; TOS -> goto addmsgs_<something>
+; NOS return address for i2cmu_read_got_byte
+ mov_wf t ; t = adj.detbasel
+ mov_fw b ; W = ?d??dddd
+ xor_wfw INDF1 ; lastd<n> = ?C??CCCC, Z iff same
+ bra_nz read_got_detectbyte_something
+ xor_wfw INDF1 ; lastd<n> = ?d??dddd
+ ; there's nothing to do
+ pop
+;...
+;----------------------------------------
+i2c_arrange_next_byte
+ tst_f_ifnz cbyte
+ goto i2cm_read_another
+;...
+;======================================================================
+; DECIDING WHICH SLAVE TO ADDRESS
+;...
+i2c_arrange_something
+; figure out what to do next - which pic to address, etc.
+ panic morse_UG
+
+;======================================================================
+; GENERATION OF DETECTION MESSAGES FOR HOST - MAD BT_F_IF1 TABLES
addmsg_testbit macro bit
bt_f_if1 w, bit
mov_fw INDF1 ; W = 1 001 0 SSS
mov_wf u ; u = 1 001 0 SSS
mov_fw b ; W = ?d??dddd
-stuff here
- and_wfw INDF0 ; W = .....d..
-
- xor_wfw
-
- bt_w_if1 INDF1,
-
-
-
-
-read_got_detectbyte_allsame
- mov_wf INDF1 ; lastd<n> = ?d??dddd
-
- pop ; skip return address
-read_done_byte
-
-
-
- and_lw 0x80 ; W = M0BB0000 / M0000000 ie M0BB0000
-
- ; this is a first (head) byte from a detectors board:
-
-
- and_lw 0xb0 ; W = M0BB0000
-
-read_got_
- mov_fw b
- xor_wf PREINC1,
-
- mov_wf b
-
- mov_
- and_lw
-
-
- ; W = b = MdBBdddd /
- and_wfw INDF1 ; flags, = 10110000 / 10000000
- mov_wf cbyte ; cbyte = M0BB0000 / M0000000
-
- bt_f_
-
-
-
- bt_f_if1 cbyte, 4
- bra read_got_moredet1
- bt_f_if1 cbyte, 5
- bra read_got_moredet2
-
-
- mov_fw cbyte
-
- bra_n read_got_extra
- bra_nz read_got_moredet
-
- bt_f_if1 sc, sc_extra
- bra got_read_extra
-
-got_read_extra
- panic morse_UX
-
-;----------------------------------------
-i2cmu_done
-i2cmu_write_next_byte
- panic morse_UI
+ and_wfw INDF0 ; W = .....d.., Z iff detect
+ bt_f_if1 STATUS, Z
+ bs_f u, 3 ; u = 1 001 Y SSS
+ mov_fw u
+ rcall serial_addbyte
+ mov_fw t
+ goto serial_addbyte_another
;======================================================================
include final.inc