
Signal_Finished  IDNT                    ; Title of  Cyclic Section

    SECTION   Sect_Signal_Finished,4,C   ; Declare a noncommon code section.
                                         ; Align to Longwords.

***************************************************************************
*                                                                         *
*   Signal Finished Processing                         Rev. 17-JAN-1993   *
*                                                                         *
***************************************************************************

***************************************************************************
*                                                                         *
*  Signal Finished Operation section.                                     *
*     Send the Data Cable Driver Finished signal to the COMINT.           *
*     Wait for the COMINT Slave Ready signal to fall.                     *
*     Drop the Data Cable Driver Finished signal.                         *
*     Return to the calling routine.                                      *
*     If the Slave Ready signal does not fall in response to the Data     *
*       Cable Driver Finished signal within a period WaitSvRdDropTime     *
*       then put an error message on the VTC console screen and try to    *
*       shack loose the Slave Ready signal by taking Data Cable Driver    *
*       Finished  Hi-Low-Hi-Low and number of times.                      *
*                                                                         *
*  Control of the Trouble Warning Bits                                    *
*     none                                                                *
*                                                                         *
*  Control of the State Bits                                              *
*     none                                                                *
*                                                                         *
***************************************************************************


*************************************************************************
*       This section defines program-specific macros:                   *
*                                                                       *
*            RDIO:  Read bit from IRONICS I/O card and returns state    *
*            WRIO:  Write bit(s) to the IRONICS I/O card                *
*                                                                       *
*************************************************************************

RdIO    MACRO                         ; Bit Test the byte in the Ironics I/O
        BTST.B  \1,\2                 ; Port.  Z is set equal to the invers
        ENDM                          ; of bit \1 in the byte at adrs \2.


WrIO    MACRO                         ; Write byte to Ironics I/O Port.
        NOT.B   \1                    ; Complement data byte \1.
        MOVE.B  \1,\2                 ; Move to Ironics port at adrs \2.
        ENDM


*************************************************************************
*  Signal Finished Section:                                             *
*                                                                       *
*    Send the Data Cable Driver Finished signal to the COMINT.          *
*    Wait for the COMINT Slave Ready signal to fall.                    *
*    Drop the Data Cable Driver Finished signal.                        *
*    Return to the calling routine.                                     *
*      If the Slave Ready signal does not fall in response to the Data  *
*        Cable Driver Finished signal within a period WaitSvRdDropTime  *
*        then put an error message on the VTC console screen and try to *
*        shack loose the Slave Ready signal by taking Data Cable Driver *
*        Finished  Hi-Low-Hi-Low and number of times.                   *
*                                                                       *
*************************************************************************


Begin_Signal_Finished     Move.B  #Bit1High,D0         ; Send a Data Cable
                          WrIO    D0,Ironics_Port_2    ;   Driver Finished
                                                       ;   signal to the
                                                       ;   COMINT card.

        Move.L  WaitSvRdDropTime,D4    ; Initialize the register to wait
                                       ;   for the Slave Ready signal to drop
                                       ;   in response to the Data Cable
                                       ;   Driver Finished signal.


LookAgain   SubI.L  #$1,D4             ; Subtract 1 from the timer for how
                                       ;   long we will wait for Slave Ready
                                       ;   to drop in responce to Data Cable
                                       ;   Driver Finished.

            BEQ     SvRdStuck          ; If register D4 has decriminted to
                                       ;   zero then We have timed out waiting
                                       ;   for Slave Ready to drop in response
                                       ;   to the Data Cable Driver Finished.


        RdIO    #$00,Ironics_Port_3    ; Look at Slave Ready and wait for it
                                       ;   to go Low.  Slave Ready is Ironics
                                       ;   Port #3, Bit Number #0.

        BNE     LookAgain              ; If Slave Ready is still high then
                                       ;   keep waiting until it drops then.

                                       ; This is the normal exit when Slave
                                       ;   Ready dropped soon after Data Cable
                                       ;   Driver was set.
        Move.B  #AllBitsLow,D0         ; Drop the Data Cable Driver
        WrIO    D0,Ironics_Port_2      ;   Finished signal.

        RTS                            ; Return to the calling routine.



                                       ; This is the error exit when Slave
                                       ;   Ready did not drop within the time
                                       ;   out period after Data Cable Driver
                                       ;   was set.

SvRdStuck   PEA.L   GiveUpDrop         ; Timed out, Push message on stack.
            JSR     ChrStrgOut         ; Display Slave Ready did not drop in
                                       ;   response to Data Cable Driver
                                       ;   Finished signal time out message.

                                       ; Now try to shake loose the Slave
                                       ;   Ready signal by taking the Data
                                       ;   Cable Driver Finished line
                                       ;   Hi-Low-Hi-Low a number of times.

        Move.B  #AllBitsLow,D0         ; Drop the Data Cable Driver
        WrIO    D0,Ironics_Port_2      ;   Finished signal.
        Move.B  #Bit1High,D0           ; Send a Data Cable Driver Finished
        WrIO    D0,Ironics_Port_2      ;   signal to the COMINT card.

        Move.B  #AllBitsLow,D0         ; Drop the Data Cable Driver
        WrIO    D0,Ironics_Port_2      ;   Finished signal.
        Move.B  #Bit1High,D0           ; Send a Data Cable Driver Finished
        WrIO    D0,Ironics_Port_2      ;   signal to the COMINT card.

        Move.B  #AllBitsLow,D0         ; Drop the Data Cable Driver
        WrIO    D0,Ironics_Port_2      ;   Finished signal.

                                       ; Ok we have put out an error message
                                       ;   and tried to shake loose Slave
                                       ;   Ready so now exit.
        RTS                            ; Return to the calling routine.




*************************************************************************
*  Define Constants:                                                    *
*                                                                       *
*  Data used to send messages to the 68k terminal screen.               *
*                                                                       *
*************************************************************************

              ALIGN   4                ; Align to Longword Address.


GiveUpDrop    DC.B    35,$0D,$0A,'  The Slave Ready did not drop. ',$0A



*************************************************************************
*  Define Constants:                 External References                *
*                                                                       *
*************************************************************************

       XDEF   Begin_Signal_finished                 ; Export this symbol
                                                    ; to other modules.

       XREF   Ironics_port_2,Ironics_port_3         ; Symbols referenced
       XREF   AllBitsLow,Bit1High                   ; in this program
       XREF   WaitSvRdDropTime                      ; module but defined
       XREF   ChrStrgOut                            ; in another module
                                                    ; Main_Symbols.Include

       END

