NAME

progrmbl_clk - controls the real-time programmable clock

SYNOPSIS

#include <pclock_p.h>
#include <iotcl_p.h>
#include <stdio_p.h>
#include <signal_p.h>

FD dopen (path)
char *path;

int dclose (fildes)
FD fildes;

int dread (fildes, pbfr)
FD fildes;
unsigned *pbfr;

int dwrite (fildes, pbfr)
FD fildes;

int dioctl (fildes, cmd, arg)
FD fildes;
int cmd;
struct pclk_cs *arg;

ck_start(fildes)
FD fildes;

ck_latch(fildes)
FD fildes;

cknovf(fildes)
FD fildes;

ck_stop(fildes)
FD fildes;

DESCRIPTION

dopen disables the programmable clock interrupts, clears the interrupt flags, sets the clock mode and rate to 0 and returns a file descriptor to be used to control, read, write and close the device. path points to a string "/dev/ck X " where X is the minor device number of the board, as specified in the configuration.

dclose disables the programmable clock interrupts, clears the interrupt flags, sets the clock mode and rate to 0 and returns 0.

dread stores the previously latched 16-bit clock buffer value in the address passed as pbfr and returns 0.

dwrite initializes the clock buffer so that the clock overflows after counting the number of ticks passed in the location pointed to by pbfr. It does this by storing the twos complement of the value passed in the clock buffer. Note that it does not affect the control-status register; it does not start the clock.

dioctl serves to read and write the status of the programmable clock specified by the descriptor fildes. When the argument cmd is SETP, then the values specified in the structure pclk_cs pointed to by argument arg are written into the control-status register of the clock. When the argument cmd is GETP, then the control-status register, the mode and the rate of the clock are stored in the structure pclk_cs pointed to by arg. Both calls use the structure defined in pclock_p.h:

struct pclk_cs {
  unsigned  ck_flags;
  char      ck_mode;
  char      ck_rate;
};
The ck_flags field of the argument structure contains several bits which program the clock. The symbolic valuse which are defined in pclock_p.h and are relevant to the user include:
IENABLE		0000100	enable interrupt on overflow	R/W
FLG_OVF		0000200	flag set on overflow		R/clear
SIM_ST1		0001000	simulate schmitt trigger 1	W only
SIM_ST2		0002000	simulate schmitt trigger 2	W only
FLG_OVRRUN	0010000	error: flag overflow overrun	R only
ST2_GO		0020000	st2 starts clock running	R/W
IENABLE_ST2	0040000	interrupt on st2		R/W
FLG_ST2		0100000	flag schmitt trigger 2 input	R/clear
These bits are used to enable and disable the two interrupts, to read and clear the two flags, to simulate the schmitt trigger inputs, to enable the external start st2 signal and to check the error flag. The user must refer to the DEC LSI-11 manual for a complete description of the clock modes, rates and options. The ck_mode and ck_rate fields of the argument structure are used to select the clock mode and rate respectively. dioctl returns a value of 0 when the call is successful.

ck_start, ck_latch, ck_novf and ck_stop are macros that serve to start the clock, save its buffer and access the running count of clock overflows maintained by the device driver interrupt routine. All are invoked with the descriptor returned from the open routine as the sole argument. ck_start starts the clock without affecting the clock parameters. ck_latch simulates a schmitt trigger 2 input, which when the clock is in either mode 2 or 3, serves to copy the current clock buffer into a register that can be read using the read routine. ck_novf is the number of clock overflows since the clock parameters were set. ck_novf is set to zero whenever the clock dioctl routine is invoked with the argument of SETP. ck_stop stops the clock without affecting the clock parameters.

When the programmable clock interrupts on a buffer overflow, the signal SIGOVF is sent with the signal number, the file descriptor, and the current overflow count.

When schmitt trigger 2 interrupts, the signal SIGST2 is sent with the signal number, the file descriptor, and the clock buffer value.

FILES

/dev/ckX path name for programmable clock X.

SEE ALSO

Digital Equipment Corporation, Microcomputer Processors. 1978,

Digital Equipment Corporation, Microcomputer Processor Handbook. 1979,

signal(2P)

DIAGNOSTICS

If dopen is invoked with an illegal minor device number, it returns -1. If dclose, dread, dwrite or dioctl are passed illegal descriptors, a value of -1 is returned. If dioctl is passed an illegal cmd argument, a value of -1 is returned.