diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-27 11:16:21 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-27 11:16:21 +0900 |
commit | 947c78887e791596d4a5ec2d1079f8b1a049628b (patch) | |
tree | 3981e88eb8764d7180722f8466f36b756dc005af /positioning_hal/inc | |
parent | 706ad73eb02caf8532deaf5d38995bd258725cb8 (diff) |
basesystem 0.1sandbox/ToshikazuOhiwa/basesystem
Diffstat (limited to 'positioning_hal/inc')
-rw-r--r-- | positioning_hal/inc/Common/LineSensDrv_Api.h | 44 | ||||
-rw-r--r-- | positioning_hal/inc/Common/MDev_Gps_API.h | 51 | ||||
-rw-r--r-- | positioning_hal/inc/Common/positioning_common.h | 63 | ||||
-rw-r--r-- | positioning_hal/inc/Common/positioning_def.h | 307 | ||||
-rw-r--r-- | positioning_hal/inc/Common/positioning_log.h | 43 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_GpsRecv.h | 170 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_GpsRollOver.h | 34 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_Gps_Common.h | 187 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_Gps_Main.h | 311 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_Gps_Mtrx.h | 90 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_Gps_Nmea.h | 313 | ||||
-rw-r--r-- | positioning_hal/inc/GpsCommon/MDev_Gps_TimerCtrl.h | 113 | ||||
-rw-r--r-- | positioning_hal/inc/LineSensDrv/LineSensDrv_Sensor.h | 183 | ||||
-rw-r--r-- | positioning_hal/inc/LineSensDrv/LineSensDrv_Thread.h | 66 |
14 files changed, 1975 insertions, 0 deletions
diff --git a/positioning_hal/inc/Common/LineSensDrv_Api.h b/positioning_hal/inc/Common/LineSensDrv_Api.h new file mode 100644 index 00000000..24c7f558 --- /dev/null +++ b/positioning_hal/inc/Common/LineSensDrv_Api.h @@ -0,0 +1,44 @@ +/* + * @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. + */ +/** +* @file LineSensDrv_Api.h +*/ + +#ifndef INC_COMMON_LINESENSDRV_API_H_ +#define INC_COMMON_LINESENSDRV_API_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Define + +#define MUTEX_GPS_IRQ_FLG "MUTEX_GPS_IRQ_FLG" + +/*---------------------------------------------------------------------------*/ +// Prototype + +void DeliveryLineSensorDataPositioning(LSDRV_MSG_LSDATA_G*, u_int8); +BOOL LineSensDrvApiInitialize(void); +void LineSensDrvApiInitEstGpsCnt(void); + +/*---------------------------------------------------------------------------*/ +#endif // INC_COMMON_LINESENSDRV_API_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/Common/MDev_Gps_API.h b/positioning_hal/inc/Common/MDev_Gps_API.h new file mode 100644 index 00000000..d165a1e6 --- /dev/null +++ b/positioning_hal/inc/Common/MDev_Gps_API.h @@ -0,0 +1,51 @@ +/* + * @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. + */ +/** +* @file MDev_Gps_API.h +*/ + +#ifndef INC_COMMON_MDEV_GPS_API_H_ +#define INC_COMMON_MDEV_GPS_API_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "gps_hal.h" +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Prototype + +RET_API SendNmeaGps(const MDEV_GPS_NMEA* p_nmea_data); +RET_API SendCustomGps(const SENSOR_MSG_GPSTIME* p_gps_time, + const SENSORLOCATION_LONLATINFO_DAT* p_lonlat, + const SENSORLOCATION_ALTITUDEINFO_DAT* p_altitude, + const SENSORMOTION_HEADINGINFO_DAT* p_heading, + const NAVIINFO_DIAG_GPS* p_diag_data); +RET_API SendSpeedGps(const SENSORMOTION_SPEEDINFO_DAT* p_seed, u_int16 us_peed); +RET_API SendTimeGps(const MDEV_GPS_RTC* p_rtc); +RET_API SendClockDriftGps(int32_t drift); +RET_API SendClockFrequencyGps(uint32_t freq); +RET_API DevGpsSndWknRollover(const SensorWknRollOverHal* p_week_rollover); +int32 DevGpsRstAnsSend(PNO u_pno, RID uc_rid, u_int32 ul_rst_sts); +int32 DevGpsTimesetAnsSend(PNO u_pno, RID uc_rid, u_int32 ul_rst_sts); +RET_API DevSendGpsConnectError(BOOL); +RET_API SndGpsTimeRaw(const SENSOR_GPSTIME_RAW* pst_gpstime_raw); +/*---------------------------------------------------------------------------*/ +#endif // INC_COMMON_MDEV_GPS_API_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/Common/positioning_common.h b/positioning_hal/inc/Common/positioning_common.h new file mode 100644 index 00000000..dad0272e --- /dev/null +++ b/positioning_hal/inc/Common/positioning_common.h @@ -0,0 +1,63 @@ +/* + * @copyright Copyright (c) 2017-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. + */ +/** +* @file positioning_common.h +*/ + +#ifndef INC_COMMON_POSITIONING_COMMON_H_ +#define INC_COMMON_POSITIONING_COMMON_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Definition + +/*---------------------------------------------------------------------------*/ +// ENUMERATION + +/*---------------------------------------------------------------------------*/ +// STRUCTURE + +typedef struct PosResetinfo { + uint8_t mode; // Reset mode + uint8_t reserve[3]; // reserve + PNO sndpno; // Caller PNO + PNO respno; // Destination PNO +} POS_RESETINFO; + +/*! + @brief Thread activation information +*/ +typedef struct StThreadSetupInfo { + EnumSetupMode_POS mode; // Thread activation mode +} ST_THREAD_SETUP_INFO; + + +/*---------------------------------------------------------------------------*/ +// Prototype +EFrameworkunifiedStatus PosInitialize(HANDLE h_app); +EnumSetupMode_POS PosSetupThread(HANDLE h_app, EnumTID_POS e_tid); +void PosTeardownThread(EnumTID_POS e_tid); +EFrameworkunifiedStatus PosCreateThread(HANDLE h_app, int8_t index); + +/*---------------------------------------------------------------------------*/ +#endif // INC_COMMON_POSITIONING_COMMON_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/Common/positioning_def.h b/positioning_hal/inc/Common/positioning_def.h new file mode 100644 index 00000000..df95cb3a --- /dev/null +++ b/positioning_hal/inc/Common/positioning_def.h @@ -0,0 +1,307 @@ +/* + * @copyright Copyright (c) 2017-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. + */ +/** +* @file positioning_def.h +*/ + +#ifndef INC_COMMON_POSITIONING_DEF_H_ +#define INC_COMMON_POSITIONING_DEF_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include <string.h> +#include <stdlib.h> +#include <sys/ioctl.h> + +#include <native_service/frameworkunified_types.h> +#include <native_service/frameworkunified_application.h> +#include <native_service/frameworkunified_framework_if.h> +#include <native_service/frameworkunified_multithreading.h> +#include <native_service/frameworkunified_service_protocol.h> +#include <vehicle_service/std_types.h> +#include <vehicle_service/pos_message_header.h> +#include <vehicle_service/sys_timerapi.h> +#include <vehicle_service/WPF_STD.h> + +#include "gps_hal.h" +#include "positioning_hal.h" + +#include "positioning_log.h" + +/*---------------------------------------------------------------------------*/ +// Definition + +#define POS_THREAD_NAME "Positioning" + +/** + * @enum ENUM_GPS_NMEA_INDEX + * \~english NMEA index + */ +typedef enum { + GPS_NMEA_INDEX_GGA = 0, //!< \~english GGA + GPS_NMEA_INDEX_DGGA, //!< \~english DGGA + GPS_NMEA_INDEX_VTG, //!< \~english VTG + GPS_NMEA_INDEX_RMC, //!< \~english RMC + GPS_NMEA_INDEX_DRMC, //!< \~english DRMC + GPS_NMEA_INDEX_GLL, //!< \~english GLL + GPS_NMEA_INDEX_DGLL, //!< \~english DGLL + GPS_NMEA_INDEX_GSA, //!< \~english GSA + GPS_NMEA_INDEX_GSV1, //!< \~english GSV1 + GPS_NMEA_INDEX_GSV2, //!< \~english GSV2 + GPS_NMEA_INDEX_GSV3, //!< \~english GSV3 + GPS_NMEA_INDEX_GSV4, //!< \~english GSV4 + GPS_NMEA_INDEX_GSV5, //!< \~english GSV5 + GPS_NMEA_INDEX_GST, //!< \~english GST + GPS_NMEA_INDEX__CWORD44__GP_3, //!< \~english _CWORD44_,GP,3 + GPS_NMEA_INDEX__CWORD44__GP_4, //!< \~english _CWORD44_,GP,4 + GPS_NMEA_INDEX_P_CWORD82_F_GP_0, //!< \~english _CWORD44_,GP,0 + GPS_NMEA_INDEX_P_CWORD82_J_GP_1, //!< \~english _CWORD44_,GP,1 + GPS_NMEA_INDEX_MAX //!< \~english GGA +} ENUM_GPS_NMEA_INDEX; + +//!< \~english Gps cycle Data Event +#define GPS_EVT_CYCLEDATA_PROV ("GPS_EVT_CYCLEDATA_PROV") +//!< \~english Event value: Waiting. +#define GPS_EVT_PROV_WAIT (0x00000000) +//!< \~english Event value: Clear Waiting status. +#define GPS_EVT_PROV_RELEASE (0x00000001) + +//!< \~english Gps received +#define GPS_CYCLECMD_NOTRCV (0x00) +//!< \~english Gps no received +#define GPS_CYCLECMD_RCV (0x01) + +//!< \~english store position of Hour data +#define GPSCMD_DRMC_HOUR_POS (7) +//!< \~english store position of minute data +#define GPSCMD_DRMC_MIN_POS (9) +//!< \~english store position of second data +#define GPSCMD_DRMC_SEC_POS (11) +//!< \~english store position of status +#define GPSCMD_DRMC_STATUS_POS (14) +//!< \~english store position of day data +#define GPSCMD_DRMC_DAY_POS (54) +//!< \~english store position of month data +#define GPSCMD_DRMC_MONTH_POS (56) +//!< \~english store position of year data +#define GPSCMD_DRMC_YEAR_POS (58) + +//!< \~english store position of control code +#define GPSCMD_RTC_CTRLCODE_POS (0) +//!< \~english store position of year data (BCD) +#define GPSCMD_RTC_BCD_YEAR_POS (1) +//!< \~english store position of month data(BCD) +#define GPSCMD_RTC_BCD_MONTH_POS (2) +//!< \~english store position of day data(BCD) +#define GPSCMD_RTC_BCD_DAY_POS (3) +//!< \~english store position of hour data(BCD) +#define GPSCMD_RTC_BCD_HOUR_POS (4) +//!< \~english store position of minute data(BCD) +#define GPSCMD_RTC_BCD_MIN_POS (5) +//!< \~english store position of second data(BCD) +#define GPSCMD_RTC_BCD_SEC_POS (6) +//!< \~english store position of status +#define GPSCMD_RTC_STATUS_POS (7) + +#define GPSCMD_RTC_CTRLCODE (0xA4) //!< \~english control code (RTC) +#define GPSCMD_RTC_STATUS_UTCTIME (0x00) //!< \~english Normal +#define GPSCMD_RTC_STATUS_ERRTIME (0x03) //!< \~english AbNormal + +// Internal thread activation status determination +#define THREAD_STS_MSK_POS_MAIN (0x01) +#define THREAD_STS_MSK_POS_SENS (0x02) +#define THREAD_STS_MSK_POS_GPS (0x04) +#define THREAD_STS_MSK_POS_GPS_RECV (0x08) +#define THREAD_STS_MSK_POS_GPS_ROLLOVER (0x10) +#define POS_DID_GPS_NMEA 0x8000009AU /* QAC 1281 */ +#define POS_DID_GPS_CLOCK_DRIFT 0x800000B3U /* QAC 1281 */ +#define POS_DID_GPS_CLOCK_FREQ 0x800000B4U /* QAC 1281 */ +#define VEHICLE_DID_GPS_CUSTOMDATA 0x80000094U +#define VEHICLE_DID_GPS_CLOCK_DRIFT POS_DID_GPS_CLOCK_DRIFT +#define VEHICLE_DID_GPS_CLOCK_FREQ POS_DID_GPS_CLOCK_FREQ +#define CID_NAVIINFO_DELIVER (0x0205) /* Navigation information setting CID */ +#define CID_NAVIINFO_SPEED_DELIVER (0x0206) /* Vehicle speed setting CID */ +#define VEHICLE_DID_GPS_WKNROLLOVER 0x800000B2U +#define VEHICLE_DID_GPS_TIME_RAW 0x800000B1 +#define POS_DID_GYRO_TEMP 0x80000090 +#define VEHICLE_DID_SPEED_PULSE 0x80000012 +#define VEHICLE_DID_GYRO_X 0x80000014 +#define VEHICLE_DID_GYRO_Y 0x80000020 +#define VEHICLE_DID_GYRO_Z 0x80000021 +#define VEHICLE_DID_GYRO VEHICLE_DID_GYRO_X +#define VEHICLE_DID_REV 0x80000017 +#define VEHICLE_DID_SNS_COUNTER 0x8000001A +#define VEHICLE_DID_GPS_COUNTER 0x8000001B +#define VEHICLE_DID_GYRO_EXT 0x80000027 /* 3 ~ 14bit A/D value,0bit:REV */ +#define VEHICLE_DID_SPEED_PULSE_FST 0x80000028 /* Pulse(Number) */ +#define VEHICLE_DID_GYRO_FST_X 0x80000029 +#define VEHICLE_DID_GYRO_FST_Y 0x80000022 +#define VEHICLE_DID_GYRO_FST_Z 0x80000023 +#define VEHICLE_DID_GYRO_FST VEHICLE_DID_GYRO_FST +#define VEHICLE_DID_GYRO_TEMP POS_DID_GYRO_TEMP +#define VEHICLE_DID_SPEED_KMPH 0x80000013 +#define VEHICLE_DID_GSNS_X 0x80000015 +#define VEHICLE_DID_GSNS_Y 0x80000016 +#define VEHICLE_DID_GSNS_Z 0x80000024 +#define VEHICLE_DID_PULSE_TIME 0x8000003A +#define CID__CWORD83__CMD_RCV 0x0103 +#define CID__CWORD83__CMD_SND_STS 0x0104 +#define CID_GPS_SERIAL0 (CID)0x0100 +#define CID_GPS_REQRESET (CID)(CID_GPS_BASE | CID_GPS_SERIAL0) + +#define VEHICLE_CONFIG_GPS_UNITSET_NOGPS (0x00U) //!< \~english no Gps +#define VEHICLE_CONFIG_GPS_UNITSET__CWORD82_ (0x01U) //!< \~english _CWORD82_ Gps +#define VEHICLE_CONFIG_GPS_UNITSET_EXTBOX (0x02U) //!< \~english extern u-blox + +//!< \~english no Navi +#define VEHICLE_CONFIG_NAVI_FUNCTION_NONAVI (0x00U) +//!< \~english Navi has AW navi +#define VEHICLE_CONFIG_NAVI_FUNCTION_AWNAVI (0x01U) + +#define VEHICLE_GPS_SYSTIME_YEAR_MAX (2085U) //!< \~english Gps Time allowed max year +#define VEHICLE_GPS_SYSTIME_MONTH_MAX (12U) //!< \~english Gps Time allowed max month +#define VEHICLE_GPS_SYSTIME_DAY_MAX (31U) //!< \~english Gps Time allowed max day +#define VEHICLE_GPS_SYSTIME_HOUR_MAX (23U) //!< \~english Gps Time allowed max hour +#define VEHICLE_GPS_SYSTIME_MINUTE_MAX (59U) //!< \~english Gps Time allowed max minute +#define VEHICLE_GPS_SYSTIME_SECOND_MAX (59U) //!< \~english Gps Time allowed max second + +#define VEHICLE_GPS_SYSTIME_YEAR_MIN (1986U) //!< \~english Gps Time allowed min year +#define VEHICLE_GPS_SYSTIME_MONTH_MIN (1U) //!< \~english Gps Time allowed min month +#define VEHICLE_GPS_SYSTIME_DAY_MIN (1U) //!< \~english Gps Time allowed min day +#define VEHICLE_GPS_SYSTIME_HOUR_MIN (0U) //!< \~english Gps Time allowed min hour +#define VEHICLE_GPS_SYSTIME_MINUTE_MIN (0U) //!< \~english Gps Time allowed min minute +#define VEHICLE_GPS_SYSTIME_SECOND_MIN (0U) //!< \~english Gps Time allowed min second +#define VEHICLE_EVENT_VAL_INIT (-14) /* Event initial value */ +//!< \~english check OK (value not change) +#define MDEV_GPS_SRAM_CHK_OK (0) +//!< \~english check OK(vaule change) +#define MDEV_GPS_SRAM_CHK_CHG (1) +//!< \~english check NG +#define MDEV_GPS_SRAM_CHK_NG (-1) + +/*---------------------------------------------------------------------------*/ +// ENUMERATION + +/*! + @brief Positioning operating status definitions +*/ +typedef enum EnumExeStsPos { + EPOS_EXE_STS_STOP = 0, /* Stopped */ + EPOS_EXE_STS_RUNNING, /* Running (from FrameworkunifiedOnStart to FrameworkunifiedOnStop) */ + EPOS_EXE_STS_RUNNING_COLDSTART /* Running after cold start */ +} EnumExeSts_POS; + +/*! + @brief Positioning Thread Startup Modes +*/ +typedef enum EnumSetupModePos { + EPOS_SETUP_MODE_NORMAL = 0, /* Normal start */ + EPOS_SETUP_MODE_DATA_RESET /* Data reset start */ /* QAC 930 */ +} EnumSetupMode_POS; + +/** + * @struct TG_GPS_RCV_DATA + * \~english Struct of Gps receive data for VehicleSens + */ +typedef struct TgGpsRcvData { + uint32_t dwret_status; //!< \~english return status + uint16_t bydata_len; //!< \~english data length + uint8_t bygps_data[GPS_READ_LEN]; //!< \~english receive data + uint8_t u_reserve2[2]; //!< \~english reserve +} TG_GPS_RCV_DATA; + +/** + * @struct TG_GPS_NMEA_DAT + * \~english Struct of NMEA data + */ +typedef struct TgGpsNmeaDat { + u_int8 uc_data[GPS_NMEA_MAX_SZ]; //!< \~english NMEA data +} TG_GPS_NMEA_DAT; + +/** + * @struct TG_GPS_CYCLEDATA_NMEA + * \~english Struct of NMEA cycle data + */ +typedef struct TgGpsCycledataNmea { + //!< \~english receive flag + u_int8 uc_rcvflag[GPS_NMEA_INDEX_MAX]; + //!< \~english reserve + u_int8 u_reserve[3]; + //!< \~english structure of NMEA data + TG_GPS_NMEA_DAT st_nmea[GPS_NMEA_INDEX_MAX]; +} TG_GPS_CYCLEDATA_NMEA; + +/** + * @struct TG_GPS_CYCLEDATA_BINARY + * \~english Struct of binary cycle data + */ +typedef struct TgGpsCycledataBinary { + u_int8 uc_rcvflag; //!< \~english receive flag + u_int8 u_reserve[3]; //!< \~english reserve + u_int8 uc_data[GPS_CMD_BINARY_SZ]; //!< \~english binary data + u_int8 u_reserve2[3]; //!< \~english reserve flag +} TG_GPS_CYCLEDATA_BINARY; + +/** + * @struct TG_GPS_CYCLEDATA_FULLBIN + * \~english Struct of full bin cycle data + */ +typedef struct TgGpsCycledataFullbin { + u_int8 uc_rcvflag; //!< \~english receive flag + u_int8 u_reserve[3]; //!< \~english reserve + u_int8 uc_data[GPS_CMD_FULLBIN_SZ]; //!< \~english fullbin data + u_int8 u_reserve2; //!< \~english reserve +} TG_GPS_CYCLEDATA_FULLBIN; + +/** + * @struct TG_GPS_CYCLEDATA_RTC + * \~english Struct of RTC cycle data + */ +typedef struct TgGpsCycledataRtc { + u_int8 uc_rcvflag; //!< \~english receive flag + u_int8 u_reserve[3]; //!< \~english reserve + u_int8 uc_data[GPS_DATASIZE_RTC]; //!< \~english Rtc data +} TG_GPS_CYCLEDATA_RTC; + +/** + * @struct TG_GPS_CYCLEDATA + * \~english Struct of Gps cycle data + */ +typedef struct TgGpsCycledata { + u_int8 uc_sesncnt; //!< \~english count value + u_int8 u_reserve[3]; //!< \~english reserve + TG_GPS_CYCLEDATA_NMEA st_nmea_data; //!< \~english NMEA Data + TG_GPS_CYCLEDATA_BINARY st_binary_data; //!< \~english binary Data + TG_GPS_CYCLEDATA_FULLBIN st_fullbin_data; //!< \~english Full Bin Data + TG_GPS_CYCLEDATA_RTC st_rtc_data; //!< \~english RTC Data +} TG_GPS_CYCLEDATA; + +typedef struct { + u_int16 year; /* YEAR */ + u_int8 month; /* MONTH */ + u_int8 date; /* DAY */ + u_int8 hour; /* HOUR */ + u_int8 minute;/* MINUTE */ + u_int8 second;/* SECOND */ + u_int8 flag; /* Whether or not the time is set */ +} ST_GPS_SET_TIME; + +/*---------------------------------------------------------------------------*/ +#endif // INC_COMMON_POSITIONING_DEF_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/Common/positioning_log.h b/positioning_hal/inc/Common/positioning_log.h new file mode 100644 index 00000000..6ca4c96e --- /dev/null +++ b/positioning_hal/inc/Common/positioning_log.h @@ -0,0 +1,43 @@ +/* + * @copyright Copyright (c) 2017-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. + */ +/** +* @file positioning_log.h +*/ + +#ifndef INC_COMMON_POSITIONING_LOG_H_ +#define INC_COMMON_POSITIONING_LOG_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include <stdio.h> + +/*---------------------------------------------------------------------------*/ +// Definition + +// #define POSITIONING_DEBUG + +#ifdef POSITIONING_DEBUG +#define POSITIONING_LOG(...) printf(__VA_ARGS__) +#else +#define POSITIONING_LOG(...) +#endif + +/*---------------------------------------------------------------------------*/ +#endif // INC_COMMON_POSITIONING_LOG_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_GpsRecv.h b/positioning_hal/inc/GpsCommon/MDev_GpsRecv.h new file mode 100644 index 00000000..6ea47877 --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_GpsRecv.h @@ -0,0 +1,170 @@ +/* + * @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. + */ +/** +* @file MDev_GpsRecv.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPSRECV_H_ +#define INC_GPSCOMMON_MDEV_GPSRECV_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "gps_hal.h" +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Define + +/* ++ GPS _CWORD82_ support */ +#define GPS__CWORD82__CMD_LEN_MAX 200 +/* -- GPS _CWORD82_ support */ + +/* ++ GPS _CWORD82_ support */ +#define GPS__CWORD82__RET_START_SEQ_NONE 0 /* _CWORD82_ Start Sequence Determination Result = None */ +#define GPS__CWORD82__RET_START_SEQ_NMEA 1 /* _CWORD82_ Start Sequence Determination Result = NMEA */ +#define GPS__CWORD82__RET_START_SEQ_FULL 2 /* _CWORD82_ Start Sequence Determination Result = Full customization */ +#define GPS__CWORD82__RET_START_SEQ_BIN 3 /* _CWORD82_ Start Sequence Determination Result = Standard binary #GPF_60_024 */ + +#define GPS_UBLOX_RET_START_SEQ_UBX 4 /* Ublox Start Sequence Decision Result = UBX Protocol (binary) */ +#define GPS__CWORD82__FULLBINARY_LEN GPS_CMD_FULLBIN_SZ /* _CWORD82_ Full Customization Instruction Length */ + +#define GPS__CWORD82__NORMALBINARY_LEN 81 /* _CWORD82_ standard binary instruction length #GPF_60_024 */ +/* -- GPS _CWORD82_ support */ + +/* Maximum size of serial data read */ +#define GPS_RCV_MAXREADSIZE (2048) /* Changed from 256 -> 2048 #01 */ + +/* Receive data storage buffer size */ +#define GPS_RCV_RCVBUFSIZE 512 /* Maximum size of the command to be received must be larger than the maximum size */ + +/* Max-size receive commands ID4:(188+8)byte */ +/* Analysis data buffer size */ +#define GPS_RCV_ANADATABUFSIZE (GPS_RCV_MAXREADSIZE + GPS_RCV_RCVBUFSIZE) + +/* Receive frame buffer size */ +#define GPS_RCV_RCVFRAMEBUFSIZE GPS_RCV_RCVBUFSIZE /* Maximum size of the command to be received must be larger than the maximum size */ + +/* Reception notification data buffer size */ +#define GPS_RCV_SNDCMD_SIZE_MAX + +/* Common return values */ +#define GPS_RCV_RET_ERR_EXT (-4) /* External cause error */ +#define GPS_RCV_RET_ERR_SYSTEM (-3) /* System error */ +#define GPS_RCV_RET_ERR (-1) /* Abnormality */ +#define GPS_RCV_RET_NML 0 /* Normal */ + +// Reception thread reception frame detection result +#define GPS_RCV_FRMSRCH_ERR_FORMAT (-1) /* Frame format error */ +#define GPS_RCV_FRMSRCH_FIXED 0 /* Frame determination */ +#define GPS_RCV_FRMSRCH_NOT_FIXED 1 /* Frame undetermined */ +#define GPS_RCV_FRMSRCH_NO_DATA 2 /* No analysis data */ + +// Result of receive thread receive frame analysis +#define GPS_RCV_FRMANA_ERR_PRM (-3) /* Parameter error */ +#define GPS_RCV_FRMANA_ERR_FORMAT (-2) /* Frame format error */ +#define GPS_RCV_FRMANA_ERR_CS (-1) /* Sumcheck error */ +#define GPS_RCV_FRMANA_OK 0 /* Normal data */ + +/* Serial reception event determination result */ +enum GpsRcvRet { + GPS_RCV_REVT_NML = 0, /* Receiving(Normal) */ + GPS_RCV_REVT_ERR, /* Receiving(Error) */ + GPS_RCV_REVT_NUM /* Number of events received */ +}; + +// Error logging +#define ERLG_SER_FRAMEERR "Serial Framing Error" +#define ERLG_SER_OVERRUNERR "Serial Overrun Error" +#define ERLG_SER_PARITYERR "Serial Parity Error" +#define ERLG_RCVEV_JDGERR "DEV_Gps_Recv_JdgSerEvt error" +#define ERLG_RCVDATA_SNDERR "DEV_Gps_Recv_SndRcvData error" +#define ERLG_COMEVNT_WAITERR "WaitCommEvent error" + +/*---------------------------------------------------------------------------*/ +// Struct + +// Serial receive buffer structure +typedef struct GPSRecvData { + u_int16 us_read_size; /* Serial data read data size */ + u_int8 uc_reserve[2]; /* Preliminary */ + u_int8 uc_read_data[GPS_RCV_MAXREADSIZE]; /* Serial read data */ +} TG_GPS_RECV_RcvData; + +// Receive data storage buffer structure +typedef struct GPSRecvBuf { + u_int16 r_size; /* Received size */ + u_int8 rsv[2]; /* Reserved */ + u_int8 r_buf[GPS_RCV_RCVBUFSIZE]; /* Receive command data */ +} TG_GPS_RECV_RcvBuf; + +// Data analysis buffer +typedef struct GPSRecvAnaDataBuf { + u_int16 datsize; /* Size of the data */ + u_int16 offset; /* Analysis start offset */ + u_int8 datbuf[GPS_RCV_ANADATABUFSIZE]; /* Analysis data */ +} TG_GPS_RECV_AnaDataBuf; + +// Receive frame buffer +typedef struct GPSRecvFrameBuf { + u_int16 size; /* Frame-size */ + u_int8 rsv[2]; /* Reserved */ + u_int8 buf[GPS_RCV_RCVFRAMEBUFSIZE]; /* Command data */ +} TG_GPS_RECV_RcvFrameBuf; + +/*---------------------------------------------------------------------------*/ +// External variable + +extern TG_GPS_RECV_RcvData g_gps_rcvdata; /* Serial receive buffer */ +extern TG_GPS_RECV_RcvBuf g_gps_rcvbuf; /* Receive data storage buffer */ +extern TG_GPS_RECV_AnaDataBuf g_gps_ana_databuf; /* Analysis data buffer */ +extern TG_GPS_RECV_RcvFrameBuf g_gps_rcv_framebuf; /* Receive frame buffer */ +extern u_int16 g_wrecv_err; /* Number of reception errors */ + +/*---------------------------------------------------------------------------*/ +// Prototype + +/* Initializing process */ +void DevGpsRecvInit(void); + +/* Buffer clear processing */ +void DevGpsRecvClrRcvBuf(void); + +/* Receive (normal) receive processing */ +void DevGpsRecvRcvNormal(void); + +/* Data reception processing */ +int32 DevGpsRecvReadRcvData(TG_GPS_RECV_RcvData* pst_rcv_data); + +/* Frame detection processing */ +int32 DevGpsRecvSearchFrameData(const TG_GPS_RECV_AnaDataBuf *adbuf_p, u_int16 *ana_size); + +/* Receive data transmission processing */ +void DevGpsRecvSndRcvData(const TG_GPS_RECV_RcvFrameBuf *p_frame_buf); + +/* Acknowledgement */ +RET_API DevRcvData(const TG_GPS_RCV_DATA* ptg_rcv_data); + +/* Pos_Gps_Recv Thread Stop Processing */ +void DevGpsRecvThreadStopProcess(void); + +EFrameworkunifiedStatus DevGpsRecvThread(HANDLE h_app); + +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPSRECV_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_GpsRollOver.h b/positioning_hal/inc/GpsCommon/MDev_GpsRollOver.h new file mode 100644 index 00000000..22da3c9c --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_GpsRollOver.h @@ -0,0 +1,34 @@ +/* + * @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. + */ +/** +* @file MDev_GpsRollOver.h +*/ +#ifndef INC_GPSCOMMON_MDEV_GPSROLLOVER_H_ +#define INC_GPSCOMMON_MDEV_GPSROLLOVER_H_ + +#include <vehicle_service/WPF_STD.h> + +typedef struct TimRolovrYMD { + u_int16 year; + u_int16 month; + u_int16 day; + u_int8 dummy[2]; +} TG_TIM_ROLOVR_YMD; + + +void GPSRollOverConvTime(TG_TIM_ROLOVR_YMD* base_ymd, TG_TIM_ROLOVR_YMD* conv_ymd, u_int8 gpsweekcorcnt); + +#endif // INC_GPSCOMMON_MDEV_GPSROLLOVER_H_ diff --git a/positioning_hal/inc/GpsCommon/MDev_Gps_Common.h b/positioning_hal/inc/GpsCommon/MDev_Gps_Common.h new file mode 100644 index 00000000..78128580 --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_Gps_Common.h @@ -0,0 +1,187 @@ +/* + * @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. + */ +/** +* @file MDev_Gps_Common.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPS_COMMON_H_ +#define INC_GPSCOMMON_MDEV_GPS_COMMON_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "positioning_def.h" +#include "MDev_Gps_Main.h" + +/*---------------------------------------------------------------------------*/ +// Define + +#define NMEA_CHECKSUM_CHAR '*' /* *## (HEX) */ +#define NMEA_DATA_SEPARATOR ',' + +#define GPS_NMEA_FIELD_LEN_MAX (GPS_NMEA_MAX_SZ) + +// NMEA GGA Sentence +/* Fix Status */ +#define GPS_NMEA_GGA_FIX_STATUS_NON 0 /* invalid */ +#define GPS_NMEA_GGA_FIX_STATUS_GPS 1 /* GPS SPS Mode, Fix valid */ +#define GPS_NMEA_GGA_FIX_STATUS_DGPS 2 /* DGPS SPS Mode, Fix valid */ +#define GPS_NMEA_GGA_FIX_STATUS_DR 6 /* Estimated/Dead Reckoning */ +/* Field No */ +#define GPS_NMEA_FNO_GGA_FS 6 +#define GPS_NMEA_FNO_GGA_MSL 9 + +/* number of SV Fields */ +#define GPS_NMEA_NUM_GSA_SV 12 +/* Fix Status */ +#define GPS_NMEA_GSA_FIX_STS_NON 1 +#define GPS_NMEA_GSA_FIX_STS_2D 2 +#define GPS_NMEA_GSA_FIX_STS_3D 3 +/* Field No */ +#define GPS_NMEA_FNO_GSA_FS 2 +#define GPS_NMEA_FNO_GSA_SV 3 + +/* number of Satellite Infomation Fields (sv+elv+az+cno) */ +#define GPS_NMEA_NUM_GSV_SINFO 4 + /* Field No */ +#define GPS_NMEA_FNO_GSV_NOSV 3 +#define GPS_NMEA_FNO_GSV_SV 4 +#define GPS_NMEA_FNO_GSV_ELV 5 +#define GPS_NMEA_FNO_GSV_AZ 6 +#define GPS_NMEA_FNO_GSV_CNO 7 + +#define GPS_NMEA_RMC_STS_INVALID 'V' +#define GPS_NMEA_RMC_STS_VALID 'A' +#define GPS_NMEA_RMC_IND_NORTH 'N' +#define GPS_NMEA_RMC_IND_EAST 'E' + +/* Field No */ +#define GPS_NMEA_FNO_RMC_UTC 1 +#define GPS_NMEA_FNO_RMC_STATUS 2 +#define GPS_NMEA_FNO_RMC_LATITUDE 3 +#define GPS_NMEA_FNO_RMC_NS 4 +#define GPS_NMEA_FNO_RMC_LONGITUDE 5 +#define GPS_NMEA_FNO_RMC_EW 6 +#define GPS_NMEA_FNO_RMC_SPEED 7 +#define GPS_NMEA_FNO_RMC_COG 8 +#define GPS_NMEA_FNO_RMC_DATE 9 + +// Diag Fix Count +#define GPS_DIAG_FIX_COUNT_3D (0x01) +#define GPS_DIAG_FIX_COUNT_2D (0x02) +#define GPS_DIAG_FIX_COUNT_ELSE (0x04) + +/* GPS time setting related */ +#define GPS_SETTIME_RANGE 5 /* 5 seconds : Valid range of GPS time setting */ +#define GPS_TIME_RANGE 10 /* 10 seconds : GPS time change range */ + +/* NAV-SVINFO logging status */ +#define GPS_NAVSVINFO_STS_INIT 0 +#define GPS_NAVSVINFO_STS_READY 1 +#define GPS_NAVSVINFO_STS_DONE 2 +#define GPS_NAVSVINFO_STS_SETTING 3 + +/* Time setting information */ +#define GPS_TIME_RX 0 /* Time not set */ +#define GPS_TIME_ROLOVR 1 /* First GPS reception(for rollover) */ +#define GPS_TIME_SET 2 /* Time setting in progress */ + +/*! + @brief Satellite position information +*/ +typedef struct GpsSatelliteInfoStr { + uint8_t sv; /* Satellite number */ + uint8_t elv; /* Height 0-99 */ + uint16_t az; /* Orientation 0-359 */ + uint8_t cno; /* Signal strength */ + uint8_t sts; /* Reception status */ +} GpsSatelliteInfo; + +/*---------------------------------------------------------------------------*/ +// Global values + +extern BOOL g_gps_rcv_thread_stop; +extern uint8_t g_is_gpstime_sts; + +/*---------------------------------------------------------------------------*/ +// Prototype + +void ChangeStatusGpsCommon(u_int32 sts); +void RtyResetGpsCommon(void); +void SendRtyResetGpsCommon(void); +void SendReqGpsCommon(void); +void GPSResetReqGpsCommon(void); +void CyclDataTimeOutGpsCommon(void); +RET_API CheckFrontStringPartGpsCommon(const u_char *p_tartget, const u_char *p_start); +int32 JudgeFormatGpsCommon(u_char *p_send_data, u_int32 ul_length, TG_GPS_OUTPUT_FORMAT *p_format); +RET_API CheckSumGpsCommon(const u_int8 p_uc_data[], u_int32 ul_length, TG_GPS_OUTPUT_FORMAT e_cmd_info); +u_int8 AtoHGpsCommon(u_int8 ascii); +RET_API DevGpsSaveCmd(TG_GPS_SAVECMD *p_send_data); +void SendSaveCmdGpsCommon(void); +void DeleteSaveCmdGpsCommon(void); +void DeleteAllSaveCmdGpsCommon(void); +void RcvCyclCmdNmeaGpsCommon(u_int8 *p_uc_data, u_int32 ul_len, TG_GPS_OUTPUT_FORMAT s_output_format); +int32 CheckSendCmdGpsCommon(const u_char *p_rcv_data, u_int32 ul_length, TG_GPS_OUTPUT_FORMAT *p_format); +int32_t GetStringFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, char* p_dst, size_t size); +double GetNumericFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, BOOL *p_valid); +int32 GetIntegerFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src); +int32 GetLonLatFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, BOOL *p_valid); +u_int16 GetHeadingFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, BOOL *p_valid); +int32 GetAltitudeFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, BOOL *p_valid); +u_int16 GetSpeedFromNmeaGpsCommon(u_int8 field_number, u_int8 *p_src, BOOL *p_valid); +void StopThreadGpsCommon(void); +uint8_t JudgeFormatOrderGpsCommon(TG_GPS_OUTPUT_FORMAT s_format_1, TG_GPS_OUTPUT_FORMAT s_format_2); +ENUM_GPS_NMEA_INDEX GetNmeaIdxGpsCommon(TG_GPS_OUTPUT_FORMAT s_output_format); +void SendResetReqGpsCommon(void); + + +void WriteGpsTimeToBackup(uint8_t flag, POS_DATETIME* pst_datetime); +void DevGpsCommSettingTime(void); +RET_API GpsSetPosBaseEvent(uint16_t snd_pno, int32_t event_val); +uint8_t HardResetChkGpsCommon(void); +void RcvCyclCmdExtGpsCommon(u_int8 *p_data, u_int32 len, TG_GPS_OUTPUT_FORMAT format); + +BOOL DevGpsRcvProcGpsResetResp(TG_GPS_RCV_DATA*); +void DevGpsRcvProcTimeSetResp(TG_GPS_RCV_DATA*); +void DevGpsRcvProcWknRolloverGetResp(TG_GPS_RCV_DATA* p_data); +void DevGpsRcvProcNavSvinfoAddResp(TG_GPS_RCV_DATA* p_data); +void DevGpsReadGpsTime(POS_DATETIME* p_st_datetime); +RET_API DevGpsRcvProcCmnResp(TG_GPS_RCV_DATA* p_data, uint8_t cmd); +RET_API DevGpsResetReq(PNO us_pno, RID uc_rid); +void DevGpsSettingTime(POS_DATETIME* p_st_datetime); +int DevGpsYMD2JD(int y, int m, int d); +BOOL DevGpsYMD2GPSTIME(const int32 y, const int32 m, const int32 d, + const int32 hh, const int32 mm, const int32 ss, + u_int16* gpsw, u_int32* gpsws); +void DevGpsSetChkSum(u_int8* uc_buffer, u_int32 ul_length); +RET_API DevGpsCatPollReq(uint8_t *p_ublox_data, uint16_t kind); +void DevGpsSetGpsweekcorcnt(void); +RET_API DevGpsNavTimeUTCAddReq(void); +RET_API DevGpsWknRolloverGetReq(void); +BOOL DevGpsCheckGpsTime(uint16_t set_gpsw, uint32_t set_gpsws, + uint16_t rcv_gpsw, uint32_t rcv_gpsws, int32_t offset_range); + +void DevGpsCnvLonLatNavi(SENSORLOCATION_LONLATINFO_DAT* p_lonlat, + u_int8 fix_sts, int32 lon, int32 lat); +void DevGpsCnvAltitudeNavi(SENSORLOCATION_ALTITUDEINFO_DAT* p_altitude, + u_int8 fix_sts, int32 alt); +void DevGpsCnvHeadingNavi(SENSORMOTION_HEADINGINFO_DAT* p_heading, + u_int8 fix_sts, u_int16 heading); +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPS_COMMON_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_Gps_Main.h b/positioning_hal/inc/GpsCommon/MDev_Gps_Main.h new file mode 100644 index 00000000..d40cb0ca --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_Gps_Main.h @@ -0,0 +1,311 @@ +/* + * @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. + */ +/** +* @file MDev_Gps_Main.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPS_MAIN_H_ +#define INC_GPSCOMMON_MDEV_GPS_MAIN_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "gps_hal.h" +#include "positioning_def.h" + +// #include "gps_hal.h" +// #include "MDev_Gps_Nmea.h" +// #include "LineSensDrv_Api.h" + +/*---------------------------------------------------------------------------*/ +// Value define + +#define OFF 0 /* OFF */ +#define ON 1 /* ON */ +#define OK 0 /* Normal */ +#define NG (-1L) /* Abnormality */ +#define DAT_END 0xff /* Exit code */ + +// State +typedef enum GpsMatrixSts { + GPS_STS_STARTUP = 0, /* Startup confirmation */ + GPS_STS_NORMAL, /* In operation */ + GPS_STS_SENT, /* Command sent status */ + GPS_STS_NUM +}TG_GPS_MATRIX_STS; + +// Event +typedef enum GpsMatrixEvt { + GPS_EVT_SENDREQ = 0, /* Transmission request */ + GPS_EVT_RESETREQ, /* GPS reset request */ + GPS_EVT_RECVCYCLDAT, /* Cyclic reception command reception */ + GPS_EVT_RECVRSPDAT, /* Receive response command */ + GPS_EVT_TIMEOUT_RSPDAT, /* Response monitoring timeout */ + GPS_EVT_TIMEOUT_CYCLDAT, /* Periodic reception data monitoring timeout */ + GPS_EVT_TIMEOUT_NAVI, /* Navigation providing data monitoring timeout */ + GPS_EVT_TIMEOUT_DIAGCLKGUARD, /* Diagnosis provision time guard monitoring timeout*/ + GPS_EVT_ACC_OFF, /* In-function ACC-OFF instructions */ + GPS_EVT_NAVI_LOCATIONINFO, /* Providing navigation information */ + GPS_EVT_NAVI_SPEEDINFO, /* Navigation speed information service */ + GPS_EVT_TIMESETTING, /* GPS time setting instruction */ + GPS_EVT_TIMEOUT_NMEADATAGUARD, /* NMEA data-providing guard monitoring timeout*/ + GPS_EVT_BACKUPDATA_LOAD, /* Backup data read request */ + GPS_EVT_STOPREQ, /* Thread stop request */ + GPS_EVT_WEEKCOR_CNT_NOTIFICATIO, /* GPS Week Adjustment Counter Notification */ + GPS_EVT_TIMEOUT_RECOVERY, /* GPS error monitoring reset timer */ + GPS_EVT_TIMEOUT_RECEIVERERR, /* GPS receiver anomaly detection timeout */ + GPS_EVT_NUM +} TG_GPS_MATRIX_EVT; + +typedef enum GpsOutputFormat { + GPS_FORMAT_MIN = -1, /* Minimum Receive Format(Initialization) */ + GPS_FORMAT_BINARY, /* Standard binary */ + GPS_FORMAT_FULLBIN, /* Full binary */ + GPS_FORMAT_GGA, /* GGA */ + GPS_FORMAT_DGGA, /* DGGA */ + GPS_FORMAT_VTG, /* VTG */ + GPS_FORMAT_RMC, /* RMC */ + GPS_FORMAT_DRMC, /* DRMC */ + GPS_FORMAT_GLL, /* GLL */ + GPS_FORMAT_DGLL, /* DGLL */ + GPS_FORMAT_GSA, /* GSA */ + GPS_FORMAT_GSV1, /* GSV(1) */ + GPS_FORMAT_GSV2, /* GSV(2) */ + GPS_FORMAT_GSV3, /* GSV(3) */ + GPS_FORMAT_GSV4, /* GSV(4) */ + GPS_FORMAT_GSV5, /* GSV(5) */ + GPS_FORMAT_GST, /* GST */ + GPS_FORMAT__CWORD44__GP3, /* _CWORD44_,GP,3 */ + GPS_FORMAT__CWORD44__GP4, /* _CWORD44_,GP,4 */ + GPS_FORMAT_P_CWORD82_F_GP0, /* P_CWORD82_F,GP,0 */ + GPS_FORMAT_P_CWORD82_J_GP1, /* P_CWORD82_J,GP,1 */ + GPS_FORMAT_P_CWORD82_I_GP, /* P_CWORD82_I,GP */ + GPS_FORMAT_P_CWORD82_E_GP0, /* P_CWORD82_E,GP,0 */ + GPS_FORMAT_P_CWORD82_J_GP0, /* P_CWORD82_J,GP,0 */ + GPS_FORMAT_P_CWORD82_E_GP2, /* P_CWORD82_E,GP,2 */ + GPS_FORMAT_P_CWORD82_G_GP0, /* P_CWORD82_G,GP,0 */ + GPS_FORMAT_P_CWORD82_J_GP7, /* P_CWORD82_J,GP,7 */ + GPS_FORMAT_P_CWORD82_J_GP8, /* P_CWORD82_J,GP,8 */ + GPS_FORMAT_MON_VER, /* MON-VER */ + GPS_FORMAT_AID_INI, /* AID-INI */ + GPS_FORMAT_ACK_ACKNACK, /* ACK-ACKNACK */ + GPS_FORMAT_NAV_TIMEUTC, /* NAV-TIMEUTC */ + GPS_FORMAT_NAV_CLOCK, /* NAV-CLOCK */ + GPS_FORMAT_RXM_RTC5, /* RXM-RTC5 */ + GPS_FORMAT_NAV_SVINFO, /* NAV-SVINFO */ + GPS_FORMAT_CFG_NAVX5, /* CFG-NAVX5 */ + GPS_FORMAT_NMEA, /* NMEA (Sentence unspecified) */ + GPS_FORMAT_UBX, /* UBX Protocol (binary) */ + GPS_FORMAT_MAX /* Maximum Receive Format */ +} TG_GPS_OUTPUT_FORMAT; + +// Return value +#define RETRY_OFF 0 /* No retry */ +#define RETRY_ON 1 /* Retry exists */ +#define RETRY_OUT 2 /* Retry out */ +#define NG_RETRYOUT 4 /* Transmission failure retry out */ + +#define GPSRET_NOPCMD (0) /* Non notification target command #GPF_60_024 */ +#define GPSRET_SNDCMD (1) /* Notification target command #GPF_60_024 */ +#define GPSRET_CMDERR (-1) /* No applicable command #GPF_60_024 */ + +// Number of Retries +#define SRSET_MAX 4 /* Maximum serial reset retry value */ +#define HRSET_MAX 3 /* Maximum value of hard reset retry */ +#define SNDNG_MAX 4 /* Maximum retry value of transmission failure */ + +/* The actual number of retries is SNDNG_MAX-1. */ +#define GPS_RECV_ERR_MAX 5 /* Maximum number of reception errors #GPF_60_024 */ + +// Others +#define SAV_MAX 11 +#define GPS_ALTITUDE_INVALID_VAL (-1000000) /* Value when fix altitude is invalid */ +#define GPS_HEADING_INVALID_VAL 36100 /* Value when measurement orientation is invalid */ + +#define GPS_RECVOK 0 /* Normal reception #13 */ +#define GPS_RECVNG 1 /* Reception error #13 */ +#define GPS_OVERRUN 2 /* Overrun detection #13 */ +#define GPS_PARITY 3 /* Parity detection #13 */ +#define GPS_FRAMING 4 /* Framing detection #13 */ + +// For the communication management thread +#define GPS_NON_RECV 0 /* Not received */ +#define GPS_RECV_ACK 1 /* ACK received */ +#define GPS_RECV_DATA 2 /* Receive response command */ + +#define GPS_SEND_ERR_MAX 5 /* Maximum number of transmission errors */ +#define GPS_CNCT_ERR_MAX 5 /* Maximum number of connection errors */ + +#define GPS_START_EVT "GPS_EVT" /* Interthread synchronization events */ +#define GPS_EVT_VAL 99 /* Event settings */ +#define GPS_MSGDAT_BUF_SZ 500 /* Receive message buffer size */ + +// Definition for receive command analysis table #GPF_60_024 +#define SENTENCE_STR_MAX 12 /* Maximum string for judging sentence */ + +#define SENSOR_MSG_VSINFO_DSIZE 1904 //!< \~english message body max size + +/*---------------------------------------------------------------------------*/ +// Structure + +/******************************************************************************** + * TAG :TG_GPS_MNG + * ABSTRACT :GPS process management information + * NOTE : + ********************************************************************************/ +typedef struct GpsMng { + u_int32 sts; /* Matrix state */ + u_int32 event; /* Matrix event code */ + u_int32 rcvsts; /* Response reception status */ + u_int32 sndcnt; /* Number of transmission attempts */ + u_int32 hrsetcnt; /* Number of tries before hard reset */ + u_int32 sndngcnt; /* Number of failed-to-send attempts */ + TG_GPS_OUTPUT_FORMAT rcv_cmd; /* Types of received GPS commands */ + TG_GPS_OUTPUT_FORMAT resp_cmd; /* Types of GPS commands during response monitoring */ + PNO resp_pno; /* Destination PNO */ + RID resp_rid; /* RID to be notified when responding */ + u_int8 resp_rst_flag; /* Response command reset flag */ + BOOL rcv_err_flag; /* GPS receiver error detection flag */ +} TG_GPS_MNG; + +/******************************************************************************** + * TAG :TG_GPS_SAVECMD + * ABSTRACT :GPS process pending command + * NOTE : + ********************************************************************************/ +typedef struct GpsSaveCmd { + TG_GPS_SND_DATA sndcmd; /* Sending commands(_CWORD82_ command) */ + PNO us_pno; /* Result notification destination process number(Unused) */ + RID uc_rid; /* Result Notification Resource ID(Unused) */ + u_int8 uc_rst; /* Reset flag */ + TG_GPS_OUTPUT_FORMAT e_cmd_info; /* Command information */ +} TG_GPS_SAVECMD; + +/******************************************************************************** + * TAG :TG_GPS_SAVEBUF + * ABSTRACT :GPS process pending buffer management information + * NOTE : + ********************************************************************************/ +typedef struct GpsSaveBuf { + u_int32 saveno; /* Current pending index number */ + u_int32 sendno; /* Current send index number */ + u_int32 bufsav; /* Number of pending buffers used */ + TG_GPS_SAVECMD savebuf[SAV_MAX]; /* Pending buffer */ +} TG_GPS_SAVEBUF; + +/******************************************************************************** + * TAG :TG_GPS_MSGRCV + * ABSTRACT :Receive message + * NOTE : + ********************************************************************************/ +typedef struct GpsMsgRcv { + T_APIMSG_MSGBUF_HEADER header; /* Message header */ + u_int8 msgdat[SENSOR_MSG_VSINFO_DSIZE + 12]; +} TG_GPS_MSGRCV; + +/******************************************************************************** + * TAG :TG_GPS_MSGEVTCHNG + * ABSTRACT :GPS message event translation table + * NOTE : + ********************************************************************************/ +typedef struct GpsMsgEvtChng { + u_int32 cid; /* Matrix state */ + u_int32 event; /* Matrix event code */ +} TG_GPS_MSGEVTCHNG; + +/******************************************************************************** + * TAG :TG_GPS_TIMEVTCHNG + * ABSTRACT :GPS timer ID and event translation table + * NOTE : + ********************************************************************************/ +typedef struct GpsTimEvtChng { + u_int16 tim_id; /* Timer ID information */ + u_int16 reserve; /* Reserved */ + u_int32 event; /* Matrix event code */ +} TG_GPS_TIMEVTCHNG; + +/******************************************************************************** + * TAG :Gps_Jmp_Tbl + * ABSTRACT :GPS jump table + * NOTE : + ********************************************************************************/ +typedef struct GpsJmpTbl { + void (*func)( void ); /* Jump-to module */ +} TG_GPS_JMP_TBL; + +/******************************************************************************** + * TAG :TG_GPS_CMD_ANA_TBL + * ABSTRACT :Receive command analysis table structure + * NOTE : + ********************************************************************************/ +typedef struct TgGpsCmdAnaTbl { + u_char c_sentence[SENTENCE_STR_MAX]; /* Sentence identifier */ + u_int32 ul_length; /* Length of the command */ + u_int32 ul_rcv_kind; /* Receiving type */ + BOOL b_snd_cmd_flg; /* Command notification flag */ + TG_GPS_OUTPUT_FORMAT e_rcv_format; /* Receive Format */ +} TG_GPS_CMD_ANA_TBL; + +/******************************************************************************** + * TAG :TG_GPS_TIME_BCD + * ABSTRACT :Time information (BCD) structure + * NOTE : + ********************************************************************************/ +typedef struct GpsTimeBCD { + u_int8 uc_year; /* Year information */ + u_int8 uc_month; /* Month information */ + u_int8 uc_day; /* Day information */ + u_int8 uc_hour; /* Time information */ + u_int8 uc_min; /* Minute information */ + u_int8 uc_sec; /* Second information */ +} TG_GPS_TIME_BCD; + +/*---------------------------------------------------------------------------*/ +// Global values + +#define MDEV_GPSMSGCHKC_MAX 10 +#define MDEV_PSTIMCHKC_MAX 11 +extern const TG_GPS_MSGEVTCHNG kGpsMsgchkC[MDEV_GPSMSGCHKC_MAX]; /* Ignore -> MISRA-C:2004 Rule 8.12 */ +extern const TG_GPS_TIMEVTCHNG kGpsTimchkC[MDEV_PSTIMCHKC_MAX]; /* Ignore -> MISRA-C:2004 Rule 8.12 */ +extern const TG_GPS_JMP_TBL kGpsMatxC[GPS_STS_NUM][GPS_EVT_NUM]; + +#define MDEV_GPSCMDANATBLNMEA_MAX 20 +extern const TG_GPS_CMD_ANA_TBL* kGpsCmdAnaTbl; +extern const TG_GPS_CMD_ANA_TBL kGpsCmdAnaTblUblox[MDEV_GPSCMDANATBLNMEA_MAX]; + +extern TG_GPS_SAVEBUF g_gps_save_cmdr; +extern TG_GPS_MSGRCV g_gps_msg_rcvr; +extern TG_GPS_MNG g_gps_mngr; + +extern u_int16 g_wsend_err; /* Number of transmission errors */ +extern u_int16 g_wcnct_err; /* Number of connection errors */ +extern TG_GPS_OUTPUT_FORMAT g_rcv_format; /* Receive Format */ + +/*---------------------------------------------------------------------------*/ +// Prototype + +EFrameworkunifiedStatus DevGpsMainThread(HANDLE h_app); +BOOL DevGpsInit(void); +void DevGpsRcvMsg(void); +void DevGpsMsgEventCheck(void); +void DevGpsTimEventCheck(void); +void DevGpsGpsVersionCheck(void); + +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPS_MAIN_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_Gps_Mtrx.h b/positioning_hal/inc/GpsCommon/MDev_Gps_Mtrx.h new file mode 100644 index 00000000..610b8d42 --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_Gps_Mtrx.h @@ -0,0 +1,90 @@ +/* + * @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. + */ +/** +* @file MDev_Gps_Mtrx.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPS_MTRX_H_ +#define INC_GPSCOMMON_MDEV_GPS_MTRX_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +/*---------------------------------------------------------------------------*/ +// Prototype + +void DevGpsNop(void); +void DevGpsInitStartSendReq(void); +void DevGpsInitStartGPSResetReq(void); +void DevGpsInitStartRcvCyclCmd(void); +void DevGpsInitStartCyclDataTimeOut(void); +void DevGpsInitStartNaviDataTimeOut(void); /* #GPF_60_077 */ +void DevGpsInitStartDiagClkGuardTimeOut(void); /* #GPF_60_077 */ +void DevGpsInitStartAccOffStart(void); /* #GPF_60_024 */ +void DevGpsInitStartNaviInfoDeliver(void); /* #GPF_60_077 */ +void DevGpsInitStartNaviSpeedDeliver(void); /* #GPF_60_077 */ +void DevGpsInitStartSettingTime(void); /* #GPF_60_077 */ +void DevGpsInitStartNmeaDataGuardTimeOut(void); /* #GPF_60_109 */ + +void DevGpsInitStartBackupDataLoadReq(void); +void DevGpsInitStartStopReq(void); +void DevGpsInitStartGpsweekcorcntNtf(void); +void DevGpsInitStartRecoveryTimeOut(void); +void DevGpsInitStartGpsReceiverErrTimeOut(void); + +void DevGpsNormalSendReq(void); +void DevGpsNormalGPSResetReq(void); +void DevGpsNormalRcvCyclCmd(void); +void DevGpsNormalCyclDataTimeOut(void); +void DevGpsNormalNaviDataTimeOut(void); /* #GPF_60_077 */ +void DevGpsNormalDiagClkGuardTimeOut(void); /* #GPF_60_077 */ +void DevGpsNormalAccOffStart(void); /* #GPF_60_024 */ +void DevGpsNormalNaviInfoDeliver(void); /* #GPF_60_077 */ +void DevGpsNormalNaviSpeedDeliver(void); /* #GPF_60_077 */ +void DevGpsNormalSettingTime(void); /* #GPF_60_077 */ +void DevGpsNormalNmeaDataGuardTimeOut(void); /* #GPF_60_109 */ + +void DevGpsNormalBackupDataLoadReq(void); +void DevGpsNormalStopReq(void); +void DevGpsNormalGpsweekcorcntNtf(void); +void DevGpsNormalRecoveryTimeOut(void); +void DevGpsNormalGpsReceiverErrTimeOut(void); + +void DevGpsSendSendReq(void); +void DevGpsSendGPSResetReq(void); +void DevGpsSendRcvCyclCmd(void); +void DevGpsSendRcvRspCmd(void); /* #GPF_60_040 */ +void DevGpsSendRspDataTimeOut(void); /* #GPF_60_040 */ +void DevGpsSendCyclDataTimeOut(void); +void DevGpsSendNaviDataTimeOut(void); /* #GPF_60_077 */ +void DevGpsSendDiagClkGuardTimeOut(void); /* #GPF_60_077 */ +void DevGpsSendAccOffStart(void); /* #GPF_60_040 */ +void DevGpsSendNaviInfoDeliver(void); /* #GPF_60_077 */ +void DevGpsSendNaviSpeedDeliver(void); /* #GPF_60_077 */ +void DevGpsSendSettingTime(void); /* #GPF_60_077 */ +void DevGpsSendNmeaDataGuardTimeOut(void); /* #GPF_60_109 */ + +void DevGpsSendBackupDataLoadReq(void); +void DevGpsSendStopReq(void); +void DevGpsSendGpsweekcorcntNtf(void); +void DevGpsSendRecoveryTimeOut(void); +void DevGpsSendGpsReceiverErrTimeOut(void); + +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPS_MTRX_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_Gps_Nmea.h b/positioning_hal/inc/GpsCommon/MDev_Gps_Nmea.h new file mode 100644 index 00000000..a19e3d9a --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_Gps_Nmea.h @@ -0,0 +1,313 @@ +/* + * @copyright Copyright (c) 2017-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. + */ +/** +* @file MDev_GpsUblox.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPS_NMEA_H_ +#define INC_GPSCOMMON_MDEV_GPS_NMEA_H_ + +/*---------------------------------------------------------------------------*/ + +#include "gps_hal.h" +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Value define + +#define TEST_NMEA (0) /* 0:Normal mode 1:Testing mode */ + +#define GPS_MAX_NUM_VISIBLE_SATELLITES (20) /* Maximum Number of Visible Satellites *Assume the GSV1~GSV5 */ + +/* UBX command *****************************/ + +/* CFG */ +#define UBX_CMD_SIZE_CFG_RST (12) /* size of CFG-RST of UBX sentences */ +#define UBX_CMD_SIZE_CFG_MSG (11) /* size of CFG-MSG of UBX sentences */ +#define UBX_CMD_SIZE_CFG_NAV5 (44) /* size of CFG-NAV5 of UBX sentences */ +#define UBX_CMD_SIZE_CFG_NAV5_POLL (8) +#define UBX_CMD_SIZE_CFG_NAV5_PLUS_POLL (UBX_CMD_SIZE_CFG_NAV5 + UBX_CMD_SIZE_CFG_NAV5_POLL) +#define UBX_CMD_SIZE_CFG_NAVX5_POLL (8) +#define UBX_CMD_OFFSET_WKNROLLOVER (18) /* offset from the top of 'payload' */ + +/* MON */ +#define UBX_CMD_SIZE_MON_VER (108) /* size of MON-VER of UBX sentences */ +#define UBX_CMD_SIZE_MON_VER_POLL (8) +#define UBX_CMD_SIZE_MON_VER_SW_VER (30) + +/* AID */ +#define UBX_CMD_SIZE_AID_INI (56) /* size of AID-INI of UBX sentences */ +#define UBX_CMD_SIZE_AID_INI_POLL (8) +#define UBX_CMD_SIZE_AID_INI_PLUS_POLL (UBX_CMD_SIZE_AID_INI + UBX_CMD_SIZE_AID_INI_POLL) + +/* ACK */ +#define UBX_CMD_OFFSET_ACKNAK (3) /* offset to Ack/Nack Infomation */ + +/* NAV */ +#define UBX_CMD_MSK_NAV_TIMEUTC_VALID_TOW (1) /* mask bit for 'validTow' of NAV-TIMEUTC */ +#define UBX_CMD_MSK_NAV_TIMEUTC_VALID_WKN (2) /* mask bit for 'validKwn' of NAV-TIMEUTC */ +#define UBX_CMD_MSK_NAV_TIMEUTC_VALID_UTC (4) /* mask bit for 'validUtc' of NAV-TIMEUTC */ + +/* Common */ +#define UBX_CMD_SIZE_HDR (2) /* size of 'header' of UBX sentence */ +#define UBX_CMD_SIZE_ID (2) /* size of 'id' of UBX sentence */ +#define UBX_CMD_SIZE_LEN (2) /* size of 'length' of UBX sentence */ +#define UBX_CMD_SIZE_MAX (400) /* size of NAV-SVINFO (numCh=32) */ +#define UBX_CMD_OFFSET_PAYLOAD (UBX_CMD_SIZE_HDR + UBX_CMD_SIZE_ID + UBX_CMD_SIZE_LEN) + /* offset to 'payload' of UBX sentence */ + +/* Types of UBX Poll Request Commands ************/ +#define UBX_POLL_CMD_KIND_AID_INI (1) +#define UBX_POLL_CMD_KIND_CFG_NAV5 (2) + +// GPS-command (_CWORD82_ NMEA) related definitions #GPF_60_024 +/* Command identification character string */ +#define GPS_CMD_NMEA_GGA ("$GPGGA") /* GGA/double precision GGAs */ +#define GPS_CMD_NMEA_VTG ("$GPVTG") /* VTG */ +#define GPS_CMD_NMEA_RMC ("$GPRMC") /* RMC/double precision RMCs */ +#define GPS_CMD_NMEA_GLL ("$GPGLL") /* GLL/double precision GLL */ +#define GPS_CMD_NMEA_GSA ("$GPGSA") /* GSA */ +#define GPS_CMD_NMEA_GSV_1 ("$GPGSV,*,1") /* GSV(1) */ +#define GPS_CMD_NMEA_GSV_2 ("$GPGSV,*,2") /* GSV(2) */ +#define GPS_CMD_NMEA_GSV_3 ("$GPGSV,*,3") /* GSV(3) */ +#define GPS_CMD_NMEA__CWORD44__GP_3 ("$_CWORD44_,GP,3") /* _CWORD44_,GP,3 */ +#define GPS_CMD_NMEA__CWORD44__GP_4 ("$_CWORD44_,GP,4") /* _CWORD44_,GP,4 */ +#define GPS_CMD_NMEA_P_CWORD82_F_GP_0 ("$P_CWORD82_F,GP,0") /* P_CWORD82_F,GP,0 */ +#define GPS_CMD_NMEA_P_CWORD82_J_GP_1 ("$P_CWORD82_J,GP,1") /* P_CWORD82_J,GP,1 */ +#define GPS_CMD_NMEA_P_CWORD82_I_GP ("$P_CWORD82_I,GP") /* P_CWORD82_I,GP */ +#define GPS_CMD_NMEA_P_CWORD82_E_GP_0 ("$P_CWORD82_E,GP,0") /* P_CWORD82_E,GP,0 */ +#define GPS_CMD_NMEA_P_CWORD82_J_GP_0 ("$P_CWORD82_J,GP,0") /* P_CWORD82_J,GP,0 */ +#define GPS_CMD_NMEA_P_CWORD82_E_GP_2 ("$P_CWORD82_E,GP,2") /* P_CWORD82_E,GP,2 */ +#define GPS_CMD_NMEA_P_CWORD82_G_GP_0 ("$P_CWORD82_G,GP,0") /* P_CWORD82_G,GP,0 */ +#define GPS_CMD_NMEA_P_CWORD82_J_GP_7 ("$P_CWORD82_J,GP,7") /* P_CWORD82_J,GP,7 */ +#define GPS_CMD_NMEA_P_CWORD82_J_GP_8 ("$P_CWORD82_J,GP,8") /* P_CWORD82_J,GP,8 */ +#define GPS_CMD_NMEA_GST ("$GPGST") /* GST */ +#define GPS_CMD_NMEA_GSV_4 ("$GPGSV,*,4") /* GSV(4) */ +#define GPS_CMD_NMEA_GSV_5 ("$GPGSV,*,5") /* GSV(5) */ + +/*------------------------------------------------------------------------------- + * GPS-command (_CWORD82_ Binary) related definitions #GPF_60_024 + -------------------------------------------------------------------------------*/ +#define GPS_CMD_BINARY (0xC6) /* Standard binary */ +#define GPS_CMD_FULLBIN (0xB0) /* FULL binaries */ + +#define ENDMARK "ENDENDEND" /* Table termination */ +#define GPSCMDANATBL_MAX 25 /* Maximum number of elements in table */ +#define RCV_CYCLE 0x01 /* Reception type cycle reception command*/ +#define RCV_RESP 0x02 /* Reception type response command */ + +// Length of FULLBINARY commands +#define GPS_CMD_FULLBIN1_SZ 30 +#define GPS_CMD_FULLBIN2_SZ 160 +#define GPS_CMD_FULLBIN3_SZ 25 +#define GPS_CMD_FULLBIN4_SZ 26 +#define GPS_CMD_FULLBIN5_SZ 14 +#define GPS_CMD_FULLBIN6_SZ 61 + +/* Start offset of FULLBINARY command */ +#define GPS_CMD_FULLBIN1_OFFSET 0 +#define GPS_CMD_FULLBIN2_OFFSET (GPS_CMD_FULLBIN1_OFFSET + GPS_CMD_FULLBIN1_SZ) +#define GPS_CMD_FULLBIN3_OFFSET (GPS_CMD_FULLBIN2_OFFSET + GPS_CMD_FULLBIN2_SZ) +#define GPS_CMD_FULLBIN4_OFFSET (GPS_CMD_FULLBIN3_OFFSET + GPS_CMD_FULLBIN3_SZ) +#define GPS_CMD_FULLBIN5_OFFSET (GPS_CMD_FULLBIN4_OFFSET + GPS_CMD_FULLBIN4_SZ) +#define GPS_CMD_FULLBIN6_OFFSET (GPS_CMD_FULLBIN5_OFFSET + GPS_CMD_FULLBIN6_SZ) + + +/* SUM value offset of FULLBINARY commands */ +#define GPS_CMD_FULLBIN1_SUMOFFSET (GPS_CMD_FULLBIN1_OFFSET + GPS_CMD_FULLBIN1_SZ - 2) +#define GPS_CMD_FULLBIN2_SUMOFFSET (GPS_CMD_FULLBIN2_OFFSET + GPS_CMD_FULLBIN2_SZ - 2) +#define GPS_CMD_FULLBIN3_SUMOFFSET (GPS_CMD_FULLBIN3_OFFSET + GPS_CMD_FULLBIN3_SZ - 2) +#define GPS_CMD_FULLBIN4_SUMOFFSET (GPS_CMD_FULLBIN4_OFFSET + GPS_CMD_FULLBIN4_SZ - 2) +#define GPS_CMD_FULLBIN5_SUMOFFSET (GPS_CMD_FULLBIN5_OFFSET + GPS_CMD_FULLBIN5_SZ - 2) +#define GPS_CMD_FULLBIN6_SUMOFFSET (GPS_CMD_FULLBIN6_OFFSET + GPS_CMD_FULLBIN6_SZ - 2) +#define GPS_CMD_FULLBIN_MASK 0x8F + +#define GPS_CMD_RESET 1 /* Reset request command */ +#define GPS_CMD_TIMESET 2 /* Time setting request command */ +#define GPS_CMD_VERSION 3 /* GPS version request command */ +#define GPS_CMD_SENTENCEADD_NMEAGST 4 /* Add sentence command NMEA GST */ +#define GPS_CMD_SENTENCEADD_NAVTIMEUTC 5 /* Add sentence command NAV-TIMEUTC */ +#define GPS_CMD_SENTENCEADD_NAVCLOCK 6 /* Add sentence command NAV-CLOCK */ +#define GPS_CMD_SENTENCEADD_RXMRTC5 7 /* Add sentence command RXM-RTC5 */ +#define GPS_CMD_SENTENCEADD_NAVSVINFO 8 /* Add sentence command NAV-SVINFO */ +#define GPS_CMD_AUTOMOTIVEMODE 9 /* Automatic mode request command */ +#define GPS_CMD_WKNROLLOVER 10 /* GPS rollover standard week number request command */ +#define GPS_CMD_NOTRST 0 /* Other request command */ + +/*---------------------------------------------------------------------------*/ +// Struct + +/*! + @brief UBX command headers +*/ +typedef struct GpsUbxPacketHeader { + u_int8 uc_sync_char1; /* u-blox starts with 2 Bytes 0xB5 0x62 */ + u_int8 uc_sync_char2; /* u-blox starts with 2 Bytes 0xB5 0x62 */ + u_int8 uc_class; /* Class */ + u_int8 uc_id; /* ID */ + u_int16 us_length; /* Length */ +} TG_GPS_UBX_PACKET_HEADER; + +/*! + @brief Command-structure without UBX data +*/ +typedef struct GpsUbxCmdNoData { + TG_GPS_UBX_PACKET_HEADER header; + u_int8 uc_cka; /* Checksum_A */ + u_int8 uc_ckb; /* Checksum_B */ +} TG_GPS_UBX_COMMAND_NO_DATA; + +/*! + @brief +*/ +typedef struct GpsUbxAidIniPolled { + u_int8 uc_sync_char1; /* u-blox starts with 2 Bytes 0xB5 0x62 */ + u_int8 uc_sync_char2; /* u-blox starts with 2 Bytes 0xB5 0x62 */ + u_int8 uc_class; /* Class */ + u_int8 uc_id; /* ID */ + u_int8 uc_length[2]; /* Length */ + u_int8 uc_ecefx_or_lat[4]; /* WGS84 ECEF X coordinate or latitude */ + u_int8 uc_ecefy_or_lon[4]; /* WGS84 ECEF Y coordinate or longitude */ + u_int8 uc_ecefz_or_alt[4]; /* WGS84 ECEF Z coordinate or altitude */ + u_int8 uc_pos_acc[4]; /* Position accuracy (stddev) */ + u_int8 uc_tm_cfg[2]; /* Time mark configuration */ + u_int8 wn[2]; /* Actual week number */ + u_int8 tow[4]; /* Actual time of week */ + u_int8 uc_tow_ns[4]; /* Sub-millisecond part of time of week */ + u_int8 uc_tacc_ms[4]; /* Milliseconds part of time accuracy */ + u_int8 uc_tacc_ns[4]; /* Nanoseconds part of time accuracy */ + u_int8 uc_clk_d_or_freq[4]; /* Clock drift or frequency */ + u_int8 uc_clk_dacc_or_freqacc[4]; /* Accuracy of clock drift or frequency */ + u_int8 uc_flags[4]; /* Bitmask with the following flags */ + u_int8 uc_cka; /* Checksum_A */ + u_int8 uc_ckb; /* Checksum_B */ +} TG_GPS_UBX_AID_INI_POLLED; + +/*! + @brief UBX ACK command data structures +*/ +typedef struct GpsUbxAckData { + uint8_t uc_msg_class; /* Message Class */ + uint8_t uc_msg_id; /* Message Identifier */ +} TG_GPS_UBX_ACK_DATA; + +/*! + @brief UBX NAV-TIMEUTC command data structures +*/ +typedef struct GpsUbxNavUTC { + uint32_t ul_itow; /* GPS time of week */ + uint32_t ul_tacc; /* Time accuracy estimate (UTC) */ + int32_t nano; /* Fraction of second */ + uint16_t year; /* Year, range 1999..2099 (UTC) */ + uint8_t month; /* Month, range 1..12 (UTC) */ + uint8_t day; /* Day of month, range 1..31 (UTC) */ + uint8_t hour; /* Hour of day, range 0..23 (UTC) */ + uint8_t min; /* Minute of hour, range 0..59 (UTC) */ + uint8_t sec; /* Seconds of minute, range 0..60 (UTC) */ + uint8_t valid; /* Validity Flags */ +} TG_GPS_UBX_NAV_TIMEUTC_DATA; + +/*! + @brief USB NAV-CLOCK command data structures +*/ +typedef struct GpsUbxNavClock { + uint32_t ul_itow; /**< GPS Time of week */ + int32_t l_clkb; /**< Clock bias */ + int32_t l_clkd; /**< Clock drift */ + uint32_t ul_tacc; /**< Time accuaracy estimate */ + uint32_t ul_facc; /**< Frequency accuracy estimate */ +} TG_GPS_UBX_NAV_CLOCK; + +/*! + @brief GPS RXM-RTC5 command data structures +*/ +typedef struct GpsUbxRxmRtc5 { + uint32_t ul_rtag_hw; /**< RTAG high word */ + uint32_t ul_rtag_lw; /**< RTAG low word */ + uint32_t freq; /**< Clock frequency */ + uint32_t ul_freq_frac; /**< Clock frequency fractional part */ + uint32_t ul_tow_frac; /**< Time of week fractional part */ + uint32_t tow; /**< Time of week */ + uint16_t wno; /**< GPS week number */ + uint8_t uc_tow_valid; /**< TOW is valid flag */ + uint8_t uc_freq_valid; /**< Frequency is valid flag */ +} TG_GPS_UBX_RXM_RTC5; + +/******************************************************************************** + * TAG :TG_GPS_RCVDATA_NMEA + * ABSTRACT :Cyclic data (NMEA) area + * NOTE :I/F information between communication management thread and vehicle sensor + ********************************************************************************/ +typedef struct GpsRcvDataNMEA { + u_int8 uc_rcv_flag[GPS_NMEA_INDEX_MAX]; /* Receive flag */ + u_int8 u_reserve[3]; /* Reserved */ + TG_GPS_NMEA_DAT st_nmea[GPS_NMEA_INDEX_MAX]; /* NMEA data area */ +} TG_GPS_RCVDATA_NMEA; + +/******************************************************************************** + * TAG :TG_GPS_RCVDATA_BINARY + * ABSTRACT :Cyclic data (standard binary) area + * NOTE :I/F information between communication management thread and vehicle sensor + ********************************************************************************/ +typedef struct GpsRcvDataBinary { + u_int8 uc_rcv_flag; /* Receive flag */ + u_int8 u_reserve[3]; /* Reserved */ + u_int8 uc_data[GPS_CMD_BINARY_SZ]; /* Standard binary data area */ + u_int8 u_reserve2[3]; /* Reserved */ +} TG_GPS_RCVDATA_BINARY; + +/******************************************************************************** + * TAG :TG_GPS_RCVDATA_FULLBIN + * ABSTRACT :Cyclic data (full binary) area + * NOTE :I/F information between communication management thread and vehicle sensor + ********************************************************************************/ +typedef struct GpsRcvDataFullbin { + u_int8 uc_rcv_flag; /* Receive flag */ + u_int8 u_reserve[3]; /* Reserved */ + u_int8 uc_data[GPS_CMD_FULLBIN_SZ]; /* Full binary data area */ + u_int8 u_reserve2; /* Reserved */ +} TG_GPS_RCVDATA_FULLBIN; + +/******************************************************************************** + * TAG :TG_GPS_RCVDATA + * ABSTRACT :Cyclic data storage area + * NOTE :I/F information between communication management thread and vehicle sensor + ********************************************************************************/ +typedef struct GpsRcvData { + u_int8 uc_sns_cnt; /* Sensor counter value */ + u_int8 u_reserve[3]; /* Reserved */ + TG_GPS_RCVDATA_NMEA st_nmea_data; /* NMEA data area */ + TG_GPS_RCVDATA_BINARY st_binary_data; /* Standard binary region */ + TG_GPS_RCVDATA_FULLBIN st_fullbin_data; /* Full binary data area */ +} TG_GPS_RCVDATA; + +/*---------------------------------------------------------------------------*/ +// Prototype + +void DevGpsSndCycleDataNmea(void); +void DevGpsRcvCyclCmd(void); +u_int8 DevGpsGetGpsRcvSts(u_int8 sv); +void DevGpsAnalyzeNmea(NAVIINFO_ALL* navilocinfo); +void DevGpsCycleDataClear(void); +void DevGpsCycleDataSetNmea(const u_int8*, u_int32, ENUM_GPS_NMEA_INDEX); +BOOL DevGpsCycleDataGetNmea(u_int8*, u_int32, ENUM_GPS_NMEA_INDEX); +void DevGpsCmdEventCheckNmea(void); +void DevGpsSetChkSum(u_int8* buffer, u_int32 length); +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPS_NMEA_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/GpsCommon/MDev_Gps_TimerCtrl.h b/positioning_hal/inc/GpsCommon/MDev_Gps_TimerCtrl.h new file mode 100644 index 00000000..96616efe --- /dev/null +++ b/positioning_hal/inc/GpsCommon/MDev_Gps_TimerCtrl.h @@ -0,0 +1,113 @@ +/* + * @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. + */ +/** +* @file MDev_Gps_TimerCtrl.h +*/ + +#ifndef INC_GPSCOMMON_MDEV_GPS_TIMERCTRL_H_ +#define INC_GPSCOMMON_MDEV_GPS_TIMERCTRL_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Value define + +/* GPS-related timer value */ +#define TIMVAL_GPS_STARTUP 500 /* 5Sec Start confirmation monitoring timer */ +#define TIMVAL_GPS_RCVCYCLDAT 500 /* 5Sec Periodic reception data monitoring timer */ +#define TIMVAL_GPS_RCVACK 500 /* 5Sec ACK reception monitoring timer */ +#define TIMVAL_GPS_RCVDAT 500 /* 5Sec Data reception monitoring timer(Unused) */ +#define TIMVAL_GPS_NAVIFST 3000 /* 30sec Initial navigation monitoring timer */ +#define TIMVAL_GPS_NAVICYCLE 300 /* 3sec Navigation monitoring timer */ +#define TIMVAL_GPS_NAVIDISRPT 1000 /* 10Sec Navigation monitoring disruption log output timer */ +#define TIMVAL_GPS_DIAGCLKGUARD 1000 /* 10sec Diagnosis provision time guard monitoring timer */ +#define TIMVAL_GPS_NMEADATAGUARD 1000 /* 10sec NMEA data-providing guard monitoring timer */ +#define TIMVAL_GPS_RECOVERY 60000 /* 600sec GPS recovery timer */ +#define TIMVAL_GPS_RECEIVERERR 60000 /* 600sec GPS receiver anomaly detection timer */ + +/* Sensor-related timer value */ +#define TIMVAL_SNS_RCVFSTDAT 3000 /* 30Sec Initial sensor data reception monitoring timer */ +#define TIMVAL_SNS_RCVCYCLDAT 300 /* 3Sec Cyclic sensor data reception monitoring timer */ +#define TIMVAL_SNS_RCVDISRPT 1000 /* 10Sec Cyclic sensor data interruption log output timer */ + +/* Timer management table */ +#define TIM_NON 0x00 /* Timer counter initial value */ +#define TIM_CNTMIN 0x01 /* Timer counter minimum value */ +#define TIM_CNTMAX 0xff /* Maximum value of timer counter */ +#define TIMER_OFF 0 /* Timer enable flag OFF */ +#define TIMER_ON 1 /* Timer enable flag ON */ + +/*! + @brief Timer type + */ +typedef enum GpsTimKind { + GPS_STARTUP_TIMER = 0, /* 0 Start confirmation monitoring timer */ + GPS_CYCL_TIMER, /* 1 Cyclic GPS data reception monitoring timer */ + GPS_RECV_ACK_TIMER, /* 2 ACK reception monitoring timer */ + GPS_NAVIFST_TIMER, /* 3 Initial navigation monitoring timer */ + GPS_NAVICYCLE_TIMER, /* 4 Navigation monitoring timer */ + GPS_NAVIDISRPT_TIMER, /* 5 Navigation monitoring disruption log output timer */ + GPS_DIAGCLK_GUARDTIMER, /* 6 Diagnosis provision time guard monitoring timer */ + GPS_NMEADATA_GUARDTIMER, /* 7 NMEA data-providing guard monitoring timer */ + GPS_RECOVERY_TIMER, /* 8 GPS recovery timer */ + GPS_RECEIVERERR_TIMER, /* 9 GPS receiver anomaly detection timer */ + SNS_FST_TIMER, /* 10 Initial sensor data reception monitoring timer */ + SNS_CYCLE_TIMER, /* 11 Cyclic sensor data reception monitoring timer */ + SNS_DISRPT_TIMER, /* 12 Cyclic sensor data interruption log output timer */ + TIM_NUM /* 13 Number of timer types */ +} GPS_TIM_KIND; + +/*! + @brief Timer status +*/ +typedef struct GpsTimSts { + u_int8 flag; /**< Timer flag OFF:Stop,ON:Start */ + u_int8 cnt; /**< Start counter */ + int8 rsv[2]; /**< Reserved */ +} GPS_TIM_STS; + +/*! + @brief Timer status management table + */ +typedef struct GpsTimMng { + GPS_TIM_STS sts[TIM_NUM]; /**< Timer status */ +} GPS_TIM_MNG; + +/*! + @brief Timer setting information table +*/ +typedef struct GpsTimInfo { + uint32_t timer_val; /**< Timer value */ + PNO pno; /**< Event notification destination process number */ +} GPS_TIM_INFO; + +/*---------------------------------------------------------------------------*/ +// Prototype + +void DevGpsTimInit(void); +BOOL DevGpsTimeSet(GPS_TIM_KIND tim_kind); +BOOL DevGpsTimeStop(GPS_TIM_KIND tim_kind); +u_int16 DevGpsTimeMakSeqNo(GPS_TIM_KIND tim_kind); +BOOL DevGpsTimeJdgKind(u_int16 seqno); + +/*---------------------------------------------------------------------------*/ +#endif // INC_GPSCOMMON_MDEV_GPS_TIMERCTRL_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/LineSensDrv/LineSensDrv_Sensor.h b/positioning_hal/inc/LineSensDrv/LineSensDrv_Sensor.h new file mode 100644 index 00000000..1b996b78 --- /dev/null +++ b/positioning_hal/inc/LineSensDrv/LineSensDrv_Sensor.h @@ -0,0 +1,183 @@ +/* + * @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. + */ +/** +* @file LineSensDrv_Sensor.h +*/ + +#ifndef INC_LINESENSDRV_LINESENSDRV_SENSOR_H_ +#define INC_LINESENSDRV_LINESENSDRV_SENSOR_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "positioning_def.h" + +/*---------------------------------------------------------------------------*/ +// Macro definitions + +/* Message related */ +/* Message identification number definition received from the ICR */ +#define LSDRV_RCVMSG_INVALID 0x00 /* Not applicable */ +#define LSDRV_RCVMSG_SENSOR 0x12 /* Sensor data */ + +/* LineSensor vehicle signal notification */ + +#define LSDRV_SENS_MASK 0xFFF /* Sensor data MASK */ +#define LSDRV_PLSMAX 65536 /* Maximum vehicle speed pulse number */ +/* #011 start */ +#define LSDRV_SENS_COEFFICIENT 14.1287284284144427 /* Vehicle speed calculation factor */ +#define LSDRV_SPKMPH_METHOD_FST 0 /* Vehicle speed calculation method(Initial Sensor Data) */ +#define LSDRV_SPKMPH_METHOD_NML 1 /* Vehicle speed calculation method(Sensor data) */ +#define LSDRV_SPKMPH_AVE_TIME 29 /* Effective time for average calculation data(in units of 100ms) */ /* #013 */ +#define LSDRV_SPKMPH_NOISE_TIME (LSDRV_SPKMPH_AVE_TIME + 2) /* Effective Time for Noise Detection(in units of 100ms) */ /* #017 */ +#define LSDRV_SPKMPH_INVALID 1 /* No pulse of previous vehicle speed */ +#define LSDRV_SPKMPH_VALID 0 /* Last vehicle speed pulse */ +#define LSDRV_SENSCNT_BRW_ADD 256 /* Measures for borrow occurrence during search of sensor counters */ +/* #011 end */ +#define LSDRV_FSENS_NRCV 0 /* Not received */ +#define LSDRV_FSENS_RCV 1 /* Receiving */ +#define LSDRV_FSENS_RCVCOMP 2 /* Reception completion */ +#define LSDRV_FSENS_NORMAL 0 /* Receive data normal */ /* #001 */ +#define LSDRV_FSENS_ERROR 1 /* Receive data anomaly */ /* #001 */ +/* #016 start */ +#define LSDRV_PLSDATA_NRCV 0 /* Not received */ +#define LSDRV_PLSDATA_RCV 1 /* Received */ +#define LSDRV_SENSCNT_MAX 255 /* Maximum value of sensor counter */ +#define LSDRV_SPKMPH_MIN_DATA_N 6 /* Number of data required for vehicle speed calculation */ +#define LSDRV_FSPDPLS_NUM 3 /* Number of cumulative pulses registered for the first time */ +/* #016 end */ +#define LSDRV_REV_MASK 0x0040 /* REV-data MASK(Before endian conversion) */ +#define LSDRV_BITSHIFT_REV 6 /* REV data bit shift */ +#define LSDRV_TEMP_MASK 0x07FF /* Gyro temperature data MASK(after endian conversion) */ +#define LSDRV_PLSTIME_LEN 232 /* Data length when inter-pulse time exists */ + + +#define LSDRV_DETAILED_DATA_MULTI_ENABLE TRUE /* Detailed data multiplexing of initial sensor data Enabled/Disabled */ + +#if LSDRV_DETAILED_DATA_MULTI_ENABLE +#define LSDRV_DETAILED_DATA_MULTI_MAX_NUM 2 /* Detailed data multiplexing of initial sensor data Maximum number */ +#else +#define LSDRV_DETAILED_DATA_MULTI_MAX_NUM 1 /* Detailed data multiplexing of initial sensor data Maximum number */ +#endif + +/* Total number of partitions of initial sensor data : Maximum value */ +#define LSDRV_FSENS_TOTAL_NUM_MAX LSDRV_FSTSNS_SENSOR_FIRST_SEND_NUM + +/* Detailed data of initial sensor data : Maximum number of acquisitions */ +#define LSDRV_DETAILED_DATA_MAX_NUM (LSDRV_FSENS_TOTAL_NUM_MAX * LSDRV_DETAILED_DATA_MULTI_MAX_NUM) + +/* Initial sensor data : Maximum number of saved messages */ +#define LSDRV_FSENS_SAVE_MSG_NUM (LSDRV_FSENS_TOTAL_NUM_MAX + 1) + +/* Initial sensor data : Maximum number of data stored */ +#define LSDRV_FSENS_SAVE_DATA_NUM (LSDRV_FSENS_SAVE_MSG_NUM * LSDRV_DETAILED_DATA_MULTI_MAX_NUM) + +#define LSDRV_DETAILED_DATA_GYRO_NUM LSDRV_FSTSNS_DETAILED_DATA_GYRO_NUM +#define LSDRV_DETAILED_DATA_GSENSOR_NUM LSDRV_FSTSNS_DETAILED_DATA_GSENSOR_NUM +#define LSDRV_DETAILED_DATA_GSENSOR_X_OFFSET 0 /* G-Sensor data X-axis offset included in detail data */ +#define LSDRV_DETAILED_DATA_GSENSOR_Y_OFFSET 1 /* G-Sensor data Y-axis offsets included in the detail data */ +#define LSDRV_DETAILED_DATA_GSENSOR_OFFSET 3 /* G-Sensor data access offset included in the detail data */ + +/* Gyro Output Specifications:11500 ~ 54036LSB */ +#define GYRO_OUTPUPT_SPEC_LOWER_LIMIT 11500U +#define GYRO_OUTPUPT_SPEC_UPPER_LIMIT 54036U + +/* Gyro Failure Status : How many normal status continues should be made to Gyro Failure Status normal when it is judged to be "error -> normal" */ +#define GYRO_TROUBLE_NORMAL_COUNTER_THRESHOLD 10U /* 10 ms (Gyro data acquisition interval) * 10 times = 100ms */ + +/* Gyro Failure Status : How many error status continues should be made to Gyro Failure Status error when it is judged to be "normal -> error" */ +#define GYRO_TROUBLE_ERROR_COUNTER_THRESHOLD 3000U /* 10 ms (Gyro data acquisition interval) * 3000 times = 30s */ + +/* 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" */ +#define SYS_GPS_INTERRUPT_SIGNAL_INVALID_COUNTER_THRESHOLD 10U + +/* Gyro Failure Status : Match values with SENSORMOTION_NORMAL and ERROR,UNFIXED in SensorMotion_API.h */ +#define GYRO_NORMAL (0U) +#define GYRO_ERROR (1U) +#define GYRO_UNFIXED (2U) + +/* Gyro connection status : Match values with SENSOR_CONNECT and SENSOR_DISCONNECT in Sensor_API.h */ +#define GYRO_DISCONNECT (0U) +#define GYRO_CONNECT (1U) + +/*** Data table for calculating vehicle speed *****************************************/ +#define LSDRV_SPKMPH_TBL_NUM 32 /* Number of data tables */ /* #50836 */ +#define LSDRV_SPKMPH_DATA_EN 0x01 /* Data storage flag valid */ +#define LSDRV_SPKMPH_DATA_DIS 0x00 /* Data storage flag invalid */ + +/*** Operation code *********************************************/ +#define LSDRV_OPC_WILDCARD 0xFF /* Wildcarded #012 */ + +#define LSDRV_OPC_EXTTERM_R 0x89 /* External pin status request */ +#define LSDRV_OPC_EXTTERM_A 0x99 /* External pin status notification */ +#define LSDRV_OPC_SENSOR 0xC1 /* Sensor data */ +#define LSDRV_OPC_FSENS_R 0xE4 /* Initial sensor data request */ +#define LSDRV_OPC_FSENS_A 0xF4 /* Initial sensor data response */ + +/*---------------------------------------------------------------------------*/ +// Enum + +/*---------------------------------------------------------------------------*/ +// Struct + +typedef struct { + u_int16 uc_sensor_x; /* G-Sensor X data */ + u_int16 uc_sensor_y; /* G-Sensor Y data */ + u_int16 uc_sensor_z; /* G-Sensor Z data */ +} SENSORINPUT_INFO_DAT_GSENS; + +// TAG : LSDRV_SPEEDKMPH_DAT +// ABSTRACT : Data Table Structure for Vehicle Speed Calculation +typedef struct LsDrvSpeedKmph { + u_int8 uc_flag; /* Data storage flag */ + u_int8 uc_sens_cnt; /* Sensor counter */ + u_int16 us_speed_pulse; /* Vehicle speed pulse */ + u_int8 uc_noise_flag; /* Noise flag */ /* #017 */ + u_int8 u_reserve[3]; /* Reserved */ /* #017 */ +} LSDRV_SPEEDKMPH_DAT_DAT; + +typedef struct LsDrvSpeedKmphLast { + u_int8 uc_flag; /* Data storage flag */ + u_int8 uc_sens_cnt; /* Sensor counter */ + u_int16 us_speed_pulse; /* Vehicle speed pulse */ +} LSDRV_SPEEDKMPH_LAST_DAT; + +typedef struct LsDrvSpeedKmphDat { + u_int8 uc_ptr; /* Data storage pointer */ + u_int8 uc_fstsns_rcv; /* Initial sensor data reception status */ /* #016 */ + u_int8 uc_sns_rcv; /* Sensor data reception status */ /* #016 */ + u_int8 uc_calc_start; /* Vehicle speed calculation start flag */ /* #016 */ + LSDRV_SPEEDKMPH_LAST_DAT st_last_data; /* Previous vehicle speed pulse information */ + LSDRV_SPEEDKMPH_DAT_DAT st_data[LSDRV_SPKMPH_TBL_NUM]; /* Data portion */ +} LSDRV_SPEEDKMPH_DAT; + +/*---------------------------------------------------------------------------*/ +// Prototype + +void LineSensDrvSensor(u_int8*); +u_int16 LineSensDrvSpeedCalc(u_int8); +void LineSensDrvSpeedKmphDataInit(void); +void LineSensDrvSpeedPulseSave(u_int16, u_int16, u_int8); +u_int8 LineSensDrvCheckNoise(u_int8); + +u_int8 LineSensDrvGetLastSpeedPulse(u_int16*, u_int16, u_int8); +void LineSensDrvSetLastSpeedPulse(u_int16, u_int8); + +/*---------------------------------------------------------------------------*/ +#endif // INC_LINESENSDRV_LINESENSDRV_SENSOR_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ diff --git a/positioning_hal/inc/LineSensDrv/LineSensDrv_Thread.h b/positioning_hal/inc/LineSensDrv/LineSensDrv_Thread.h new file mode 100644 index 00000000..54a01dc0 --- /dev/null +++ b/positioning_hal/inc/LineSensDrv/LineSensDrv_Thread.h @@ -0,0 +1,66 @@ +/* + * @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. + */ +/** +* @file LineSensDrv_Thread.h +*/ + +#ifndef INC_LINESENSDRV_LINESENSDRV_THREAD_H_ +#define INC_LINESENSDRV_LINESENSDRV_THREAD_H_ + +/*---------------------------------------------------------------------------*/ +// Include files + +#include "LineSensDrv_Api.h" +#include "LineSensDrv_Sensor.h" + +/*---------------------------------------------------------------------------*/ +// Define + +// Return value +#define RET_LSDRV_SUCCESS RET_NORMAL // API processing success +#define RET_LSDRV_ERROR RET_ERROR // API processing failed + +/*---------------------------------------------------------------------------*/ +// Rcv Message Related + +// Size of data section +#define LSDRV_RCVMSG_MSGBUF 512 // Byte count of RcvMSG data section + +/*---------------------------------------------------------------------------*/ +// Struct + +// TAG : LSDRV_RCVDATA +// ABSTRACT : Message receive buffer structure +typedef struct LsDrvRcvData { + T_APIMSG_MSGBUF_HEADER st_head; // Message header + u_int8 uc_data[LSDRV_RCVMSG_MSGBUF]; // Data portion +} LSDRV_RCVDATA; + +/*---------------------------------------------------------------------------*/ +// Prototype + +int32 LineSensDrvMainThreadInit(HANDLE); +void LineSensDrvParamInit(void); + +EFrameworkunifiedStatus LineSensDrvThread(HANDLE); +void LineSensDrvThreadStopProcess(void); +u_int8 LineSensDrvGetSysRecvFlag(void); + +/*---------------------------------------------------------------------------*/ +#endif // INC_LINESENSDRV_LINESENSDRV_THREAD_H_ + +/*---------------------------------------------------------------------------*/ +/*EOF*/ |