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.
17 /******************************************************************************
18 * File name : ClockDataMng.h
19 * System name : PastModel002
20 * Subsystem name : Time-related processing
21 ******************************************************************************/
22 #ifndef POSITIONING_SERVER_INCLUDE_SENSOR_CLOCKDATAMNG_H_
23 #define POSITIONING_SERVER_INCLUDE_SENSOR_CLOCKDATAMNG_H_
25 #include <vehicle_service/positioning_base_library.h>
28 #include "positioning_hal.h"
29 #include "CanInput_API.h"
30 #include "Sensor_API.h"
32 /********************************************************************************
34 *********************************************************************************/
35 #define CLOCKDATAMNG_SECONDS_PAR_WEEK (7 * 24 * 60 * 60)
36 #define CLOCKDATAMNG_CNV_WEEK2SEC(WEEK) ((WEEK)* CLOCKDATAMNG_SECONDS_PAR_WEEK)
38 /* [PastModel002 Specifications]Time difference tolerance(plus or minus 512 week or less,GPS TIME range from 0 to 1023 week) */
39 #define CLOCKDATAMNG_TIME_DIFF_LIMIT_UPPER (512 * CLOCKDATAMNG_SECONDS_PAR_WEEK)
40 #define CLOCKDATAMNG_TIME_DIFF_LIMIT_LOWER (-512 * CLOCKDATAMNG_SECONDS_PAR_WEEK)
42 /* [PastModel002 Specifications]Time difference addition value(+1024week,GPS TIME range from 0 to 1023 week) */
43 #define CLOCKDATAMNG_TIME_DIFF_ADD_VALUE (CLOCKDATAMNG_TIME_DIFF_LIMIT_UPPER * 2)
45 /* [PastModel002 Specifications]GPS TIME weekNo scope */
46 #define CLOCKDATAMNG_GPS_TIME_WEEKNO_LIMIT 1024
48 /* [PastModel002 Specifications]Initial value of time difference information at the previous shutdown */
49 #define CLOCKDATAMNG_TIME_DIFF_INIT_VALUE 0x7FFFFFFFL
51 /* [PastModel002 Specifications]AID-INI lifetime(+4Time) */
52 #define CLOCKDATAMNG_AID_INI_EFFECTIVE_TIME (4 * 60 * 60)
54 /* [PastModel002 Specifications]AID-EPH lifetime(plus or minus 2 hours) */
55 #define CLOCKDATAMNG_AID_EPH_EFFECTIVE_TIME (2 * 60 * 60)
57 #define MUTEX_CLOCKDATAMNG __TEXT("MUTEX_VEHICLE_CLOCKDATAMNG")
59 /********************************************************************************
60 * Struct definitions *
61 *********************************************************************************/
62 /********************************************************************************
63 * TAG :CLOCKDATAMNG_GPS_TIME
64 * ABSTRACT :GPS time structure
66 ********************************************************************************/
68 u_int32 tow; /* Time of week (msec) */
69 int16 week_no; /* GPS Week No. */
70 u_int8 reserve[2]; /* reserve */
71 BOOL validity_flag; /* Enabled/DisabledFlagging */
72 } CLOCKDATAMNG_GPS_TIME;
74 /********************************************************************************
75 * Function prototype *
76 *********************************************************************************/
81 BOOL ClockDataMngInitialize(void);
82 void ClockDataMngSetLastTimeDiff(int32 time_diff);
84 void ClockDataMngSetGpsTime(const SENSOR_MSG_GPSDATA_DAT *gps_time_data);
85 void ClockDataMngGetGpsTime(CLOCKDATAMNG_GPS_TIME *gps_time_data);
87 BOOL ClockDataMngGetLocalTime(const CANINPUT_MSG_LOCALTIMEINFO_DAT *can_local_time, LOCALTIME *vehicle_local_time);
88 BOOL ClockDataMngGetTimeDiff(LOCALTIME *local_time, int32 *time_diff);
90 void ClockDataMngGetStartupTime(CLOCKDATAMNG_GPS_TIME *start_up_time);
91 int32 ClockDataMngCalculateTimeDiff(int32 munuend, int32 subtrahend);
93 BOOL ClockDataMngCheckLocalTime(LOCALTIME *local_time);
94 int32 ClockDataMngConversionLocalTime2GpsTime(LOCALTIME *local_time, BOOL calc_second_available);
100 #endif // POSITIONING_SERVER_INCLUDE_SENSOR_CLOCKDATAMNG_H_