z8536Timer.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:19k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* z8536Timer.c - Z8536 timer library */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. #include "copyright_wrs.h"
  4. /*
  5. modification history
  6. --------------------
  7. 01i,20dec96,dat  fixed SPR 4274, sysTimestampLock, didn't do a lock.
  8. 01h,23sep96,dat  merged with timestamp driver.
  9. 01g,11jul96,wlf  doc: cleanup.
  10. 01f,06jun96,wlf  doc: cleanup.
  11. 01e,09aug95,kkk  fixed I960 warnings. (spr# 4177)
  12. 01d,06jan93,dzb  removed sysClk1Int().
  13. 01c,07dec92,ccc  added sysCioReset() routine to reset specified device.
  14. 01b,20oct92,ccc  added volatile to register pointer.
  15. 01a,28aug92,caf  moved clock routines from ver.01p of hkv30/sysLib.c, ansified.
  16. */
  17. /*
  18. DESCRIPTION
  19. This library contains routines to manipulate the timer functions on the
  20. Zilog Z8536.  This library handles both the system clock and the auxiliary
  21. clock functions.
  22. The macros SYS_CLK_RATE_MIN, SYS_CLK_RATE_MAX, AUX_CLK_RATE_MIN, and
  23. AUX_CLK_RATE_MAX must be defined to provide parameter checking for the
  24. sys[Aux]ClkRateSet() routines.
  25. The macros ZCIO_CNTRL_ADRS and ZCIO_HZ must also be defined to indicate the
  26. control register address and clock frequency of the Z8536, respectively.
  27. The system clock is the ZCIO counter/timer 3.
  28. The auxiliary clock is the ZCIO counter/timer 2.
  29. The timestamp clock is the ZCIO counter/timer 1.
  30. SEE ALSO
  31. .I "ZCIO Counter/Timer and Parallel I/O Unit Technical Manual"
  32. */
  33. /* includes */
  34. #include "drv/timer/timestampDev.h"
  35. /* locals */
  36. LOCAL FUNCPTR sysClkRoutine           = NULL;
  37. LOCAL int     sysClkArg               = NULL;
  38. LOCAL int     sysClkTicksPerSecond    = 60;
  39. LOCAL BOOL    sysClkConnected         = FALSE;
  40. LOCAL int     sysClkRunning           = FALSE;
  41. LOCAL FUNCPTR sysAuxClkRoutine        = NULL;
  42. LOCAL int     sysAuxClkArg            = NULL;
  43. LOCAL int     sysAuxClkTicksPerSecond = 60;
  44. LOCAL BOOL    sysAuxClkConnected      = FALSE;
  45. LOCAL int     sysAuxClkRunning        = FALSE;
  46. #ifdef INCLUDE_TIMESTAMP
  47. #define ZCIO_MAX_TIME_CNST 0x10000
  48. LOCAL void sysTimestampInt (void);
  49. LOCAL FUNCPTR sysTimestampRoutine     = NULL;
  50. LOCAL int sysTimestampArg         = NULL;
  51. LOCAL BOOL sysTimestampConnected   = FALSE;
  52. LOCAL int sysTimestampRunning     = FALSE;
  53. #endif /*INCLUDE_TIMESTAMP*/
  54.      
  55. /******************************************************************************
  56. *
  57. * sysCioReset - z8536 reset
  58. *
  59. * This routine resets the specified z8536.
  60. *
  61. * NOMANUAL
  62. */
  63. void sysCioReset
  64.     (
  65.     volatile UINT8 *pCio /* cio to reset */
  66.     )
  67.     {
  68.     volatile UINT8 temp;
  69.     int delay;
  70.     temp  = *pCio; /* see CIO manual sec 2.3 */
  71.     *pCio = ZERO;
  72.     temp  = *pCio;
  73.     *pCio = ZCIO_MCC; /* master config control */
  74.     *pCio = ZERO;
  75.     *pCio = ZCIO_MIC; /* master interrupt control */
  76.     *pCio = ZCIO_MIC_RESET; /* device RESET */
  77.     for (delay = 0; delay < 1000; delay++)
  78. ; /* allow reset to complete */
  79.     *pCio = ZCIO_MIC;
  80.     *pCio = ZERO;
  81.     }
  82. /*******************************************************************************
  83. *
  84. * sysClkConnect - connect a routine to the system clock interrupt
  85. *
  86. * This routine specifies the interrupt service routine to be called at each
  87. * clock interrupt.  Normally, it is called from usrRoot() in usrConfig.c to
  88. * connect usrClock() to the system clock interrupt.  It also connects the clock
  89. * error interrupt service routine.
  90. *
  91. * RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.
  92. *
  93. * SEE ALSO: intConnect(), usrClock(), sysClkEnable()
  94. */
  95. STATUS sysClkConnect
  96.     (
  97.     FUNCPTR routine,    /* routine called at each system clock interrupt */
  98.     int arg             /* argument with which to call routine           */
  99.     )
  100.     {
  101.     sysHwInit2 ();      /* XXX for now -- needs to be in usrConfig.c */
  102.     sysClkRoutine = routine;
  103.     sysClkArg = arg;
  104.     sysClkConnected = TRUE;
  105.     return (OK);
  106.     }
  107. /*******************************************************************************
  108. *
  109. * sysClkInt - handle a system clock interrupt
  110. *
  111. * This routine handles a system clock interrupt.  It acknowledges the
  112. * interrupt and calls the routine installed by sysClkConnect().
  113. */
  114. LOCAL void sysClkInt (void)
  115.     {
  116.     /* acknowledge the interrupt */
  117.     *ZCIO_CNTRL_ADRS = ZCIO_CT3CS; /* C/T 3 Command and Status */
  118.     *ZCIO_CNTRL_ADRS = ZCIO_CS_CLIPIUS | /* Clear IP and IUS */
  119.        ZCIO_CS_GCB; /* Gate Command Bit */
  120.     if (sysClkRoutine != NULL)
  121. (*sysClkRoutine) (sysClkArg); /* call system clock service routine */
  122.     }
  123. /*******************************************************************************
  124. *
  125. * sysClkDisable - turn off system clock interrupts
  126. *
  127. * This routine disables system clock interrupts.
  128. *
  129. * RETURNS: N/A
  130. *
  131. * SEE ALSO: sysClkEnable()
  132. */
  133. void sysClkDisable (void)
  134.     {
  135.     if (sysClkRunning)
  136.         {
  137. /* disable interrupts */
  138. *ZCIO_CNTRL_ADRS = ZCIO_CT3CS; /* C/T 3 Command and Status */
  139. *ZCIO_CNTRL_ADRS = ZCIO_CS_CLIE; /* Clear Interrupt Enable */
  140. sysClkRunning = FALSE;
  141.         }
  142.     }
  143. /*******************************************************************************
  144. *
  145. * sysClkEnable - turn on system clock interrupts
  146. *
  147. * This routine enables system clock interrupts.
  148. *
  149. * RETURNS: N/A
  150. *
  151. * SEE ALSO: sysClkConnect(), sysClkDisable(), sysClkRateSet()
  152. */
  153. void sysClkEnable (void)
  154.     {
  155.     volatile UINT8 *cioCtl;
  156.     ULONG  tc;    /* time constant */
  157.     if (!sysClkRunning)
  158. {
  159. cioCtl = ZCIO_CNTRL_ADRS;
  160. /* set time constant */
  161. tc = ZCIO_HZ / sysClkTicksPerSecond;
  162. *cioCtl = ZCIO_CT3TCMSB;             /* C/T 3 Time Const (MS Byte) */
  163. *cioCtl = (UINT8) MSB(tc);
  164. *cioCtl = ZCIO_CT3TCLSB;             /* C/T 3 Time Const (LS Byte) */
  165. *cioCtl = (UINT8) LSB(tc);
  166. /* clear and start timer */
  167. *cioCtl = ZCIO_CT3CS;                /* C/T 3 Command and Status */
  168. *cioCtl = ZCIO_CS_CLIPIUS;           /* Clear IP and IUS */
  169. *cioCtl = ZCIO_CT3CS;                /* C/T 3 Command and Status */
  170. *cioCtl = ZCIO_CS_SIE                /* Set Interrupt Enable */
  171. | ZCIO_CS_GCB                /* Gate Command Bit */
  172. | ZCIO_CS_TCB;               /* Trigger Command Bit */
  173. sysClkRunning = TRUE;
  174. }
  175.     }
  176. /*******************************************************************************
  177. *
  178. * sysClkRateGet - get the system clock rate
  179. *
  180. * This routine returns the system clock rate.
  181. *
  182. * RETURNS: The number of ticks per second of the system clock.
  183. *
  184. * SEE ALSO: sysClkEnable(), sysClkRateSet()
  185. */
  186. int sysClkRateGet (void)
  187.     {
  188.     return (sysClkTicksPerSecond);
  189.     }
  190. /*******************************************************************************
  191. *
  192. * sysClkRateSet - set the system clock rate
  193. *
  194. * This routine sets the interrupt rate of the system clock.
  195. * It is called by usrRoot() in usrConfig.c.
  196. *
  197. * NOTE: The valid range for the system clock is 38 to 10000
  198. * ticks per second.
  199. *
  200. * RETURNS: OK, or ERROR if the tick rate is invalid or the timer cannot be set.
  201. *
  202. * SEE ALSO: sysClkEnable(), sysClkRateGet()
  203. */
  204. STATUS sysClkRateSet
  205.     (
  206.     int ticksPerSecond  /* number of clock interrupts per second */
  207.     )
  208.     {
  209.     if (ticksPerSecond < SYS_CLK_RATE_MIN || ticksPerSecond > SYS_CLK_RATE_MAX)
  210.         return (ERROR);
  211.     sysClkTicksPerSecond = ticksPerSecond;
  212.     if (sysClkRunning)
  213. {
  214. sysClkDisable ();
  215. sysClkEnable ();
  216. }
  217.     return (OK);
  218.     }
  219. /*******************************************************************************
  220. *
  221. * sysAuxClkConnect - connect a routine to the auxiliary clock interrupt
  222. *
  223. * This routine specifies the interrupt service routine to be called at each
  224. * auxiliary clock interrupt.  It does not enable auxiliary clock
  225. * interrupts.
  226. *
  227. * RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.
  228. *
  229. * SEE ALSO: intConnect(), sysAuxClkEnable()
  230. */
  231. STATUS sysAuxClkConnect
  232.     (
  233.     FUNCPTR routine,    /* routine called at each aux clock interrupt */
  234.     int arg             /* argument with which to call routine        */
  235.     )
  236.     {
  237.     sysAuxClkRoutine = routine;
  238.     sysAuxClkArg = arg;
  239.     sysAuxClkConnected = TRUE;
  240.     return (OK);
  241.     }
  242. /*******************************************************************************
  243. *
  244. * sysAuxClkInt - handle an auxiliary clock interrupt
  245. *
  246. * This routine handles an auxiliary clock interrupt.  It acknowledges the
  247. * interrupt and calls the routine installed by sysAuxClkConnect().
  248. *
  249. * RETURNS: N/A
  250. */
  251. LOCAL void sysAuxClkInt (void)
  252.     {
  253.     /* acknowledge the interrupt */
  254.     *ZCIO_CNTRL_ADRS = ZCIO_CT2CS;          /* C/T 2 Command and Status */
  255.     *ZCIO_CNTRL_ADRS = ZCIO_CS_CLIPIUS      /* Clear IP and IUS */
  256.   | ZCIO_CS_GCB;         /* Gate Command Bit */
  257.     /* call auxiliary clock service routine */
  258.     if (sysAuxClkRoutine != NULL)
  259. (*sysAuxClkRoutine) (sysAuxClkArg);
  260.     }
  261. /*******************************************************************************
  262. *
  263. * sysAuxClkDisable - turn off auxiliary clock interrupts
  264. *
  265. * This routine disables auxiliary clock interrupts.
  266. *
  267. * RETURNS: N/A
  268. *
  269. * SEE ALSO: sysAuxClkEnable()
  270. */
  271. void sysAuxClkDisable (void)
  272.     {
  273.     if (sysAuxClkRunning)
  274.         {
  275. /* disable interrupts */
  276. *ZCIO_CNTRL_ADRS = ZCIO_CT2CS; /* C/T 2 Command and Status */
  277. *ZCIO_CNTRL_ADRS = ZCIO_CS_CLIE;   /* Clear Interrupt Enable */
  278. sysAuxClkRunning = FALSE;
  279.         }
  280.     }
  281. /*******************************************************************************
  282. *
  283. * sysAuxClkEnable - turn on auxiliary clock interrupts
  284. *
  285. * This routine enables auxiliary clock interrupts.
  286. *
  287. * RETURNS: N/A
  288. *
  289. * SEE ALSO: sysAuxClkDisable()
  290. */
  291. void sysAuxClkEnable (void)
  292.     {
  293.     volatile UINT8 *cioCtl;
  294.     ULONG  tc;             /* time constant */
  295.     if (!sysAuxClkRunning)
  296.         {
  297. cioCtl = ZCIO_CNTRL_ADRS;
  298. /* set time constant */
  299. tc = ZCIO_HZ / sysAuxClkTicksPerSecond;
  300. *cioCtl = ZCIO_CT2TCMSB;             /* C/T 2 Time Const (MS Byte) */
  301.         *cioCtl = (UINT8) MSB(tc);
  302. *cioCtl = ZCIO_CT2TCLSB;             /* C/T 2 Time Const (LS Byte) */
  303.         *cioCtl = (UINT8) LSB(tc);
  304. /* clear and start timer */
  305. *cioCtl = ZCIO_CT2CS;                /* C/T 2 Command and Status */
  306. *cioCtl = ZCIO_CS_CLIPIUS;           /* Clear IP and IUS */
  307. *cioCtl = ZCIO_CT2CS;                /* C/T 2 Command and Status */
  308. *cioCtl = ZCIO_CS_SIE                /* Set Interrupt Enable */
  309. | ZCIO_CS_GCB                /* Gate Command Bit */
  310. | ZCIO_CS_TCB;               /* Trigger Command Bit */
  311. sysAuxClkRunning = TRUE;
  312. }
  313.     }
  314. /*******************************************************************************
  315. *
  316. * sysAuxClkRateGet - get the auxiliary clock rate
  317. *
  318. * This routine returns the interrupt rate of the auxiliary clock.
  319. *
  320. * RETURNS: The number of ticks per second of the auxiliary clock.
  321. *
  322. * SEE ALSO: sysAuxClkEnable(), sysAuxClkRateSet()
  323. */
  324. int sysAuxClkRateGet (void)
  325.     {
  326.     return (sysAuxClkTicksPerSecond);
  327.     }
  328. /*******************************************************************************
  329. *
  330. * sysAuxClkRateSet - set the auxiliary clock rate
  331. *
  332. * This routine sets the interrupt rate of the auxiliary clock.
  333. * It does not enable auxiliary clock interrupts.
  334. *
  335. * RETURNS: OK, or ERROR if the tick rate is invalid or the timer cannot be set.
  336. *
  337. * SEE ALSO: sysAuxClkEnable(), sysAuxClkRateGet()
  338. */
  339. STATUS sysAuxClkRateSet
  340.     (
  341.     int ticksPerSecond  /* number of clock interrupts per second */
  342.     )
  343.     {
  344.     if (ticksPerSecond < AUX_CLK_RATE_MIN || ticksPerSecond > AUX_CLK_RATE_MAX)
  345.         return (ERROR);
  346.     sysAuxClkTicksPerSecond = ticksPerSecond;
  347.     if (sysAuxClkRunning)
  348. {
  349. sysAuxClkDisable ();
  350. sysAuxClkEnable ();
  351. }
  352.     return (OK);
  353.     }
  354. /*******************************************************************************
  355. *
  356. * sysClkErrInt - handle a clock error interrupt
  357. *
  358. * An error interrupt occurs because a timer interrupt
  359. * was not serviced before the next interrupt from the same timer
  360. * occurred.  One or more clock ticks have been lost.
  361. * An error interrupt is treated as a regular timer interrupt.
  362. *
  363. * NOTE:
  364. * The system clock is the ZCIO counter/timer 3.
  365. * The auxiliary clock is the ZCIO counter/timer 2.
  366. * The timestamp clock is the ZCIO counter/timer 1.
  367. */
  368. LOCAL void sysClkErrInt (void)
  369.     {
  370.     FAST UINT8  ctcs;           /* C/T Command and Status */
  371.     FAST volatile UINT8 *cioCtl = ZCIO_CNTRL_ADRS;
  372.     /* check if counter/timer 3 error set */
  373.     *cioCtl = ZCIO_CT3CS;
  374.     ctcs    = *cioCtl;
  375.     if (ctcs & (ZCIO_CS_IP | ZCIO_CS_ERR))
  376. sysClkInt ();
  377.     /* check if counter/timer 2 error set */
  378.     *cioCtl = ZCIO_CT2CS;
  379.     ctcs    = *cioCtl;
  380.     if (ctcs & (ZCIO_CS_IP | ZCIO_CS_ERR))
  381. sysAuxClkInt ();
  382.     /* check if counter/timer 1 error set */
  383.     *cioCtl = ZCIO_CT1CS;
  384.     ctcs    = *cioCtl;
  385.     if (ctcs & (ZCIO_CS_IP | ZCIO_CS_ERR))
  386. {
  387. #ifdef INCLUDE_TIMESTAMP
  388. sysTimestampInt ();
  389. #else
  390. /* acknowledge the clock interrupt */
  391. *cioCtl = ZCIO_CT1CS;             /* C/T 1 Command and Status */
  392. *cioCtl = ZCIO_CS_CLIPIUS         /* Clear IP and IUS */
  393. | ZCIO_CS_GCB;            /* Gate Command Bit */
  394. logMsg ("counter/timer 1 interruptn", 0, 0, 0, 0, 0, 0);
  395. #endif
  396. }
  397.     }
  398. #ifdef INCLUDE_TIMESTAMP
  399. /*******************************************************************************
  400. *
  401. * sysTimestampConnect - connect a routine to the stamp clock interrupt
  402. *
  403. * This routine specifies the interrupt service routine to be called at each
  404. * timestamp clock rollover interrupt.  It is also called from clock error
  405. * interrupt service routine.
  406. *
  407. * RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.
  408. *
  409. * SEE ALSO: intConnect(), sysTimestampEnable()
  410. */
  411. STATUS sysTimestampConnect
  412.     (
  413.     FUNCPTR routine,    /* routine called at each system clock interrupt */
  414.     int arg             /* argument with which to call routine           */
  415.     )
  416.     {
  417.     sysTimestampRoutine = routine;
  418.     sysTimestampArg = arg;
  419.     sysTimestampConnected = TRUE;
  420.     return (OK);
  421.     }
  422. /*******************************************************************************
  423. *
  424. * sysTimestampInt - handle a timestamp clock interrupt
  425. *
  426. * This routine handles a rollover timer interrupt.  It acknowledges the
  427. * interrupt and calls the routine installed by sysTimestampConnect().
  428. */
  429. LOCAL void sysTimestampInt (void)
  430.     {
  431.     /* acknowledge the interrupt */
  432.     *ZCIO_CNTRL_ADRS = ZCIO_CT1CS; /* C/T 3 Command and Status */
  433.     *ZCIO_CNTRL_ADRS = ZCIO_CS_CLIPIUS | /* Clear IP and IUS */
  434.        ZCIO_CS_GCB ; /* Gate Command Bit */
  435.     /* call system clock service routine */
  436.     if (sysTimestampRoutine != NULL)
  437. (*sysTimestampRoutine) (sysTimestampArg);
  438.     }
  439. /*******************************************************************************
  440. *
  441. * sysTimestampDisable - turn off timestamp clock without disabling interrupts
  442. *
  443. * This routine disables timestamp clock(it actually stops the counting
  444. * sequence).
  445. *
  446. * RETURNS: N/A
  447. *
  448. * SEE ALSO: sysTimestampEnable()
  449. */
  450. STATUS sysTimestampDisable (void)
  451.     {
  452.     volatile UINT8 *cioCtl = ZCIO_CNTRL_ADRS;
  453.     FAST UINT8 temp;
  454.     if (sysTimestampRunning)
  455.         {
  456. /* Stop counting  sequence */
  457.         *cioCtl = ZCIO_MCC;              /* Master Configuration Cntrl     */
  458.         temp = *cioCtl;                  /* get the configuration          */
  459.         *cioCtl = ZCIO_MCC;              /* Master Configuration Cntrl     */
  460.         *cioCtl = temp&(~ZCIO_MCC_CT1E); /* Disable the timer/count 1      */
  461. *cioCtl = ZCIO_CT1CS;     /* C/T 1 Command and Status */
  462. *cioCtl = ZCIO_CS_CLIPIUS;       /* CLear IP and IUS,  */
  463. sysTimestampRunning = FALSE;
  464.         }
  465.     return (OK);
  466.     }
  467. /*******************************************************************************
  468. *
  469. * sysTimestampEnable - turn on Timestamp clock
  470. *
  471. * This routine enables timer/count1 which used as Timestamp clock. It also
  472. * enables the interrupt for this timer/count.
  473. *
  474. * RETURNS: OK
  475. *
  476. * SEE ALSO: sysTimestampConnect(), sysTimestampDisable(),sysTimestampRateSet()
  477. */
  478. STATUS sysTimestampEnable (void)
  479.     {
  480.     volatile UINT8 *cioCtl = ZCIO_CNTRL_ADRS;
  481.     UINT8 temp;
  482.     if (!sysTimestampRunning)
  483. {
  484.         *cioCtl = ZCIO_MCC;              /* Master Configuration Cntrl     */
  485.         temp = *cioCtl;                  /* read the master configuration  */
  486.         *cioCtl = ZCIO_MCC;              /* Master Configuration Cntrl     */
  487.         *cioCtl = temp|ZCIO_MCC_CT1E;    /* enables the timer/count 1      */
  488. /* set time constant, zero constant equal to 0x10000 */
  489.         *cioCtl = ZCIO_CT1TCMSB;             /* C/T 1 Time Const (MS Byte) */
  490. *cioCtl = (UINT8) 0;
  491. *cioCtl = ZCIO_CT1TCLSB;             /* C/T 1 Time Const (LS Byte) */
  492. *cioCtl = (UINT8) 0;
  493. /* clear and start timer */
  494. *cioCtl = ZCIO_CT1CS;                /* C/T 1 Command and Status */
  495. *cioCtl = ZCIO_CS_CLIPIUS;           /* Clear IP and IUS */
  496. *cioCtl = ZCIO_CT1CS;                /* C/T 1 Command and Status */
  497. *cioCtl = ZCIO_CS_SIE                /* Set Interrupt Enable */
  498. | ZCIO_CS_GCB                /* Gate Command Bit */
  499. | ZCIO_CS_TCB;               /* Trigger Command Bit */
  500. sysTimestampRunning = TRUE;
  501. }
  502.     return (OK);
  503.     }
  504. /*******************************************************************************
  505. *
  506. * sysTimestampPeriod - get the period of the timer
  507. *
  508. * This routine returns the period of the timer in timestamp ticks
  509. *
  510. * RETURNS: The period of the timer.
  511. *
  512. * SEE ALSO: sysTimestampEnable(), sysTimestampFreq()
  513. */
  514. UINT32 sysTimestampPeriod (void)
  515.     {
  516.     return (ZCIO_MAX_TIME_CNST);
  517.     }
  518. /*******************************************************************************
  519. *
  520. * sysTimestampFreq - get the Timestamp clock output frequence
  521. *
  522. * This routine returns the output frequency of the timer, in timestamp ticks
  523. *
  524. * RETURNS: The number of ticks per second of the timestamp clock.
  525. *
  526. * SEE ALSO: sysTimestampEnable(), sysTimestampFreq()
  527. */
  528. UINT32 sysTimestampFreq (void)
  529.     {
  530.     return (ZCIO_HZ);  /* the frequency */
  531.     } 
  532. /*******************************************************************************
  533. *
  534. * sysTimestamp - get the current value of the timestamp counter
  535. *
  536. * This routine returns the current value of the timestamp counter.
  537. *
  538. * RETURNS: The current timestamp counter value.
  539. *
  540. * SEE ALSO: sysTimestampEnable(), sysTimestampFreq()
  541. */
  542. UINT32 sysTimestamp (void)
  543.     {
  544.     volatile UINT8 *cioCtl;
  545.     FAST UINT16 temp=0;
  546.     /* freeze and read current counter value */
  547.     cioCtl = ZCIO_CNTRL_ADRS;
  548.     *cioCtl = ZCIO_CT1CS;                /* C/T 1 Command and Status */
  549.     *cioCtl = ZCIO_CS_RCC |              /* freeze the counter value */
  550.               ZCIO_CS_GCB;               /* do not reset the Gate bit */
  551.  
  552.     *cioCtl = ZCIO_CT1CCMSB;             /* C/T 1 Current Count (MS Byte) */
  553.     temp = *cioCtl;
  554.     temp <<= 8;                   
  555.     *cioCtl = ZCIO_CT1CCLSB;            /* C/T 1 Current Count (LS Byte) */
  556.     temp |= *cioCtl;                   /* it also reset the ZCIO_CS_RCC bit*/
  557.     return (ZCIO_MAX_TIME_CNST-temp);  /* This is a count down timer */
  558.     }
  559. /*******************************************************************************
  560. *
  561. * sysTimestampLock - get the current value of the timestamp counter
  562. *
  563. * This routine returns the current value of the timestamp counter.
  564. *
  565. * RETURNS: The current timestamp counter value.
  566. *
  567. * SEE ALSO: sysTimestampEnable(), sysTimestampFreq()
  568. */
  569. UINT32 sysTimestampLock (void)
  570.     {
  571.     int lvl;
  572.     UINT32 result;
  573.     lvl = intLock ();
  574.     result = sysTimestamp ();
  575.     intUnlock (lvl);
  576.     return result;
  577.     }
  578. #endif