NAME

clock - programmable clock user functions

SYNOPSIS

#include <clock_u.h>

ckwait(rate, dur)
int rate;
unsigned dur;

ckreset(date)
int rate;

ckstart

ckstop

ckpause (dur)
unsigned dur;

ckread (time)
unsigned *time;

cknovf

DESCRIPTION

ckwait
ckwait is for timing fixed intervals. It clears all clock paramters, sets the rate to rate , waits for the clock to count dur pulses, and returns. Allowable rates are as follows:
CKR_1US		1 microsecond
CKR_10US	10 microseconds
CKR_100US	100 microseconds
CKR_1MS		1 millisecond
CKR_10MS	10 milliseconds
CKR_ST1		Schmitt Trigger 1
CKR_LINE	Line Time Clock
ckreset
ckreset sets the rate to rate as specified above, enables the interrupt-on-overflow flag arranging to have the signal SIGOVF ignored, and clears the overflow count. The user may choose not to ignore the overflow signal by calling signal(2F) after calling ckreset and specifying an address of a function for catching that signal. Once the clock is started it will run continuously until explicitly turned off. After initializing the clock with ckreset , any of the following may access the clock.

ckstart, ckstop
ckstart and ckstop respectively start and stop the clock without affecting the other parameters.

ckpause
ckpause waits dur clock intervals without having to start and stop the clock.

ckread
ckread latches the current value of the clock counter into a register and returns it in the address passed as time.

cknovf
cknovf is the number of clock overflows since the last call to ckreset. It is important to know the overflow count when running the clock during events that last more than 65,535 clock intervals. (An alternative to keeping track of the overflows is to adjust the clock rate so that the event being timed lasts for less than 65,535 clock intervals).

_ckcs
_ckcs is macro that gives information such as rate, mode and whether the clock is running. For information about using and interpreting _ckcs see progrmbl_clk(4P) and your local systems person.

EXAMPLES

The following call generates a 250 millisecond delay:
ckwait(CKR_1MS, 250);
The following illustrates the use of ckreset and the clock macros:
unsigned time, otime;

ckreset(CKR_10MS); ckstart; . . . ckread(&time); otime = cknovf; . . . ckstop;

FILES

/dev/ck0

SEE ALSO

signal(2F) , prgrmbl_clk(4P).