common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning_base_library / library / include / vehicle_service / sys_timerapi.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
17 #define POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
18
19 /**
20  * @file sys_timerapi.h
21  * @brief Header file for timer management
22  */
23
24 /** @addtogroup BaseSystem
25  *  @{
26  */
27 /** @addtogroup vehicle_service
28  *  @ingroup BaseSystem
29  *  @{
30  */
31 /** @addtogroup positioning_base_library
32  *  @ingroup vehicle_service
33  *  @{
34  */
35
36 /*---------------------------------------------------------------------------------*
37  * Definition                                                                      *
38  *---------------------------------------------------------------------------------*/
39
40 #define WTM_DUPTIME_MAX   5  //!< \~english duplication timer max count
41
42 #define  TIMER_TYPE_SYN   1
43 //!< \~english fixing cycle timer(unit: 100ms)
44 #define  TIMER_TYPE_USN   2
45 //!< \~english asynchronous timer(unit: 100ms)
46 #define  TIMER_TYPE_ALM   5  //!< \~english specific time timer
47
48 #define  SUN              0    //!< \~english sunday
49 #define  MON              1    //!< \~english monday
50 #define  TUE              2    //!< \~english tuesday
51 #define  WED              3    //!< \~english wednesday
52 #define  THU              4    //!< \~english thursday
53 #define  FRI              5    //!< \~english friday
54 #define  SAT              6    //!< \~english saturday
55 #define DEFAULT_DIFFTIME  0x00  //!< \~english time difference value of japan
56
57 #define  GPS_SAT          0x00  //!< \~english corrected GPS time
58 #define  GPS_IST          0x01  //!< \~english not corrected GPS time
59 #define  GPS_RTC          0x02  //!< \~english RTC time
60 #define  GPS_IRG          0x03  //!< \~english initial time
61 #define GPS_NON           0x7E  //!< \~english GPS unused
62 #define  GPS_IGN          0x7F  //!< \~english time not received
63
64 #define END_TIMER_RPT_OFF 0     //!< \~english No continuation
65 #define END_TIMER_RPT_ON  1     //!< \~english With continuation
66
67 #define  CID_TIMER_SETGPS 0x4040
68 //!< \~english command ID of GPS setting timer
69 #define  CID_TIMER_DIFSET 0x4045
70 //!< \~english command ID of time difference setting timer
71 #define  CID_TIMER_CYCLE  (CID)(CID_TIMER_BASE | CID_COM_SERIAL5)
72 //!< \~english command ID of cycle data receive timer
73
74 #define  CNV_YEAR_MAX     136
75 //!< \~english max value of conversion year(number of years + 1)
76 #define  SEC_PER_MIN      60  //!< \~english 60[sec]
77 #define  SEC_PER_HOUR     3600          //!< \~english 60[min] * 60[sec]
78 #define  SEC_PER_DAY      86400  //!< \~english 24[h] * 60[min] * 60[sec]
79
80 #define TIM_ROLOVR_DISABLE 0  //!< \~english GPS week rollover correct prohibition
81 #define TIM_ROLOVR_ENABLE   1  //!< \~english GPS week rollover correct permission
82
83 /*
84  * Definition
85  * \~english timer manager error definition
86  */
87 #define RET_ERR_NONEINIT  (-30)  //!< \~english initialization untreated error
88 #define RET_ERR_SEMLOCK   (-31)  //!< \~english get semaphore error
89 #define RET_ERR_SEMUNLOCK (-32)  //!< \~english open semaphore error
90 #define RET_ERR_SRAMREAD  (-33)  //!< \~english read SRAM error
91
92 /*
93  * Definition
94  * \~english command notify information definition(almanac abnormality notify, and time enable notify)
95  */
96 #define TIM_NUM_SNDCMD    4    //!< \~english command send number
97
98 #define NON_TIMEUNIT_INVALID_TIME  0
99 //!< \~english No time manager unit - system time not set
100 #define NON_TIMEUNIT_VALID_TIME    1
101 //!< \~english No time manager unit - system time set complete
102 #define GPS_INVALID_TIME           2
103 //!< \~english With GPS unit - system time not set
104 #define GPS_VALID_TIME             3
105 //!< \~english With GPS unit - system time set complete
106
107 #define TMT_RETRY                  3    //!< \~english retry count
108 #define TMT_RETRY_INTERVAL         500  //!< \~english retry interval(500[msec])
109
110
111 /*---------------------------------------------------------------------------------*
112  * Struct declaration                                                              *
113  *---------------------------------------------------------------------------------*/
114
115 /**
116  * \~english define data type
117  */
118 typedef struct {
119   u_int32    TimeOut[WTM_DUPTIME_MAX];  //!< \~english timeout value
120   u_int8     ContFlg;  //!< \~english continue flag
121   u_int8     Dummy1;  //!< \~english dummy data
122   u_int16    Dummy2;  //!< \~english dummy data
123 } TimerDupData;
124
125 /**
126  * @struct RealTimeData
127  * \~english current time data
128  */
129 typedef struct {
130   u_int16    Yyear;    //!< \~english current time(year:A.D.)
131   u_int8     Mmonth;   //!< \~english (month)
132   u_int8     Dday;     //!< \~english (day)
133   u_int8     Hhour;    //!< \~english (hour)
134   u_int8     Mmin;     //!< \~english (min)
135   u_int8     Ssec;     //!< \~english (sec)
136   u_int8     Wweek;    //!< \~english (week)
137   u_int8     CrtFlg;   //!< \~english GPS time not corrected/corrected flag
138   u_int8     CrtHou;   //!< \~english the last correction(hour)
139   u_int8     CrtMin;   //!< \~english min
140   u_int8     CrtSec;   //!< \~english sec
141 } RealTimeData;
142
143 /**
144  * @struct RealTimeDataBcd
145  * \~english current time data(BCD format)
146  */
147 typedef struct {
148   u_int16    Yyear;  //!< \~english current time(year:A.D.BCD ex.0x1998)
149   u_int8     Mmonth;  //!< \~english (month            BCD 0x01 to 0x12)
150   u_int8     Dday;   //!< \~english (day              BCD 0x01 to 0x31)
151   u_int8     Hhour;  //!< \~english (hour             BCD 0x00 to 0x23)
152   u_int8     Mmin;   //!< \~english (min              BCD 0x00 to 0x59)
153   u_int8     Ssec;   //!< \~english (sec              BCD 0x00 to 0x59)
154   u_int8     Wweek;  //!< \~english (week             BIN 0x00 to 0x06)
155   u_int8     CrtFlg;
156   //!< \~english GPS time not corrected or corrected flag(BIN 0x00 to 0x03)
157   u_int8     CrtHou;   //!< \~english the last correction(hour BCD 0x00 to 0x23)
158   u_int8     CrtMin;   //!< \~english (min              BCD 0x00 to 0x59)
159   u_int8     CrtSec;   //!< \~english (sec              BCD 0x00 to 0x59)
160 } RealTimeDataBcd;
161
162 /**
163  * @struct GpsSetData
164  * \~english GPS time setting data
165  */
166 typedef struct {
167   u_int16    Yyear;    //!< \~english current time(year:A.D.)
168   u_int8     Mmonth;   //!< \~english (month)
169   u_int8     Dday;     //!< \~english (day)
170   u_int8     Hhour;    //!< \~english (hour)
171   u_int8     Mmin;     //!< \~english (min)
172   u_int8     Ssec;     //!< \~english (sec)
173   u_int8     Dummy;    //!< \~english dummy data
174 } GpsSetData;
175
176 /**
177  * @struct TimerToutMsg
178  * \~english timeout message
179  */
180 typedef struct {
181   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
182   u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
183   u_int16    Dummy;     //!< \~english dummy
184 } TimerToutMsg;
185
186 /**
187  * @struct TimerTimeReq
188  * \~english timer start request
189  */
190 typedef struct {
191   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
192   PNO        SndPno;    //!< \~english process No.(claimant specific)
193   u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
194   u_int8     TimeType;  //!< \~english timer type
195   u_int8     Dummy[3];  //!< \~english dummy data
196   TimerDupData  DupData;  //!< \~english timeout value
197 } TimerTimeReq;
198
199 /**
200  * @struct TimerAlrmReq
201  * \~english time specified timer start request
202  */
203 typedef struct {
204   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
205   PNO        SndPno;    //!< \~english process No.(claimant specific)
206   u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
207   u_int8     TimeHou;   //!< \~english specific timeout hour
208   u_int8     TimeMin;   //!< \~english                   min
209   u_int8     TimeSec;   //!< \~english                   sec
210   u_int8     Dummy;     //!< \~english dummy
211 } TimerAlrmReq;
212
213 /**
214  * @struct TimerStopReq
215  * \~english timer stop request
216  */
217 typedef struct {
218   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
219   PNO        SndPno;    //!< \~english process No.(claimant specific)
220   u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
221   u_int8     TimeType;  //!< \~english timer type
222   u_int8     Dummy[3];  //!< \~english dummy data
223 } TimerStopReq;
224
225 /**
226  * @struct GpsSetTimeReq
227  * \~english GPS RTC time set request
228  */
229 typedef struct {
230   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
231   PNO        SndPno;   //!< \~english process No.(claimant specific)
232   u_int8     Dummy1;   //!< \~english dummy data
233   u_int8     Dummy2;   //!< \~english dummy data
234   GpsSetData SetData;  //!< \~english GPS setting data
235 } GpsSetTimeReq;
236
237 /**
238  * @struct GpsSetTimeReq
239  * \~english time difference set request
240  */
241 typedef struct {
242   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
243   int8       DiffTime;  //!< \~english time difference value
244   int8       Dummy1;    //!< \~english dummy data
245   int16      Dummy2;    //!< \~english dummy data
246 } SetDiffTimeReq;
247
248
249 /**
250  * @struct T_TIM_RCV_DATA
251  * \~english command notify information structure
252  */
253 typedef struct {
254   PNO        SndPno;   //!< \~english command delivery PNO
255   u_int8     ucAlmanc_Flg;
256   //!< \~english almanac abnormal judgement notify complete flag
257   u_int8     ucInvalid_Flg;
258   //!< \~english time acquisition notify complete flag
259 } T_TIM_RCV_DATA;
260
261 /**
262  * @struct TimerSramData
263  * \~english timer SRAM data structure
264  */
265 typedef struct {
266   u_int32    navitime;   //!< \~english Navi operation addition time
267   int8       _difftime;  //!< \~english time difference value of current time
268   int8       timeUnit;   //!< \~english specific time manager unit
269   int8       dummy[2];   //!< \~english dummy data
270   T_TIM_RCV_DATA  timCmdData[TIM_NUM_SNDCMD];
271   //!< \~english command receive information
272 } TimerSramData;
273
274 /**
275  * @struct SysTimeData
276  * \~english system time data
277  */
278 typedef struct {
279   u_int16    Yyear;    //!< \~english current time(year:A.D.BCD ex. 0x1998)
280   u_int8     Mmonth;   //!< \~english (month      BCD 0x01 to 0x12)
281   u_int8     Dday;     //!< \~english (day        BCD 0x01 to 0x31)
282   u_int8     Hhour;    //!< \~english (hour       BCD 0x00 to 0x23)
283   u_int8     Mmin;     //!< \~english (min        BCD 0x00 to 0x59)
284   u_int8     Ssec;     //!< \~english (sec        BCD 0x00 to 0x59)
285   u_int8     Wweek;    //!< \~english (week       BIN 0x00 to 0x06)
286 } SysTimeData;
287
288 /**
289  * @struct YearCntTbl
290  * \~english year convert table
291  */
292 typedef struct TimeCnvTbl_tag {
293   uint32_t  ulYear;       //!< \~english year
294   uint32_t  ulCount;       //!< \~english count
295   uint32_t  ulMonth[12];       //!< \~english month
296 }  YearCntTbl;
297
298 /**
299  * @struct DayCntTbl
300  * \~english day convert table
301  */
302 typedef struct DayCnvTbl_tag {
303   YearCntTbl    stTbl[CNV_YEAR_MAX];       //!< \~english year convert table
304 } DayCntTbl;
305
306 /**
307  * @struct TG_TIM_ROLOVR_GPSWEEKCORDATA
308  * \~english GPS week correction data
309  */
310 typedef struct {
311   u_int8 gpsweekcorcnt;       //!< \~english GPS week rollover correct count
312   u_int8 permission;       //!< \~english GPS week rollover correct permission
313   u_int8 dummy[2];    //!< \~english dummy data
314 } TG_TIM_ROLOVR_GPSWEEKCORDATA;
315
316 /**
317  * @struct TIMECHGIND_MSG
318  * \~english time change information message structure
319  */
320 typedef struct {
321   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
322   RealTimeData    RealTime;  //!< \~english data body(current time data)
323 } TIMECHGIND_MSG;
324
325 /**
326  * @struct T_TIM_CMDMSG
327  * \~english time available notification/almanac abnormality notification structure
328  */
329 typedef struct {
330   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
331 } T_TIM_CMDMSG;
332
333 /**
334  * @struct T_TIM_RETTIMEMSG
335  * \~english time setting response message
336  */
337 typedef struct {
338   T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
339   int8            cResult;  //!< \~english process result
340   int8            dummy[2];       //!< \~english dummy data
341 } T_TIM_RETTIMEMSG;
342
343 /**
344  * @struct TimerModDat
345  * \~english current time data module structure
346  */
347 typedef struct {
348   u_int32    InitFlg;  //!< \~english initialization complete flag
349   u_int8     CrtFlg;   //!< \~english corrected/not corrected flag
350   u_int8     CrtHou;   //!< \~english the last correction: hour
351   u_int8     CrtMin;   //!< \~english                       min
352   u_int8     CrtSec;   //!< \~english                       sec
353 } TimerModDat;
354
355 /** @}*/  // end of positioning_base_library
356 /** @}*/  // end of vehicle_service
357 /** @}*/  // end of BaseSystem
358 #endif  // POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
359