chiark / gitweb /
go back to polarities_commanded_buffer; starting on needwrite_....
authorian <ian>
Fri, 23 Dec 2005 01:42:22 +0000 (01:42 +0000)
committerian <ian>
Fri, 23 Dec 2005 01:42:22 +0000 (01:42 +0000)
detpic/panic.asm
detpic/reverse.asm
detpic/variables.asm

index 4908b29927a154c0df5e546a535a64517e418352..151d0bcf9b9c109d0af3ba7da4c8752584e83556 100644 (file)
@@ -19,7 +19,7 @@ panicst                               res     1
 panicst_restart_i2c            equ     7
 panicst_acked                  equ     5
 
-panic_vars_section udata 0x060 ; not available via access bank
+panic_vars_section udata 0x060 + maxpics ; not available via access bank
 ; used in panic routine for temporary storage:
 
 flash_pattern          res     1
index 892e535334ff842c050425bbd2baee515623eb5d..7f2eb0f032469b7936533c43d61ff21cc09b09b4 100644 (file)
@@ -13,10 +13,13 @@ maske                               res     1
 ;----------------------------------------
 ; MASTER - Access bank variables and other sections
 
-; values for ste_revcmd:
+polarities_commanded_buffer_section udata 0x5f
+polarities_commanded_buffer    res     maxpics+1
+       ; Each byte is:
        ;       11RRRRRR        reverse command for slave, waiting to write
        ;       00000001        this is not a reversers pic
        ;       00000000        we have written any relevant command
+       ;       01000000        sentinel
 
 ;======================================================================
 ; LOCAL REVERSERS
@@ -112,7 +115,7 @@ command_polarity
 ;              and so on until f for bit 5.  (See polarity_do_here, below.)
 ;
 ; we accumulate (`gather') the `g' bits in t.
-       mov_lfsr slavetable + ste_revcmd, 1
+       mov_lfsr polarities_commanded_buffer, 1
        mov_fw  POSTINC0        ; W =           10010RRR
        mov_wf  t               ; t =           10010ggg
        xor_lw  b'10001000'     ; t =           00011ggg
@@ -141,21 +144,13 @@ board
                                ; FSR1 -> pic we've just filled
 ;...
 board_next_loop
-       mov_lw  ste_size
-       add_wff FSR1L           ; FSR1 -> pic after one we're testing
-    if ste_szln2 + maxpics_ln2 == 8
-       bra_c   board_next_none
-    else
-       error "reliance on carry flag for incrementing FSR1 fails"
-    endif
-       dec_fw  INDF1           ; W = 1???????  existing reverse command
+       dec_fw  PREINC1         ; FSR1 -> pic after one we're testing
+                               ; W = 1???????  existing reverse command
                                ;     00000000  not a reversers pic
-                               ;     ffffffff  no existing command
+                               ;     11111111  no existing command
+                               ;     00111111  sentinel
        bra_z   board_next_loop ; not a reversers pic
-
-       bt_f_if0 INDF1, 7       ;     1.......  existing command
-                               ;     0.......  no existing command
-       inc_f   polarities_waiting
+       bra_nn  board_next_none ; sentinel
        return
 
 ;----------
@@ -167,13 +162,44 @@ board_next_none
        pop      ; that disposes of the call to `board'
 
        call    power_polarising
-       mov_lfsr slavetable + ste_revcmd, 1
-       mov_fw  INDF1 ; there's always a board 0, us:
-       goto    polarity_local_do
+
+       mov_fw  polarities_commanded_buffer ; there's always a board 0, us
+       call    polarity_local_do
+       rcall   needwrite_polarity ; does `return' because it will find one
+       return                     ; ... or maybe not if only 1 rev board
 
 ;----------
 board_next_none_more_message
        panic   morse_RL
 
+;----------------------------------------------------------------------
+needwrite_polarity
+;  <something>_needwrite will see if we need to talk to a slave
+;    if not it will simply return
+;    if we _do_, it will store the slave no. in needwrite_slave
+;    and then pop and return
+;  nb register usage may need to be adjusted for wiring into mascan i2cm_...
+       mov_lfsr polarities_commanded_buffer, 0
+polarity_needwrite_loop
+       rlc_fw  PREINC1         ; W = 1RRRRRR? C=1  reverse command
+                               ; W = 0000001? C=0  not a reversers pic
+                               ; W = 0000000? C=0  no existing command
+                               ; W = 1000000? C=0  sentinel
+       bra_nn  polarity_needwrite_loop
+       bt_f_if0 STATUS, C
+       return ; we found the sentinel
+       ; we found a pic to tell to polarise:
+
+       mov_fw  FSR1L
+       add_lw  -polarities_commanded_buffer
+       mov_wf  needwrite_slave
+       pop
+       return
+
+;----------------------------------------------------------------------
+polarity_master_init
+       panic   morse_RIM
+       ; need to set up polarities_commanded_buffer
+
 ;======================================================================
  include final.inc
index 24acae590db00644862d2947f1d8c133825724d1..e70fae2a40cdd4c0e1ad3b484f44d9c7008dc345 100644 (file)
@@ -28,13 +28,13 @@ isr_high_save_fsr0  res     2 ; for isrh_fsr0_{save,restore}
 
 xdebug                 res     8
 
-polarities_waiting     res     1
- ; no of 11... entries in polarities_commanded_buffer, see reversers.asm
+needwrite_slave                res     1 ; 0 means we don't need to write to any slave
+                                 ; non-0 means at least this slave
+                                 ; and perhaps others
 
 qqtrislat_start equ 0x50
 qqtrislat_section udata qqtrislat_start
-qqtrislat_szln2 equ 4 ; ln2(buffer size)
-qqtrislat res 1<<qqtrislat_szln2
+qqtrislat res 15
 
 qqTRISA equ qqtrislat_start + 1
 qqTRISB equ qqtrislat_start + 2
@@ -72,13 +72,11 @@ ste_detbasel        equ 2 ; dk added to 11111bbb to make 0SSSSSSS; ie first-0xf8
 ste_lastd0     equ 3 ; d  } [o0]*  ie every bit is either 0 (for an
 ste_lastd1     equ 4 ; d  }        irrelevant bit) or o, meaning the
 ste_lastd2     equ 5 ; d  }        previously seen detection data bit
-ste_revcmd     equ 6 ; r  see reverse.asm
 ste_detmsgh    equ 7 ; dk 1 001 1 000 being 1 001 Y SSS
 ;             offset^   ^which module(s) use this data:
 ;                        G     global - for use by any code
 ;                        d     for master detection, see mascan.asm
 ;                        *     varies per bit
-;                        r     for polarity, see reverse.asm
 ;                        .k    entry is constant, created during init'n
 ; flags in ste_flags:
 stf_detect     equ 7 ; Gk  this is a detectors board