Now that we are registering a clock even for the PPS master when it supports that (i.e. when it is a PHC), introduce a new API to retrieve its clock in order to add timestamps to it. The PHC master can be synchronized to the extts events of a PHC slave, when in automatic mode. Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /**
 | |
|  * @file ts2phc_master.h
 | |
|  * @note Copyright (C) 2019 Richard Cochran <richardcochran@gmail.com>
 | |
|  * @note SPDX-License-Identifier: GPL-2.0+
 | |
|  */
 | |
| #ifndef HAVE_TS2PHC_MASTER_H
 | |
| #define HAVE_TS2PHC_MASTER_H
 | |
| 
 | |
| #include <time.h>
 | |
| 
 | |
| struct config;
 | |
| 
 | |
| /**
 | |
|  * Opaque type
 | |
|  */
 | |
| struct ts2phc_private;
 | |
| struct ts2phc_master;
 | |
| 
 | |
| /**
 | |
|  * Defines the available PPS master clocks.
 | |
|  */
 | |
| enum ts2phc_master_type {
 | |
| 	TS2PHC_MASTER_GENERIC,
 | |
| 	TS2PHC_MASTER_NMEA,
 | |
| 	TS2PHC_MASTER_PHC,
 | |
| };
 | |
| 
 | |
| /**
 | |
|  * Create a new instance of a PPS master clock.
 | |
|  * @param priv	Pointer to the program's data structure.
 | |
|  * @param dev   Name of the master clock or NULL.
 | |
|  * @param type	The type of the clock to create.
 | |
|  * @return	A pointer to a new PPS master clock on success, NULL otherwise.
 | |
|  */
 | |
| struct ts2phc_master *ts2phc_master_create(struct ts2phc_private *priv,
 | |
| 					   const char *dev,
 | |
| 					   enum ts2phc_master_type type);
 | |
| 
 | |
| /**
 | |
|  * Destroy an instance of a PPS master clock.
 | |
|  * @param master Pointer to a master obtained via @ref ts2phc_master_create().
 | |
|  */
 | |
| void ts2phc_master_destroy(struct ts2phc_master *master);
 | |
| 
 | |
| /**
 | |
|  * Returns the time on the PPS source device at which the most recent
 | |
|  * PPS event was generated.
 | |
|  * @param master Pointer to a master obtained via @ref ts2phc_master_create().
 | |
|  * @param ts     Buffer to hold the time of the last PPS event.
 | |
|  * @return       Zero if the reported time is valid, non-zero otherwise.
 | |
|  */
 | |
| int ts2phc_master_getppstime(struct ts2phc_master *master, struct timespec *ts);
 | |
| 
 | |
| struct clock *ts2phc_master_get_clock(struct ts2phc_master *m);
 | |
| 
 | |
| #endif
 |