return
;--------------------
-power_polarising_settling @
+power_polarising_nonetodo @
; idempotent
+ bs_f xdebug+6, 2
+ bt_f_if0 flags, flags_polarising
+ return
+ bs_f xdebug+6, 3
tst_f_ifnz settling
return
mov_lw settling_timeout / tick_us
mov_wf settling
+ bs_f xdebug+6, 4
return
;--------------------
power_polarising_tick @
+ bs_f xdebug+6, 6
tst_f_ifnz settling
dec_f_ifnz settling ; decrement if not zero
return ; return if not dec'd, or if decrement didn't make zero
; settle timeout complete:
+ bs_f xdebug+6, 7
bc_f flags, flags_polarising
+ pin_vh p0_booster_pwm
call nmra_restartmessage
bs_f INTCON, TMR0IE ; reenables NMRA interrupt
goto i2c_consider_restartread
; We have an interrupt:
;...
i2cm_interrupt_definite
+ bs_f xdebug+0, 5
mov_ff SSPSTAT, sspstat
mov_ff SSPCON1, sspcon1
mov_ff SSPCON2, sspcon2
; W slave number any
; slave any slave_number
; expects to return directly to main program (caller)
+ bs_f xdebug+0, 2
mov_wf slave
bs_f SSPCON2, SEN
m_start_or_restart
; At call On return
; State Idle/Reading-Wait Writing-Setup
; W slave number any
- mov_wf xdebug+3
- mov_ff st, xdebug+4
- set_f xdebug+5
+ bs_f xdebug+0, 1
tst_f_ifnz st
bra m_write_start_busy
mov_fw slave_next
bra_z m_stop
; ok, we want to read another:
- mov_wf xdebug+2
mov_wf slave
clr_f slave_next
bt_f_if0 st, st_writing ; because of i2cm_write_start ?
bs_f st, st_reading ; no, then we will want to read
bs_f SSPCON2, RSEN
- set_f xdebug+0
bra m_start_or_restart
;----------
call tick_init
call power_polarising_init
call power_fault_init
+ clr_f xdebug+0
return
;----------------------------------------
call tick_intrl
call nmra_serialrx_intrl
call power_fault_intrl
+ mov_ff PIR1, xdebug+2
+ mov_ff PIE1, xdebug+3
+ mov_ff IPR1, xdebug+4
+ mov_ff INTCON, xdebug+5
call serialtxfc_intrl
call serialtx_intrl
call points_local_intrl
call i2cm_intrl
+ bs_f xdebug+0, 5
panic morse_IL
;----------------------------------------------------------------------
; and so on until f for bit 5. (See polarity_do_here, below.)
;
; we accumulate (`gather') the `g' bits in t.
+ clr_f xdebug+0
+ clr_f xdebug+6
mov_lfsr polarity_cmds, 1
mov_fw POSTINC0 ; W = 10010RRR
mov_wf t ; t = 10010ggg
; if we _do_, it will put the slave no. in W, and then pop
; and branch to i2c_needwrite. See mascan.asm.
; nb register usage may need to be adjusted for wiring into mascan i2cm_...
+ bs_f xdebug+6, 0
mov_lfsr polarity_cmds, 0
polarity_needwrite_loop
rlc_fw PREINC0 ; W = 1RRRRRR? C=1 reverse command
bra polarity_needwrite_found
; we found the sentinel:
- bt_f_if0 flags, flags_polarising
- return
- goto power_polarising_settling
+ goto power_polarising_nonetodo
polarity_needwrite_found
+ bs_f xdebug+6, 1
mov_fw FSR0L
add_lw -polarity_cmds
pop
clr_f INDF0 ; we're about to write this
bra_n i2c_getwritebyte_yes
; no:
+ bs_f xdebug+0, 7
return
;======================================================================