Re-organized sub-directory by category
[staging/basesystem.git] / service / vehicle / positioning / server / src / Sensor / VehicleSens_Did_GyroX_l.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*******************************************************************************
18  *  File name    :VehicleSens_Did_GyroX_l.cpp
19  *  System name    :_CWORD107_
20  *  Subsystem name  :Vehicle sensor process
21  *  Program name  :Vehicle sensor data master(POSHAL_DID_GYRO_X)
22  *  Module configuration  :VehicleSensInitGyroXl()    Vehicle Sensor GYRO Initialization Functions
23  *                  :VehicleSensSetGyroXl()    Vehicle Sensor GYRO SET Functions
24  *                  :VehicleSensGetGyroXl()    Vehicle Sensor GYRO GET Functions
25  ******************************************************************************/
26
27 #include <vehicle_service/positioning_base_library.h>
28 #include "VehicleSens_DataMaster.h"
29
30 /*************************************************/
31 /*           Global variable                      */
32 /*************************************************/
33 static  VEHICLESENS_DATA_MASTER  gstGyroX_l;    // NOLINT(readability/nolint)
34
35 /*******************************************************************************
36 * MODULE    : VehicleSensInitGyroXl
37 * ABSTRACT  : Vehicle Sensor GYRO_X Initialization Functions
38 * FUNCTION  : GYRO data master initialization process
39 * ARGUMENT  : void
40 * NOTE      :
41 * RETURN    : void
42 ******************************************************************************/
43 void VehicleSensInitGyroXl(void) {
44     memset(&gstGyroX_l, 0x00, sizeof(VEHICLESENS_DATA_MASTER));
45     gstGyroX_l.ul_did    = POSHAL_DID_GYRO_X;
46     gstGyroX_l.us_size  = VEHICLE_DSIZE_GYRO_X;
47     gstGyroX_l.uc_rcvflag  = VEHICLE_RCVFLAG_OFF;
48 }
49
50 /*******************************************************************************
51 * MODULE    : VehicleSensSetGyroXl
52 * ABSTRACT  : Vehicle Sensor GYRO_X SET Functions
53 * FUNCTION  : Update the GYRO data master
54 * ARGUMENT  : *pst_data : Pointer to the message data received by the direct line
55 * NOTE      :
56 * RETURN    : VEHICLESENS_EQ  : No data change
57 *             VEHICLESENS_NEQ  : Data change
58 ******************************************************************************/
59 u_int8 VehicleSensSetGyroXl(const LSDRV_LSDATA *pst_data) {
60     u_int8 uc_ret;
61     VEHICLESENS_DATA_MASTER *pst_master;
62
63     pst_master = &gstGyroX_l;
64
65     /* Compare data master and received data */
66     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
67
68     /* Received data is set in the data master. */
69     pst_master->ul_did    = pst_data->ul_did;
70     pst_master->us_size    = pst_data->uc_size;
71     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
72     pst_master->uc_snscnt    = pst_data->uc_sns_cnt;
73     (void)memcpy(reinterpret_cast<void *>(pst_master->uc_data),
74         (const void *)(pst_data->uc_data), (size_t)pst_data->uc_size);
75
76     return(uc_ret);
77 }
78
79 /*******************************************************************************
80 * MODULE    : VehicleSensSetGyroXlG
81 * ABSTRACT  : Vehicle Sensor GYRO_X SET Functions
82 * FUNCTION  : Update the GYRO data master
83 * ARGUMENT  : *pst_data : Pointer to the message data received by the direct line
84 * NOTE      :
85 * RETURN    : VEHICLESENS_EQ  : No data change
86 *             VEHICLESENS_NEQ  : Data change
87 ******************************************************************************/
88 u_int8 VehicleSensSetGyroXlG(const LSDRV_LSDATA_G *pst_data) {
89     u_int8 uc_ret;
90     VEHICLESENS_DATA_MASTER *pst_master;
91
92     pst_master = &gstGyroX_l;
93
94     /* Compare data master and received data */
95     uc_ret = VehicleSensmemcmp(pst_master->uc_data, pst_data->uc_data, pst_data->uc_size);
96
97     /* Received data is set in the data master. */
98     pst_master->ul_did    = pst_data->ul_did;
99     pst_master->us_size    = pst_data->uc_size;
100     pst_master->uc_rcvflag  = VEHICLE_RCVFLAG_ON;
101     pst_master->uc_snscnt    = pst_data->uc_sns_cnt;
102     (void)memcpy(reinterpret_cast<void *>(pst_master->uc_data),
103         (const void *)(pst_data->uc_data), (size_t)(pst_data->uc_size));
104
105     return(uc_ret);
106 }
107
108 /*******************************************************************************
109 * MODULE    : VehicleSensGetGyroXl
110 * ABSTRACT  : Vehicle Sensor GYRO_X GET Functions
111 * FUNCTION  : Provide a GYRO data master
112 * ARGUMENT  : *pst_data : Pointer to the data master acquisition destination
113 * NOTE      :
114 * RETURN    : void
115 ******************************************************************************/
116 void VehicleSensGetGyroXl(VEHICLESENS_DATA_MASTER *pst_data) {
117     const VEHICLESENS_DATA_MASTER *pst_master;
118
119     pst_master = &gstGyroX_l;
120
121     /* Store the data master in the specified destination. */
122     pst_data->ul_did    = pst_master->ul_did;
123     pst_data->us_size    = pst_master->us_size;
124     pst_data->uc_rcvflag  = pst_master->uc_rcvflag;
125     pst_data->uc_snscnt  = pst_master->uc_snscnt;
126     (void)memcpy(reinterpret_cast<void *>(pst_data->uc_data),
127         (const void *)(pst_master->uc_data), (size_t)(pst_master->us_size));
128 }