-- Copyright (C) 1984  by Xerox Corporation. All rights reserved. 
-- WatchdogDicentra.mesa, HGM,  8-Jan-84  5:45:42

DIRECTORY
  DicentraInputOutput USING [IOAddress, Output],
  Inline USING [HighByte, LowByte],
  MultibusAddresses USING [timeout],
  Watchdog USING [];

 WatchdogDicentra: PROGRAM IMPORTS DicentraInputOutput, Inline EXPORTS Watchdog =
  BEGIN
  
  timeout: DicentraInputOutput.IOAddress = MultibusAddresses.timeout;
  
  Activate, Reactivate: PUBLIC PROCEDURE [seconds: CARDINAL] =
    BEGIN
    -- Cnt 1 runs at 12.8 microseconds.  12800ns*2↑16 => 838ms
    seconds ← seconds + seconds/6 + 1;
    DicentraInputOutput.Output[Inline.HighByte[seconds], timeout + 01AH];  -- Cnt 3 MSB
    DicentraInputOutput.Output[Inline.LowByte[seconds], timeout + 01BH];  -- Cnt 3 LSB
    DicentraInputOutput.Output[006H, timeout + 00CH];  -- Counter 3 Cntrl ← Trgr, Gate on
    END;
    
  Deactivate: PUBLIC PROCEDURE =
    BEGIN
    DicentraInputOutput.Output[002H, timeout + 00CH];  -- Counter 3 Cntrl ← Trgr, Gate off
    END;
    
  END.