stop_wait res 1 ; or otherwise count down
retry_wait res 1
+fault_spurious_count res 1
+
code
;======================================================================
bs_f INTCON3, INT1IE
clr_f stop_wait
clr_f retry_wait
+ clr_f fault_spurious_count
pin_h p0_booster_shutdown
pin_h p0_booster_userfault
; now we are Off
power_fault_intrl @
bt_f_if0 INTCON3, INT1IF
return
- ; we have a fault:
+ ; we may have a fault:
bc_f INTCON3, INT1IF
+ call portb_read
+ pin_inw_ifh p0_booster_overload
+ bra fault_isactual
+ ; spurious:
+
+ inc_f_ifz fault_spurious_count ; ++f.s._count == 0x00 ?
+ bs_f fault_spurious_count, 7 ; f.s._count = 0x80
+
+ intrl_handled_nostack
+
+;-----
+fault_isactual
pinlat_ifh p0_booster_shutdown
- return ; Off, Stopping or Persists - must have lost the race
+ bra faultintrl_noop
+ ; Off, Stopping or Persists - must have lost the race
; or flapped while we faffed. Well, never mind, it's
; off now and we're taking care of it. (If the host
; caused Off by OFF they can at worst send an OFF and
;--------------------
power_fault_tickdiv @
+ tst_f_ifnz fault_spurious_count
+ bra fault_spurious_tickdiv
+ ; in any case:
+fault_tickdiv_rest
tst_f_ifnz stop_wait
dec_f_ifnz stop_wait
return
pin_vh p0_booster_userfault
return
+;----------
+fault_spurious_tickdiv
+; does not return, instead continues with fault_tickdiv_rest
+ mov_lw 0xc1 ; SPURIOUS
+ call serial_addbyte
+
+ mov_fw fault_spurious_count
+ bra_n fault_spurious_tickdiv_isoverflow
+fault_spurious_tickdiv_writeamt
+ call serial_addbyte_another
+ clr_f fault_spurious_count
+ bra fault_tickdiv_rest
+
+;-----
+fault_spurious_tickdiv_isoverflow
+ mov_lw 0x7f
+ bra fault_spurious_tickdiv_writeamt
+
;--------------------
power_panichook @
pin_vh p0_booster_shutdown