# File: reset_tlm.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/flight/src/reset_tlm_v08.src"
descr "Loads IP queue instructions"
#
# DSBQUE                ; Disable Queue
tcblock mbipldin 0x0154 
#
#=======================================================
#
#
#; RESET_TLM - Resets Telemetry output board to 
#;               i) halt current downlink or
#;              ii) Recover from a board hang.
#; 
#; Restrictions:
#;    1) Resets Prime Telemetry board only
#;    2) Resets only page 8 or 9
#;    3) A page must be initialised as list (8 byte EDAC) memory
#;       with it's parameters in IP registers 136-143.
#;
#; Side Effects:
#;    1) First 550 words of page 11 are clobbered.
#;    2) IP Registers 552-560 are clobbered.
#;
#; Parameters:
#;    1) $IPRL_TLM_STATUS - Status of the reset operation
#;                              0 - Successful
#;                              1 - Failed
#;                           0xff - Reset not attempted
#; 
#; History:
#;    Written by Dnyanesh Mathur, 17-Oct-95
#;    V01 -  9-Jan-96 Dnyanesh Mathur
#;       1. R81 set on exit. If board hang condition is detected R
#;          set to request savemode.
#;
#;    V07 -  4 Apr 96 Dnyanesh Mathur
#;       1. Purge page 12 for delay instead of 14.
#;       2. Increase delay time to 164ms from 82 ms.
#;----------------------------------------------------------------
#;
#QSR_TLM_RESET::
#;
#    BRANCHNE R0081   0   &SKIP_RESET  ; HR Not OK => Skip Reset 
tcblock mbipcmd 0x0091 0x0B80   0x01B0 0x0051 0x0000 0x0BBA 
#;
#CKPAGE:
#    BRANCHNR 0x4000  &DOHRDINIT       ; Page 8 busy => Do Reset
tcblock mbipcmd 0x0091 0x0B84   0x01A6 0x4000 0x0B8E 
#    BRANCHNR 0x4800  &DOHRDINIT       ; Page 9 Busy => Do Reset
tcblock mbipcmd 0x0091 0x0B87   0x01A6 0x4800 0x0B8E 
#;
#    SETREG   $IPRL_TLM_STATUS  0      ; Clear Error Status
tcblock mbipcmd 0x0091 0x0B8A   0x0140 0x1FFC 0x0000 
#    RTNQUE                            ; No Page Busy => Exit
tcblock mbipcmd 0x0091 0x0B8D   0x01FA 
#
#DOHRDINIT:
#;
#    SETREGS  R552  6  1 0x0000  0x5800  0x00  0xCFFF 0xFF98
tcblock mbipcmd 0x0091 0x0B8E   0x01B2 0x0228 0x0006 0x0001 \
                                0x0000 0x5800 0x0000 0xCFFF \
                                0xFF98 
#    HRDINIT  R552
tcblock mbipcmd 0x0091 0x0B97   0x019C 0x0228 
#    SETREGS  R558  2  0x00001L
tcblock mbipcmd 0x0091 0x0B99   0x01B2 0x022E 0x0002 0x0001 \
                                0x0000 
#    START1HR 0x33  0x5800  R558       ; D/L P11 to free P8 (or P9
tcblock mbipcmd 0x0091 0x0B9E   0x0174 0x0033 0x5800 0x022E 
#;
#    COPYREG  R159  R552               ; Save Block Count
tcblock mbipcmd 0x0091 0x0BA2   0x0142 0x009F 0x0228 
#    SETREG   R159  32                 ; Set Block count to 32
tcblock mbipcmd 0x0091 0x0BA5   0x0140 0x009F 0x0020 
#    PURGELST R152                     ; While away 164 ms
tcblock mbipcmd 0x0091 0x0BA8   0x0190 0x0098 
#    COPYREG  R552  R159               ; Restore Block Count
tcblock mbipcmd 0x0091 0x0BAA   0x0142 0x0228 0x009F 
#;
#    BRANCHNR 0x4000 &ERR_RESET        ; P8 still busy => HR NOK
tcblock mbipcmd 0x0091 0x0BAD   0x01A6 0x4000 0x0BC1 
#    BRANCHNR 0x4800 &ERR_RESET        ; P9 still busy => HR NOK
tcblock mbipcmd 0x0091 0x0BB0   0x01A6 0x4800 0x0BC1 
#;
#;----------------------------------------------------------------
#;
#FIN_RESET:
#    SETREG   R0081    0               ; Clear NOK flag
tcblock mbipcmd 0x0091 0x0BB3   0x0140 0x0051 0x0000 
#    SETREG   $IPRL_TLM_STATUS  0      ; No Error
tcblock mbipcmd 0x0091 0x0BB6   0x0140 0x1FFC 0x0000 
#    RTNQUE
tcblock mbipcmd 0x0091 0x0BB9   0x01FA 
#;
#SKIP_RESET:
#    SETREG   $IPRL_TLM_STATUS 0x00ff  ; Status Code = "RESET not 
tcblock mbipcmd 0x0091 0x0BBA   0x0140 0x1FFC 0x00FF 
#    ADDREGD  R0081  0xFFFF            ; R81 <- R81 - 1
tcblock mbipcmd 0x0091 0x0BBD   0x01BC 0x0051 0xFFFF 
#    RTNQUE                            ; HR NOK => Skip Reset
tcblock mbipcmd 0x0091 0x0BC0   0x01FA 
#
#ERR_RESET:
#    SETREG   $IPRL_TLM_STATUS   1     ; Set Status = "Error"
tcblock mbipcmd 0x0091 0x0BC1   0x0140 0x1FFC 0x0001 
#    SETREG   R0081              3     ; Set NOK flag
tcblock mbipcmd 0x0091 0x0BC4   0x0140 0x0051 0x0003 
#    SETREG   R0026              1     ; Request "Savemode"
tcblock mbipcmd 0x0091 0x0BC7   0x0140 0x001A 0x0001 
#    RTNQUE
tcblock mbipcmd 0x0091 0x0BCA   0x01FA 
#;================================================================
#=======================================================
#
# ENBQUE                ; Enable Queue
tcblock mbipldin 0x0136
#
#
return
#
#=======================================================
