common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / positioning_hal / inc / Common / positioning_def.h
1 /*
2  * @copyright Copyright (c) 2017-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 /**
17 * @file positioning_def.h
18 */
19
20 #ifndef INC_COMMON_POSITIONING_DEF_H_
21 #define INC_COMMON_POSITIONING_DEF_H_
22
23 /*---------------------------------------------------------------------------*/
24 // Include files
25
26 #include <string.h>
27 #include <stdlib.h>
28 #include <sys/ioctl.h>
29
30 #include <native_service/frameworkunified_types.h>
31 #include <native_service/frameworkunified_application.h>
32 #include <native_service/frameworkunified_framework_if.h>
33 #include <native_service/frameworkunified_multithreading.h>
34 #include <native_service/frameworkunified_service_protocol.h>
35 #include <vehicle_service/std_types.h>
36 #include <vehicle_service/pos_message_header.h>
37 #include <vehicle_service/sys_timerapi.h>
38 #include <vehicle_service/WPF_STD.h>
39
40 #include "gps_hal.h"
41 #include "positioning_hal.h"
42
43 #include "positioning_log.h"
44
45 /*---------------------------------------------------------------------------*/
46 // Definition
47
48 #define POS_THREAD_NAME             "Positioning"
49
50 /**
51  * @enum ENUM_GPS_NMEA_INDEX
52  * \~english  NMEA index
53  */
54 typedef enum  {
55   GPS_NMEA_INDEX_GGA = 0,                     //!< \~english GGA
56   GPS_NMEA_INDEX_DGGA,                        //!< \~english DGGA
57   GPS_NMEA_INDEX_VTG,                         //!< \~english VTG
58   GPS_NMEA_INDEX_RMC,                         //!< \~english RMC
59   GPS_NMEA_INDEX_DRMC,                        //!< \~english DRMC
60   GPS_NMEA_INDEX_GLL,                         //!< \~english GLL
61   GPS_NMEA_INDEX_DGLL,                        //!< \~english DGLL
62   GPS_NMEA_INDEX_GSA,                         //!< \~english GSA
63   GPS_NMEA_INDEX_GSV1,                        //!< \~english GSV1
64   GPS_NMEA_INDEX_GSV2,                        //!< \~english GSV2
65   GPS_NMEA_INDEX_GSV3,                        //!< \~english GSV3
66   GPS_NMEA_INDEX_GSV4,                        //!< \~english GSV4
67   GPS_NMEA_INDEX_GSV5,                        //!< \~english GSV5
68   GPS_NMEA_INDEX_GST,                         //!< \~english GST
69   GPS_NMEA_INDEX__CWORD44__GP_3,                  //!< \~english _CWORD44_,GP,3
70   GPS_NMEA_INDEX__CWORD44__GP_4,                  //!< \~english _CWORD44_,GP,4
71   GPS_NMEA_INDEX_P_CWORD82_F_GP_0,                  //!< \~english _CWORD44_,GP,0
72   GPS_NMEA_INDEX_P_CWORD82_J_GP_1,                  //!< \~english _CWORD44_,GP,1
73   GPS_NMEA_INDEX_MAX                          //!< \~english GGA
74 } ENUM_GPS_NMEA_INDEX;
75
76 //!< \~english Gps cycle Data Event
77 #define GPS_EVT_CYCLEDATA_PROV       ("GPS_EVT_CYCLEDATA_PROV")
78 //!< \~english Event value: Waiting.
79 #define GPS_EVT_PROV_WAIT            (0x00000000)
80 //!< \~english Event value: Clear Waiting status.
81 #define GPS_EVT_PROV_RELEASE         (0x00000001)
82
83 //!< \~english Gps received
84 #define GPS_CYCLECMD_NOTRCV          (0x00)
85 //!< \~english Gps no received
86 #define GPS_CYCLECMD_RCV             (0x01)
87
88 //!< \~english store position of Hour data
89 #define GPSCMD_DRMC_HOUR_POS         (7)
90 //!< \~english store position of minute data
91 #define GPSCMD_DRMC_MIN_POS          (9)
92 //!< \~english store position of second data
93 #define GPSCMD_DRMC_SEC_POS          (11)
94 //!< \~english store position of status
95 #define GPSCMD_DRMC_STATUS_POS       (14)
96 //!< \~english store position of day data
97 #define GPSCMD_DRMC_DAY_POS          (54)
98 //!< \~english store position of month data
99 #define GPSCMD_DRMC_MONTH_POS        (56)
100 //!< \~english store position of year data
101 #define GPSCMD_DRMC_YEAR_POS         (58)
102
103 //!< \~english store position of control code
104 #define GPSCMD_RTC_CTRLCODE_POS      (0)
105 //!< \~english store position of year data (BCD)
106 #define GPSCMD_RTC_BCD_YEAR_POS      (1)
107 //!< \~english store position of month data(BCD)
108 #define GPSCMD_RTC_BCD_MONTH_POS     (2)
109 //!< \~english store position of day data(BCD)
110 #define GPSCMD_RTC_BCD_DAY_POS       (3)
111 //!< \~english store position of hour data(BCD)
112 #define GPSCMD_RTC_BCD_HOUR_POS      (4)
113 //!< \~english store position of minute data(BCD)
114 #define GPSCMD_RTC_BCD_MIN_POS       (5)
115 //!< \~english store position of second data(BCD)
116 #define GPSCMD_RTC_BCD_SEC_POS       (6)
117 //!< \~english store position of status
118 #define GPSCMD_RTC_STATUS_POS        (7)
119
120 #define GPSCMD_RTC_CTRLCODE          (0xA4)       //!< \~english control code (RTC)
121 #define GPSCMD_RTC_STATUS_UTCTIME    (0x00)       //!< \~english Normal
122 #define GPSCMD_RTC_STATUS_ERRTIME    (0x03)       //!< \~english AbNormal
123
124 // Internal thread activation status determination
125 #define THREAD_STS_MSK_POS_MAIN             (0x01)
126 #define THREAD_STS_MSK_POS_SENS             (0x02)
127 #define THREAD_STS_MSK_POS_GPS              (0x04)
128 #define THREAD_STS_MSK_POS_GPS_RECV         (0x08)
129 #define THREAD_STS_MSK_POS_GPS_ROLLOVER     (0x10)
130 #define POS_DID_GPS_NMEA                    0x8000009AU /* QAC 1281 */
131 #define POS_DID_GPS_CLOCK_DRIFT             0x800000B3U /* QAC 1281 */
132 #define POS_DID_GPS_CLOCK_FREQ              0x800000B4U /* QAC 1281 */
133 #define VEHICLE_DID_GPS_CUSTOMDATA          0x80000094U
134 #define VEHICLE_DID_GPS_CLOCK_DRIFT         POS_DID_GPS_CLOCK_DRIFT
135 #define VEHICLE_DID_GPS_CLOCK_FREQ          POS_DID_GPS_CLOCK_FREQ
136 #define CID_NAVIINFO_DELIVER                (0x0205)  /* Navigation information setting CID  */
137 #define CID_NAVIINFO_SPEED_DELIVER          (0x0206)  /* Vehicle speed setting CID    */
138 #define VEHICLE_DID_GPS_WKNROLLOVER         0x800000B2U
139 #define VEHICLE_DID_GPS_TIME_RAW            0x800000B1
140 #define POS_DID_GYRO_TEMP                   0x80000090
141 #define VEHICLE_DID_SPEED_PULSE             0x80000012
142 #define VEHICLE_DID_GYRO_X                  0x80000014
143 #define VEHICLE_DID_GYRO_Y                  0x80000020
144 #define VEHICLE_DID_GYRO_Z                  0x80000021
145 #define VEHICLE_DID_GYRO                    VEHICLE_DID_GYRO_X
146 #define VEHICLE_DID_REV                     0x80000017
147 #define VEHICLE_DID_SNS_COUNTER             0x8000001A
148 #define VEHICLE_DID_GPS_COUNTER             0x8000001B
149 #define VEHICLE_DID_GYRO_EXT                0x80000027    /* 3 ~ 14bit A/D value,0bit:REV */
150 #define VEHICLE_DID_SPEED_PULSE_FST         0x80000028    /* Pulse(Number)        */
151 #define VEHICLE_DID_GYRO_FST_X              0x80000029
152 #define VEHICLE_DID_GYRO_FST_Y              0x80000022
153 #define VEHICLE_DID_GYRO_FST_Z              0x80000023
154 #define VEHICLE_DID_GYRO_FST                VEHICLE_DID_GYRO_FST
155 #define VEHICLE_DID_GYRO_TEMP               POS_DID_GYRO_TEMP
156 #define VEHICLE_DID_SPEED_KMPH              0x80000013
157 #define VEHICLE_DID_GSNS_X                  0x80000015
158 #define VEHICLE_DID_GSNS_Y                  0x80000016
159 #define VEHICLE_DID_GSNS_Z                  0x80000024
160 #define VEHICLE_DID_PULSE_TIME              0x8000003A
161 #define CID__CWORD83__CMD_RCV                     0x0103
162 #define CID__CWORD83__CMD_SND_STS                 0x0104
163 #define CID_GPS_SERIAL0                     (CID)0x0100
164 #define CID_GPS_REQRESET                    (CID)(CID_GPS_BASE | CID_GPS_SERIAL0)
165
166 #define VEHICLE_CONFIG_GPS_UNITSET_NOGPS    (0x00U)  //!< \~english no Gps
167 #define VEHICLE_CONFIG_GPS_UNITSET__CWORD82_      (0x01U)  //!< \~english _CWORD82_ Gps
168 #define VEHICLE_CONFIG_GPS_UNITSET_EXTBOX   (0x02U)  //!< \~english extern u-blox
169
170 //!< \~english no Navi
171 #define VEHICLE_CONFIG_NAVI_FUNCTION_NONAVI (0x00U)
172 //!< \~english Navi has AW navi
173 #define VEHICLE_CONFIG_NAVI_FUNCTION_AWNAVI (0x01U)
174
175 #define VEHICLE_GPS_SYSTIME_YEAR_MAX        (2085U)  //!< \~english Gps Time allowed max year
176 #define VEHICLE_GPS_SYSTIME_MONTH_MAX       (12U)   //!< \~english Gps Time allowed max month
177 #define VEHICLE_GPS_SYSTIME_DAY_MAX         (31U)   //!< \~english Gps Time allowed max day
178 #define VEHICLE_GPS_SYSTIME_HOUR_MAX        (23U)   //!< \~english Gps Time allowed max hour
179 #define VEHICLE_GPS_SYSTIME_MINUTE_MAX      (59U)   //!< \~english Gps Time allowed max minute
180 #define VEHICLE_GPS_SYSTIME_SECOND_MAX      (59U)   //!< \~english Gps Time allowed max second
181
182 #define VEHICLE_GPS_SYSTIME_YEAR_MIN        (1986U)  //!< \~english Gps Time allowed min year
183 #define VEHICLE_GPS_SYSTIME_MONTH_MIN       (1U)    //!< \~english Gps Time allowed min month
184 #define VEHICLE_GPS_SYSTIME_DAY_MIN         (1U)    //!< \~english Gps Time allowed min day
185 #define VEHICLE_GPS_SYSTIME_HOUR_MIN        (0U)    //!< \~english Gps Time allowed min hour
186 #define VEHICLE_GPS_SYSTIME_MINUTE_MIN      (0U)    //!< \~english Gps Time allowed min minute
187 #define VEHICLE_GPS_SYSTIME_SECOND_MIN      (0U)    //!< \~english Gps Time allowed min second
188 #define VEHICLE_EVENT_VAL_INIT              (-14)       /* Event initial value        */
189 //!< \~english check OK (value not change)
190 #define MDEV_GPS_SRAM_CHK_OK                (0)
191 //!< \~english check OK(vaule change)
192 #define MDEV_GPS_SRAM_CHK_CHG               (1)
193 //!< \~english   check NG
194 #define MDEV_GPS_SRAM_CHK_NG                (-1)
195
196 /*---------------------------------------------------------------------------*/
197 // ENUMERATION
198
199 /*!
200    @brief   Positioning operating status definitions
201 */
202 typedef enum EnumExeStsPos {
203   EPOS_EXE_STS_STOP = 0,             /* Stopped                               */
204   EPOS_EXE_STS_RUNNING,              /* Running (from FrameworkunifiedOnStart to FrameworkunifiedOnStop) */
205   EPOS_EXE_STS_RUNNING_COLDSTART     /* Running after cold start             */
206 } EnumExeSts_POS;
207
208 /*!
209    @brief   Positioning Thread Startup Modes
210 */
211 typedef enum EnumSetupModePos {
212   EPOS_SETUP_MODE_NORMAL = 0,        /* Normal start           */
213   EPOS_SETUP_MODE_DATA_RESET         /* Data reset start */ /* QAC 930 */
214 } EnumSetupMode_POS;
215
216 /**
217  * @struct TG_GPS_RCV_DATA
218  * \~english  Struct of Gps receive data for VehicleSens
219  */
220 typedef struct TgGpsRcvData {
221   uint32_t    dwret_status;                       //!< \~english return status
222   uint16_t    bydata_len;                         //!< \~english data length
223   uint8_t     bygps_data[GPS_READ_LEN];           //!< \~english receive data
224   uint8_t     u_reserve2[2];                      //!< \~english reserve
225 } TG_GPS_RCV_DATA;
226
227 /**
228  * @struct TG_GPS_NMEA_DAT
229  * \~english  Struct of NMEA data
230  */
231 typedef struct TgGpsNmeaDat {
232   u_int8      uc_data[GPS_NMEA_MAX_SZ];           //!< \~english NMEA data
233 } TG_GPS_NMEA_DAT;
234
235 /**
236  * @struct TG_GPS_CYCLEDATA_NMEA
237  * \~english  Struct of NMEA cycle data
238  */
239 typedef struct TgGpsCycledataNmea {
240   //!< \~english receive flag
241   u_int8      uc_rcvflag[GPS_NMEA_INDEX_MAX];
242   //!< \~english reserve
243   u_int8      u_reserve[3];
244   //!< \~english structure of NMEA data
245   TG_GPS_NMEA_DAT    st_nmea[GPS_NMEA_INDEX_MAX];
246 } TG_GPS_CYCLEDATA_NMEA;
247
248 /**
249  * @struct TG_GPS_CYCLEDATA_BINARY
250  * \~english  Struct of binary cycle data
251  */
252 typedef struct TgGpsCycledataBinary {
253   u_int8      uc_rcvflag;                        //!< \~english receive flag
254   u_int8      u_reserve[3];                       //!< \~english reserve
255   u_int8      uc_data[GPS_CMD_BINARY_SZ];        //!< \~english binary data
256   u_int8      u_reserve2[3];                      //!< \~english reserve flag
257 } TG_GPS_CYCLEDATA_BINARY;
258
259 /**
260  * @struct TG_GPS_CYCLEDATA_FULLBIN
261  * \~english  Struct of full bin cycle data
262  */
263 typedef struct TgGpsCycledataFullbin {
264   u_int8      uc_rcvflag;                        //!< \~english receive flag
265   u_int8      u_reserve[3];                       //!< \~english reserve
266   u_int8      uc_data[GPS_CMD_FULLBIN_SZ];       //!< \~english fullbin data
267   u_int8      u_reserve2;                         //!< \~english reserve
268 } TG_GPS_CYCLEDATA_FULLBIN;
269
270 /**
271  * @struct TG_GPS_CYCLEDATA_RTC
272  * \~english  Struct of RTC cycle data
273  */
274 typedef struct TgGpsCycledataRtc {
275   u_int8      uc_rcvflag;                        //!< \~english receive flag
276   u_int8      u_reserve[3];                       //!< \~english reserve
277   u_int8      uc_data[GPS_DATASIZE_RTC];         //!< \~english Rtc data
278 } TG_GPS_CYCLEDATA_RTC;
279
280 /**
281  * @struct TG_GPS_CYCLEDATA
282  * \~english  Struct of Gps cycle data
283  */
284 typedef struct TgGpsCycledata {
285   u_int8                        uc_sesncnt;      //!< \~english count value
286   u_int8                        u_reserve[3];     //!< \~english reserve
287   TG_GPS_CYCLEDATA_NMEA         st_nmea_data;     //!< \~english NMEA Data
288   TG_GPS_CYCLEDATA_BINARY       st_binary_data;   //!< \~english binary Data
289   TG_GPS_CYCLEDATA_FULLBIN      st_fullbin_data;  //!< \~english Full Bin Data
290   TG_GPS_CYCLEDATA_RTC          st_rtc_data;      //!< \~english RTC Data
291 } TG_GPS_CYCLEDATA;
292
293 typedef struct {
294     u_int16 year; /* YEAR */
295     u_int8 month; /* MONTH */
296     u_int8 date;  /* DAY */
297     u_int8 hour;  /* HOUR */
298     u_int8 minute;/* MINUTE */
299     u_int8 second;/* SECOND */
300     u_int8 flag;  /* Whether or not the time is set */
301 } ST_GPS_SET_TIME;
302
303 /*---------------------------------------------------------------------------*/
304 #endif  // INC_COMMON_POSITIONING_DEF_H_
305
306 /*---------------------------------------------------------------------------*/
307 /*EOF*/