You are on page 1of 127

VxWorks Device Driver Guide for the Datum bc635/637 PCI Time Frequency Processor Card

Document No. VS-DRV-DATUMBC635 (for software release 1.0+)

October 12, 2000 Release 1.1

Revision History
Manual Release Level 1.0 1.1 Release Date 5/28/00 10/16/00 Comments Original Release Added sample code to ch6

Datum
1.0 PREFACE .............................................................................................................................................. 4 SCOPE.......................................................................................................................................................... 4 RELATED DOCUMENTS ................................................................................................................................ 4 2.0 OVERVIEW ......................................................................................................................................... 5 PRODUCT..................................................................................................................................................... 5 Time-of-day ............................................................................................................................................ 5 Flywheel Operation ................................................................................................................................ 5 External Event Timestamping................................................................................................................. 5 Time Coincidence Strobe........................................................................................................................ 5 Periodic or Heartbeat Pulse Train Generation...................................................................................... 5 HARDWARE CONFIGURATION ...................................................................................................................... 5 3.0 USING THE DEVICE DRIVER INTERFACE.................................................................................. 7 CREATING BC635 VXWORKS IOS DEVICES ................................................................................................ 7 DELETING A VXWORKS IOS DEVICE ........................................................................................................... 9 OPENING/CLOSING A BC635 IOS............................................................................................................... 10 READ AND WRITE OPERATIONS ................................................................................................................. 11 I/O CONTROLS .......................................................................................................................................... 12 SELTIMINGMODE ............................................................................................................................ 13 SELTCFORMAT ................................................................................................................................. 16 SELTIMEFORMAT............................................................................................................................ 19 SELTCMOD ........................................................................................................................................ 22 SETPROPDELAY ............................................................................................................................... 25 RDTIMETMREQ, RDTIMETM......................................................................................................... 28 RDTIMETVREQ, RDTIMETV........................................................................................................... 32 TIMEREQUEST.................................................................................................................................. 35 SETTIMETM....................................................................................................................................... 38 SETTIMETV ....................................................................................................................................... 40 SETYEAR ............................................................................................................................................ 42 SETPERIODIC.................................................................................................................................... 44 SELFREQUENCYOUT ...................................................................................................................... 46 CONTROLEVENT .............................................................................................................................. 48 RDEVENTTMREQ, RDEVENTM ..................................................................................................... 52 RDEVENTTVREQ, RDEVENTTV .................................................................................................... 57 EVENTREQUEST............................................................................................................................... 61 BC635_INT_WAITONEVENT........................................................................................................... 64 BC635_INT_WAITONPERIODIC ..................................................................................................... 67 BC635_INT_WAITON1PPS ............................................................................................................... 69 RDINTSTAT, SETINTSTAT .............................................................................................................. 71 SETGPSMDFLG................................................................................................................................. 74 REQGPSPACKET ............................................................................................................................... 76 SENDGPSPACKET............................................................................................................................. 79 MANREQGPSPACKET ...................................................................................................................... 81 BC635_INT_WAITONGPS................................................................................................................. 84 CONTROLSTROBE............................................................................................................................ 86 SETSTROBETM ................................................................................................................................. 89 SETSTROBETV .................................................................................................................................. 92 BC635_INT_WAITONSTROBE......................................................................................................... 95 4.0 TARGET CPU CONSIDERATIONS ................................................................................................ 99 5.0 SOFTWARE INSTALLATION ....................................................................................................... 100 6.0 EXAMPLE ......................................................................................................................................... 101

Datum BC635 PCI VxWorks Device Driver

3

3. Related Documents The following table lists the related documents referred to in this manual. Title VxWorks Programmer's Guide (Release 5.4) bc635/bc637 PCI/CPCI/PMC Time & Frequency Processor User's Guide (rev E) Author Wind River Systems Datum Date 1998 1999 Datum BC635 PCI VxWorks Device Driver 4 . refer to the VxWorks Programmer's Reference Guide.1. For information on the underlying VxWorks I/O System (IOS).0 Preface Scope This document describes the use of the Datum VxWorks driver for the bc635 PCI/PMC card.Datum 1. 5.

IRIG B.4. the TFP can be programmed to timestamp it and return the timestamp to the application.GPS time reference source. The bc635/637 TFP supportst he following features. This feature is typically used to implement an alarm function. 4. 5..The internal 10Mhz oscillator can keep time if the chosen time reference is lost. 3. Flywheel Operation If the time reference is lost by the TFP. Time-of-day Time-of-day may be captured on-demand where the time reference source may be: 1. unix time using struct timeval (located in sys/times.Battery backed on-board real-time clock. This driver operates under the VxWorks Operating System and is compatible with VxWorks 5. Time Coincidence Strobe The TFP may be programmed to generate a single strobe pulse of a 1 PPS strobe pulse at some later time.h)) or binary time (eg.3. Free Running . Time Code .. IRIG A or IEEE-1344 2. then the internal 10Mhz oscillator will continue to keep time based on the last valid time reference.h)). Note: GPS as time reference source is supported by hardware version bc635/637 PCI – 12083 only. Hardware Configuration There are no hardware configuration jumpers associated with this card Datum BC635 PCI VxWorks Device Driver 5 . Time may be read and set using decimal time (eg. unix time using struct tm (located in time. 1 PPS .Datum 2. External Event Timestamping If an external event occurs.0 Overview Product This driver controls the PCI bus version of the bc635 Time/Frequency Processor (TFP) as well as the bc637 (GPS option).External 1 Pulse Per Second input in conjunction with the internal 10Mhz oscillator.1 as well as VxWorks 5. GPS . Periodic or Heartbeat Pulse Train Generation The TFP can be programmed to generate a user-specified pulse train (also known as periodic or heartbeat). RTC .

Datum Register I/O and Interrupts This driver accesses the bc635/637 using 32 bit register reads and writes using standard VxWorks PCI bus access routines. The bc635/637 does generate interrupts and this driver processes those interrupts. Datum BC635 PCI VxWorks Device Driver 6 .

Under the BSP in use. 0x19) In the above sequence. Also. The bc635 driver must view the card addresses as seen from the CPU. the user should be familiar with the basic interface to these functions which are generically described in the VxWorks Programmer's Reference Guide. then the global variable bc635PciMemOffset is to be used to account for this. This is a one time only operation per boot of VxWorks.o sysBC635Init tfpDrv tfpDevInstall (0.0 Using the Device Driver Interface This section describes how to initialize and use the bc635 PCI card under the VxWorks IOS. If these addresses are not applicable to your BSP. The sysBC635Init function is a BSP specific routine that searches for a single instance of a PCI bc635 device and programs the PCI base address that the card is to respond to. It also programs the PCI Base Address Register 1 (BAR1) address as 0xFD041000. The tfpDrv routine initializes the TFP (Time/Frequency Processor) VxWorks driver into the VxWorks IOS. you need not call a routine like sysBC635Init. the object files sysBC635. If the BSP in use uses a fixed offset to view PCI addresses from the CPU.o and bc635. then you must set this variable. Refer to your VxWorks Board Support Packages (BSP) documentation for information on what interrupt numbers Datum BC635 PCI VxWorks Device Driver 7 . The tfpDevInstall routine initializes/installs a specific instance of a bc635 PCI card into the VxWorks IOS. This is one time only operation per boot of VxWorks. If you need to create a sysBC635Init routine specific to your BSP. then an alternative routine(s) must be used to program the BAR0/BAR1 addresses for your card.o ld < bc635. Once this is accomplished the user's application may invoke open.Datum 3. close. The first argument is the instance number of the card to install. Before continuing on with this manual. the BAR0/BAR1 addresses used may be addresses as seen from the PCI bus and not the CPU. The IOS calls used to invoke card operations are open. Creating bc635 VxWorks IOS Devices The following sequence of vxWorks calls will install a single instance of a bc635 PCI card into the VxWorks IOS. The second argument is the interrupt number assigned to the card. If these cards are not in use then this routine may be used as a guide for creation of a routine that will function for your specific BSP. Note that under the Motorola MV2604/2700. your BSP may automatically program BAR0/BAR1 addresses for all PCI devices installed. If so. close and ioctl. ioctl calls to operate the bc635 TFP (Time/Frequency Processor): -> -> -> -> -> ld < sysBC635. This routine has been tailored for the Motorola MV2600/2700 boards. This is a one time only operation per boot of vxWorks.o are loaded into RAM by the vxWorks ‘ld' function. this value is 0. This routine uses BSP based PCI programming routines to program the PCI Base Address Register 0 (BAR0) address for 0xFD040000.

0x19) -> tfpDevInstall (1. If there are two physical bc635 cards installed.Datum to use for PCI devices. -> tfpDevInstall (0. Datum BC635 PCI VxWorks Device Driver 8 . For example. then this routine will be called twice. The VxWorks IOS device names created for these cards will be “/tfp0” and “/tfp1” respectively. 0x23) These two calls will initialize the two cards (instance ‘0' and instance ‘1') into the VxWorks IOS where the cards will issue interrupts on interrupt numbers 0x19 and 0x23 respectively.

Host CPU: mvme2604 running VxWorks 5. PCI Bus Base Address of card: Interrupt number: 0x19 VxWorks IOS device name: /tfp0 -> tfpDevInstall (0. The following example initializes a bc635 PCI (PMC) card that is installed on an MVME2604 PowerPC VME Bus based Single Board Computer. OK(0) if initialization is successful. Specific bc635 PCI device to initialize into the IOS. ERROR if unsucessful. When installed in this cards lone PMC site.4. Datum BC635 PCI VxWorks Device Driver 9 . Interrupt number that the card will use to issue interrupts to VxWorks. 0x19) Deleting a VxWorks IOS device To delete a bc635 PCI VxWorks device. It is a matter of reading your VxWorks BSP documentation so as to discover what interrupt numbers are to be used.&tail) -> iosDevDelete(phdr) You may now re-invoke tfpDevInstall so as to create a “/tfp0” device without having to reboot vxWorks. An example invocation that results in “/tfp0” device being removed from the IOS is: -> tail=0 -> phdr=iosDevFind(“/tfp0”.Datum Table 1: bc635 PCI VxWorks Driver tfpDevInstall Parameters index interrupt number return integer (0 . there are a couple of vxWorks system calls to invoke.5). integer. the interrupt number the bc635 card will use is hard-wired to 0x19.

printErrno (errnoGet ()). int fd. Examples of these calls are listed below. 0)) == ERROR) { (void) printf (“open failed: “). The second and third arguments to the open function are not used by this driver. return (ERROR). /* open bc635 device */ if ((fd = open (“/tfp0”. Datum BC635 PCI VxWorks Device Driver 10 . close must be called. O_RDWR. } < perform ioctl operations here> /* close bc635 device */ (void) close (fd). This handle is then used when invoking ioctl.Datum Opening/Closing a bc635 IOS The function open is used to obtain an IOS handle for a bc635 device. To close the device after access has been completed. close functions.

Datum Read and Write Operations The IO functions read and write are not supported by this driver. Datum BC635 PCI VxWorks Device Driver 11 .

Datum I/O Controls The IOS routine ioctl is used to perform all user accessible TFP operations. What follows are usage descriptions of each I/O control operation. Datum BC635 PCI VxWorks Device Driver 12 .

SELTIMINGMODE Select time derivation source. The MODE_GPS is to be set when time is to be derived via GPS (Global Positioning System). It does this by extracting a 1 PPS from the time reference.h” Datum BC635 PCI VxWorks Device Driver 13 . IEEE-1344 is to be used as a time source. The following values for modeVal may be used:: MODE_TIMECODE(0) MODE_FREERUN(1) MODE_EXT1PPS(2) MODE_RTC(3) MODE_GPS(6) The MODE_TIMECODE is to be set when IRIG-A.Mode that time is based on. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. The card will synchronize its internal 10Mhz oscillator to the time reference (mode) selected. then the TFP is in flywheel mode and the internal 10Mhz oscillator is solely used to derive time. If synchronization is lost once achieved. EXAMPLE: The following example code performs the SELTIMINGMODE ioctl in the context of completely configuring the driver and card to derive time using IRIGB as the time reference source: : #include “vxWorks.h” #include “stdio. The MODE_EXT1PPS is to be set when an external device is providing a 1 pulse-per-second pulse via the external 1PPS input line. This operation will select the timing mode that the card is to use when determining time. The MODE_RTC is to be set when the on-board battery backed real-time clock is to be used as the time synchronization source. The MODE_FREERUN is to be set when the cards on-board 10Mhz oscillator is used as a reference. For this mode to operate you must be using a bc637 card and have a GPS antenna attached. IRIG-B.Datum SELTIMINGMODE COMMAND: PURPOSE: INPUTS: Type int Name/Description modeVal .

(void) close (fd). } /* tell card which type of timecode input to look for */ if (ioctl (fd. SELTCFORMAT. (void) close (fd). 0)) == ERROR) { (void) printf (“open of %s failed: “. } /* want to retrieve time in decimal format */ if (ioctl (fd. return (ERROR). MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). printErrno (errnoGet ()).h” #include “bc635. printErrno (errnoGet ()). } /* select time reference (will use IRIG-B input) */ if (ioctl (fd.get handle */ if ((fd = open (“/tfp0”. (void) close (fd). TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). 0. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). return (ERROR). “/bc635/0”).h” void test () { int fd. SELTIMEFORMAT. SELTIMINGMODE.Datum #include “ioLib. printErrno (errnoGet ()). /* open device . } /* tell card what type of timecode modulation to expect */ Datum BC635 PCI VxWorks Device Driver 14 . return (ERROR). return (ERROR). printErrno (errnoGet ()).

} /* ready to retrieve time using time retrieval ioctls */ }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 15 . } return (ERROR). return (ERROR). } /* assume no(0) time offset to compensate for */ if (ioctl (fd. 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “).Datum if (ioctl (fd. SETPROPDELAY. SELTCMOD. (void) close (fd). return (ERROR). printErrno (errnoGet ()). printErrno (errnoGet ()). (void) close (fd). MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “).

h” #include “stdio.get handle */ if ((fd = open (“/tfp0”. The following values for fmtVal may be used:: TC_IRIGA TC_IRIGB TC_IEEE The TC_IRIGA is to be set when IRIG-A is the expected timecode input. This operation will select the timecode format that the card is to use when the timing reference (mode) selected is MODE_TIMECODE (IRIG-A. IRIG-B or IEEE-3144).Datum SELTCFORMAT COMMAND: PURPOSE: INPUTS: Type int Name/Description fmtVal . SELTCFORMAT Select the time code format. /* open device . The TC_IRIGB is to be set when IRIG-B is the expectied timecode input.h” #include “bc635. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. EXAMPLE: The following example code performs the SELTCFORMAT ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source: #include “vxWorks. 0)) == ERROR) Datum BC635 PCI VxWorks Device Driver 16 .Timecode format to use. The TC_IEEE is to be set when IEEE-1344 is the expected timecode input. 0. This ioctl need only be called if MODE_TIMECODE had been set as the timing mode using the ioctl:SELTIMINGMODE.h” #include “ioLib.h” void test () { int fd.

SELTCMOD. (void) close (fd). printErrno (errnoGet ()). SELTIMINGMODE. MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “). SELTCFORMAT. (void) close (fd). (void) close (fd). } /* tell card what type of timecode modulation to expect */ if (ioctl (fd. printErrno (errnoGet ()). return (ERROR).Datum { (void) printf (“open of %s failed: “. TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). SELTIMEFORMAT. } /* tell card which type of timecode input to look for */ if (ioctl (fd. return (ERROR). } /* want to retrieve time in decimal format */ if (ioctl (fd. (void) close (fd). printErrno (errnoGet ()). “/bc635/0”). printErrno (errnoGet ()). } /* assume no(0) time offset to compensate for */ Datum BC635 PCI VxWorks Device Driver 17 . return (ERROR). TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). printErrno (errnoGet ()). return (ERROR). MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). } /* select time reference (will use IRIG-B input) */ if (ioctl (fd. return (ERROR).

(void) close (fd).Datum if (ioctl (fd. } /* ready to retrieve time using time retrieval ioctls */ }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 18 . printErrno (errnoGet ()). 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). SETPROPDELAY. } return (ERROR). return (ERROR).

