/****************************************************************************/
/* Copyright 1992 to 1996 MBARI                                             */
/****************************************************************************/
/* Summary  : Timer library declarations for 80C196 micro-controller        */
/* Filename : timer.h                                                       */
/* Author   : Andrew Pearce                                                 */
/* Project  : Tiburon Microcontroller Applications                          */
/* Version  : 2.1                                                           */
/* Created  : 03/02/92                                                      */
/* Modified : 02/12/96                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: /usr/tiburon/.cvsroot/micro/h/timer.h,v 1.1.1.1 1997/05/02 17:15:42 pean Exp $
 * $Log: timer.h,v $
 * Revision 1.1.1.1  1997/05/02 17:15:42  pean
 * Initial release of the microcontroller software after Tiburon
 * Moolpool Dive to test IView, Lapboxes, modified Power can
 * GF/5V using bus capacitance mode.
 *
 * Revision 1.1  92/05/14  09:17:54  09:17:54  pean (Andrew Pearce 408-647-3746)
 * Initial revision
 *
*/
/****************************************************************************/

#ifndef TIMER_H
#define TIMER_H


typedef struct timer Timer;

struct timer
{
    Timer   *lst_next;                  /* Links to next and previous nodes */
    Timer   *lst_prev;

    Nat16     delay;                    /* Timer value in milliseconds      */
    Nat16     reloadDelay;              /* Reload value in milliseconds     */
    Nat16     status;                   /* Timer status                     */
    Void      (*routinePtr) ();         /* routine to call if timer expires */
    Int16     parameter;                /* parameter to pass to routine     */
};

typedef Timer *timerId;                 /* timer functions use ptr to struct*/

                                        /* Timer status field values        */
#define TIMER_INACTIVE      1           /* Timer inactive                   */
#define TIMER_ACTIVE        2           /* Timer is active                  */
#define TIMER_EXPIRED       3           /* Timer has expired                */

#ifdef __STDC__                         /* ANSI C function prototypes       */

Void initTimerChain( Void );

timerId timerCreate( Void );

Void timerStart(timerId timer, Nat16 delay, Void (*routinePtr) (), Int16 param);

Void timerRestart(Reg timerId timer, Nat16 delay);

Void timerCancel(Reg timerId timer);

Void timerDelete(Reg timerId timer);

Void timerEvent( Void );

Void timerReloadDelay(timerId timer, Nat16 reloadDelay);

#endif

#endif
