2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * VehicleSens_Did_GyroTempFst_l.cpp
21 * Vehicle sensor data master(POSHAL_DID_GYRO_TEMP_FST)
24 #include <vehicle_service/positioning_base_library.h>
25 #include "VehicleSens_DataMaster.h"
27 /*************************************************/
29 /*************************************************/
30 static VEHICLESENS_DATA_MASTER_FST g_st_gyro_tempfst_l; // NOLINT(readability/nolint)
34 * Vehicle sensor gyro temperature initialization function
36 * Gyro Temperature Data Master Initialization Processing
38 void VehicleSensInitGyroTempFstl(void) {
39 memset(&g_st_gyro_tempfst_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_FST));
40 g_st_gyro_tempfst_l.ul_did = POSHAL_DID_GYRO_TEMP_FST;
41 g_st_gyro_tempfst_l.us_size = VEHICLE_DSIZE_GYRO_TEMP_EXT_INIT;
42 g_st_gyro_tempfst_l.uc_rcvflag = VEHICLE_RCVFLAG_OFF;
43 g_st_gyro_tempfst_l.partition_flg = 0;
48 * Vehicle Sensor Gyro Temperature SET Function
50 * Update the gyro temperature data master
52 * @param[in] *pst_data : Pointer to the message data received by the direct line
54 * @return VEHICLESENS_EQ No data change<br>
55 * VEHICLESENS_NEQ Data change
57 u_int8 VehicleSensSetGyroTempFstG(const LSDRV_LSDATA_FST_GYRO_TEMP *pst_data) {
58 static u_int8 uc_ret = VEHICLESENS_EQ;
59 VEHICLESENS_DATA_MASTER_FST *pst_master;
61 u_int8 partition_max; /* Total number of partitions */
62 u_int8 partition_num; /* Data number */
64 pst_master = &g_st_gyro_tempfst_l;
66 partition_max = pst_data->uc_partition_max;
67 partition_num = pst_data->uc_partition_num;
69 if (partition_max == 1) {
70 /* Compare data master and received data */
71 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
73 /* Received data is set in the data master. */
74 pst_master->ul_did = pst_data->ul_did;
75 pst_master->us_size = pst_data->uc_size;
76 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
77 pst_master->partition_flg = 0;
78 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
79 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
80 } else if (partition_max == 2) {
81 if (partition_num == 1) {
82 /* Compare data master and received data */
83 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
85 /* Received data is set in the data master. */
86 pst_master->ul_did = pst_data->ul_did;
87 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
88 pst_master->partition_flg = 1;
89 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
90 } else if (partition_num == 2) {
91 /* Compare data master and received data */
92 if (uc_ret == VEHICLESENS_EQ) {
93 uc_ret = VehicleSensmemcmp(&pst_master->uc_data[VEHICLE_DSIZE_GYROTEMP_FST],
94 pst_data->uc_data, pst_data->uc_size);
97 /* Received data is set in the data master. */
98 pst_master->ul_did = pst_data->ul_did;
99 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
100 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
101 pst_master->partition_flg = 1;
102 memcpy(&pst_master->uc_data[VEHICLE_DSIZE_GYROTEMP_FST], pst_data->uc_data, pst_data->uc_size);
111 * Vehicle Sensor Gyro Temperature GET Function
113 * Provide a gyro temperature data master
115 * @param[in] Pointer to the data master acquisition destination
117 void VehicleSensGetGyroTempFstl(VEHICLESENS_DATA_MASTER_FST *pst_data) {
118 const VEHICLESENS_DATA_MASTER_FST *pst_master;
120 pst_master = &g_st_gyro_tempfst_l;
122 /* Store the data master in the specified destination. */
123 pst_data->ul_did = pst_master->ul_did;
124 pst_data->us_size = pst_master->us_size;
125 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
126 pst_data->partition_flg = pst_master->partition_flg;
127 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);