h” #include “stdio. then you must use the ioctl:RDTIMETV or ioctl:RDTIMETVREQ to retrieve time and the ioctl:SETTIMETV to set time. #include “vxWorks. EXAMPLE: The following example code performs the SELTIMEFORMAT ioctl in the context of completely configuring the driver and card to derive time using IRIGB as the time reference source and to set/read time in the TIME_DECIMAL format. the caller must set and retrieve time using the format selected. This operation will select the time format that the card will use when delivering the current time to the caller via subsequent ioctls.59) hours (0 . The following values for fmtVal may be used:: TIME_DECIMAL TIME_BINARY The TIME_DECIMAL format results in a time breakdown of the following: seconds (0 .Time format used when reading time.Datum SELTIMEFORMAT COMMAND: PURPOSE: INPUTS: Type int Name/Description fmtVal . January 1.23) days (0 .999) If TIME_DECIMAL is selected. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. SELTIMEFORMAT Select how time is formatted when delivered to the caller.2050) usecs (0 .h” Datum BC635 PCI VxWorks Device Driver 19 .999) hnsecs (hunreds of nsecs (0 .59) minutes (0 .9. then you must use the ioctl:RDTIMETM or ioctl:RDTIMETMREQ to retrieve time and the ioctl:SETTIMETM to set time.999. If this time format is selected. The TIME_BINARY format results in time representation as the number of seconds from midnight.999. Once set.366 year (1970 .h” #include “ioLib. 1970 (UTC).

} /* tell card which type of timecode input to look for */ if (ioctl (fd. TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). return (ERROR). return (ERROR). SELTCMOD.Datum #include “bc635. SELTIMEFORMAT. } /* tell card what type of timecode modulation to expect */ if (ioctl (fd. “/bc635/0”). printErrno (errnoGet ()). (void) close (fd). SELTIMINGMODE. printErrno (errnoGet ()). return (ERROR). } /* select time reference (will use IRIG-B input) */ if (ioctl (fd. 0)) == ERROR) { (void) printf (“open of %s failed: “. (void) close (fd).get handle */ if ((fd = open (“/tfp0”. /* open device .h” void test () { int fd. printErrno (errnoGet ()). MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). printErrno (errnoGet ()). TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). 0. return (ERROR). SELTCFORMAT. (void) close (fd). MOD_AM) == ERROR) Datum BC635 PCI VxWorks Device Driver 20 . } /* want to retrieve time in decimal format */ if (ioctl (fd.

(void) close (fd). } /* assume no(0) time offset to compensate for */ if (ioctl (fd. SETPROPDELAY. return (ERROR). printErrno (errnoGet ()). (void) close (fd).Datum { (void) printf (“ioctl(SELTCMOD) failed: “). } return (ERROR). return (ERROR). } /* ready to retrieve time using time retrieval ioctls */ }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 21 . 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). printErrno (errnoGet ()).

printErrno (errnoGet ()). RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.h” #include “bc635.Datum SELTCMOD COMMAND: PURPOSE: INPUTS: Type int Name/Description modVal . Datum BC635 PCI VxWorks Device Driver 22 .h” #include “ioLib.Timecode modulation format to expect. /* open device . The MOD_DCLS is to be selected when a DC level shift type of modulation is expected EXAMPLE: The following example code performs the SELTCMOD ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source and to set amplitude modulated sine wave as the modulation type. 0.h” #include “stdio. “/bc635/0”). IRIG-B. 0)) == ERROR) { (void) printf (“open of %s failed: “. #include “vxWorks.get handle */ if ((fd = open (“/tfp0”. IEEE1344). The following values for modVal may be used:: MOD_AM MOD_DCLS The MOD_AM is to be selected when an amplitude modulated sine wave is used. This operation will tell the card what timecode modulation type to expect when the timing mode selected is MODE_TIMECODE(IRIG-A.h” void test () { int fd. SELTCMOD Select timecode modulation type on the timecode input.

SELTIMEFORMAT. (void) close (fd). (void) close (fd). } /* select time reference (will use IRIG-B input) */ if (ioctl (fd. MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). printErrno (errnoGet ()). (void) close (fd). MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “). printErrno (errnoGet ()). return (ERROR). return (ERROR). return (ERROR). } /* tell card which type of timecode input to look for */ if (ioctl (fd. } /* want to retrieve time in decimal format */ if (ioctl (fd.Datum return (ERROR). TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). SETPROPDELAY. } /* assume no(0) time offset to compensate for */ if (ioctl (fd. SELTIMINGMODE. } /* tell card what type of timecode modulation to expect */ if (ioctl (fd. SELTCMOD. (void) close (fd). SELTCFORMAT. printErrno (errnoGet ()). TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). Datum BC635 PCI VxWorks Device Driver 23 . return (ERROR). printErrno (errnoGet ()).

(void) close (fd). } /* ready to retrieve time using time retrieval ioctls */ }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 24 . return (ERROR).Datum printErrno (errnoGet ()). } return (ERROR).

“/bc635/0”). The propagation delay in this example is -15 usecs. SELTIMINGMODE.h” #include “bc635.h” #include “stdio. The value is set in terms of microseconds and has a range of -9. /* open device .999.h” #include “ioLib. MODE_TIMECODE) == ERROR) { EXAMPLE: Datum BC635 PCI VxWorks Device Driver 25 . #include “vxWorks. Value may be negative.Value in usecs to offset derived time. } /* select time reference (will use IRIG-B input) */ if (ioctl (fd. SETPROPDELAY Set propagation delay compensation.999 usecs. return (ERROR). printErrno (errnoGet ()). RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.get handle */ if ((fd = open (“/tfp0”. this ioctl is used to take that delay into account when the TFP is to derive time.999 to 9.Datum SETPROPDELAY COMMAND: PURPOSE: INPUTS: Type int Name/Description propVal .h” void test () { int fd.999. The following example code performs the SETPROPDELAY ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source. This operation may be used to set a time offset relative to the reference input. If there is a known time delay due to cable length between the time reference generator and the TFP. 0)) == ERROR) { (void) printf (“open of %s failed: “. 0.

} /* tell card what type of timecode modulation to expect */ if (ioctl (fd. SELTIMEFORMAT. } Datum BC635 PCI VxWorks Device Driver 26 . SELTCFORMAT. printErrno (errnoGet ()). printErrno (errnoGet ()). SELTCMOD. -15) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). return (ERROR). (void) close (fd). } /* tell card which type of timecode input to look for */ if (ioctl (fd. (void) close (fd). TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). } /* assume no(0) time offset to compensate for */ if (ioctl (fd. SETPROPDELAY. (void) close (fd). (void) close (fd). } /* want to retrieve time in decimal format */ if (ioctl (fd. printErrno (errnoGet ()). TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). return (ERROR). return (ERROR). printErrno (errnoGet ()). (void) close (fd). printErrno (errnoGet ()). return (ERROR). return (ERROR). MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “).Datum (void) printf (“ioctl(SELTIMINGMODE) failed: “).

Datum /* ready to retrieve time using time retrieval ioctls */ }/*end of test*/ Datum BC635 PCI VxWorks Device Driver 27 .

