chiark / gitweb /
do not show plat edges as rails
[trains.git] / detpic / watchdog.asm
1 ;======================================================================
2 ; WATCHDOG TIMEOUTS
3
4   include common.inc
5
6   udata_acs
7 watchdog        res     1
8
9   code
10 ;----------------------------------------------------------------------
11 command_watchdog @
12         mov_fw  POSTINC0        ; W =           10011OOO
13         and_lw  0x07            ; W =           00000OOO
14         bra_nz  command_watchdog_bad
15         mov_fw  INDF0           ; W =           OMMMMMMM
16         bra_n   command_watchdog_bad
17         mov_wf  watchdog        ; watchdog =    OMMMMMMM
18
19         pinlat_ifl p0_booster_shutdown
20         call    cdu_on
21
22         goto    nmra_sendwatchdog_stop
23
24 command_watchdog_bad panic morse_WX
25
26 ;----------------------------------------------------------------------
27 watchdog_tickdiv @
28         tst_f_ifnz watchdog
29         dec_f_ifnz watchdog
30         return
31         ; oops, we've timed out
32
33         call    nmra_sendwatchdog_start
34         call    cdu_off
35         mov_lw  0x0d
36         goto    serial_addbyte
37
38 ;----------------------------------------------------------------------
39 watchdog_init @
40         clr_f   watchdog
41         mov_lfsr bufferw, 1
42
43 wdog_byte macro wdog_byte_v
44         mov_lw  wdog_byte_v
45         mov_wf  POSTINC1
46         endm
47
48         ; An extra idle byte:
49         set_f   POSTINC1        ; ff
50         ; Baseline Broadcast stop Forwards(I) non-Emergency S9.2 B l.98-
51         ; as computed by ./hostside-old -st bstop
52         set_f   POSTINC1        ; ff
53         set_f   POSTINC1        ; ff
54         wdog_byte               0x80
55         wdog_byte               0x87
56         wdog_byte               0x81
57         wdog_byte               0x61
58
59         return
60
61 ;======================================================================
62   include final.inc