/*
 * libtimer.h   Defines the public interface to the timing module.  The
 *              strategy is to implement a bank of "virtual timers" that do
 *              a callback on timeout.
 *
 * Copyright (c) 1993 by Siemens AG All rights reserved.
 *
 * $Header:   P:/VCS/FCCLIB/LIBTIMER.H_V   1.1   10 Dec 1993 12:40:30   ror  $
 *
 * -------------------------------- Changes -----------------------------------
 * 3/9/93   eah (1) Original code started.
 */

#ifndef __LIBTIMER_H__
#define __LIBTIMER_H__

/*********************
 * Public Data Types *
 *********************/

    /* A time (count of timer ticks) */

typedef unsigned long ticks_t;

    /*
     * A pointer to a timeout callback procedure
     */

#ifdef  FCC_STDC_STYLE

  typedef void (*TIMEOUT_CALLBACK) (void);

#else

  typedef void (*TIMEOUT_CALLBACK) ();

#endif

#ifdef  __C51__
#define FCCINTATTR  reentrant
#else
#define FCCINTATTR
#endif

/***************
 * Public data *
 ***************/

extern ticks_t FCC_timing_ticks;                    /* Current time in ticks */

/*****************************
 * Public Routine Prototypes *
 *****************************/

#ifdef  FCC_STDC_STYLE

  void FCC_timing_init (void);                  /* Set up the timing module */
  void FCC_timing_cleanup (void);               /* Clean up the timing module for exit */

  void FCC_timing_poll (void);                  /* Poll the timer */

  ticks_t FCC_timing_ticks_to_usecs (ticks_t ticks);  /* Cvt. ticks to us. */
  ticks_t FCC_timing_usecs_to_ticks (ticks_t usecs);  /* Cvt. us. to ticks */

  int FCC_timing_set_timeout (ticks_t ticks, TIMEOUT_CALLBACK callback) FCCINTATTR; /* Call *p at timeout */
  int FCC_timing_cancel_timeout (int timeout) FCCINTATTR;            /* Cancel timeout */

#else

  void FCC_timing_init ();                      /* Set up the timing module */
  void FCC_timing_cleanup ();                   /* Clean up the timing module for exit */

  void FCC_timing_poll ();                      /* Poll the timer */

  ticks_t FCC_timing_ticks_to_usecs ();         /* Cvt. ticks to us. */
  ticks_t FCC_timing_usecs_to_ticks ();         /* Cvt. us. to ticks */

  int FCC_timing_set_timeout () FCCINTATTR;      /* Call *p at timeout */
  int FCC_timing_cancel_timeout () FCCINTATTR;   /* Cancel timeout */

#endif

#endif  /* not defined (__LIBTIMER_H__) */
