summaryrefslogtreecommitdiffstats
path: root/positioning_base_library/library/include/vehicle_service/sys_timerapi.h
blob: 03a24ff46ec6a1423ec4722db2e296d8aaf4d933 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
#define POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_

/**
 * @file sys_timerapi.h
 * @brief Header file for timer management
 */

/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup vehicle_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup positioning_base_library
 *  @ingroup vehicle_service
 *  @{
 */

/*---------------------------------------------------------------------------------*
 * Definition                                                                      *
 *---------------------------------------------------------------------------------*/

#define WTM_DUPTIME_MAX   5  //!< \~english duplication timer max count

#define  TIMER_TYPE_SYN   1
//!< \~english fixing cycle timer(unit: 100ms)
#define  TIMER_TYPE_USN   2
//!< \~english asynchronous timer(unit: 100ms)
#define  TIMER_TYPE_ALM   5  //!< \~english specific time timer

#define  SUN              0    //!< \~english sunday
#define  MON              1    //!< \~english monday
#define  TUE              2    //!< \~english tuesday
#define  WED              3    //!< \~english wednesday
#define  THU              4    //!< \~english thursday
#define  FRI              5    //!< \~english friday
#define  SAT              6    //!< \~english saturday
#define DEFAULT_DIFFTIME  0x00  //!< \~english time difference value of japan

#define  GPS_SAT          0x00  //!< \~english corrected GPS time
#define  GPS_IST          0x01  //!< \~english not corrected GPS time
#define  GPS_RTC          0x02  //!< \~english RTC time
#define  GPS_IRG          0x03  //!< \~english initial time
#define GPS_NON           0x7E  //!< \~english GPS unused
#define  GPS_IGN          0x7F  //!< \~english time not received

#define END_TIMER_RPT_OFF 0     //!< \~english No continuation
#define END_TIMER_RPT_ON  1     //!< \~english With continuation

#define  CID_TIMER_SETGPS 0x4040
//!< \~english command ID of GPS setting timer
#define  CID_TIMER_DIFSET 0x4045
//!< \~english command ID of time difference setting timer
#define  CID_TIMER_CYCLE  (CID)(CID_TIMER_BASE | CID_COM_SERIAL5)
//!< \~english command ID of cycle data receive timer

#define  CNV_YEAR_MAX     136
//!< \~english max value of conversion year(number of years + 1)
#define  SEC_PER_MIN      60  //!< \~english 60[sec]
#define  SEC_PER_HOUR     3600          //!< \~english 60[min] * 60[sec]
#define  SEC_PER_DAY      86400  //!< \~english 24[h] * 60[min] * 60[sec]

#define TIM_ROLOVR_DISABLE 0  //!< \~english GPS week rollover correct prohibition
#define TIM_ROLOVR_ENABLE   1  //!< \~english GPS week rollover correct permission

/*
 * Definition
 * \~english timer manager error definition
 */
#define RET_ERR_NONEINIT  (-30)  //!< \~english initialization untreated error
#define RET_ERR_SEMLOCK   (-31)  //!< \~english get semaphore error
#define RET_ERR_SEMUNLOCK (-32)  //!< \~english open semaphore error
#define RET_ERR_SRAMREAD  (-33)  //!< \~english read SRAM error

/*
 * Definition
 * \~english command notify information definition(almanac abnormality notify, and time enable notify)
 */
#define TIM_NUM_SNDCMD    4    //!< \~english command send number

#define NON_TIMEUNIT_INVALID_TIME  0
//!< \~english No time manager unit - system time not set
#define NON_TIMEUNIT_VALID_TIME    1
//!< \~english No time manager unit - system time set complete
#define GPS_INVALID_TIME           2
//!< \~english With GPS unit - system time not set
#define GPS_VALID_TIME             3
//!< \~english With GPS unit - system time set complete

#define TMT_RETRY                  3    //!< \~english retry count
#define TMT_RETRY_INTERVAL         500  //!< \~english retry interval(500[msec])


/*---------------------------------------------------------------------------------*
 * Struct declaration                                                              *
 *---------------------------------------------------------------------------------*/

/**
 * \~english define data type
 */
typedef struct {
  u_int32    TimeOut[WTM_DUPTIME_MAX];  //!< \~english timeout value
  u_int8     ContFlg;  //!< \~english continue flag
  u_int8     Dummy1;  //!< \~english dummy data
  u_int16    Dummy2;  //!< \~english dummy data
} TimerDupData;

/**
 * @struct RealTimeData
 * \~english current time data
 */
typedef struct {
  u_int16    Yyear;    //!< \~english current time(year:A.D.)
  u_int8     Mmonth;   //!< \~english (month)
  u_int8     Dday;     //!< \~english (day)
  u_int8     Hhour;    //!< \~english (hour)
  u_int8     Mmin;     //!< \~english (min)
  u_int8     Ssec;     //!< \~english (sec)
  u_int8     Wweek;    //!< \~english (week)
  u_int8     CrtFlg;   //!< \~english GPS time not corrected/corrected flag
  u_int8     CrtHou;   //!< \~english the last correction(hour)
  u_int8     CrtMin;   //!< \~english min
  u_int8     CrtSec;   //!< \~english sec
} RealTimeData;

/**
 * @struct RealTimeDataBcd
 * \~english current time data(BCD format)
 */
typedef struct {
  u_int16    Yyear;  //!< \~english current time(year:A.D.BCD ex.0x1998)
  u_int8     Mmonth;  //!< \~english (month            BCD 0x01 to 0x12)
  u_int8     Dday;   //!< \~english (day              BCD 0x01 to 0x31)
  u_int8     Hhour;  //!< \~english (hour             BCD 0x00 to 0x23)
  u_int8     Mmin;   //!< \~english (min              BCD 0x00 to 0x59)
  u_int8     Ssec;   //!< \~english (sec              BCD 0x00 to 0x59)
  u_int8     Wweek;  //!< \~english (week             BIN 0x00 to 0x06)
  u_int8     CrtFlg;
  //!< \~english GPS time not corrected or corrected flag(BIN 0x00 to 0x03)
  u_int8     CrtHou;   //!< \~english the last correction(hour BCD 0x00 to 0x23)
  u_int8     CrtMin;   //!< \~english (min              BCD 0x00 to 0x59)
  u_int8     CrtSec;   //!< \~english (sec              BCD 0x00 to 0x59)
} RealTimeDataBcd;

/**
 * @struct GpsSetData
 * \~english GPS time setting data
 */
typedef struct {
  u_int16    Yyear;    //!< \~english current time(year:A.D.)
  u_int8     Mmonth;   //!< \~english (month)
  u_int8     Dday;     //!< \~english (day)
  u_int8     Hhour;    //!< \~english (hour)
  u_int8     Mmin;     //!< \~english (min)
  u_int8     Ssec;     //!< \~english (sec)
  u_int8     Dummy;    //!< \~english dummy data
} GpsSetData;

/**
 * @struct TimerToutMsg
 * \~english timeout message
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
  u_int16    Dummy;     //!< \~english dummy
} TimerToutMsg;

/**
 * @struct TimerTimeReq
 * \~english timer start request
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  PNO        SndPno;    //!< \~english process No.(claimant specific)
  u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
  u_int8     TimeType;  //!< \~english timer type
  u_int8     Dummy[3];  //!< \~english dummy data
  TimerDupData  DupData;  //!< \~english timeout value
} TimerTimeReq;

/**
 * @struct TimerAlrmReq
 * \~english time specified timer start request
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  PNO        SndPno;    //!< \~english process No.(claimant specific)
  u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
  u_int8     TimeHou;   //!< \~english specific timeout hour
  u_int8     TimeMin;   //!< \~english                   min
  u_int8     TimeSec;   //!< \~english                   sec
  u_int8     Dummy;     //!< \~english dummy
} TimerAlrmReq;

/**
 * @struct TimerStopReq
 * \~english timer stop request
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  PNO        SndPno;    //!< \~english process No.(claimant specific)
  u_int16    TimerSeq;  //!< \~english timer sequence No.(claimant specific)
  u_int8     TimeType;  //!< \~english timer type
  u_int8     Dummy[3];  //!< \~english dummy data
} TimerStopReq;

/**
 * @struct GpsSetTimeReq
 * \~english GPS RTC time set request
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  PNO        SndPno;   //!< \~english process No.(claimant specific)
  u_int8     Dummy1;   //!< \~english dummy data
  u_int8     Dummy2;   //!< \~english dummy data
  GpsSetData SetData;  //!< \~english GPS setting data
} GpsSetTimeReq;

/**
 * @struct GpsSetTimeReq
 * \~english time difference set request
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  int8       DiffTime;  //!< \~english time difference value
  int8       Dummy1;    //!< \~english dummy data
  int16      Dummy2;    //!< \~english dummy data
} SetDiffTimeReq;


/**
 * @struct T_TIM_RCV_DATA
 * \~english command notify information structure
 */
typedef struct {
  PNO        SndPno;   //!< \~english command delivery PNO
  u_int8     ucAlmanc_Flg;
  //!< \~english almanac abnormal judgement notify complete flag
  u_int8     ucInvalid_Flg;
  //!< \~english time acquisition notify complete flag
} T_TIM_RCV_DATA;

/**
 * @struct TimerSramData
 * \~english timer SRAM data structure
 */
typedef struct {
  u_int32    navitime;   //!< \~english Navi operation addition time
  int8       _difftime;  //!< \~english time difference value of current time
  int8       timeUnit;   //!< \~english specific time manager unit
  int8       dummy[2];   //!< \~english dummy data
  T_TIM_RCV_DATA  timCmdData[TIM_NUM_SNDCMD];
  //!< \~english command receive information
} TimerSramData;

/**
 * @struct SysTimeData
 * \~english system time data
 */
typedef struct {
  u_int16    Yyear;    //!< \~english current time(year:A.D.BCD ex. 0x1998)
  u_int8     Mmonth;   //!< \~english (month      BCD 0x01 to 0x12)
  u_int8     Dday;     //!< \~english (day        BCD 0x01 to 0x31)
  u_int8     Hhour;    //!< \~english (hour       BCD 0x00 to 0x23)
  u_int8     Mmin;     //!< \~english (min        BCD 0x00 to 0x59)
  u_int8     Ssec;     //!< \~english (sec        BCD 0x00 to 0x59)
  u_int8     Wweek;    //!< \~english (week       BIN 0x00 to 0x06)
} SysTimeData;

/**
 * @struct YearCntTbl
 * \~english year convert table
 */
typedef struct TimeCnvTbl_tag {
  uint32_t  ulYear;       //!< \~english year
  uint32_t  ulCount;       //!< \~english count
  uint32_t  ulMonth[12];       //!< \~english month
}  YearCntTbl;

/**
 * @struct DayCntTbl
 * \~english day convert table
 */
typedef struct DayCnvTbl_tag {
  YearCntTbl    stTbl[CNV_YEAR_MAX];       //!< \~english year convert table
} DayCntTbl;

/**
 * @struct TG_TIM_ROLOVR_GPSWEEKCORDATA
 * \~english GPS week correction data
 */
typedef struct {
  u_int8 gpsweekcorcnt;       //!< \~english GPS week rollover correct count
  u_int8 permission;       //!< \~english GPS week rollover correct permission
  u_int8 dummy[2];    //!< \~english dummy data
} TG_TIM_ROLOVR_GPSWEEKCORDATA;

/**
 * @struct TIMECHGIND_MSG
 * \~english time change information message structure
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  RealTimeData    RealTime;  //!< \~english data body(current time data)
} TIMECHGIND_MSG;

/**
 * @struct T_TIM_CMDMSG
 * \~english time available notification/almanac abnormality notification structure
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
} T_TIM_CMDMSG;

/**
 * @struct T_TIM_RETTIMEMSG
 * \~english time setting response message
 */
typedef struct {
  T_APIMSG_MSGBUF_HEADER  Header;    //!< \~english message header
  int8            cResult;  //!< \~english process result
  int8            dummy[2];       //!< \~english dummy data
} T_TIM_RETTIMEMSG;

/**
 * @struct TimerModDat
 * \~english current time data module structure
 */
typedef struct {
  u_int32    InitFlg;  //!< \~english initialization complete flag
  u_int8     CrtFlg;   //!< \~english corrected/not corrected flag
  u_int8     CrtHou;   //!< \~english the last correction: hour
  u_int8     CrtMin;   //!< \~english                       min
  u_int8     CrtSec;   //!< \~english                       sec
} TimerModDat;

/** @}*/  // end of positioning_base_library
/** @}*/  // end of vehicle_service
/** @}*/  // end of BaseSystem
#endif  // POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_