chiark / gitweb /
i2cmu_read_got_byte - main scanning loop - wip
authorian <ian>
Wed, 21 Dec 2005 15:44:18 +0000 (15:44 +0000)
committerian <ian>
Wed, 21 Dec 2005 15:44:18 +0000 (15:44 +0000)
detpic/mascan.asm
detpic/morse.messages

index b80e1075f7e3a11ad1e80d94b3366cc8ded208a3..f1d4f25a2f6290ea73665873f02af8fc5c34e2d8 100644 (file)
@@ -2,8 +2,35 @@
 ; MASTER - SCANNING ETC.
 
  include common.inc
- code
 
+ udata_acs
+
+cslot  res     1       ; current slave in slave table, points to flags byte
+main   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
+; X0BB0000
+                       ; where X 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 
+
+slavetable_section udata 0x280
+slavetable res maxpics * 2
+       ; each entry is:
+       ;  1 byte slave number
+       ;  1 byte flags
+       ;       00DD0000        where D is 1 iff a detectors board
+
+ code
 ;======================================================================
 
 ;----------------------------------------
@@ -16,8 +43,44 @@ i2cm_intrl
        intrl_handled_nostack
 
 ;----------------------------------------
-i2cmu_done
 i2cmu_read_got_byte
+;              Beforehand      At call
+;   State      Reading         Reading-Wait
+;   W                          data from slave
+;
+; See detect.asm head comment for protocol info, in particular
+; the meaning of these bytes.
+       mov_wf  t               ; remember the byte for a moment
+       mov_lw  slavetable >> 8
+       mov_wf  FSR1H
+       mov_ff  cslot, FSR1L
+
+       tst_f_ifnz cbyte
+       bra     read_got_notfirst
+       ; this is a first (head) byte:
+
+       and_wfw POSTINC1, 
+       
+
+       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
 
index 82083a3a7a7a779d3a5512309fafbc40da3644c6..8a02152244a0e5d0f7faf59354a32544273696a1 100644 (file)
@@ -48,6 +48,7 @@ UM
 UE
 UC
 UI
+UX
 
 # Messages for i2clib, S*
 SM     i2clib:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state