;--------------------
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
; 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
- bs_f xdebug+0, 1
tst_f_ifnz st
bra m_write_start_busy
i2cm_intrl @
; handles i2c interrupt using i2cm_interrupt[_definite],
; according to the rules for <something>_intrl.
- bs_f xdebug+0, 3
- mov_ff PIR1, xdebug+1
bt_f_if0 PIR1, SSPIF
return
- bs_f xdebug+0, 4
call i2cm_interrupt_definite
intrl_handled_nostack
; end of list of calls to needwrite_<foo>
; no, if we're here, no-one wants to write:
- bs_f xdebug+0, 6
nextslave_nowrite
; no writing needed, we consider reading:
;----------
arrange_write
; wslave slave to write to
- bs_f xdebug+0, 0
bc_f cbyte, cbyte_halted
mov_fw wslave
mov_wf cwslave
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
goto power_polarising_nonetodo
polarity_needwrite_found
- bs_f xdebug+6, 1
mov_fw FSR0L
add_lw -polarity_cmds
pop