2 * @copyright Copyright (c) 2019-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*******************************************************************************
18 * File name :VehicleSens_Did_GyroZFst_l.cpp
19 * Subsystem name :Vehicle sensor process
20 * Program name :Vehicle sensor data master(POSHAL_DID_GYRO_Z_FST)
21 * Module configuration :VehicleSensInitGyroZFstl() Vehicle sensor GYRO (initial sensor) initialization functions
22 * :VehicleSensSetGyroZFstl() Vehicle sensor GYRO (initial sensor) SET-function
23 * :VehicleSensSetGyroZFstG() Vehicle sensor GYRO (initial sensor) SET-function
24 * :VehicleSensGetGyroZFstl() Vehicle sensor GYRO (initial sensor) GET-function
25 ******************************************************************************/
27 #include "VehicleSens_DataMaster.h"
29 #if CONFIG_SENSOR_EXT_VALID /* Initial Sensor Support */
30 /*************************************************/
32 /*************************************************/
33 static VEHICLESENS_DATA_MASTER_FST gstGyroZFst_l; // NOLINT(readability/nolint)
35 /*******************************************************************************
36 * MODULE : VehicleSensInitGyroZFstl
37 * ABSTRACT : Vehicle Sensor GYRO_Z Initialization Functions
38 * FUNCTION : GYRO data master initialization process
42 ******************************************************************************/
43 void VehicleSensInitGyroZFstl(void) {
46 memset(&gstGyroZFst_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER_FST));
47 gstGyroZFst_l.ul_did = POSHAL_DID_GYRO_Z_FST;
48 gstGyroZFst_l.us_size = 0;
49 gstGyroZFst_l.partition_flg = 0;
51 pus = reinterpret_cast<u_int16 *>(gstGyroZFst_l.uc_data);
52 memset(reinterpret_cast<void*>(pus), VEHICLE_DINIT_GYRO_Z, VEHICLE_DSIZE_GYRO_Z_FST);
55 /*******************************************************************************
56 * MODULE : VehicleSensSetGyroZFstl
57 * ABSTRACT : Vehicle Sensor GYRO_Z SET Functions
58 * FUNCTION : Update the GYRO data master
59 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
61 * RETURN : VEHICLESENS_EQ : No data change
62 * VEHICLESENS_NEQ : Data change
63 ******************************************************************************/
64 u_int8 VehicleSensSetGyroZFstl(const LSDRV_LSDATA_FST *pst_data) { // LCOV_EXCL_START 8: dead code.
65 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
67 VEHICLESENS_DATA_MASTER_FST *pst_master;
69 pst_master = &gstGyroZFst_l;
71 /* Compare data master and received data */
72 uc_ret = VehicleSensmemcmp(pst_master->uc_data,
73 pst_data->uc_data, pst_data->uc_size);
75 /* Received data is set in the data master. */
76 pst_master->ul_did = pst_data->ul_did;
77 pst_master->us_size = pst_data->uc_size;
78 pst_master->partition_flg = 0;
79 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
80 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
81 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
87 /*******************************************************************************
88 * MODULE : VehicleSensSetGyroZFstG
89 * ABSTRACT : Vehicle Sensor GYRO_Z SET Functions
90 * FUNCTION : Update the GYRO data master
91 * ARGUMENT : *pst_data : Pointer to the message data received by the direct line
93 * RETURN : VEHICLESENS_EQ : No data change
94 * VEHICLESENS_NEQ : Data change
95 ******************************************************************************/
96 u_int8 VehicleSensSetGyroZFstG(const LSDRV_LSDATA_FST_GYRO_Z *pst_data) {
97 static u_int8 uc_ret = VEHICLESENS_EQ;
98 VEHICLESENS_DATA_MASTER_FST *pst_master;
100 u_int8 partition_max; /* Total number of partitions */
101 u_int8 partition_num; /* Data number */
103 partition_max = pst_data->uc_partition_max;
104 partition_num = pst_data->uc_partition_num;
106 pst_master = &gstGyroZFst_l;
108 if (partition_max == 1) {
109 /* Compare data master and received data */
110 uc_ret = VehicleSensmemcmp(pst_master->uc_data,
111 pst_data->uc_data, pst_data->uc_size);
113 /* Received data is set in the data master. */
114 pst_master->ul_did = pst_data->ul_did;
115 pst_master->us_size = pst_data->uc_size;
116 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
117 pst_master->partition_flg = 0;
118 memset(pst_master->uc_data, 0x00, sizeof(pst_master->uc_data));
119 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
120 } else if (partition_max == 2) {
121 if (partition_num == 1) {
122 /* Compare data master and received data */
123 uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
125 /* Received data is set in the data master. */
126 pst_master->ul_did = pst_data->ul_did;
127 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
128 pst_master->partition_flg = 1;
129 memcpy(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
130 } else if (partition_num == 2) {
131 /* Compare data master and received data */
132 if (uc_ret == VEHICLESENS_EQ) {
133 uc_ret = VehicleSensmemcmp(&pst_master->uc_data[VEHICLE_DSIZE_GYRO_Z_FST],
134 pst_data->uc_data, pst_data->uc_size);
137 /* Received data is set in the data master. */
138 pst_master->ul_did = pst_data->ul_did;
139 pst_master->us_size = static_cast<u_int16>(pst_master->us_size + pst_data->uc_size);
140 pst_master->uc_rcvflag = VEHICLE_RCVFLAG_ON;
141 pst_master->partition_flg = 1;
142 memcpy(&pst_master->uc_data[VEHICLE_DSIZE_GYRO_Z_FST], pst_data->uc_data, pst_data->uc_size);
149 /*******************************************************************************
150 * MODULE : VehicleSensGetGyroZFstl
151 * ABSTRACT : Vehicle Sensor GYRO_Z GET Functions
152 * FUNCTION : Provide a GYRO data master
153 * ARGUMENT : *pst_data : Pointer to the data master acquisition destination
156 ******************************************************************************/
157 void VehicleSensGetGyroZFstl(VEHICLESENS_DATA_MASTER_FST *pst_data) {
158 const VEHICLESENS_DATA_MASTER_FST *pst_master;
160 pst_master = &gstGyroZFst_l;
162 /* Store the data master in the specified destination. */
163 pst_data->ul_did = pst_master->ul_did;
164 pst_data->us_size = pst_master->us_size;
165 pst_data->uc_rcvflag = pst_master->uc_rcvflag;
166 pst_data->partition_flg = pst_master->partition_flg;
167 memcpy(pst_data->uc_data, pst_master->uc_data, pst_master->us_size);