forked from xl4-shiro/excelfore-gptp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgptpmasterclock.h
More file actions
143 lines (129 loc) · 4.83 KB
/
gptpmasterclock.h
File metadata and controls
143 lines (129 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* Excelfore gptp - Implementation of gPTP(IEEE 802.1AS)
* Copyright (C) 2019 Excelfore Corporation (https://excelfore.com)
*
* This file is part of Excelfore-gptp.
*
* Excelfore-gptp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Excelfore-gptp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Excelfore-gptp. If not, see
* <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>.
*/
/**
* @addtogroup gptp
* @{
* @file gptpmasterclock.h
* @author Shiro Ninomiya
* @copyright Copyright (C) 2017-2018 Excelfore Corporation
* @brief file contains gptp master clock related functions.
*
*/
#ifndef __GPTPMASTERCLOCK_H_
#define __GPTPMASTERCLOCK_H_
/**
* @brief Pre-initialize to get the gptp clock.
* @param object platform specific object, refer to the platforms supported below.
* @return -1 on error, 0 on Successful initialization.
*
* @note This API needs to called only on platforms that recommends against using
* shared memory.
*
* The following are known target platforms requiring this API:
*
* GHS INTEGRITY:
*
* usage: gptpmasterclock_preinit(Semaphore object)
* The semaphore object used to synchronize communication between
* gptp2d VAS and VASes the uses libgptp2If library. User can get
* this shared semaphore object by calling the INTEGRITY API
* SemaphoreObjectNumber(TheObjectIndex). Where TheObjectIndex
* is a LINK object number defined in the application's ".int"
* file which is linked to the binary semaphore defined in the
* gptp2d '.int' file.
* e.g: gptpmasterclock_preinit(SemaphoreObjectNumber(10));
*
* This API doesn't need to be called in platforms other than the above mentioned.
* Calling this API in other platforms has no effect.
*/
int gptpmasterclock_preinit(void *object);
/**
* @brief initialize to get gptp clock from gptp2 daemon.
* if previously initialized, it will simply return 0.
* @param shemem_name shared memory node name. set NULL to use the default
* @return -1 on error, 0 on Successful initialization.
* @note argument 'shmem_name' will not be used in platforms that recommends against
* using shared memory (e.g GHS INTEGRITY). Pass NULL is such case.
*/
int gptpmasterclock_init(const char *shmem_name);
/**
* @brief close gptpmasterclcock
* @return -1: on error, 0:on successfull
*/
int gptpmasterclock_close(void);
/**
* @brief return the domainIndex which is currently used as systeme wide gptp clock.
* @return domainIndex, -1: error
*/
int gptpmasterclock_gm_domainIndex(void);
/**
* @brief return the domainNumber which is currently used as system wide gptp clock.
* @return domainIndex, -1: error, domain number on success.
*/
int gptpmasterclock_gm_domainNumber(void);
/**
* @brief get 64-bit nsec unit ts of system wide gptp clock
* @return 0 on success, -1 on error
*
*/
int64_t gptpmasterclock_getts64(void);
/**
* @brief Wait until tts comes.
* @return -1: error, 1:already passed, 2:in vclose, 3:farther than toofar seconds,
* 0:returns from nanosleep(has been waited to very close timing)
* @param tts target time in nano second unit
* @param vclose nano second unit; treated as very close, and stop waiting
* even ttv is still in future
* @param toofar nano second unit; treated as too far, and stop waiting
*/
int gptpmasterclock_wait_until_ts64(int64_t tts, int64_t vclose, int64_t toofar);
/**
* @brief expand 32-bit nsec time to 64 bit with aligning to gptp clock.
* @param timestamp timestamp which we are going to convert into 32bit to 64 bit.
* @return expanded time
* @note a range of -2.147 to 2.147 secconds can be correctly aligned
*
*/
uint64_t gptpmasterclock_expand_timestamp(uint32_t timestamp);
/**
* @brief get GM change indicator, the number is incremented whenever GM is changed
* @return GM change indicator value, -1: on error
*/
int gptpmasterclock_gmchange_ind(void);
/**
* @brief get maximum number of domains
* @param void
* @return returns availabe number of domains.
*/
int gptpmasterclock_get_max_domains(void);
/**
* @brief get a synchronized clock value on specific domain
* @param ts64 pointer to return clock value
* @param domainIndex domain index number
* @return 0 on success, -1 on error.
*/
int gptpmasterclock_get_domain_ts64(int64_t *ts64, int domainIndex);
/**
* @brief print phase offset for all domains
*/
void gptpmasterclock_dump_offset(void);
#endif
/** @}*/