2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
17 #define POSITIONING_BASE_LIBRARY_LIBRARY_INCLUDE_VEHICLE_SERVICE_SYS_TIMERAPI_H_
20 * @file sys_timerapi.h
21 * @brief Header file for timer management
24 /** @addtogroup BaseSystem
27 /** @addtogroup vehicle_service
31 /** @addtogroup positioning_base_library
32 * @ingroup vehicle_service
36 /*---------------------------------------------------------------------------------*
38 *---------------------------------------------------------------------------------*/
40 #define WTM_DUPTIME_MAX 5 //!< \~english duplication timer max count
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
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
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
64 #define END_TIMER_RPT_OFF 0 //!< \~english No continuation
65 #define END_TIMER_RPT_ON 1 //!< \~english With continuation
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
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]
80 #define TIM_ROLOVR_DISABLE 0 //!< \~english GPS week rollover correct prohibition
81 #define TIM_ROLOVR_ENABLE 1 //!< \~english GPS week rollover correct permission
85 * \~english timer manager error definition
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
94 * \~english command notify information definition(almanac abnormality notify, and time enable notify)
96 #define TIM_NUM_SNDCMD 4 //!< \~english command send number
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
107 #define TMT_RETRY 3 //!< \~english retry count
108 #define TMT_RETRY_INTERVAL 500 //!< \~english retry interval(500[msec])
111 /*---------------------------------------------------------------------------------*
112 * Struct declaration *
113 *---------------------------------------------------------------------------------*/
116 * \~english define data type
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
126 * @struct RealTimeData
127 * \~english current time data
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
144 * @struct RealTimeDataBcd
145 * \~english current time data(BCD format)
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)
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)
164 * \~english GPS time setting data
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
177 * @struct TimerToutMsg
178 * \~english timeout message
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
187 * @struct TimerTimeReq
188 * \~english timer start request
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
200 * @struct TimerAlrmReq
201 * \~english time specified timer start request
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
214 * @struct TimerStopReq
215 * \~english timer stop request
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
226 * @struct GpsSetTimeReq
227 * \~english GPS RTC time set request
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
238 * @struct GpsSetTimeReq
239 * \~english time difference set request
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
250 * @struct T_TIM_RCV_DATA
251 * \~english command notify information structure
254 PNO SndPno; //!< \~english command delivery PNO
256 //!< \~english almanac abnormal judgement notify complete flag
257 u_int8 ucInvalid_Flg;
258 //!< \~english time acquisition notify complete flag
262 * @struct TimerSramData
263 * \~english timer SRAM data structure
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
275 * @struct SysTimeData
276 * \~english system time data
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)
290 * \~english year convert table
292 typedef struct TimeCnvTbl_tag {
293 uint32_t ulYear; //!< \~english year
294 uint32_t ulCount; //!< \~english count
295 uint32_t ulMonth[12]; //!< \~english month
300 * \~english day convert table
302 typedef struct DayCnvTbl_tag {
303 YearCntTbl stTbl[CNV_YEAR_MAX]; //!< \~english year convert table
307 * @struct TG_TIM_ROLOVR_GPSWEEKCORDATA
308 * \~english GPS week correction data
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;
317 * @struct TIMECHGIND_MSG
318 * \~english time change information message structure
321 T_APIMSG_MSGBUF_HEADER Header; //!< \~english message header
322 RealTimeData RealTime; //!< \~english data body(current time data)
326 * @struct T_TIM_CMDMSG
327 * \~english time available notification/almanac abnormality notification structure
330 T_APIMSG_MSGBUF_HEADER Header; //!< \~english message header
334 * @struct T_TIM_RETTIMEMSG
335 * \~english time setting response message
338 T_APIMSG_MSGBUF_HEADER Header; //!< \~english message header
339 int8 cResult; //!< \~english process result
340 int8 dummy[2]; //!< \~english dummy data
344 * @struct TimerModDat
345 * \~english current time data module structure
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
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_