1 ;======================================================================
2 ; TRACK POWER AND SHORT CIRCUIT
6 settling_timeout equ 10000 ; us
13 ;======================================================================
14 ; POLARISING/SETTLING:
16 ; NMRA flag_p. settling Booster PWM
18 ; Normal running 0 0x00 mark
19 ; Polarising paused 1 0x00 space
20 ; Settling paused 1 >0, count down space
22 ; NMRA is paused by disabling timer 0 intr; when we restart,
23 ; we restart the current message.
25 ;----------------------------------------------------------------------
33 power_polarising_begin
36 bs_f flags, flags_polarising
41 power_polarising_settling
45 mov_lw settling_timeout / tick_us
52 dec_f_ifnz settling ; decrement if not zero
53 return ; return if not dec'd, or if decrement didn't make zero
54 ; settle timeout complete:
56 bc_f flags, flags_polarising
58 call nmra_restartmessage
60 goto i2c_consider_restartread
62 ;======================================================================
66 ; Shutdown CDU Fault timeout User Fault Next states
67 ; Off shutdown off stopped off On*, Fault+
68 ; On power-up on stopped off Fault, Off*
69 ; Fault shutdown off 500ms 1/2x50ms Retry
70 ; Retry power-up off 50ms on Persists, Off
71 ; Persists shutdown off 50ms on Retry
72 ; * = when host instructs
78 ; C 1 iff command is ON undefined
82 start nmra with empty buffers
92 ; from cebpic/nmra-stream.asm's setup
93 bcf PORTB,2,0 ; booster shutdown L
94 bcf TRISB,2,0 ; booster shutdown not-Z
96 bcf PORTB,0,0 ; user fault L or Z
105 ;======================================================================