common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / positioning_hal / inc / LineSensDrv / LineSensDrv_Sensor.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 /**
17 * @file LineSensDrv_Sensor.h
18 */
19
20 #ifndef INC_LINESENSDRV_LINESENSDRV_SENSOR_H_
21 #define INC_LINESENSDRV_LINESENSDRV_SENSOR_H_
22
23 /*---------------------------------------------------------------------------*/
24 // Include files
25
26 #include "positioning_def.h"
27
28 /*---------------------------------------------------------------------------*/
29 // Macro definitions
30
31 /* Message related */
32 /* Message identification number definition received from the ICR */
33 #define LSDRV_RCVMSG_INVALID      0x00    /* Not applicable          */
34 #define LSDRV_RCVMSG_SENSOR       0x12    /* Sensor data        */
35
36 /* LineSensor vehicle signal notification */
37
38 #define LSDRV_SENS_MASK           0xFFF   /* Sensor data MASK      */
39 #define LSDRV_PLSMAX              65536   /* Maximum vehicle speed pulse number    */
40 /* #011 start */
41 #define LSDRV_SENS_COEFFICIENT    14.1287284284144427    /* Vehicle speed calculation factor */
42 #define LSDRV_SPKMPH_METHOD_FST   0       /* Vehicle speed calculation method(Initial Sensor Data) */
43 #define LSDRV_SPKMPH_METHOD_NML   1       /* Vehicle speed calculation method(Sensor data)  */
44 #define LSDRV_SPKMPH_AVE_TIME     29      /* Effective time for average calculation data(in units of 100ms) */  /* #013 */
45 #define LSDRV_SPKMPH_NOISE_TIME   (LSDRV_SPKMPH_AVE_TIME + 2)  /* Effective Time for Noise Detection(in units of 100ms) */  /* #017 */
46 #define LSDRV_SPKMPH_INVALID      1       /* No pulse of previous vehicle speed    */
47 #define LSDRV_SPKMPH_VALID        0       /* Last vehicle speed pulse    */
48 #define LSDRV_SENSCNT_BRW_ADD     256     /* Measures for borrow occurrence during search of sensor counters */
49 /* #011 end */
50 #define LSDRV_FSENS_NRCV          0       /* Not received          */
51 #define LSDRV_FSENS_RCV           1       /* Receiving          */
52 #define LSDRV_FSENS_RCVCOMP       2       /* Reception completion          */
53 #define LSDRV_FSENS_NORMAL        0       /* Receive data normal      */  /* #001 */
54 #define LSDRV_FSENS_ERROR         1       /* Receive data anomaly      */  /* #001 */
55 /* #016 start */
56 #define LSDRV_PLSDATA_NRCV        0       /* Not received          */
57 #define LSDRV_PLSDATA_RCV         1       /* Received          */
58 #define LSDRV_SENSCNT_MAX         255     /* Maximum value of sensor counter    */
59 #define LSDRV_SPKMPH_MIN_DATA_N   6       /* Number of data required for vehicle speed calculation    */
60 #define LSDRV_FSPDPLS_NUM         3       /* Number of cumulative pulses registered for the first time    */
61 /* #016 end */
62 #define LSDRV_REV_MASK            0x0040  /* REV-data MASK(Before endian conversion)      */
63 #define LSDRV_BITSHIFT_REV        6       /* REV data bit shift  */
64 #define LSDRV_TEMP_MASK           0x07FF  /* Gyro temperature data MASK(after endian conversion)  */
65 #define LSDRV_PLSTIME_LEN         232     /* Data length when inter-pulse time exists */
66
67
68 #define LSDRV_DETAILED_DATA_MULTI_ENABLE      TRUE    /* Detailed data multiplexing of initial sensor data Enabled/Disabled    */
69
70 #if LSDRV_DETAILED_DATA_MULTI_ENABLE
71 #define LSDRV_DETAILED_DATA_MULTI_MAX_NUM     2       /* Detailed data multiplexing of initial sensor data Maximum number    */
72 #else
73 #define LSDRV_DETAILED_DATA_MULTI_MAX_NUM     1       /* Detailed data multiplexing of initial sensor data Maximum number    */
74 #endif
75
76 /* Total number of partitions of initial sensor data : Maximum value */
77 #define LSDRV_FSENS_TOTAL_NUM_MAX             LSDRV_FSTSNS_SENSOR_FIRST_SEND_NUM
78
79 /* Detailed data of initial sensor data : Maximum number of acquisitions      */
80 #define LSDRV_DETAILED_DATA_MAX_NUM           (LSDRV_FSENS_TOTAL_NUM_MAX * LSDRV_DETAILED_DATA_MULTI_MAX_NUM)
81
82 /* Initial sensor data : Maximum number of saved messages      */
83 #define LSDRV_FSENS_SAVE_MSG_NUM              (LSDRV_FSENS_TOTAL_NUM_MAX + 1)
84
85 /* Initial sensor data : Maximum number of data stored        */
86 #define LSDRV_FSENS_SAVE_DATA_NUM             (LSDRV_FSENS_SAVE_MSG_NUM * LSDRV_DETAILED_DATA_MULTI_MAX_NUM)
87
88 #define LSDRV_DETAILED_DATA_GYRO_NUM          LSDRV_FSTSNS_DETAILED_DATA_GYRO_NUM
89 #define LSDRV_DETAILED_DATA_GSENSOR_NUM       LSDRV_FSTSNS_DETAILED_DATA_GSENSOR_NUM
90 #define LSDRV_DETAILED_DATA_GSENSOR_X_OFFSET  0      /* G-Sensor data X-axis offset included in detail data  */
91 #define LSDRV_DETAILED_DATA_GSENSOR_Y_OFFSET  1      /* G-Sensor data Y-axis offsets included in the detail data  */
92 #define LSDRV_DETAILED_DATA_GSENSOR_OFFSET    3      /* G-Sensor data access offset included in the detail data  */
93
94 /* Gyro Output Specifications:11500 ~ 54036LSB */
95 #define GYRO_OUTPUPT_SPEC_LOWER_LIMIT         11500U
96 #define GYRO_OUTPUPT_SPEC_UPPER_LIMIT         54036U
97
98 /* Gyro Failure Status : How many normal status continues should be made to Gyro Failure Status normal when it is judged to be "error -> normal" */
99 #define GYRO_TROUBLE_NORMAL_COUNTER_THRESHOLD 10U     /* 10 ms (Gyro data acquisition interval) * 10 times = 100ms */
100
101 /* Gyro Failure Status : How many error status continues should be made to Gyro Failure Status error when it is judged to be "normal -> error" */
102 #define GYRO_TROUBLE_ERROR_COUNTER_THRESHOLD  3000U   /* 10 ms (Gyro data acquisition interval) * 3000 times = 30s */
103
104 /* SYS GPS Interrupt Signal : How many disable continues should be made to SYS GPS Interrupt Signal disable when it is judged to be "enable -> disable" */
105 #define SYS_GPS_INTERRUPT_SIGNAL_INVALID_COUNTER_THRESHOLD 10U
106
107 /* Gyro Failure Status : Match values with SENSORMOTION_NORMAL and ERROR,UNFIXED in SensorMotion_API.h */
108 #define GYRO_NORMAL             (0U)
109 #define GYRO_ERROR              (1U)
110 #define GYRO_UNFIXED            (2U)
111
112 /* Gyro connection status : Match values with SENSOR_CONNECT and SENSOR_DISCONNECT in Sensor_API.h */
113 #define GYRO_DISCONNECT         (0U)
114 #define GYRO_CONNECT            (1U)
115
116 /*** Data table for calculating vehicle speed *****************************************/
117 #define LSDRV_SPKMPH_TBL_NUM    32      /* Number of data tables      */ /* #50836 */
118 #define LSDRV_SPKMPH_DATA_EN    0x01    /* Data storage flag valid    */
119 #define LSDRV_SPKMPH_DATA_DIS   0x00    /* Data storage flag invalid    */
120
121 /*** Operation code *********************************************/
122 #define LSDRV_OPC_WILDCARD      0xFF    /* Wildcarded      #012 */
123
124 #define LSDRV_OPC_EXTTERM_R     0x89    /* External pin status request      */
125 #define LSDRV_OPC_EXTTERM_A     0x99    /* External pin status notification      */
126 #define LSDRV_OPC_SENSOR        0xC1    /* Sensor data        */
127 #define LSDRV_OPC_FSENS_R       0xE4    /* Initial sensor data request    */
128 #define LSDRV_OPC_FSENS_A       0xF4    /* Initial sensor data response    */
129
130 /*---------------------------------------------------------------------------*/
131 // Enum
132
133 /*---------------------------------------------------------------------------*/
134 // Struct
135
136 typedef struct {
137   u_int16   uc_sensor_x;            /* G-Sensor X data */
138   u_int16   uc_sensor_y;            /* G-Sensor Y data */
139   u_int16   uc_sensor_z;            /* G-Sensor Z data */
140 } SENSORINPUT_INFO_DAT_GSENS;
141
142 // TAG      : LSDRV_SPEEDKMPH_DAT
143 // ABSTRACT : Data Table Structure for Vehicle Speed Calculation
144 typedef struct LsDrvSpeedKmph {
145   u_int8    uc_flag;                /* Data storage flag        */
146   u_int8    uc_sens_cnt;            /* Sensor counter        */
147   u_int16   us_speed_pulse;         /* Vehicle speed pulse          */
148   u_int8    uc_noise_flag;          /* Noise flag          */  /* #017 */
149   u_int8    u_reserve[3];           /* Reserved            */  /* #017 */
150 } LSDRV_SPEEDKMPH_DAT_DAT;
151
152 typedef struct LsDrvSpeedKmphLast {
153   u_int8    uc_flag;                /* Data storage flag        */
154   u_int8    uc_sens_cnt;            /* Sensor counter        */
155   u_int16   us_speed_pulse;         /* Vehicle speed pulse          */
156 } LSDRV_SPEEDKMPH_LAST_DAT;
157
158 typedef struct LsDrvSpeedKmphDat {
159   u_int8                    uc_ptr;                         /* Data storage pointer      */
160   u_int8                    uc_fstsns_rcv;                  /* Initial sensor data reception status    */  /* #016 */
161   u_int8                    uc_sns_rcv;                     /* Sensor data reception status      */  /* #016 */
162   u_int8                    uc_calc_start;                  /* Vehicle speed calculation start flag      */  /* #016 */
163   LSDRV_SPEEDKMPH_LAST_DAT  st_last_data;                   /* Previous vehicle speed pulse information      */
164   LSDRV_SPEEDKMPH_DAT_DAT   st_data[LSDRV_SPKMPH_TBL_NUM];  /* Data portion  */
165 } LSDRV_SPEEDKMPH_DAT;
166
167 /*---------------------------------------------------------------------------*/
168 // Prototype
169
170 void    LineSensDrvSensor(u_int8*);
171 u_int16 LineSensDrvSpeedCalc(u_int8);
172 void    LineSensDrvSpeedKmphDataInit(void);
173 void    LineSensDrvSpeedPulseSave(u_int16, u_int16, u_int8);
174 u_int8  LineSensDrvCheckNoise(u_int8);
175
176 u_int8  LineSensDrvGetLastSpeedPulse(u_int16*, u_int16, u_int8);
177 void    LineSensDrvSetLastSpeedPulse(u_int16, u_int8);
178
179 /*---------------------------------------------------------------------------*/
180 #endif  // INC_LINESENSDRV_LINESENSDRV_SENSOR_H_
181
182 /*---------------------------------------------------------------------------*/
183 /*EOF*/