From: ian Date: Fri, 23 Dec 2005 01:42:22 +0000 (+0000) Subject: go back to polarities_commanded_buffer; starting on needwrite_.... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=af57c197c034790e6fda05fc034bc2db1bfc59b3;p=trains.git go back to polarities_commanded_buffer; starting on needwrite_.... --- diff --git a/detpic/panic.asm b/detpic/panic.asm index 4908b29..151d0bc 100644 --- a/detpic/panic.asm +++ b/detpic/panic.asm @@ -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 diff --git a/detpic/reverse.asm b/detpic/reverse.asm index 892e535..7f2eb0f 100644 --- a/detpic/reverse.asm +++ b/detpic/reverse.asm @@ -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 +; _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 diff --git a/detpic/variables.asm b/detpic/variables.asm index 24acae5..e70fae2 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -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<