Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / server / src / Sensor / GpsInt.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        :GpsInt.cpp
19  *  System name        :PastModel002
20  *  Subsystem name    :GPS interrupt thread
21  ******************************************************************************/
22
23 /*******************************************************************************
24 * Include File
25 *******************************************************************************/
26 #include <vehicle_service/positioning_base_library.h>
27 #include "POS_private.h"
28 #include "GpsInt.h"
29
30 #define RD_REG32(reg) \
31             (*(volatile ULONG * const)(reg))
32
33 #define     COMREGMSK_OR    1
34 #define     ALLINTMASK      0x0f
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 void    com_regmsk_dword(ULONG *, ULONG, UCHAR, UCHAR);    // NOLINT(readability/nolint)
40 #ifdef __cplusplus
41 }
42 #endif
43
44 /*******************************************************************************
45 * Define
46 *******************************************************************************/
47 #define GPS_INT_THREAD_DEBUG_SWITCH                    0    /* 0:OFF 1:ON */
48
49 /*******************************************************************************
50 * Global Parameter
51 *******************************************************************************/
52 GPS_INT_DATA    g_gps_int_data;
53
54 /*******************************************************************************
55 * Module
56 *******************************************************************************/
57 /*******************************************************************************
58  * MODULE    : DEVGpsIntUnMapDevice
59  * ABSTRACT  : Register mapping release processing
60  * FUNCTION  : Release the register mapping
61  * ARGUMENT  : None
62  * NOTE      :
63  * RETURN    : None
64  ******************************************************************************/
65 void DEVGpsIntUnMapDevice(void) {
66     /* Release GPIO Register Mapping */
67     if ((g_gps_int_data.irq_status_reg        != 0)
68         || (g_gps_int_data.irq_status_set_reg  != 0)
69         || (g_gps_int_data.rising_detect_reg  != 0)) {
70         /* When GPIO registers are mapped */
71         /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
72         MunMapDeviceIo((HANDLE)g_gps_int_data.irq_status_reg, sizeof(g_gps_int_data.irq_status_reg));
73         /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
74         MunMapDeviceIo((HANDLE)g_gps_int_data.irq_status_set_reg, sizeof(g_gps_int_data.irq_status_set_reg));
75         /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
76         MunMapDeviceIo((HANDLE)g_gps_int_data.rising_detect_reg, sizeof(g_gps_int_data.rising_detect_reg));
77
78         g_gps_int_data.irq_status_reg        = 0;
79         g_gps_int_data.irq_status_set_reg    = 0;
80         g_gps_int_data.rising_detect_reg    = 0;
81     }
82 }
83
84 /*******************************************************************************
85  * MODULE    : DEVGpsIntSetInterupt
86  * ABSTRACT  : GPS interrupt setting
87  * FUNCTION  : Setting GPS Interrupt
88  * ARGUMENT  : None
89  * NOTE      :
90  * RETURN    : TRUE        : Interrupt setting success
91  *           : FALSE    : Interrupt setting failure
92  ******************************************************************************/
93 void DEVGpsIntSetInterupt(void) {
94 #if GPS_INT_THREAD_DEBUG_SWITCH
95     /* Dummy read */
96     itr_ret = RD_REG32(g_gps_int_data.irq_status_set_reg);
97
98     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS_SET reg value(before) = 0x%08X ", itr_ret);
99 #endif
100
101     /* GPS interrupt Enable setting */
102     /* Dummy read */
103     /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
104     (void)RD_REG32(g_gps_int_data.irq_status_set_reg);
105
106 #if GPS_INT_THREAD_DEBUG_SWITCH
107     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS_SET reg value(after) = 0x%08X ", itr_ret);
108 #endif
109
110
111
112 #if GPS_INT_THREAD_DEBUG_SWITCH
113     /* Dummy read */
114     itr_ret = RD_REG32(g_gps_int_data.rising_detect_reg);
115
116     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, RISINGDETECT reg value(before) = 0x%08X ", itr_ret);
117 #endif
118
119     /* GPS Interrupt Detection Method Setting */
120     /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
121     com_regmsk_dword(reinterpret_cast<ULONG *>(g_gps_int_data.rising_detect_reg), \
122         GPS_MASK_6BIT, COMREGMSK_OR, ALLINTMASK);
123
124     /* Dummy read */
125     /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
126     (void)RD_REG32(g_gps_int_data.rising_detect_reg);
127
128 #if GPS_INT_THREAD_DEBUG_SWITCH
129     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, RISINGDETECT reg value(after)  = 0x%08X ", itr_ret);
130 #endif
131 }
132
133 /*******************************************************************************
134  * MODULE    : DEVGpsIntIntRegClear
135  * ABSTRACT  : Interrupt cause register clear processing
136  * FUNCTION  : Clear the interrupt cause register
137  * ARGUMENT  : None
138  * NOTE      :
139  * RETURN    : None
140  ******************************************************************************/
141 void DEVGpsIntIntRegClear(void) {
142 #if GPS_INT_THREAD_DEBUG_SWITCH
143     /* Dummy read */
144     itr_ret = RD_REG32(g_gps_int_data.irq_status_reg);
145
146     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS reg value(before) = 0x%08X ", itr_ret);
147 #endif
148
149     /* Clear Interrupt Source Register */
150     /* Dummy read */
151     /* #QAC confirmation Rule11.3 Data Size Equivalent (4Byte),No problem due to unsigned relation */
152     (void)RD_REG32(g_gps_int_data.irq_status_reg);
153
154 #if GPS_INT_THREAD_DEBUG_SWITCH
155     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS reg value(after)  = 0x%08X ", itr_ret);
156 #endif
157 }
158
159 /*******************************************************************************
160  * MODULE    : DEVGpsIntSndMsg
161  * ABSTRACT  : Send GPS interrupt occurrence notification
162  * FUNCTION  : Notify GPS communication management that an interrupt has occurred.
163  * ARGUMENT  : None
164  * NOTE      :
165  * RETURN    : RET_NORMAL    : Normal completion
166  *           : Other than the above        : Processing error
167  ******************************************************************************/
168 RET_API DEVGpsIntSndMsg(void) {
169     return RET_NORMAL;
170 }
171