chiark / gitweb /
init polarity master table
authorian <ian>
Mon, 26 Dec 2005 23:58:03 +0000 (23:58 +0000)
committerian <ian>
Mon, 26 Dec 2005 23:58:03 +0000 (23:58 +0000)
detpic/morse.messages
detpic/reverse.asm

index dac7d8feece77f04fe9e21e7ec2a6e2d17b81c75..35882aa51c45bf278e2a8509f76c5080ef9c14ca 100644 (file)
@@ -56,7 +56,6 @@ UER
 UCT
 UCI
 UCP
-URM
 
 # Messages for i2clib, S*
 SM     i2clib+panic:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
@@ -81,6 +80,8 @@ DM    detect:buf0                     ; master has MM bit set in buf0
 # R - Reversers (polarity)
 RS     FSR0L                           ; POLARITY message too short
 RL     FSR0L                           ; POLARITY message too long
+RF                                     ; master board has no reversers
+RG                                     ; too many reversers boards
 
 # P - Points
 PB     points:pointmsg                 ; Firing point when already busy
index e2318cd37e37371da18535d2722822f58427f7f2..4416c107e985105d9ef6a91fa8e324ab67bbba0d 100644 (file)
@@ -18,7 +18,7 @@ polarity_cmds_section udata polarity_cmds
  res maxpics+1
        ; Each byte is:
        ;       11RRRRRR        reverse command for slave, waiting to write
-       ;       00000001        this is not a reversers pic
+       ;       00000001        this is not a reversers board
        ;       00000000        we have written any relevant command
        ;       01000000        sentinel
 
@@ -175,8 +175,43 @@ board_next_none_more_message
 
 ;----------------------------------------------------------------------
 polarity_master_init
-       panic   morse_URM
-       ; need to set up polarity_cmds
+
+       load_tblptr picno2revmasks
+       mov_lfsr polarity_cmds - 1, 0
+       mov_lw  maxpics
+       mov_wf  t
+       mov_lw  0x01 ; meaning `not a reversers board'
+polarity_master_init_boardloop
+       mov_wf  PREINC0
+       rcall   polarity_master_init_board_mask_check
+       rcall   polarity_master_init_board_mask_check
+       dec_f_ifnz t
+       bra     polarity_master_init_boardloop
+
+       tst_f_ifnz polarity_cmds
+       bra     polarity_bad_masternotused
+
+       ; OK, but now we have to work our way back and place
+       ; the sentinel
+       mov_lw  0x40 ; meaning `sentinel'
+       tst_f_ifnz INDF0
+       bra     polarity_bad_lastpicused
+polarity_master_init_truncateloop
+       mov_wf  POSTDEC0 ; overwrite with sentinel
+       tst_f_ifnz INDF0 ; previous one is also `not reversers board' ?
+       bra     polarity_master_init_truncateloop ; yes
+       ; no.  hah, we have truncated it.
+
+       return
+
+polarity_master_init_board_mask_check
+       tblrd_postinc_fixup
+       tst_f_ifnz TABLAT
+       clr_f   INDF0 ; meaning `reversers board but no command to send'
+       return
+
+polarity_bad_masternotused panic morse_RF
+polarity_bad_lastpicused panic morse_RG
 
 ;----------------------------------------------------------------------
 polarity_needwrite