Datum RDTIMETMREQ. whatever time the time registers currently hold are returned. time is latched by the TFP into these registers. 59] */ int tm_min. The tm structure is defined in the vxWorks file time. Embedded in this structure is the UNIX time structure called tm. UINT32 usec. [0. [0. The ioctl:RDTIMETMREQ will return latched time. The values contained in the tm structure is called major time by the TFP. Before reading the TFP time registers.h and is a standard structure for holding time of day in unix. This ioctl is to be called when the TIME_DECIMAL time format had been selected using the ioctl:SELTIMEFORMAT. UINT32 hnsec. This ioctl is used to read the current time from the TFP. DESCRIPTION: The vxWorks defined definition of the tm structure is: struct tm { int tm_sec. The following is the definition of the TFP_TM structure: typedef struct { struct tm tm. Also on return the pTfpTm structure is filled with current time data.h. } TFP_TM. The driver will then fill this structure with the current time and return. RETURNS: The ioctl returns OK or ERROR.Pointer to TFP_TM structure RDTIMETMREQ. The caller passes the address of a TFP_TM structure defined in bc635. Note that the ioctl:SELTIMEFORMAT need only be called once. With this form. The minor time values of microseconds and hundreds of nanoseconds are also returned in the TFP_TM structure. The ioctl:RDTIMETM will return non-latched time. RDTIMETM COMMAND: PURPOSE: INPUTS: Type TFP_TM * Name/Description pTfpTm . RDTIMETM Read decimal time from the TFP. The ioctl:TIMEREQUEST can be called before this ioctl to specifically latch the time. 59] */ /* minutes after the hour - /* seconds after the minute - Datum BC635 PCI VxWorks Device Driver 28 .

range: 0 ..h” #include “ioLib. [0.2050 Note that the tm_year member has a range different than the standard unix range listed above. 23] */ int tm_mday. This bit is updated approximately once per second. #include “vxWorks.range: 0 .h” #include “stdio.23 tm_yday . If bit 0 of status is set. 6] */ int tm_yday.range: 0 . the usec and hnsec members give current number of microseconds and hundreds of nanoseconds.59 tm_hour . Bit #1 is indicates the synchonization accuracy of the TFP relative to the timing source. The other members of the unix tm strcture are not filled in by this ioctl call. 31] */ int tm_mon. This bit is updated approximately once per second and reflects the short-term stability of the TFP's oscillator.range: 1970 .h” Datum BC635 PCI VxWorks Device Driver 29 . then the TFP is not tracking the time reference source. Bit #2 is an indication of the TFP on-board oscillator frequency offset relative to the timing source. [1.g. The ioctl described here is then called and the current time displayed. the tm structure gives the time-of-day. EXAMPLE: The following example code performs the RDTIMETMREQ ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source and to set/read time in the TIME_DECIMAL format.Datum int tm_hour. mode = MODE_TIMECODE) and 2 microseconds in other modes.range: 0 . In addition. then the TFP is tracking the time reference. this bit is cleared. }. 11] */ int tm_year.59 tm_min . 365] */ int tm_isdst.365 tm_year . /* hours after midnight /* day of the month /* months since January /* years since 1900 /* days since Sunday /* days since January 1 /* Daylight Saving Time flag */ */ - - On return from this call. int tm_wday. [0. The following members of the tm structure are used: tm_sec . If Bit 0 is not set. The status member contains 3 bits that indicate the following status conditions: Bit 0: flywheeling Bit 1: Time offset Bit 2: Frequency offset Bit #0 indicates the flywheeling state. [0. When the TFP's 10Mhz oscillator is synchronized to less than 5 microseconds in time code mode (e. [0.

return (ERROR). “/bc635/0”). } /* want to retrieve time in decimal format */ if (ioctl (fd. TFP_TM tfpTm.Datum #include “time. return (ERROR). } /* select time reference (will use IRIG-B input) */ if (ioctl (fd. SELTCFORMAT. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). 0)) == ERROR) { (void) printf (“open of %s failed: “. printErrno (errnoGet ()). printErrno (errnoGet ()). } /* tell card which type of timecode input to look for */ if (ioctl (fd. (void) close (fd).get handle */ if ((fd = open (“/tfp0”.h” void test () { int fd. printErrno (errnoGet ()). return (ERROR).h” #include “bc635. printErrno (errnoGet ()). /* open device . TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). SELTIMINGMODE. (void) close (fd). MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). } Datum BC635 PCI VxWorks Device Driver 30 . 0. (void) close (fd). return (ERROR). SELTIMEFORMAT.

Datum /* tell card what type of timecode modulation to expect */ if (ioctl (fd. (void) close (fd). (void) close (fd). printErrno (errnoGet ()). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 31 . } /* use unix derived time display function to show time */ (void) printf (“%s\n”. return (ERROR). RDTIMETMREQ. return (ERROR). SETPROPDELAY. asctime (&tfpTm. (void) close (fd). &tfpTM) == ERROR) { (void) printf (“ioctl(RDTIMETMREQ) failed: “). MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “). 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). SELTCMOD.tm)). printErrno (errnoGet ()). } /* assume no(0) time offset to compensate for */ if (ioctl (fd. printErrno (errnoGet ()). return (ERROR). } return (ERROR). } /* ready to retrieve time in ‘decimal' form */ if (ioctl (fd.

The tv structure is defined in the vxWorks file time. RETURNS: The ioctl returns OK or ERROR. Datum BC635 PCI VxWorks Device Driver 32 . The ioctl:TIMEREQUEST can be called before this ioctl to specifically latch the time. Also on return the pTfpTv structure is filled with current time data. whatever time the time registers currently hold are returned. } TFP_TV. long tv_usec. The minor time values of microseconds and hundreds of nanoseconds are also returned in the TFP_TV structure. DESCRIPTION: The vxWorks defined definition of the tv structure is: struct timeval tv { time_t tv_sec.h. This ioctl is used to read the current time from the TFP. The driver will then fill this structure with the current time and return.h and is a standard structure for holding time of day in unix. Embedded in this structure is the UNIX time structure called tv. RDTIMETV COMMAND: PURPOSE: INPUTS: Type TFP_TV * Name/Description pTfpTv . With this form. UINT32 hnsec. The ioctl:RDTIMETV will return non-latched time. The following is the definition of the TFP_TV structure: typedef struct { struct timeval tv. The values contained in the tv structure is called major binary time by the TFP. }.Datum RDTIMETVREQ. The ioctl:RDTIMETVREQ will return latched time. This ioctl is to be called when the TIME_BINARY time format had been selected using the ioctl:SELTIMEFORMAT. time is latched by the TFP into these registers. Before reading the TFP time registers.Pointer to TFP_TV structure RDTIMETVREQ. The caller passes the address of a TFP_TV structure defined in bc635. Note that the ioctl:SELTIMEFORMAT need only be called once. UINT8 status. RDTIMETV Read binary time from the TFP.

h” void test () { int fd. then the TFP is tracking the time reference.h” #include “stdio.h” #include “bc635. mode = MODE_TIMECODE) and 2 microseconds in other modes.. EXAMPLE: The following example code performs the RDTIMETVREQ ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source and to set/read time in the TIME_BINARY format. Bit #1 is indicates the synchonization accuracy of the TFP relative to the timing source. Bit #2 is an indication of the TFP on-board oscillator frequency offset relative to the timing source. return (ERROR). The tv_usec member is the number of microseconds.h” #include “ioLib. this bit is cleared. } /* want to set/retrieve time in binary format */ if (ioctl (fd. This bit is updated approximately once per second and reflects the short-term stability of the TFP's oscillator. The status member contains 3 bits that indicate the following status conditions: Bit 0: flywheeling Bit 1: Time offset Bit 2: Frequency offset Bit #0 indicates the flywheeling state. 0)) == ERROR) { (void) printf (“open of %s failed: “. #include “vxWorks.get handle */ if ((fd = open (“/tfp0”. The hnsec member gives the number of nanoseconds in terms of hundreds of nanoseconds. then the TFP is not tracking the time reference source. 0. If bit 0 of status is set. TIME_BINARY) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). /* open device . TFP_TV tfpTv.Datum The tv_sec member is the number of seconds from Jan 1. This bit is updated approximately once per second. SELTIMEFORMAT. The ioctl described here is then called and the current time displayed. “/bc635/0”). 1970. If Bit 0 is not set.g. Datum BC635 PCI VxWorks Device Driver 33 . printErrno (errnoGet ()). printErrno (errnoGet ()). When the TFP's 10Mhz oscillator is synchronized to less than 5 microseconds in time code mode (e.

1970. RDTIMETVREQ. 1. 1. return (ERROR). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 34 . } /* display number of seconds since Jan. */ (void) printf (“Number of seconds since Jan. return (ERROR). tfpTv->tv. } /* ready to retrieve time in ‘binary' form */ if (ioctl (fd.tv_sec). printErrno (errnoGet ()).Datum (void) close (fd). (void) close (fd). &tfpTv) == ERROR) { (void) printf (“ioctl(RDTIMETVREQ) failed: “). 1970: %d\n”.

EXAMPLE: The following example code performs the TIMEREQUEST ioctl in the context of completely configuring the driver and card to derive time using IRIG-B as the time reference source and to set/read time in the TIME_DECIMAL format. TFP_TM tfpTm. } Datum BC635 PCI VxWorks Device Driver 35 .h” #include “ioLib. This ioctl latches the current time in the TFP to the time registers.h” #include “bc635. This ioctl can be used to read time in conjunction with ioctl:RDTIMETM or ioctl:RDTIMETV. The time is then held in these registers until the next call of this ioctl. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. return (ERROR).h” #include “stdio. 0)) == ERROR) { (void) printf (“open of %s failed: “.Datum TIMEREQUEST COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0/ TIMEREQUEST Latch TFP time registers.h” void test () { int fd.h” #include “time. 0.get handle */ if ((fd = open (“/tfp0”. /* open device . #include “vxWorks. The ioctls ioctl:RDTIMETMREQ and ioctl:RDTIMETVREQ perform this function as well as return the current time. See example below. printErrno (errnoGet ()). “/bc635/0”).

Datum /* select time reference (will use IRIG-B input) */ if (ioctl (fd. printErrno (errnoGet ()). printErrno (errnoGet ()). printErrno (errnoGet ()). TC_IRIGB) == ERROR) { (void) printf (“ioctl(SELTCFORMAT) failed: “). TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). } /* tell card which type of timecode input to look for */ if (ioctl (fd. } /* want to retrieve time in decimal format */ if (ioctl (fd. SELTIMINGMODE. (void) close (fd). Datum BC635 PCI VxWorks Device Driver 36 . SETPROPDELAY. (void) close (fd). printErrno (errnoGet ()). 0) == ERROR) { (void) printf (“ioctl(SETPROPDELAY) failed: “). } /* assume no(0) time offset to compensate for */ if (ioctl (fd. SELTCMOD. return (ERROR). } /* tell card what type of timecode modulation to expect */ if (ioctl (fd. return (ERROR). return (ERROR). printErrno (errnoGet ()). (void) close (fd). return (ERROR). SELTIMEFORMAT. MOD_AM) == ERROR) { (void) printf (“ioctl(SELTCMOD) failed: “). return (ERROR). SELTCFORMAT. (void) close (fd). (void) close (fd). MODE_TIMECODE) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “).

asctime (&tfpTm. &tfpTM) == ERROR) { (void) printf (“ioctl(RDTIMETMREQ) failed: “). 0) == ERROR) { (void) printf (“ioctl(TIMEREQUEST) failed: “). (void) close (fd). } /* use unix derived time display function to show time */ (void) printf (“%s\n”.tm)). (void) close (fd). } /* ready to retrieve time in ‘decimal' form */ if (ioctl (fd. RDTIMETM. printErrno (errnoGet ()). printErrno (errnoGet ()). return (ERROR). } /* latch time */ if (ioctl (fd. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 37 . TIMEREQUEST.Datum } return (ERROR). return (ERROR).

This ioctl is to be called when the TIME_DECIMAL time format had been selected using the ioctl:SELTIMEFORMAT. refer to the manual section regarding the ioctl:RDTIMETMREQ.h” void test () { int fd. Datum BC635 PCI VxWorks Device Driver 38 . #include “vxWorks. Note that the status member is not to be set by the caller.Datum SETTIMETM COMMAND: PURPOSE: INPUTS: Type TFP_TM * Name/Description pTfpTm .get handle */ if ((fd = open (“/tfp0”.Pointer to TFP_TM structure SETTIMETM Set the the time-of-day on the TFP using decimal format. This is a feature of the TFP. The tm_year member set by the caller will not take effect until a power-cycle of system reset is performed on the TFP. All subsequent time retrievals using the ioctl:RDTIMETMREQ will be current relative to this the new time-of-day. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. printErrno (errnoGet ()). “/bc635/0”).h” #include “ioLib. /* open device . This ioctl is used to set the current time for the TFP.h” #include “bc635. 0)) == ERROR) { (void) printf (“open of %s failed: “.h” #include “stdio. 0.h. This structure is to be filled by the caller. TFP_TM tfpTm. Note that the ioctls used to configure the card are not called here. See the ioctl:RDTIMETMREQ for an example that configures the card completely. EXAMPLE: The following example code performs the SETTIMETM ioctl. For information on the TFP_TM structure. The caller passes the address of a TFP_TM structure defined in bc635. The ioctl:SETYEAR need not be called if this ioctl is used.

}/*end of test() */ Datum BC635 PCI VxWorks Device Driver 39 .tm_yday = 255. } /* want to set/retrieve time in decimal format */ if (ioctl (fd.tm. tfpTm. &tfpTm) == ERROR) { (void) printf (“ioctl(SETTIMETM) failed: “). return (ERROR). SELTIMEFORMAT. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). SETTIMETM. if (ioctl (fd.tm. (void) close (fd).tm_min = 33.tm.tm. return (ERROR).tm_year = 2000. printErrno (errnoGet ()).tm_hour = 13.tm. } (void) close (fd). tfpTm.Datum return (ERROR). (void) close (fd). tfpTm. } /* ready to set time in ‘decimal' form */ /* set this date */ tfpTm. tfpTm. printErrno (errnoGet ()).tm_sec = 48.

The ioctl:SETYEAR need not be called if this ioctl is used. #include “vxWorks.Datum SETTIMETV COMMAND: PURPOSE: INPUTS: Type TFP_TV * Name/Description pTfpTv . This structure is to be filled by the caller. Datum BC635 PCI VxWorks Device Driver 40 . refer to the manual section regarding the ioctl:RDTIMETVREQ.Pointer to TFP_TV structure SETTIMETV Set the the time-of-day on the TFP using binary format. This ioctl is to be called when the TIME_BINARY time format had been selected using the ioctl:SELTIMEFORMAT. This ioctl is used to set the current time for the TFP. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.h” #include “bc635. printErrno (errnoGet ()). This is a feature of the TFP. Note that the ioctls used to configure the card are not called here. For information on the TFP_TV structure. 0)) == ERROR) { (void) printf (“open of %s failed: “. /* open device . TFP_TV tfpTv. All subsequent time retrievals using the ioctl:RDTIMETVREQ will be current relative to this the new time-of-day. The tm_year member set by the caller will not take effect until a power-cycle of system reset is performed on the TFP.h” #include “stdio. 0. The caller passes the address of a TFP_TV structure defined in bc635. See the ioctl:RDTIMETMREQ for an example that configures the card completely. “/bc635/0”). Note that the status member is not to be set by the caller. EXAMPLE: The following example code performs the SETTIMETV ioctl.get handle */ if ((fd = open (“/tfp0”.h” void test () { int fd.h” #include “ioLib.h.

printErrno (errnoGet ()). SETTIMETV. return (ERROR).235.Datum return (ERROR). TIME_BINARY) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “).tv_sec = 1. &tfpTv) == ERROR) { (void) printf (“ioctl(SETTIMETV) failed: “).444. return (ERROR). } /* want to set/retrieve time in binary format */ if (ioctl (fd. (void) close (fd).tv. SELTIMEFORMAT. } /* ready to set time in ‘binary' form */ /* set the time */ tfpTv. (void) close (fd). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 41 . } (void) close (fd). printErrno (errnoGet ()). if (ioctl (fd.

This ioctl is to be called to set the year. /* open device .get handle */ if ((fd = open (“/tfp0”. } /* set year to 2010 */ yearVal = 2010. Note that the ioctls used to configure the card are not called here. #include “vxWorks. int yearVal. SETYEAR Set the the year for the TFP..Datum SETYEAR COMMAND: PURPOSE: INPUTS: Type int Name/Description yearVal .h” #include “ioLib.Range is from 1970 .2050.h” void test () { int fd. printErrno (errnoGet ()). Datum BC635 PCI VxWorks Device Driver 42 . RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. “/bc635/0”). 0. 0)) == ERROR) { (void) printf (“open of %s failed: “. Note that this value does not take effect on the TFP until a power-cycle or system reset is performed.h” #include “stdio. See the ioctl:RDTIMETMREQ for an example that configures the card completely. EXAMPLE: The following example code performs the SETYEAR ioctl. return (ERROR).h” #include “bc635. The value is a decimal number in the range of 1970 to 2050. This is a feature of the TFP.

} (void) close (fd). yearVal) == ERROR) { (void) printf (“ioctl(SETYEAR) failed: “). (void) close (fd). printErrno (errnoGet ()). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 43 .Datum if (ioctl (fd. return (ERROR). SETYEAR.

RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. n2 values are determined according to the following description: Terms: n1: Counter divider number 1 n2: Counter divider number 2 Duty Cycle: signal period Percentage of high pulse width to This signal is generated by dividing down a 1 Mhz clock. SETPERIODIC Program the periodic output of the TFP. then the periodic output is synchronized to the TFP 1pps signal. The 1 Mhz clock is derived directly from the 10 Mhz oscillator.000. and is determined by the relationship: Frequency = 1. This is especially useful when a pulse train is desired of a certain pulse width and frequency. the 1pps signal will cut short one of the periodic output cycles. n2 <= 65535) Datum BC635 PCI VxWorks Device Driver 44 .000 / (n1 * n2) Hz (where 2 <= n1. thus the periodic output is synchronous with the timing source. UINT16 n2. The n1. The periodic output frequency can range from 250 kHz (n1 = n2 = 2) to less than 1 Hz. UINT16 n1.Values describing periodic output characteristics. The periodic output can be optionally synchronized to the TFP 1pps signal. The following structure is to be filled by the caller: struct periodic { UINT8 sync1pps. The 1pps synchronization works besst when the periodic output frequency is an integer value. otherwise. This ioctl is to be called so as to program the periodic output of the TFP. } If the sync1pps value is set to 1.Datum SETPERIODIC COMMAND: PURPOSE: INPUTS: Type struct periodic Name/Description perStruct .

h” #include “ioLib. SETPERIODIC. return (ERROR).get handle */ if ((fd = open (“/tfp0”. printErrno (errnoGet ()).Datum Duty Cycle = (1 . 0. EXAMPLE: The following example code performs the ioctl:SETPERIODIC where a 100 Hz pulse train is formed with a 75% duty cycle. pulseDescrip.n1 = 4. though the periodic output frequency will be correct. (void) close (fd). pps */ pulseDescrip.sync1pps = PERIODIC_SYNC.h” void test () { int fd. 0)) == ERROR) { (void) printf (“open of %s failed: “.n1 = 2500. if (ioctl (fd. } pulseDescrip. 1pps synchronization will not work correctly. “/bc635/0”). printErrno (errnoGet ()).(1 / n2)) * 100 % Note: If n1 or n2 is set to 2. &pulseDescrip) == ERROR) { (void) printf (“ioctl(SETPERIODIC) failed: “).h” #include “bc635. return (ERROR). /* open device . } (void) close (fd). struct periodic pulseDescrip. }/*end of test() */ /* sync to 1 Datum BC635 PCI VxWorks Device Driver 45 .h” #include “stdio. #include “vxWorks.

SELFREQUENCYOUT Select the output frequency for the TFP's TTL output signal. This ioctl is to be called so as to select an output frequency for the TFP TTL output signal. #include “vxWorks.h” void test () { int fd. FREQ_5MHZ .get handle */ if ((fd = open (“/tfp0”.h” #include “bc635.Datum SELFREQUENCYOUT COMMAND: PURPOSE: INPUTS: Type int Name/Description freqOut . EXAMPLE: The following example code performs the ioctl:SELFREQUENCYOUT where a 5 Mhz output TTL signal frequency is selected.10 Mhz output frequency selected. printErrno (errnoGet ()). “/bc635/0”). return (ERROR). struct periodic pulseDescrip.h” #include “stdio. 0. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.Choose one of the following defines listed below. /* open device . } Datum BC635 PCI VxWorks Device Driver 46 .1 Mhz output frequency selected. One of the following freqOut values is to be used: FREQ_10MHZ .h” #include “ioLib.5 Mhz output frequency selected. 0)) == ERROR) { (void) printf (“open of %s failed: “. FREQ_1MHZ .

(void) close (fd).Datum if (ioctl (fd. } (void) close (fd). FREQ_5MHZ) == ERROR) { (void) printf (“ioctl(SETPERIODIC) failed: “). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 47 . printErrno (errnoGet ()). SELFREQUENCYOUT. return (ERROR).

Set CAPLOCK_DISABLE to disable event capture lockout so that the timestamp captured on the next event will be overwritten if new events occur. Set EVCAP_PERIODIC or EVCAP_EVENT as well. events. Datum BC635 PCI VxWorks Device Driver 48 . Set EVENT_RISING so as to detect an event on a rising edge. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.Datum CONTROLEVENT COMMAND: PURPOSE: INPUTS: Type int Name/Description ctrlVal . Set EVCAP_EVENT when detecting external EVENT_RISING or EVENT_FALLING as well. then the control parameter CAPLOCK_DISABLE can be set so as to re-enable event timestamping. One of the following defines is to be set. Set CAPLOCK_ENABLE to enable event capture lockout so that the timestamp captured on the next event is not overwritten when new events occur. After the timestamp is read using one of the ioctls RDEVENTTM or RDEVENTTV. Set EVCAP_DISABLE to disable timestamp of events. Set EVENT_FALLING so as to detect an event on a falling edge. This ioctl is to be called so as to set a specific control parameter with regards to recording a timestamp of an event. CONTROLEVENT Set event time recording parameters. You must set Set EVCAP_PERIODIC when the events to be timestamped are the periodic output of the TFP.Choose one of the following defines listed below. This ioctl is to be called multiple times when setting multiple parameters: EVENT_RISING EVENT_FALLING CAPLOCK_ENABLE CAPLOCK_DISABLE EVCAP_ENABLE EVCAP_DISABLE EVCAP_PERIODIC EVCAP_EVENT Set EVCAP_ENABLE to enable timestamp of events.

(void) close (fd). return (ERROR). printErrno (errnoGet ()).get handle */ if ((fd = open (“/tfp0”. return (ERROR). EVCAP_EVENT) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). } /* capture timestamps for external events (non-tfpperiodic) */ if (ioctl (fd. CONTROLEVENT. The event capture lockout parameter is set so that the subsequent timestamps read are for the most recent external event. SELTIMEFORMAT. printErrno (errnoGet ()). TFP_TM tfpTm. 0)) == ERROR) { (void) printf (“open of %s failed: “. EVENT_FALLING) == ERROR) Datum BC635 PCI VxWorks Device Driver 49 .h” #include “stdio. printErrno (errnoGet ()). 0. #include “vxWorks. /* open device . (void) close (fd).h” #include “ioLib. } /* read event time in ‘decimal' format */ if (ioctl (fd.h” void test () { int fd.h” #include “bc635. “/bc635/0”). return (ERROR). CONTROLEVENT. } /* capture event on the falling edge */ if (ioctl (fd. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “).Datum EXAMPLE: The following example code performs the ioctl:CONTROLEVENT so as to capture timestamps for external events (non TFP-periodic) on the falling edge.

printErrno (errnoGet ()). } /* event occurred. CAPLOCK_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). EVCAP_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). return (ERROR). printErrno (errnoGet ()). CONTROLEVENT. return (ERROR). } /* enable event capture */ if (ioctl (fd. (void) close (fd). &tfpTm) == ERROR) { (void) printf (“ioctl(RDEVENTTMREQ) failed: “). CONTROLEVENT. 0) == ERROR) { (void) printf (“ioctl(BC635_WAITONEVENT) failed: “). } /* wait for next event to occur */ if (ioctl (fd. (void) close (fd). printErrno (errnoGet ()).Datum { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). BC635_INT_WAITONEVENT. return (ERROR). printErrno (errnoGet ()). } Datum BC635 PCI VxWorks Device Driver 50 . return (ERROR). now get timestamp */ if (ioctl (fd. (void) close (fd). printErrno (errnoGet ()). (void) close (fd). } /* disable timestamp lockout mode (timestamps are for most recent events) */ if (ioctl (fd. RDEVENTTMREQ. return (ERROR).

asctime (&tfpTm. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 51 .Datum /* use unix derived time display function to show time */ (void) printf (“%s\n”. (void) close (fd).tm)).

The values contained in the tm structure is called major time by the TFP. Before calling this ioctl. The caller passes the address of a TFP_TM structure defined in bc635. The minor time values of microseconds and hundreds of nanoseconds are also returned in the TFP_TM structure. RETURNS: The ioctl returns OK or ERROR. Before reading the TFP event time registers. UINT32 hnsec. the ioctl:CONTROLEVENT must have been called to configure the TFP for event time processing.Pointer to TFP_TM structure RDEVENTTMREQ. Embedded in this structure is the UNIX time structure called tm. With this form.h and is a standard structure for holding time of day in unix. Also on return the pTfpTm structure is filled with current time data. The ioctl:RDEVENTTMREQ will return latched event time. event time is latched by the TFP into these registers. This ioctl is to be called when the TIME_DECIMAL time format had been selected using the ioctl:SELTIMEFORMAT.Datum RDEVENTTMREQ. DESCRIPTION: The vxWorks defined definition of the tm structure is: struct tm { int tm_sec. The driver will then fill this structure with the current event time and return. The ioctl:RDEVENTTM will return non-latched event time. whatever event time the event time registers currently hold are returned. RDEVENTM COMMAND: PURPOSE: INPUTS: Type TFP_TM * Name/Description pTfpTm . This ioctl is used to read the current time for an event from the TFP. [0. The tm structure is defined in the vxWorks file time. The ioctl:EVENTREQUEST can be called before this ioctl to specifically latch the time. } TFP_TM. 59] */ /* seconds after the minute - Datum BC635 PCI VxWorks Device Driver 52 . Note that the ioctl:SELTIMEFORMAT need only be called once.h. UINT32 usec. RDEVENTTM Read decimal time of an event from the TFP. The following is the definition of the TFP_TM structure: typedef struct { struct tm tm.

Bit #1 is indicates the synchonization accuracy of the TFP relative to the timing source. In addition. The status member contains 3 bits that indicate the following status conditions: Bit 0: flywheeling Bit 1: Time offset Bit 2: Frequency offset Bit #0 indicates the flywheeling state.59 tm_hour . 11] */ int tm_year. then the TFP is not tracking the time reference source. [0. EXAMPLE: The following example code performs the ioctl:RDEVENTTMREQ so as to capture a timestamp for the next external event once event capture is enabled. When the TFP's 10Mhz oscillator is synchronized to less than 5 microseconds in time code mode (e. [1.range: 0 .Datum int tm_min.. the usec and hnsec members give current number of microseconds and hundreds of nanoseconds. [0. 59] */ int tm_hour. 31] */ int tm_mon. the tm structure gives the time-of-day.range: 0 . this bit is cleared. The other members of the unix tm strcture are not filled in by this ioctl call. The following members of the tm structure are used: tm_sec .365 tm_year .range: 0 . Datum BC635 PCI VxWorks Device Driver 53 . [0. This bit is updated approximately once per second. 23] */ int tm_mday.59 tm_min . then the TFP is tracking the time reference.2050 Note that the tm_year member has a range different than the standard unix range listed above.g. If bit 0 of status is set. This bit is updated approximately once per second and reflects the short-term stability of the TFP's oscillator. [0. The event capture lockout parameter is set so that the subsequent timestamps read are for the most recent external event. 365] */ int tm_isdst. mode = MODE_TIMECODE) and 2 microseconds in other modes. /* minutes after the hour /* hours after midnight /* day of the month /* months since January /* years since 1900 /* days since Sunday /* days since January 1 /* Daylight Saving Time flag */ */ - - On return from this call.range: 0 . The external events (non TFP-periodic) are on the falling edge. [0. 6] */ int tm_yday.23 tm_yday . }. Bit #2 is an indication of the TFP on-board oscillator frequency offset relative to the timing source. If Bit 0 is not set.range: 1970 . int tm_wday.

TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). printErrno (errnoGet ()). } /* capture timestamps for external events (non-tfpperiodic) */ if (ioctl (fd. (void) close (fd). (void) close (fd). /* open device .h” #include “bc635. return (ERROR). 0)) == ERROR) { (void) printf (“open of %s failed: “. Datum BC635 PCI VxWorks Device Driver 54 . 0. } /* capture event on the falling edge */ if (ioctl (fd. } /* read event time in ‘decimal' format */ if (ioctl (fd. EVENT_FALLING) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). “/bc635/0”). CONTROLEVENT. CONTROLEVENT. return (ERROR). printErrno (errnoGet ()). return (ERROR). printErrno (errnoGet ()). SELTIMEFORMAT.h” #include “stdio.h” void test () { int fd. return (ERROR). EVCAP_EVENT) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “).get handle */ if ((fd = open (“/tfp0”. printErrno (errnoGet ()).Datum #include “vxWorks.h” #include “ioLib. TFP_TM tfpTm. (void) close (fd).

now get timestamp */ if (ioctl (fd. (void) close (fd).tm)). printErrno (errnoGet ()). (void) close (fd). } /* event occurred. EVCAP_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). return (ERROR). RDEVENTTMREQ. return (ERROR). return (ERROR). printErrno (errnoGet ()). printErrno (errnoGet ()). 0) == ERROR) { (void) printf (“ioctl(BC635_WAITONEVENT) failed: “). } /* enable event capture */ if (ioctl (fd. printErrno (errnoGet ()). asctime (&tfpTm. } /* wait for next event to occur */ if (ioctl (fd. Datum BC635 PCI VxWorks Device Driver 55 . CONTROLEVENT. } /* use unix derived time display function to show event time */ (void) printf (“%s\n”. (void) close (fd). CONTROLEVENT. (void) close (fd).Datum } /* disable timestamp lockout mode (timestamps are for most recent events) */ if (ioctl (fd. return (ERROR). BC635_INT_WAITONEVENT. CAPLOCK_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). &tfpTm) == ERROR) { (void) printf (“ioctl(RDEVENTTMREQ) failed: “).

Datum }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 56 .

event time is latched by the TFP into these registers. RDEVENTTV COMMAND: PURPOSE: INPUTS: Type TFP_TV * Name/Description pTfpTv . With this form. Datum BC635 PCI VxWorks Device Driver 57 . UINT8 status. RDEVENTTV Read binary time for an event from the TFP. This ioctl is used to read the current event time from the TFP. } TFP_TV. The tv structure is defined in the vxWorks file time. RETURNS: The ioctl returns OK or ERROR. whatever event time the event time registers currently hold are returned.Datum RDEVENTTVREQ. The minor time values of microseconds and hundreds of nanoseconds are also returned in the TFP_TV structure. The ioctl:EVENTREQUEST can be called before this ioctl to specifically latch the event time.Pointer to TFP_TV structure RDEVENTTVREQ. DESCRIPTION: The vxWorks defined definition of the tv structure is: struct timeval tv { time_t tv_sec. Also on return the pTfpTv structure is filled with current time data.h.h and is a standard structure for holding time of day in unix. The driver will then fill this structure with the current event time and return. Embedded in this structure is the UNIX time structure called tv. The ioctl:RDEVENTTVREQ will return latched event time. Note that the ioctl:SELTIMEFORMAT need only be called once. The ioctl:RDEVENTTV will return non-latched event time. Before reading the TFP event time registers. long tv_usec. The following is the definition of the TFP_TV structure: typedef struct { struct timeval tv. }. The values contained in the tv structure is called major binary time by the TFP. The caller passes the address of a TFP_TV structure defined in bc635. UINT32 hnsec. This ioctl is to be called when the TIME_BINARY time format had been selected using the ioctl:SELTIMEFORMAT.

. 0.get handle */ if ((fd = open (“/tfp0”. This bit is updated approximately once per second. The external events (non TFP-periodic) are on the falling edge. 0)) == ERROR) { (void) printf (“open of %s failed: “. } /* read event time in ‘decimal' format */ if (ioctl (fd. SELTIMEFORMAT. If bit 0 of status is set. Bit #2 is an indication of the TFP on-board oscillator frequency offset relative to the timing source. “/bc635/0”).h” #include “bc635. The event capture lockout parameter is set so that the subsequent timestamps read are for the most recent external event. then the TFP is tracking the time reference. TIME_DECIMAL) == ERROR) Datum BC635 PCI VxWorks Device Driver 58 . The tv_usec member is the number of microseconds. TFP_TV tfpTv. The hnsec member gives the number of nanoseconds in terms of hundreds of nanoseconds. If Bit 0 is not set. When the TFP's 10Mhz oscillator is synchronized to less than 5 microseconds in time code mode (e. /* open device . return (ERROR). printErrno (errnoGet ()). This bit is updated approximately once per second and reflects the short-term stability of the TFP's oscillator.h” #include “ioLib. 1970. mode = MODE_TIMECODE) and 2 microseconds in other modes. EXAMPLE: The following example code performs the ioctl:RDEVENTTVREQ in the process of reading a timestamp for the next external event once event capture is enabled.h” void test () { int fd. then the TFP is not tracking the time reference source.h” #include “stdio. #include “vxWorks. The status member contains 3 bits that indicate the following status conditions: Bit 0: flywheeling Bit 1: Time offset Bit 2: Frequency offset Bit #0 indicates the flywheeling state.g. this bit is cleared.Datum The tv_sec member is the number of seconds from Jan 1. Bit #1 is indicates the synchonization accuracy of the TFP relative to the timing source.

EVCAP_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). CONTROLEVENT. printErrno (errnoGet ()). return (ERROR). (void) close (fd).Datum { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). (void) close (fd). CAPLOCK_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). printErrno (errnoGet ()). return (ERROR). } /* capture timestamps for external events (non-tfpperiodic) */ if (ioctl (fd. } Datum BC635 PCI VxWorks Device Driver 59 . } /* capture event on the falling edge */ if (ioctl (fd. CONTROLEVENT. } /* enable event capture */ if (ioctl (fd. EVCAP_EVENT) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). printErrno (errnoGet ()). return (ERROR). printErrno (errnoGet ()). EVENT_FALLING) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). return (ERROR). return (ERROR). printErrno (errnoGet ()). CONTROLEVENT. } /* disable timestamp lockout mode (timestamps are for most recent events) */ if (ioctl (fd. CONTROLEVENT. (void) close (fd).

} /* display number of seconds since Jan. &tfpTv) == ERROR) { (void) printf (“ioctl(RDEVENTTVREQ) failed: “). tfpTv->tv. (void) close (fd). RDEVENTTVREQ. (void) close (fd). BC635_INT_WAITONEVENT. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 60 .tv_sec). 0) == ERROR) { (void) printf (“ioctl(BC635_WAITONEVENT) failed: “). 1970: %d\n”. } /* event occurred. 1970 for this event */ (void) printf (“Number of seconds since Jan. 1. printErrno (errnoGet ()). 1. return (ERROR). return (ERROR). (void) close (fd). printErrno (errnoGet ()).Datum /* wait for next event to occur */ if (ioctl (fd. now get timestamp */ if (ioctl (fd.

get handle */ if ((fd = open (“/tfp0”. This ioctl latches the current event time in the TFP to the time registers. printErrno (errnoGet ()). “/bc635/0”). RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. #include “vxWorks. 0. The external events (non TFP-periodic) are on the falling edge. The event time is then held in these registers until the next call of this ioctl.h” #include “bc635.h” #include “ioLib. EVENTREQUEST Latch TFP event time registers. The ioctls ioctl:RDVENTTMREQ and ioctl:RDEVENTTVREQ perform this function as well as return the current time. return (ERROR). See example below. This ioctl can be used to read time in conjunction with ioctl:RDEVENTTM or ioctl:RDTEVENTTV.h” #include “stdio. } Datum BC635 PCI VxWorks Device Driver 61 .h” void test () { int fd.Datum EVENTREQUEST COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0. EXAMPLE: The following example code performs the ioctl:EVENTREQUEST in the process of reading a timestamp for the next external event once event capture is enabled. 0)) == ERROR) { (void) printf (“open of %s failed: “. TFP_TM tfpTm. The event capture lockout parameter is set so that the subsequent timestamps read are for the most recent external event. /* open device .

(void) close (fd). EVENT_FALLING) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). printErrno (errnoGet ()). } /* capture event on the falling edge */ if (ioctl (fd. CONTROLEVENT. printErrno (errnoGet ()). EVCAP_EVENT) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). EVCAP_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). (void) close (fd). (void) close (fd). return (ERROR). (void) close (fd). printErrno (errnoGet ()). } /* capture timestamps for external events (non-tfpperiodic) */ if (ioctl (fd. CONTROLEVENT. CONTROLEVENT. Datum BC635 PCI VxWorks Device Driver 62 . CONTROLEVENT. return (ERROR). return (ERROR). } /* enable event capture */ if (ioctl (fd. SELTIMEFORMAT. printErrno (errnoGet ()). printErrno (errnoGet ()). } /* disable timestamp lockout mode (timestamps are for most recent events) */ if (ioctl (fd. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). CAPLOCK_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “). return (ERROR).Datum /* read event time in ‘decimal' format */ if (ioctl (fd.

(void) close (fd). return (ERROR). printErrno (errnoGet ()). 0) == ERROR) { (void) printf (“ioctl(EVENTREQUEST) failed: “). printErrno (errnoGet ()). } /* read TFP event time registers */ if (ioctl (fd. asctime (&tfpTm. return (ERROR). BC635_INT_WAITONEVENT.tm)). (void) close (fd). (void) close (fd). printErrno (errnoGet ()). (void) close (fd). } /* latch TFP event time registers */ if (ioctl (fd. 0) == ERROR) { (void) printf (“ioctl(BC635_WAITONEVENT) failed: “). } /* wait for next event to occur */ if (ioctl (fd. } /* use unix derived time display function to show event time */ (void) printf (“%s\n”. EVENTREQUEST. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 63 .Datum return (ERROR). &tfpTm) == ERROR) { (void) printf (“ioctl(RDEVENTTM) failed: “). return (ERROR). RDEVENTTM.

Datum

BC635_INT_WAITONEVENT
COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0 BC635_INT_WAITONEVENT Wait for event interrupt to occur.

RETURNS: DESCRIPTION:

The ioctl returns OK or ERROR. This ioctl is to be called after the ioctl:CONTROLEVENT has been called to configure the TFP for event processing and after event capture has been enabled using ioctl:CONTROLEVENT. This ioctl will block waiting for an event to occur as configured by the ioctl:CONTROLEVENT.

EXAMPLE:

The following example code performs the ioctl:BC635_INT_WAITONEVENT in the process of reading a timestamp for the next external event once event capture is enabled. The external events (non TFP-periodic) are on the falling edge. The event capture lockout parameter is set so that the subsequent timestamps read are for the most recent external event.
#include “vxWorks.h” #include “stdio.h” #include “ioLib.h” #include “bc635.h” void test () { int fd; TFP_TM tfpTm; /* open device - get handle */ if ((fd = open (“/tfp0”, 0, 0)) == ERROR) { (void) printf (“open of %s failed: “, “/bc635/0”); printErrno (errnoGet ()); return (ERROR); } /* read event time in ‘decimal' format */

Datum BC635 PCI VxWorks Device Driver

64

Datum

if (ioctl (fd, SELTIMEFORMAT, TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* capture timestamps for external events (non-tfpperiodic) */ if (ioctl (fd, CONTROLEVENT, EVCAP_EVENT) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* capture event on the falling edge */ if (ioctl (fd, CONTROLEVENT, EVENT_FALLING) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* disable timestamp lockout mode (timestamps are for most recent events) */ if (ioctl (fd, CONTROLEVENT, CAPLOCK_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* enable event capture */ if (ioctl (fd, CONTROLEVENT, EVCAP_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLEVENT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR);

Datum BC635 PCI VxWorks Device Driver

65

Datum

} /* wait for next event to occur */ if (ioctl (fd, BC635_INT_WAITONEVENT, 0) == ERROR) { (void) printf (“ioctl(BC635_WAITONEVENT) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* event occurred, now get timestamp */ if (ioctl (fd, RDEVENTTMREQ, &tfpTm) == ERROR) { (void) printf (“ioctl(RDEVENTTMREQ) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* use unix derived time display function to show event time */ (void) printf (“%s\n”, asctime (&tfpTm.tm)); (void) close (fd); }/*end of test() */

Datum BC635 PCI VxWorks Device Driver

66

struct periodic pulseDescrip. /* sync to 1 EXAMPLE: code performs the Datum BC635 PCI VxWorks Device Driver 67 . this ioctl will enable the generation of the periodic interrupt.Datum BC635_INT_WAITONPERIODIC COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0 BC635_INT_WAITONPERIODIC Wait for next TFP periodic pulse interrupt to occur. “/bc635/0”).n1 = 4. 0)) == ERROR) { (void) printf (“open of %s failed: “. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. 0. printErrno (errnoGet ()).sync1pps = PERIODIC_SYNC. pps */ pulseDescrip..h” #include “stdio. /* open device .get handle */ if ((fd = open (“/tfp0”. #include “vxWorks.h” #include “ioLib. The ioctl:SETINTMASK need not be explicitly called to enable this type of interrupt. This ioctl will block waiting for the TFP to generate a PCI interrupt when the next periodic pulse generated by the TFP occurs.h” #include “bc635. pulseDescrip.n1 = 2500. } pulseDescrip. return (ERROR). The following example ioctl:BC635_INT_WAITONPERIODIC.h” void test () { int fd.

} /* wait for next ‘periodic' interrupt to generated by the TFP */ if (ioctl (fd. printErrno (errnoGet ()). BC635_INT_WAITONPERIODIC. } (void) close (fd). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 68 . printErrno (errnoGet ()). &pulseDescrip) == ERROR) { (void) printf (“ioctl(SETPERIODIC) failed: “). SETPERIODIC. (void) close (fd). 0) == ERROR) { (void) printf (“ioctl(BC635_INT_WAITONPERIODIC) failed: “). return (ERROR). (void) close (fd). return (ERROR).Datum if (ioctl (fd.

#include “vxWorks.. BC635_INT_WAITON1PPS. The ioctl:SETINTMASK need not be explicitly called to enable this type of interrupt. struct periodic pulseDescrip.get handle */ if ((fd = open (“/tfp0”. printErrno (errnoGet ()). “/bc635/0”). } EXAMPLE: /* wait for next ‘periodic' interrupt to generated by the TFP */ if (ioctl (fd.Datum BC635_INT_WAITON1PPS COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0 BC635_INT_WAITON1PPS Wait for next 1 PPS interrupt to occur. return (ERROR).h” #include “stdio. The following example code performs the ioctl:BC635_INT_WAITON1PPS. This ioctl will block waiting for the TFP to generate a PCI interrupt when the next 1 PPS pulse occurs.h” #include “bc635.h” #include “ioLib. 0.h” void test () { int fd. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. this ioctl will enable the generation of the 1 PPS interrupt. 0) == ERROR) { Datum BC635 PCI VxWorks Device Driver 69 . /* open device . 0)) == ERROR) { (void) printf (“open of %s failed: “.

}/*end of test() */ Datum BC635 PCI VxWorks Device Driver 70 . } (void) close (fd). printErrno (errnoGet ()).Datum (void) printf (“ioctl(BC635_INT_WAITON1PPS) failed: “). return (ERROR). (void) close (fd).

The TFP sets a register bit in the INTSTAT register corresponding to the type of interrupt source when interrupt source has generated an interrupt.Used to clear all interrupt sources. INT_1PPS . The interrupt source status register contains information regarding the TFP interrupt sources. RDINTMASK) int Type (SETINTSTAT. EXAMPLE: The following example code performs the ioctl:SETINTMASK.Datum RDINTSTAT. Name/Description intStatVal .Interrupt status/mask register value read Name/Description intStatVal . Use the following defines to enable or poll/clear the corresponding interrupt source: BCINT_EVENT . SETINTSTAT COMMAND: PURPOSE: INPUTS: Type (RDINTSTAT.GPS packet interrupt.Strobe interrupt. INT_PACKET . RDINTMASK. The interrupt enable mask value has the same form as is used for ioctl:RDINTSTAT and ioctl:SETINTSTAT.Periodic interrupt. INT_STROBE . SETINTMASK Used to poll/clear TFP interrupts.h” #include “stdio.1 PPS interrupt. INT_BITMASK .h” Datum BC635 PCI VxWorks Device Driver 71 . SETINTMASK) int * RETURNS: DESCRIPTION: RDINTSTAT. The ioctl:RDINTMASK is used to read the current interrupt enable (mask) value. SETINTSTAT.h” #include “ioLib.Event interrupt. The ioctl:RDINTSTAT call can be used to poll the TFP for the occurrence of an interrupt source. ioctl:RDINTSTAT and ioctl:SETINTSTAT so as to manage an event interrupt source: #include “vxWorks. INT_PERIODIC . The ioctl:SETINTMASK is used to enable TFP interrupt sources. The ioctl returns OK or ERROR.Interrupt status/mask register value to set.h” #include “bc635. The corresponding bit can be cleared using the ioctl:SETINTSTAT.

printErrno (errnoGet ()).Datum void test () { int fd. 0)) == ERROR) { (void) printf (“open of %s failed: “. } /* Poll for event interrupt */ done = FALSE. “/bc635/0”). for (. return (ERROR).) { /* get interrupt status */ (void) ioctl (fd. if (ioctl (fd. done == FALSE && timeout < 10. 0. SETINTSTAT. return (ERROR). } /* Enable event interrupts */ intMask = BCINT_EVENT. &intStat) == ERROR) /* did event interrupt occur ? */ if ((intStat & BCINT_EVENT) > 0) { (void) printf (“Event occurred\n”). int timeout. SETINTMASK. Datum BC635 PCI VxWorks Device Driver 72 . intMask) == ERROR) { (void) printf (“ioctl(SETINTMASK) failed: “). (void) ioctl (fd. UINT32 intStat. (void) close (fd). RDINTSTAT. intStat). BOOL done.get handle */ if ((fd = open (“/tfp0”. UINT32 intMask. /* open device . printErrno (errnoGet ()). /* clear */ intStat = INT_BITMASK. timeout = 0.

timeout ++. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 73 . } taskDelay (sysClkRateGet () / 4). } (void) close (fd).Datum done = TRUE.

h” #include “bc635. This ioctl is to be called to enable or disable GPS mode packet processing.Enable or Disable value SETGPSMDFLG Read binary time for an event from the TFP.Datum SETGPSMDFLG COMMAND: PURPOSE: INPUTS: Type int Name/Description modeVal . “/bc635/0”).h” #include “ioLib. UINT32 id.h” #include “stdio.h” void test () { int fd. int i.get handle */ if ((fd = open (“/tfp0”. 0)) == ERROR) { (void) printf (“open of %s failed: “. 0. TFP_GPS_PACKET gps_packet. return (ERROR). } /* enable GPS mode */ if (ioctl (fd. MODE_GPS) == ERROR) Datum BC635 PCI VxWorks Device Driver 74 . RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. /* open device . SELTIMINGMODE. You may use the following defines as the modeVal: GPS_FLG_DIS(0) GPS_FLG_ENA(1) EXAMPLE: The following example code performs the ioctl:SETGPSMDFLG in the process of requesting a GPS packet: #include “vxWorks. printErrno (errnoGet ()).

packet_data[i]). 4a) : “). i < gps_packet. } (void) close (fd). ioctl (fd.packet_length == 0) printf(“Could not receive GPS System Message\n”). if (gps_packet. i. printErrno (errnoGet ()). SETGPSMDFLG.packet_id = id. else { printf (“Packet id = %x. printErrno (errnoGet ()). GPS_FLG_ENA) == ERROR) { (void) printf (“ioctl(SETGPSMDFLG) failed: “). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 75 . gps_packet.packet_id. REQGPSPACKET.e.i. gps_packet. } printf(“Enter Packet to receive (hex .packet_length = 0. lenght=%d\n”. &id). gps_packet. i++) printf (“[%x] = %x\n”. } /* enable GPS packet processing mode */ if (ioctl (fd.packet_length-1. gps_packet. for (i=0. return (ERROR).packet_length). (void) close (fd). (int) &gps_packet). gps_packet. scanf (“%x”. (void) close (fd).Datum { (void) printf (“ioctl(SELTIMINGMODE) failed: “). return (ERROR).

0)) == ERROR) { (void) printf (“open of %s failed: “. 0. UINT8 packet_id.GPS packet received.get handle */ if ((fd = open (“/tfp0”. /* one bigger than necessary */ } TFP_GPS_PACKET. /* open device . UINT8 packet_data[256]. Datum BC635 PCI VxWorks Device Driver 76 . On return. int i.h” #include “ioLib. printErrno (errnoGet ()). EXAMPLE: The following example code performs the ioctl:REQGPSPACKET: #include “vxWorks. the following packet definition is filled: typedef struct { UINT8 packet_length. UINT32 id.h” #include “bc635. Control does not return to the caller until a packet is received. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.Datum REQGPSPACKET COMMAND: PURPOSE: INPUTS: Type TFP_GPS_PACKET * Name/Description pTfpGpsPacket . REQGPSPACKET Receive GPS packet from the TFP.h” #include “stdio.h” void test () { int fd. TFP_GPS_PACKET gps_packet. “/bc635/0”). This ioctl waits for the next GPS packet to be received.

Datum

return (ERROR); } /* enable GPS mode */ if (ioctl (fd, SELTIMINGMODE, MODE_GPS) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } /* enable GPS packet processing mode */ if (ioctl (fd, SETGPSMDFLG, GPS_FLG_ENA) == ERROR) { (void) printf (“ioctl(SETGPSMDFLG) failed: “); printErrno (errnoGet ()); (void) close (fd); return (ERROR); } printf(“Enter Packet to receive (hex - i.e. 4a) : “); scanf (“%x”, &id); gps_packet.packet_id = id; gps_packet.packet_length = 0; ioctl (fd, REQGPSPACKET, (int) &gps_packet); if (gps_packet.packet_length == 0) printf(“Could not receive GPS System Message\n”); else { printf (“Packet id = %x, lenght=%d\n”, gps_packet.packet_id, gps_packet.packet_length); for (i=0; i < gps_packet.packet_length-1; i++) printf (“[%x] = %x\n”, i, gps_packet.packet_data[i]); } (void) close (fd);

Datum BC635 PCI VxWorks Device Driver

77

Datum

}/*end of test() */

Datum BC635 PCI VxWorks Device Driver

78

Datum

SENDGPSPACKET
COMMAND: PURPOSE: INPUTS: Type TFP_GPS_PACKET * Name/Description pTfpGpsPacket - GPS packet received. SENDGPSPACKET Send GPS packet to TFP.

RETURNS: DESCRIPTION:

The ioctl returns OK or ERROR. This ioctl sends a GPS packet to the TFP. The following packet definition is to be filled by the caller:
typedef struct { UINT8 packet_length; UINT8 packet_id; UINT8 packet_data[256]; /* one bigger than

necessary */ } TFP_GPS_PACKET;

EXAMPLE:

The following example code performs the ioctl:SENDGPSPACKET:
#include “vxWorks.h” #include “stdio.h” #include “ioLib.h” #include “bc635.h” void test () { int fd; TFP_GPS_PACKET gps_packet; UINT32 id; int i; /* open device - get handle */ if ((fd = open (“/tfp0”, 0, 0)) == ERROR) { (void) printf (“open of %s failed: “, “/bc635/0”); printErrno (errnoGet ()); return (ERROR);

Datum BC635 PCI VxWorks Device Driver

79

packet_data[i] = (UINT8) tmp. printf(“Enter Packet Length (decimal plus one) : “). printErrno (errnoGet ()). MODE_GPS) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). SELTIMINGMODE. i).packet_length = (UINT8) tmp.packet_id = id.packet_length . printErrno (errnoGet ()). &tmp). (void) close (fd). i < gps_packet. } /* enable GPS packet processing mode */ if (ioctl (fd. } ioctl (fd. return (ERROR).Datum } /* enable GPS mode */ if (ioctl (fd. (void) close (fd). &id). for (i = 0. scanf (“%x”. scanf (“%d”. 4a) : “). gps_packet.i. i++) { printf(“Enter data (in hex) [%d] : “.e. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 80 . scanf (“%x”. SETGPSMDFLG. } /* fill GPS packet to send */ printf(“Enter Packet to Send (hex . GPS_FLG_ENA) == ERROR) { (void) printf (“ioctl(SETGPSMDFLG) failed: “). gps_packet. (void) close (fd). &tmp).1. return (ERROR). SENDGPSPACKET. gps_packet. (int) &gps_packet).

int i. } TFP_GPS_SENDRECEIVE_PACKET.h” #include “ioLib.h” #include “stdio. UINT8 packet_data[256].h” void test () { int fd. EXAMPLE: The following example code performs the ioctl:MANREQGPSPACKET: #include “vxWorks. This ioctl manually requests a GPS packet from the GPS. The send packet embedded in the following structure must be filled by the caller. /* one bigger than necessary */ } TFP_GPS_PACKET. UINT8 packet_id. /* open device . typedef struct { TFP_GPS_PACKET send. MANREQGPSPACKET Manually request a packet from GPS.Datum MANREQGPSPACKET COMMAND: PURPOSE: INPUTS: Type TFP_GPS_SENDRECEIVE_PACKET * Name/Description pTfpGpsPacket .get handle */ Datum BC635 PCI VxWorks Device Driver 81 .h” #include “bc635.GPS packet received. typedef struct { UINT8 packet_length. TFP_GPS_PACKET receive. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. UINT32 id. TFP_GPS_SENDRECEIVE_PACKET gps_packet.

packet_data[i] = (UINT8) tmp. 0)) == ERROR) { (void) printf (“open of %s failed: “.1. printErrno (errnoGet ()).packet_id = id. printErrno (errnoGet ()). scanf (“%d”. SETGPSMDFLG. } /* manually request gps packet */ Datum BC635 PCI VxWorks Device Driver 82 .i. gps_packet. MODE_GPS) == ERROR) { (void) printf (“ioctl(SELTIMINGMODE) failed: “). return (ERROR).Datum if ((fd = open (“/tfp0”. &tmp). return (ERROR). &tmp). (void) close (fd). i++) { printf(“Enter data (in hex) [%d] : “. scanf (“%x”.packet_length . 0. &id). 4a) : “). } /* enable GPS mode */ if (ioctl (fd. “/bc635/0”). i). SELTIMINGMODE. gps_packet. } /* enable GPS packet processing mode */ if (ioctl (fd. i < gps_packet. GPS_FLG_ENA) == ERROR) { (void) printf (“ioctl(SETGPSMDFLG) failed: “). scanf (“%x”. gps_packet. (void) close (fd). printf(“Enter Packet Length (decimal plus one) : “). printErrno (errnoGet ()). return (ERROR).packet_length = (UINT8) tmp. } /* fill GPS packet to send */ printf(“Enter Packet to Send (hex . for (i = 0.e.

packet_length . /* check if GPS link was ok */ if (gps_packet. gps_packet.receive. gps_packet. MANREQGPSPACKET. else { /* display packet received */ printf (“Packet id = %x. i < gps_packet. i++) printf (“[%x] = %x\n”. (int) &gps_packet).receive.packet_data[i]). for (i=0.receive.Datum ioctl (fd. gps_packet.packet_length == 0) printf (“Could not receive GPS System Message\n”). length=%d\n”.packet_id.1. } (void) close (fd). i.packet_length). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 83 .receive.receive.

h” void test () { int fd. this ioctl will enable the generation of the GPS packet received interrupt. BC635_INT_WAITONGPS. #include “vxWorks.h” #include “bc635.Datum BC635_INT_WAITONGPS COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0 BC635_INT_WAITONGPS Wait for next GPS event (packet) to arrive. 0) == ERROR) { Datum BC635 PCI VxWorks Device Driver 84 .h” #include “stdio.h” #include “ioLib. The ioctl:SETINTMASK need not be explicitly called to enable this type of interrupt. “/bc635/0”). printErrno (errnoGet ()). This ioctl will block waiting for the TFP to generate a PCI interrupt when the next GPS packet is received.get handle */ if ((fd = open (“/tfp0”. /* open device . } EXAMPLE: /* wait for next ‘GPS' interrupt to generated by the TFP */ if (ioctl (fd. return (ERROR). 0)) == ERROR) { (void) printf (“open of %s failed: “. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. 0. The following example code performs the ioctl:BC635_INT_WAITONGPS. Note that the ioctl:REQGPSPACKET and ioctl:MANREQGPSPACKET operate independent of this ioctl.

}/*end of test() */ Datum BC635 PCI VxWorks Device Driver 85 . return (ERROR). printErrno (errnoGet ()). } (void) close (fd). (void) close (fd).Datum (void) printf (“ioctl(BC635_INT_GPS) failed: “).

Set STROBE_USONLY to enable use of the minor (number of useconds) strobe time register only so as to strobe some number of microseconds ahead.h” #include “stdio. Set STROBE_DISABLE to disable strobe output (the output is held low). CONTROLSTROBE Set strobe control parameters. With this parameter set. Just the strobe related ioctls are called here: #include “vxWorks. This ioctl is to be called multiple times when setting multiple parameters: STROBE_SECUS STROBE_USONLY STROBE_ENABLE STROBE_DISABLE Set STROBE_SECUS to enable use of major and minor strobe time registers when setting the time at which the strobe output is to occur.h” #include “bc635. EXAMPLE: The following example code performs the ioctl:CONTROLSTROBE in the context of programming the strobe output to occur 24 hours ahead ot the time reference source..Choose one of the following defines listed below. Set STROBE_ENABLE to enable strobe output. Set this parameter when you wish to output the strobe some number of days ahead. This ioctl is to be called so as to set a specific control parameter for the strobe function of the TFP. One of the following defines is to be set.h” void test () { Datum BC635 PCI VxWorks Device Driver 86 .Datum CONTROLSTROBE COMMAND: PURPOSE: INPUTS: Type int Name/Description ctrlVal .h” #include “ioLib. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. the strobe output continues once per second once started.

get handle */ if ((fd = open (“/tfp0”. STROBE_SECUS) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). printErrno (errnoGet ()). return (ERROR). (void) close (fd).tv_usec = 0. printErrno (errnoGet ()). /* open device . TIME_BINARY) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). “/bc635/0”). return (ERROR). &tfpTv) == ERROR) { Datum BC635 PCI VxWorks Device Driver 87 . (void) close (fd). tfpTv. TFP_TV tfpTv. CONTROLSTROBE. SETSTROBETV. 0.tv. return (ERROR). STROBE_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). (void) close (fd). 0)) == ERROR) { (void) printf (“open of %s failed: “. if (ioctl (fd. } /* defensively disable strobe output for now */ if (ioctl (fd. SELTIMEFORMAT. return (ERROR).Datum int fd. printErrno (errnoGet ()). } /* program strobe to occur 24hrs ahead */ tfpTv. CONTROLSTROBE.tv_sec = 60 * 60 * 24.tv. } /* will use binary time to set strobe time */ if (ioctl (fd. printErrno (errnoGet ()). } /* enable use of major/minor strobe time */ if (ioctl (fd.

} /* a single strobe pulse will occur 24 hours ahead */ (void) close (fd). STROBE_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). } /* now enable strobe output */ if (ioctl (fd. printErrno (errnoGet ()). printErrno (errnoGet ()). return (ERROR). CONTROLSTROBE. (void) close (fd). (void) close (fd).Datum (void) printf (“ioctl(SETSTROBETV) failed: “). return (ERROR). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 88 .

/* Daylight Saving Time flag */ /* days since January 1 /* years since 1900 /* days since Sunday */ /* months since January /* day of the month /* hours after midnight /* minutes after the hour - /* seconds after the minute - Datum BC635 PCI VxWorks Device Driver 89 . 11] */ int tm_year. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. } TFP_TM. UINT32 status. 59] */ int tm_hour. [1. This ioctl is to be called when the TIME_DECIMAL time format had been selected using the ioctl:SELTIMEFORMAT. 365] */ int tm_isdst. 23] */ int tm_mday. [0. This ioctl must be used in conjunction with ioctl:CONTROLSTROBE. UINT32 usec.Pointer to TFP_TM structure SETSTROBETM Set the strobe time registers usind decimal time. [0. [0. Note that the ioctl:SELTIMEFORMAT need only be called once. int tm_wday. UINT32 hnsec. The vxWorks defined definition of the tm structure is: struct tm { int tm_sec. 59] */ int tm_min. }. The following is the definition of the TFP_TM structure: typedef struct { struct tm tm. 31] */ int tm_mon.Datum SETSTROBETM COMMAND: PURPOSE: INPUTS: Type TFP_TM * Name/Description pTfpTm . This ioctl is used to set the amount of time ahead of the current time reference that a strobe output will occur. [0. [0. [0. 6] */ int tm_yday.

} /* defensively disable strobe output for now */ if (ioctl (fd. If number of days is to be included in the strobe time. EXAMPLE: The following example code performs the SETSTROBETM ioctl.h” #include “bc635. } /* will use binary time to set strobe time */ Datum BC635 PCI VxWorks Device Driver 90 .Datum For this ioctl only the tm_hour. /* open device . } /* enable use of major/minor strobe time */ if (ioctl (fd. 0)) == ERROR) { (void) printf (“open of %s failed: “. return (ERROR). STROBE_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). printErrno (errnoGet ()).h” void test () { int fd. tm_min. tm_sec and usec members are used. printErrno (errnoGet ()). CONTROLSTROBE.h” #include “stdio. printErrno (errnoGet ()). “/bc635/0”). TFP_TM tfpTm. CONTROLSTROBE. #include “vxWorks.get handle */ if ((fd = open (“/tfp0”. 0.h” #include “ioLib. STROBE_SECUS) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). then use the ioctl:SETSTROBETV. (void) close (fd). return (ERROR). (void) close (fd). return (ERROR).

STROBE_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “).tm. &tfpTm) == ERROR) { (void) printf (“ioctl(SETSTROBETM) failed: “). printErrno (errnoGet ()). (void) close (fd). } /* now enable strobe output */ if (ioctl (fd.Datum if (ioctl (fd.tm_hour = 20.usec = 0. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 91 . if (ioctl (fd. } /* a single strobe pulse will occur 20 hours ahead */ (void) close (fd). (void) close (fd). printErrno (errnoGet ()). tfpTm. SELTIMEFORMAT. TIME_DECIMAL) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). return (ERROR). printErrno (errnoGet ()).tm_sec = 0. CONTROLSTROBE. return (ERROR). tfpTm.tm_min = 0. (void) close (fd). tfpTm. return (ERROR). } /* program strobe to occur 20hrs ahead */ tfpTm. SETSTROBETM.

Note that the ioctl:SELTIMEFORMAT need only be called once. UINT32 hnsec. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR. The following is the definition of the TFP_TV structure: typedef struct { struct timeval tv. This ioctl is used to set the amount of time ahead of the current time reference that a strobe output will occur. UINT8 status. The tv_sec member can be programmed so that the strobe output occurs up to 48 days ahead. #include “vxWorks. }. The vxWorks defined definition of the tv structure is: struct timeval tv { time_t tv_sec.h” #include “ioLib.h” Datum BC635 PCI VxWorks Device Driver 92 . This ioctl is to be called when the TIME_BINARY time format had been selected using the ioctl:SELTIMEFORMAT. This ioctl must be used in conjunction with ioctl:CONTROLSTROBE.h” #include “bc635. long tv_usec. EXAMPLE: The following example code performs the SETSTROBETV ioctl.Pointer to TFP_TV structure SETSTROBETV Set the strobe time registers using binary time.h” #include “stdio. } TFP_TV.Datum SETSTROBETV COMMAND: PURPOSE: INPUTS: Type TFP_TV * Name/Description pTfpTv . For this ioctl only the tv_sec and tv_usec members are used.

SELTIMEFORMAT. tfpTv.tv. printErrno (errnoGet ()). printErrno (errnoGet ()). CONTROLSTROBE. (void) close (fd). CONTROLSTROBE. /* open device . (void) close (fd). return (ERROR).tv_sec = 60 * 60 * 24 * 40. printErrno (errnoGet ()).Datum void test () { int fd.tv_usec = 0. return (ERROR).get handle */ if ((fd = open (“/tfp0”. Datum BC635 PCI VxWorks Device Driver 93 . } /* program strobe to occur 40 days ahead */ tfpTv. return (ERROR). 0. STROBE_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). return (ERROR). } /* enable use of major/minor strobe time */ if (ioctl (fd.tv. 0)) == ERROR) { (void) printf (“open of %s failed: “. “/bc635/0”). } /* defensively disable strobe output for now */ if (ioctl (fd. TIME_BINARY) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). STROBE_SECUS) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). printErrno (errnoGet ()). (void) close (fd). TFP_TV tfpTv. } /* will use binary time to set strobe time */ if (ioctl (fd.

Datum if (ioctl (fd. return (ERROR). (void) close (fd). &tfpTv) == ERROR) { (void) printf (“ioctl(SETSTROBETV) failed: “). CONTROLSTROBE. }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 94 . return (ERROR). (void) close (fd). printErrno (errnoGet ()). SETSTROBETV. STROBE_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). } /* now enable strobe output */ if (ioctl (fd. printErrno (errnoGet ()). } /* a single strobe pulse will occur 40 days ahead */ (void) close (fd).

SETSTROBETV must be called so as to configure strobe operation. TFP_TV tfpTv. “/bc635/0”). } /* defensively disable strobe output for now */ if (ioctl (fd. 0.get handle */ if ((fd = open (“/tfp0”. The following example code performs the ioctl:BC635_INT_WAITONSTROBE. printErrno (errnoGet ()). SETSTROBETM. STROBE_DISABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “).h” void test () { int fd.h” #include “stdio. RETURNS: DESCRIPTION: The ioctl returns OK or ERROR.h” #include “ioLib. This ioctl will block waiting for the TFP to generate a PCI interrupt when the time coincidence strobe output occurs. 0)) == ERROR) { (void) printf (“open of %s failed: “. CONTROLSTROBE. EXAMPLE: Datum BC635 PCI VxWorks Device Driver 95 . return (ERROR).Datum BC635_INT_WAITONSTROBE COMMAND: PURPOSE: INPUTS: Type int Name/Description Always 0 BC635_INT_WAITONSTROBE Wait for strobe output to occur. The ioctls CONTROLSTROBE. printErrno (errnoGet ()). /* open device .h” #include “bc635. #include “vxWorks.

return (ERROR).Datum (void) close (fd). printErrno (errnoGet ()). printErrno (errnoGet ()).tv_sec = 60 * 60 * 24 * 40.tv. (void) close (fd). tfpTv. printErrno (errnoGet ()). } /* will use binary time to set strobe time */ if (ioctl (fd. printErrno (errnoGet ()). STROBE_SECUS) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). SELTIMEFORMAT. &tfpTv) == ERROR) { (void) printf (“ioctl(SETSTROBETV) failed: “). return (ERROR). CONTROLSTROBE. return (ERROR). STROBE_ENABLE) == ERROR) { (void) printf (“ioctl(CONTROLSTROBE) failed: “). (void) close (fd). SETSTROBETV. } /* wait for strobe to occur */ Datum BC635 PCI VxWorks Device Driver 96 . TIME_BINARY) == ERROR) { (void) printf (“ioctl(SELTIMEFORMAT) failed: “). CONTROLSTROBE.tv_usec = 0. } /* now enable strobe output */ if (ioctl (fd. } /* program strobe to occur 40 days ahead */ tfpTv. (void) close (fd). return (ERROR).tv. } /* enable use of major/minor strobe time */ if (ioctl (fd. if (ioctl (fd. (void) close (fd). return (ERROR).

BC635_INT_WAITONSTROBE. 0) == ERROR) { (void) printf (“ioctl(BC635_INT_WAITONSTROBE) failed: “). } /* a single strobe pulse will occur 40 days ahead */ (void) close (fd). (void) close (fd).Datum if (ioctl (fd. printErrno (errnoGet ()). }/*end of test() */ Datum BC635 PCI VxWorks Device Driver 97 . return (ERROR).

Select GPS time format (default: UTC) SETLOCTMFLG .Request TFP data SETTCOUTFMT . Examples of how to use the ioctls listed below are found in the sample code file sample_vx. Also. SETCLKVAL . DISCBATT .c is listed in section 6 of this manual.Perform software reset of TFP.Set/Request Advance/Retard clock value (for 12083 boards only) SETGPSTMFMT .c.Year auto-increment flag (default: yes) Datum BC635 PCI VxWorks Device Driver 98 . Control Jam-Sync.Load D/A converter SETDISCGAIN . SETGENTMOFFSET .Observe IEEE 1344 Local Time Flag (default: enabled) SETYRINCFLG . SYNCRTC . SOFTWARERESET .Datum Undocumented IOCTLs The following ioctl calls are supported by this driver but not documented in this manual.Disconnect battery to RTC chip.Set TimeCode output format (default: IRIG-B) CONTROLTIMEBASE .Set generator Time Offset (default: 0) SETLOCTMOFFSET .Set clock source. sample_vx. Force Jam-Sync SETDAC .Set local time offset (default: 0) GETDATA .Sync external time to RTC.Set disciplining gain.

It programs PCI base address 0 (BAR0) register for a single instance of the bc635/637 board as. then an alternative routine(s) must be used to program the BAR0 address for your card Datum BC635 PCI VxWorks Device Driver 99 . The base address programmed is 0xFD04000.Datum 4.0 Target CPU Considerations The sysBC635Init routine is a BSP specific routine developed for the Motorola PowerPC Single-Board-Computer running VxWorks. If this address is not applicable to your BSP.

Example code.o bc635. 0x19) sample Datum bc635 PCI VxWorks Device Driver 100 . The file bc635.h sample_vx. There is a single bc635/637 installed on the MVME2604.Datum 5. The following is an example VxWorks shell session for an MVME2604 PowerPC singleboard-computer running vxWorks 5.o ld < sample_vx. The software is installed.0 Software Installation The following table gives a list of the object and header files needed to operate this driver: Filename bc635.c file contains a menu-driven program that may be compiled and loaded into vxWorks via the vxWorks shell.4. -> -> -> -> -> -> -> ld < sysBC635. then the driver is installed into the VxWorks IOS.o ld < bc635. Driver header file containing defines and structure definitions required by the application.h must be installed in an area that is accessible to the application software at software build time. The sample_vx.c Description Driver object file. Lastly the sample menu-driven routine is invoked. The output of the vxWorks devs routine would list the device “/tfp0”. The user then invokes sample at the shell prompt. The bc635/637 card installed is initialized for operation under VxWorks.o sysBC635Init tfpDrv tfpDevInstall (0.

** ** In no event will AP Labs be liable for any lost revenue or profits ** or other special. to assist a programmer in developing their own code using the driver.c . ****************************************************************************** */ /**************************************************************************************/ #include “vxWorks. usage or trade practice. even if AP Labs ** has been advised of the possibility of such damages.h” #include “stdio.0 Example /* sample.Datum 6. (An example of an erroneous action would be to read a decimal time format when the board is in binary time mode). It is intended as example code. (AP Labs) ** All rights reserved. and also does not prevent erroneous actions.This is an interactive test program demonstrating the functionality of the bc635/637 VxWorks Device Driver. with no warranties of any kind including ** the warranties of design. ** ** This file and its contents are a product of AP Labs. This test program lacks proper error checking. ** ** AP Labs shall have no liability with respect to the infringement of ** copyrights.h” #include “logLib.h” Datum bc635 PCI VxWorks Device Driver 101 . trade secrets or any patents by this file or any part thereof. ** All software distributed by AP Labs is done so under a software license. ** This file may not be copied or modified without execution of the ** appropriate software license agreement with AP Labs or explicit written ** permission of AP Labs. as a result of the ** usage of this file and software for which this file is a part. indirect and consequential damages. or arising from a course of dealing. ** ** This file is provided as is. */ /* ******************************************************************************* ** Copyright (C) 2000 Advanced Processing Laboratories Inc. merchantability and fitness for a particular ** purpose.

Datum

#include “taskLib.h” #include “ioLib.h” #include “errnoLib.h” #include “sysLib.h” #include “usrLib.h” #include “selectLib.h” #include “ctype.h” #include “string.h” #include “bc635.h” #include “sysLib.h”

#define RC_OK #define RC_ERROR -1

1

/**************************************************************************************/ /* Global Variables */ /**************************************************************************************/ int fd;

struct getdata_t get;

/* Forward declarations */

int

menu_main ();

/**************************************************************************************/ /* Description : main */ /**************************************************************************************/ int sample () {

if ((fd = open (“/tfp0”, 0, 0)) == ERROR) {

/* open bc635pci device */

printf (“Error opening Device Driver ......... Exiting”); printErrno (errnoGet ()); return (ERROR); }

return menu_main ();

}

/**************************************************************************************/

Datum bc635 PCI VxWorks Device Driver

102

Datum

/* Description: Set Oper Mode */ /**************************************************************************************/ void pci_mode () { int oper_mode = 0;

printf (“\n\n\n\t

Select Operational Mode:\n\n”);

printf (“\t0. Time Code Mode\n”); printf (“\t1. Free Running Mode\n”); printf (“\t2. External 1PPS\n”); printf (“\t3. Real Time Clock Mode\n”); printf (“\t4. GPS Mode\n\n”); printf (“\t Select: “);

scanf (“%i”, &oper_mode);

switch (oper_mode) { case 0: ioctl (fd, SELTIMINGMODE, (int) MODE_TIMECODE); /* Timing Mode: time * code */ break; case 1: ioctl (fd, SELTIMINGMODE, (int) MODE_FREERUN); /* Timing Mode: Free * Running */ break; case 2: ioctl (fd, SELTIMINGMODE, (int) MODE_EXT1PPS); break; case 3: ioctl (fd, SELTIMINGMODE, (int) MODE_RTC); break; case 4: ioctl (fd, SELTIMINGMODE, (int) MODE_GPS); break; default: printf (“Error setting opertional mode!!!!”); break; } } /* Timing Mode: GPS */ /* Timing Mode: RTC */ /* Timing Mode: 1PPS */

/**************************************************************************************/ /* Description : Set Time Code Format */ /**************************************************************************************/ void

Datum bc635 PCI VxWorks Device Driver

103

Datum

pci_time_code () { int int tc_fmt; tc_mod;

printf (“\n\n\n\t

Select Time Code Format:\n\n”);

printf (“\t1. IRIG A\n”); printf (“\t2. IRIG B\n\n”); printf (“\t Select: “);

scanf (“%d”, &tc_fmt); switch (tc_fmt) { case 1: ioctl (fd, SELTCFORMAT, TC_IRIGA); break; case 2: ioctl (fd, SELTCFORMAT, TC_IRIGB); break; default: printf (“Error Setting Time Code Format!”); break; } /* IRIG B time code */ /* IRIG A time code */

printf (“\n\n\n\t

Select Time Code Modulation:\n\n”);

printf (“\t1. Modulated\n”); printf (“\t2. DC Level Shift\n\n”); printf (“\t Select: “);

scanf (“%d”, &tc_mod); switch (tc_mod) { case 1: ioctl (fd, SELTCMOD, MOD_AM); break; case 2: ioctl (fd, SELTCMOD, MOD_DCLS); break; default: printf (“Error Setting Time Code Modulation!”); break; } } /* DCLS */ /* Modulated */

/**************************************************************************************/ /* Description : Set Output Frequency */ /**************************************************************************************/

Datum bc635 PCI VxWorks Device Driver

104

FREQ_5MHZ). FREQ_10MHZ). break. default: printf (“Error Setting output frequency!”). SELFREQUENCYOUT. break. case 1: /* decimal time format */ Datum bc635 PCI VxWorks Device Driver 105 . SELFREQUENCYOUT. case 2: ioctl (fd. printf (“Select Time Format\n scanf (“%d”. break. SELFREQUENCYOUT. case 3: ioctl (fd. 5 Select Output Frequency:\n\n”). switch (time_format) { case 0: ioctl (fd. &time_format).Datum void pci_out_freq () { int out_freq = 3. 10 MHz\n\n”). MHz\n”). Binary\n\nSelect: “). MHz\n”). switch (out_freq) { case 1: ioctl (fd. 1 printf (“\t2. &out_freq). TIME_DECIMAL). break. Decimal\n 1. } } /* 10 MHz */ /* 5 MHz */ /* 1 MHz */ /**************************************************************************************/ /* Description : Set Time Format */ /**************************************************************************************/ void pci_time_format () { int time_format = 0. scanf (“%d”. break. FREQ_1MHZ). SELTIMEFORMAT. printf (“\t Select: “). 0. printf (“\n\n\n\t printf (“\t1. printf (“\t3.

SETPERIODIC. Synchronous mode\n”). if (counter2 >= 2 && counter2 <= 65535) sper. break. &hrt_mode). counter2 = 10. } } /* Binary time format */ /**************************************************************************************/ /* Description : Set Heartbeat Counters */ /**************************************************************************************/ void pci_heartbeat () { struct periodic sper.Datum ioctl (fd. sper. printf (“\t1. &counter1). (int) &sper). &counter2). if (counter1 >= 2 && counter1 <= 65535) sper. counter1 = 10. if (hrt_mode == 2) sper. SELTIMEFORMAT. scanf (“%i”. default: printf (“\nError Setting Time Format!”). } /**************************************************************************************/ /* Description : Set Time */ /**************************************************************************************/ Datum bc635 PCI VxWorks Device Driver 106 . printf (“\n\tEnter 4 hex value for counetr2: \n”). printf (“\t2.sync1pps = PERIODIC_SYNC. printf (“\n\n\n\t Heartbeat Counters and Mode:\n\n”). TIME_BINARY). printf (“\n\tEnter 4 hex value for counetr1: \n”). Asynchronous mode\n\n”).n2 = counter2. printf (“\t Select: “). scanf (“%i”. scanf (“%i”.n1 = counter1. int int int hrt_mode. ioctl (fd.sync1pps = PERIODIC_NOSYNC. break.

year).tm. /* Set year */ case 2: printf (“\n\tEnter Year [1970-2036]: “). scanf (“%d”.tm. scanf (“%d”. SETTIMETM. scanf (“%d”. &tm. else printf (“\nError: Value Out of Range”). printf (“\t2.tm. printf (“\t Enter Sec [0-59]: “). Datum bc635 PCI VxWorks Device Driver 107 . Set Year\n”). &tm. time_t tUsr_secs.tm. if (year >= 1990 && year <= 2050) ioctl (fd. scanf (“%d”. printf (“\t1.tm_sec).tm. year = 1999. (int)&tm). SETYEAR. ioctl (fd. printf (“\t3. &(tm. &year). scanf (“%d”. Set Time TV\n”). printf (“\t Select: “). scanf (“%d”. printf (“\t Enter Hour [0-23]: “). scanf (“%d”. &tm. break. &choice). printf (“\tEnter Year Day [0-366]: “).tm_min).Datum void pci_set_time () { int int TFP_TM TFP_TV choice. printf (“\n\n\n\t Set Time Functions :\n\n”).tm_year)). time_t t1970_secs. switch (choice) { case 1: printf (“\n\tEnter Year (1990 to 2050): \n”). printf (“\t Enter Min [0-59]: “).tm_hour). struct tm tmpTm. tv. tm. &tm.tm_yday). Set Time TM\n”).

tmpTm.tm_mon = 0. * But.h). &tmpTm.month.tm_hour = 0. case 3: /* * We will prompt the user for year.tm_sec).tm_min = 0. tmpTm.tm_min).tm_mday = 1. tmpTm. /* now get 1970 seconds */ tmpTm. we will * calculate ‘seconds from 1900 to 1970' and * ‘seconds from 1900 to user's date' and then subtract two. tmpTm.tm_isdst = 0. scanf (“%d”.tm_hour).day info * and then use the vxWorks mktime() routine * to generate a ‘binary' time of ‘seconds from 1970'.tm_year)). scanf (“%d”. &tmpTm. &tmpTm.tm_mday).tm_wday = 0. &tmpTm.tm_sec = 0.Datum break. printf (“\t Enter Hour [0-23]: “). &(tmpTm. tmpTm.tm_yday = 0. Datum bc635 PCI VxWorks Device Driver 108 . tmpTm.tm_mon). scanf (“%d”. scanf (“%d”.tm_yday = 0. tmpTm. printf (“\t Enter Month [0-11]: “). tmpTm. printf (“\tEnter Month Day [1-31]: “). printf (“\t Enter Min [0-59]: “). printf (“\t Enter Sec [0-59]: “). */ /* prompt user for time/date info */ printf (“\n\tEnter Year [1970-2036]: “). vxWorks apparently calculates this based on * ‘seconds from 1900' (see time. &tmpTm. scanf (“%d”. /* generate ‘1900 to user-date seconds' */ tUsr_secs = mktime (&tmpTm).tm_wday = 0. So. tmpTm. scanf (“%d”.

Datum tmpTm. const char stm_fmt[2][10] = {“Decimal”. tmpTm.tm_year = 1970. tc_fmt = ‘ ‘.tmode. /* generate ‘1900 to 1970 seconds' */ t1970_secs = mktime (&tmpTm). “GPS”}. smode[mode]).arg = GETDATA_MODE. dac_val = 0. “RTC”. /* now generate ‘1970 to user-date seconds' */ tv. int int int int INT16 INT16 u_char u_char u_char UINT8 tm_fmt = 0. timing_off = 0. clk_scr = ‘ ‘. loc_off = 0. (int)&tv).data. ioctl (fd. } } /**************************************************************************************/ /* Description : Request Current Settings */ /**************************************************************************************/ void pci_req_current_settings () { const char smode[7][10] = {“Time Code”. break. mode = 0.tv. year = 0. tc_mod = ‘ ‘.t1970_secs. (int) &get)) < 0)) mode = (int) get.tm_isdst = 0. get. gen_off = 0. /* Timing Mode */ if (!((ioctl (fd. “ Reserved”. printf (“\nMode\t\t: %s”. Datum bc635 PCI VxWorks Device Driver 109 . default: break. “Ext 1PPS”.tv_sec = tUsr_secs . “Reserved”. GETDATA. SETTIMETV. “Free Run”. “Binary”}.

get.year. /* Time Code Modulation */ if (!((ioctl (fd. get. get. printf (“\nLoc Time Offset\t: %d”.data.arg = GETDATA_PER. GETDATA.arg = GETDATA_TCOUTFMT. printf (“\nTCOUTFMT\t: %d”. get. timing_off).arg = GETDATA_UTCINFO.data.leapevt=%d. GETDATA. /* Year */ if (!((ioctl (fd.n1.locoff.utc. year).data. get. if (!((ioctl (fd. GETDATA.arg = GETDATA_TCFMT.evttime). get. get.utc. GETDATA. (int) &get)) < 0)) tc_mod = (u_char) get. get.leapsec. GETDATA. tc_mod). GETDATA. printf (“\nTime Format\t: %s”. (int) &get)) < 0)) tm_fmt = (int) get. get.arg = GETDATA_YEAR. ioctl (fd. get.data. GETDATA.data. printf (“\nPeriodic Output\t: sync1pps=%x n1=%x.leapsec=%d.offset. printf (“\nTime Code\t: IRIG %c”. ioctl (fd.evttime=%x”. get. get.period.data.sync1pps. get. (int) &get)) < 0)) tc_fmt = (u_char) get. printf (“\nCode Modulation\t: %c”. stm_fmt[tm_fmt]). get. (int) &get)) < 0)) timing_off = (int) get.offset.data. printf (“\nTiming Offset\t: %d”. GETDATA.data.Datum get.data. (int) &get)) < 0)) loc_off = get.enable.arg = GETDATA_LOCTMOFF. Datum bc635 PCI VxWorks Device Driver 110 . ioctl (fd.period.data.arg = GETDATA_TOFF.utc. n2=%x”.tcoutfmt).data. loc_off).tformat.utc. printf (“\nUTC\t : enable=%d. printf (“\nYear\t\t: %d”. (int)&get). (int) &get). if (!((ioctl (fd. GETDATA. (int) &get).arg = GETDATA_TFORMAT. /* Time Format */ if (!((ioctl (fd.tcmod.data. get. (int) &get)) < 0)) year = (int) get.leapevt.arg = GETDATA_TCMOD.tcformat. /* Time Code Format */ if (!((ioctl (fd.data. get. tc_fmt).period.data.n2).

arg = GETDATA_JAMSC.data. get. get. printf (“\nFWVER\t: vmajor=%d.data. leap_tm=%d”. GETDATA.ocsctl.month. gen_off). get. get.gain. printf (“\nOCSCTL\t: discctl=%d. get.data.data. ioctl (fd.ocsctl.arg = GETDATA_DAVAL. GETDATA. ioctl (fd.con).ocsctl. gain=%x. get. \t: Internal”).data.data. GETDATA.ls_flag.arg = GETDATA_LEAPSEC. get.discctl. (int) &get).leap_tm).arg = GETDATA_OSCCTL. if (clk_scr == ‘I') printf (“\nOscillator else printf (“\nOscillator \t: External”).data.ocsctl. get. get.arg = GETDATA_FWVER. get. get.genoff.davalue. (int) &get)) < 0)) clk_scr = (u_char) get. year=%d”.data. (int) &get).version. get. GETDATA.arg = GETDATA_BATTSTAT. (int) &get)) < 0)) gen_off = get.data.vmajor. printf (“\nGen Time Offset\t: %d”.version. ioctl (fd. printf (“\nJAMSC\t\t: %d”.year).offset.data. get. get. phasestep=%d. (int) &get)) < 0)) dac_val = (int) get. con=%x”.version.phasectl. ioctl (fd.jsctl). get.vminor.arg = GETDATA_TCGENOFF. if (!((ioctl (fd. dac_val).leapsec.version.data. if (!((ioctl (fd. day=%d. get. GETDATA.clksrc.ocsctl.version.data. get. get. (int) &get).data.data.Datum get. printf (“\nDAC Value\t: %x”. vminor=%d. printf (“\nLEAPSEC: ls_flag=%d.phasestep. phasectl=%d.day. (int) &get). month=%d. Datum bc635 PCI VxWorks Device Driver 111 . get.arg = GETDATA_CLKSRC. GETDATA. GETDATA. get.data.leapsec. if (!((ioctl (fd.data.

data.dt01.data. get. ioctl (fd.tfp7.assemb).arg = GETDATA_DTFW.tfpm. get.data.dt08.dt11).serialnum). (int) &get).data.data.arg = GETDATA_TFPMODEL.data.tfp8). get. get.tfpm.data. (int) &get). get.dt06.data.data.dtfw.Datum ioctl (fd.battstat).dt07.tfpm. get. get.tfp2. (int) &get).data.tfp4.tfp1.dtfw.dtfw. get.dtfw.tfpm. get. GETDATA.data. printf (“\nSERIAL Number\t: %x”. printf (“\nDTFW\t\t: %c%c%c%c%c%c%c%c%c%c%c”. GETDATA. get. get.dt09. get.tfp6.dtfw.data.arg= GETDATA_CLKVAL. get. GETDATA.arg = GETDATA_SERIAL. get.data.dtfw. printf (“\nASSEMB\t\t: %x”. ioctl (fd.dtfw.data.dtfw.dtfw. GETDATA. (int) &get).tfpm.clkval).tfp5. get.tfp3.data. get. ioctl (fd. get. get. printf (“\nBATSTATT\t: %x”.data.data. (int) &get). Datum bc635 PCI VxWorks Device Driver 112 .dt04.dt10.dt03.tfpm. get. get. ioctl (fd.tfpm.data.data.arg = GETDATA_ASSEMB.data. printf (“\nCLKVAL\t\t: %x”. get. get. ioctl (fd.data.dt05.data. get. get. GETDATA. get. get. get.dtfw. GETDATA.tfpm. printf (“\nTFPMODEL\t: %c%c%c%c%c%c%c%c”.dtfw. (int) &get).dt02. get.data.

pTm->hnsec).tm_year).Datum return.tm_hour). char tmbuf[80]. pTm->tm. pTm->tm.tm_sec). pTm->tm.tm_yday). (void) printf (“ tv_sec: %lu (x%08X)\n”. tm_min: %d\n”.tm_min). pTm->usec). status: x%01X\n”. tm_year: %d\n”. } /*************************************************************************** * tmPrint . pTm->tm. usec: %d\n”.print ‘tm' struct * * RETURNS: OK */ LOCAL STATUS tmPrint ( TFP_TM * pTm ) { (void) printf (“\n (void) printf (“ (void) printf (“ (void) printf (“ (void) printf (“ (void) printf (“ (void) printf (“ (void) printf (“ tm_sec: %d\n”. return (OK). pTm->status). Datum bc635 PCI VxWorks Device Driver 113 . } /*************************************************************************** * tvPrint .print ‘tv' struct * * RETURNS: OK */ LOCAL STATUS tvPrint ( TFP_TV * pTv ) { struct tm tm. tm_hour: %d\n”. size_t bufLen = sizeof(tmbuf). tm_yday: %d\n”. hnsec: %d\n”. pTm->tm.

BINARY)\n”). RDTIMETVREQ (Latched. DECIMAL)\n”). BINARY)\n”). RDTIMETMREQ (Latched.tv_sec). &tm). RDEVENTTVREQ (Latched. DECIMAL)\n”). printf (“\t5. status: x%01X\n”. pTv->tv. tfpTM. printf (“\t7. BINARY)\n\n”). printf (“\n Enter Choice : “). EVENTREQUEST (Latch Event)\n”).tv_sec. printf (“\t8. RDTIMETM (Unlatched. /* display date/time */ (void) printf (“time/date: %s\n”. TIMEREQUEST (Latch Time)\n”). (int) pTv->tv. return (OK). printf (“\t1. printf (“\t4. pTv->hnsec). gmtime_r (&pTv->tv. printf (“\t9.tv_usec). printf (“\t2. &choice). pTv->status). scanf (“%i”. DECIMAL)\n”). printf (“\t3. ioctl_choice. printf (“\t6. hnsec: x%x\n”. } /**************************************************************************************/ /* Description : read_time_menu */ /**************************************************************************************/ void read_time_menu () { int int int int TFP_TM TFP_TV choice. tmbuf. tfpTV. RDEVENTTM (Unlatched. BINARY)\n\n”). printf (“\n\n\n Read Time Formats:\n\n”). asctime_r (&tm. printf (“\t10. (void) printf (“ (void) printf (“ (void) printf (“ usec: x%ld\n”. tmbuf). print_choice. RDTIMETV (Unlatched. &bufLen). RDEVENTRTMEQ (Latched.Datum pTv->tv. Datum bc635 PCI VxWorks Device Driver 114 . RDEVENTTV (Unlatched. DECIMAL)\n”).tv_sec. arg_choice.

arg_choice = (int) &tfpTV. break. case 7: print_choice = TIME_BINARY. arg_choice = (int) &tfpTM. ioctl_choice = TIMEREQUEST. case 5: print_choice = TIME_DECIMAL. ioctl_choice = RDTIMETMREQ. break. break. case 8: print_choice = TIME_BINARY. /* none */ Datum bc635 PCI VxWorks Device Driver 115 . ioctl_choice = RDTIMETM.Datum switch (choice) { case 1: print_choice = TIME_DECIMAL. arg_choice = (int) &tfpTM. break. arg_choice = (int) &tfpTV. ioctl_choice = RDTIMETVREQ. arg_choice = (int) &tfpTM. case 4: print_choice = TIME_BINARY. break. ioctl_choice = RDEVENTTVREQ. case 9: print_choice = TIME_BINARY + TIME_DECIMAL. ioctl_choice = RDEVENTTM. break. case 2: print_choice = TIME_DECIMAL. ioctl_choice = RDEVENTTV. ioctl_choice = RDEVENTTMREQ. arg_choice = (int) &tfpTV. break. case 3: print_choice = TIME_BINARY. arg_choice = (int) &tfpTV. break. case 6: print_choice = TIME_DECIMAL. arg_choice = (int) &tfpTM. ioctl_choice = RDTIMETV.

else if (print_choice == TIME_BINARY) (void) tvPrint (&tfpTV). arg_choice = (int) 0. arg_choice) == ERROR) { (void) printf (“ioctl (%d) failed: “.Datum arg_choice = (int) 0. &strobe_secs). ioctl_choice. case 10: print_choice = TIME_BINARY + TIME_DECIMAL. TFP_TM tfpTM. scanf(“%i”. } /**************************************************************************************/ /* Description : pci_strobe_routines */ /**************************************************************************************/ void pci_strobe_routines () { int strobe_secs. return. } if (print_choice == TIME_DECIMAL) (void) tmPrint (&tfpTM). } Datum bc635 PCI VxWorks Device Driver 116 . return. printf(“\n\tEnter number of seconds till strobe : “). } if (ioctl (fd. /* none */ default: printf (“Not implemented\n”). ioctl_choice). break. break. printErrno (errnoGet ()). return. if ((strobe_secs < 1) || (strobe_secs > 59)) /* can't do this */ { printf(“strobe must be between 1 and 59 seconds for this test \n”). ioctl_choice = EVENTREQUEST.

tm_sec + strobe_secs < 60) tfpTM. TIME_DECIMAL).but since our example is in seconds we have time to it after */ printf(“Got Strobe\n”). } /**************************************************************************************/ /* Description : pci_interrupt_routines */ /**************************************************************************************/ void pci_interrupt_routines () { int choice. Wait on Strobe\n”).tm.tm_sec + strobe_secs . else { tfpTM. Wait on 1 PPS\n”).tm.tm_sec = tfpTM. ioctl (fd.tm. } } printf (“\nStrobe time is: \n”).tm_min + 1. SETSTROBETM. SELTIMEFORMAT. (int)&tfpTM). ioctl (fd. RDTIMETMREQ. printf (“3. if (tfpTM. Wait on Periodic\n”). 0).tm. Datum bc635 PCI VxWorks Device Driver 117 . BC635_INT_WAITONSTROBE.tm_sec + strobe_secs.tm.Datum ioctl (fd.60.tm_sec = tfpTM. printf (“1. printf (“4. /* Should be a task that starts up before the strobe . tmPrint(&tfpTM). printf (“\n\n”).tm.tm_min = tfpTM. return. /* doesn't handle the roll over */ else { printf(“Test program is not smart enough to strobe now\n”). tmPrint(&tfpTM). (int)&tfpTM). /* decimal time format */ /* Get current time */ ioctl (fd. printf (“2. printf(“\nCurrent time is: \n”). if (tfpTM.tm. Wait on Event\n”).tm_min < 59) tfpTM.tm.

BC635_INT_WAITONPERIODIC. case 3: ioctl (fd. i < 5. i++) { ioctl (fd. break. i++) { ioctl (fd. printf (“Got 1PPS\n”). } } break. case 4: { int i. 0). Wait on GPS\n”).0). scanf (“%i”. i < 5. BC635_INT_WAITONSTROBE. } } break. case 5: ioctl (fd. printf (“Got STROBE\n”). 0). default: break. switch (choice) { case 1: ioctl (fd. 0). printf (“ Select : “). for (i=0. printf (“Got EVENT\n”). printf (“Got PERIODIC\n”). BC635_INT_WAITONEVENT. BC635_INT_WAITONGPS. for (i=0. &choice). } } /**************************************************************************************/ /* Description : pci_intstat_routines() */ Datum bc635 PCI VxWorks Device Driver 118 . BC635_INT_WAITON1PPS.Datum printf (“5. printf (“Got GPS\n”).0). case 2: { int i. break. break.

intstat & INT_BITMASK). &intstat). scanf (“%i”. break. scanf (“%i”. RDINTSTAT. break. SETINTMASK. case 2: printf (“/nEnter value : “). ioctl (fd. switch (choice) { case 1: intstat = 0. printf (“3. break. Read Intstat \n”). ioctl (fd. &choice). break.Datum /**************************************************************************************/ void pci_intstat_routines () { int choice. printf (“2. } } /**************************************************************************************/ /* Description : Main Menu */ /**************************************************************************************/ void pci_sw_reset () Datum bc635 PCI VxWorks Device Driver 119 . printf (“ Select : “). intstat). Set Intmask \n”). RDINTMASK. (int)&intstat). &intstat). intstat & INT_BITMASK). printf (“1. case 4: printf (“/nEnter value : “). ioctl (fd. scanf (“%i”. Read Intmask \n”). UINT32 intstat. printf (“\n\n”). (int)&intstat). Set Intstat \n”). SETINTSTAT. case 3: intstat = 0. printf (“INTSTAT = %x\n”. printf (“INTMASK = %x\n”. intstat). printf (“4. default: break. ioctl (fd.

Set Local Time Offset \n”). int choice.half_hour = (UINT8) halfhour.offset = (INT16) offset. switch (choice) { case 1: { struct tcgenoffset genoffset. &halfhour). Datum bc635 PCI VxWorks Device Driver 120 . ioctl (fd. printf (“Enter Offset : “). scanf (“%i”. case 2: { struct loctmoffset locoffset. (int)&genoffset). scanf (“%i”. locoffset.offset = (INT16) offset. scanf (“%i”. &choice).Datum { ioctl (fd. genoffset. SOFTWARERESET. locoffset. printf (“Enter Half Hour (0 or 1) : “). printf (“2. default: break. (int) &locoffset). genoffset. ioctl (fd. UINT32 halfhour. SETLOCTMOFFSET.half_hour = (UINT8) halfhour. &offset). } void pci_set_offsets () { UINT32 offset. 0). printf (“\n\n 1. printf (“ Select : “). SETGENTMOFFSET. Set Generator time offset \n”). } break. } break.

&id). gps_packet.packet_length = 0. &utmp). (int) &leapsec). gps_packet.packet_length == 0) Datum bc635 PCI VxWorks Device Driver 121 . leapsec.ls_flag = (INT8) tmp.i. ioctl (fd. printf(“Enter Packet to receive (hex . ioctl (fd. if (gps_packet. scanf (“%i”. &delay). scanf (“%x”. UINT32 id. scanf (“%i”. 4a) : “). printf(“Enter delay : “). } void pci_set_leapsec_event () { INT32 tmp. scanf (“%i”. ioctl (fd. (int)&gps_packet).leap_tm = tmp. leapsec. printf (“Enter Leap Sec Flag : “). SETLEAPSECEVENT. struct leapseconds leapsec. SETPROPDELAY.packet_id = id.Datum } } void pci_set_prop_delay() { UINT32 delay. UINT32 utmp. delay). } void pci_gps_example () { TFP_GPS_PACKET gps_packet. &tmp). printf (“Enter Leap Time (Unix Format) : “).e. int i. REQGPSPACKET.

tmp.tmp.packet_id = id. gps_packet.send.packet_data[i]). 4a) : “). scanf (“%x”. } void pci_gps_example3 () { TFP_GPS_SENDRECEIVE_PACKET gps_packet. scanf (“%x”. } ioctl (fd.e. i). gps_packet. Datum bc635 PCI VxWorks Device Driver 122 .Datum printf(“GPS Example .Could not receive GPS System Message\n”).packet_data[i] = (UINT8) tmp. SENDGPSPACKET.packet_length-1. gps_packet. printf(“Enter Packet to Send (hex .packet_id. &id). i++) printf (“[%x] = %x\n”. printf(“Enter Packet Length (decimal plus one) : “).packet_id = id. gps_packet. i < gps_packet. &id). scanf (“%d”.i++) { printf(“Enter data (in hex) [%d] : “. int i. printf(“Enter Packet to Send (hex . gps_packet. else { printf(“Packet id = %x. UINT32 id.packet_length). lenght=%d\n”. } } void pci_gps_example2 () { TFP_GPS_PACKET gps_packet. scanf (“%x”. i<gps_packet. gps_packet. (int)&gps_packet). scanf (“%d”.i. for (i=0. &tmp).packet_length = (UINT8) tmp. gps_packet. int i. &tmp). 4a) : “). for (i=0.packet_length-1. &tmp).e.i. UINT32 id. printf(“Enter Packet Length (decimal plus one) : “). i.

Datum gps_packet. 4a) : “). printf (“\n\t Select : “). gps_packet. printf (“\n\t 1) Disable”).send. ioctl (fd. gps_packet. gps_packet.packet_length-1.send.Could not receive GPS System Message\n”).receive. else { printf(“Packet id = %x. } printf(“Enter Packet to receive (hex .packet_data[i]).receive.packet_length). &tmp). gps_packet. gps_packet. i).i.i++) { printf(“Enter data (in hex) [%d] : “.packet_length == 0) printf(“GPS Example . for (i=0. printf (“\n\t 2) Enable”).packet_length = 0.receive. if (gps_packet. MANREQGPSPACKET. } } void pci_set_gps_mode () { int mode. gps_packet.packet_id = id. &mode).receive. scanf (“%x”. mode). &id).e.receive. scanf (“%i”. } Datum bc635 PCI VxWorks Device Driver 123 .packet_id.packet_data[i] = (UINT8) tmp. scanf (“%x”. SETGPSMDFLG.packet_length-1. lenght=%d\n”. (int)&gps_packet).receive. for (i=0. i < gps_packet. i++) printf (“[%x] = %x\n”. ioctl (fd.send. i.packet_length = (UINT8) tmp. i<gps_packet.receive.

CLOCK_EXTERNAL). int i. scanf (“%i”. tvPrint(&tfpTV). else printf (“Invalid value\n”). /* binary time format */ for (i = 0. RDTIMETVREQ. else if (clock == 2) ioctl(fd. CONTROLTIMEBASE. if (clock == 1) ioctl(fd. TIME_BINARY). /* every 2 seconds */ } } /**************************************************************************************/ /* Description : Main Menu */ /**************************************************************************************/ int menu_main () { Datum bc635 PCI VxWorks Device Driver 124 . CONTROLTIMEBASE. &clock). i ++) { /* Get current time */ ioctl (fd. (int)&tfpTV). CLOCK_INTERNAL). ioctl (fd. } void pci_looping_time() { TFP_TV tfpTV. External=2) : “). taskDelay(60*2). printf(“\nCurrent time is: \n”).Datum void pci_set_gps_time_format() { } void pci_set_clock_source() { int clock. SELTIMEFORMAT. i <= 10. printf (“\n\t Enter Clock Source (Internal = 1.

case 4: pci_out_freq (). Set GPS Mode \n”). break. break. 22. switch (menu) { case 1: read_time_menu (). break.Datum int menu. printf (“0. printf (“5. Set GPS TM Fmt\n”). case 7: pci_set_time (). Read time/Event Functions Select Operational Mode Select Time Code Format Select Output Freq Select Time Format Program Heartbeat Set Time Functions Select Clock Source Current Settings 14. 16. GPS Example3\n”). break. printf (“4. 15. &menu). break. case 5: pci_time_format (). scanf (“%i”. break. printf (“10. 17. printf (“8. bc635PCI Time & Frequency Processor\n\n”). GPS Example1 \n”). printf (“9. Interrupt Routines\n”). Strobe printf (“11. Select: “). 18. case 2: pci_mode (). 20. case 3: pci_time_code (). printf (“3. Datum bc635 PCI VxWorks Device Driver 125 . Capunlock \n”). printf (“7. do { printf (“\n printf (“ printf (“1. 23. printf (“12. printf (“13. printf (“2. 19. Bancomm-Timing Division\n\n”). Set Offsets \n”). 21. Software reset\n”). Interrupt Stat Routines\n”). GPS Example2\n”). case 6: pci_heartbeat (). Leap Sec \n”). printf (“ Exit the Program \n\n”). printf (“6. Datum Inc. Prop Delay \n”). Looping Time\n”).

CAPUNLOCK. Datum bc635 PCI VxWorks Device Driver 126 . case 17: ioctl (fd. break. break. case 19: pci_set_gps_mode(). case 16: pci_set_leapsec_event(). case 22: pci_gps_example3(). break. break. case 14: pci_set_offsets (). break. case 9: pci_req_current_settings (). break. case 12: pci_intstat_routines (). case 18: pci_gps_example(). case 13: pci_sw_reset (). break. 0). break. case 10: pci_strobe_routines (). break. break. case 15: pci_set_prop_delay(). case 11: pci_interrupt_routines (). case 8: pci_set_clock_source(). case 21: pci_gps_example2(). break. break. break.Datum break. case 20: pci_set_gps_time_format(). break.

} Datum bc635 PCI VxWorks Device Driver 127 . } } while (1). break.Datum break. case 0: default: return OK. case 23: pci_looping_time().