# File: reset_tlm_v03.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "reset_tlm_v03.ips"
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_PAGE - Page to be freed
#;    2) $IPRL_TLM_STATUS - Status of the reset operation
#;                              0 - Successful
#;                              1 - Failed
#;                           0xff - Reset not attempted
#; 
#; History:
#;    Written by Dnyanesh Mathur, 17-Oct-95
#;----------------------------------------------------------------
#;
#QSR_TLM_RESET::
#;
#    BRANCHIF R0081 &CKPAGE            ; HR OK => Continue Reset 
tcblock mbipcmd 0x0091 0x108B   0x015A 0x0051 0x1092 
#    SETREG   $IPRL_TLM_STATUS 0x00ff  ; Status Code = "RESET not 
tcblock mbipcmd 0x0091 0x108E   0x0140 0x1FFC 0x00FF 
#    RTNQUE                            ; HR NOK => Skip Reset
tcblock mbipcmd 0x0091 0x1091   0x01FA 
#;
#CKPAGE:
#    BRANCHNR 0x4000  &DOHRDINIT       ; Page 8 busy => Do Reset
tcblock mbipcmd 0x0091 0x1092   0x01A6 0x4000 0x1099 
#    BRANCHNR 0x4800  &DOHRDINIT       ; Page 9 Busy => Do Reset
tcblock mbipcmd 0x0091 0x1095   0x01A6 0x4800 0x1099 
#    RTNQUE                            ; No Page Busy => Exit
tcblock mbipcmd 0x0091 0x1098   0x01FA 
#
#DOHRDINIT:
#    SETREG   $IPRL_TLM_STATUS  0      ; Assume success
tcblock mbipcmd 0x0091 0x1099   0x0140 0x1FFC 0x0000 
#;
#    SETREGS  R552  6  1 0x0000  0x5800  0x00  0xCFFF 0xFF98
tcblock mbipcmd 0x0091 0x109C   0x01B2 0x0228 0x0006 0x0001 \
                                0x0000 0x5800 0x0000 0xCFFF \
                                0xFF98 
#    HRDINIT  R552
tcblock mbipcmd 0x0091 0x10A5   0x019C 0x0228 
#    SETREGS  R558  2  0x00001L
tcblock mbipcmd 0x0091 0x10A7   0x01B2 0x022E 0x0002 0x0001 \
                                0x0000 
#    START1HR 0x33  0x5800  R558       ; D/L P11 to free P8
tcblock mbipcmd 0x0091 0x10AC   0x0174 0x0033 0x5800 0x022E 
#;
#    COPYREG  R143  R552               ; Save Block Count
tcblock mbipcmd 0x0091 0x10B0   0x0142 0x008F 0x0228 
#    SETREG   R143  16                 ; Set Block count to 16
tcblock mbipcmd 0x0091 0x10B3   0x0140 0x008F 0x0010 
#    PURGELST R136                     ; While away 82 ms
tcblock mbipcmd 0x0091 0x10B6   0x0190 0x0088 
#    COPYREG  R552  R143               ; Restore Block Count
tcblock mbipcmd 0x0091 0x10B8   0x0142 0x0228 0x008F 
#;
#    BRANCHNR 0x4000 &ERREXT           ; P8 still busy => HR NOK
tcblock mbipcmd 0x0091 0x10BB   0x01A6 0x4000 0x10C2 
#    BRANCHNR 0x4800 &ERREXT           ; P8 still busy => HR NOK
tcblock mbipcmd 0x0091 0x10BE   0x01A6 0x4800 0x10C2 
#    RTNQUE
tcblock mbipcmd 0x0091 0x10C1   0x01FA 
#;
#ERREXT:
#    SETREG   $IPRL_TLM_STATUS   1
tcblock mbipcmd 0x0091 0x10C2   0x0140 0x1FFC 0x0001 
#    RTNQUE
tcblock mbipcmd 0x0091 0x10C5   0x01FA 
#
#=======================================================
#
# ENBQUE                ; Enable Queue
tcblock mbipldin 0x0136
#
#
return
#
#=======================================================
