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.
17 /*******************************************************************************
18 * File name :GpsInt.cpp
19 * System name :PastModel002
20 * Subsystem name :GPS interrupt thread
21 ******************************************************************************/
23 /*******************************************************************************
25 *******************************************************************************/
26 #include <vehicle_service/positioning_base_library.h>
27 #include "POS_private.h"
30 #define RD_REG32(reg) \
31 (*(volatile ULONG * const)(reg))
33 #define COMREGMSK_OR 1
34 #define ALLINTMASK 0x0f
39 void com_regmsk_dword(ULONG *, ULONG, UCHAR, UCHAR); // NOLINT(readability/nolint)
44 /*******************************************************************************
46 *******************************************************************************/
47 #define GPS_INT_THREAD_DEBUG_SWITCH 0 /* 0:OFF 1:ON */
49 /*******************************************************************************
51 *******************************************************************************/
52 GPS_INT_DATA g_gps_int_data;
54 /*******************************************************************************
56 *******************************************************************************/
57 /*******************************************************************************
58 * MODULE : DEVGpsIntUnMapDevice
59 * ABSTRACT : Register mapping release processing
60 * FUNCTION : Release the register mapping
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));
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;
84 /*******************************************************************************
85 * MODULE : DEVGpsIntSetInterupt
86 * ABSTRACT : GPS interrupt setting
87 * FUNCTION : Setting GPS Interrupt
90 * RETURN : TRUE : Interrupt setting success
91 * : FALSE : Interrupt setting failure
92 ******************************************************************************/
93 void DEVGpsIntSetInterupt(void) {
94 #if GPS_INT_THREAD_DEBUG_SWITCH
96 itr_ret = RD_REG32(g_gps_int_data.irq_status_set_reg);
98 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS_SET reg value(before) = 0x%08X ", itr_ret);
101 /* GPS interrupt Enable setting */
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);
106 #if GPS_INT_THREAD_DEBUG_SWITCH
107 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS_SET reg value(after) = 0x%08X ", itr_ret);
112 #if GPS_INT_THREAD_DEBUG_SWITCH
114 itr_ret = RD_REG32(g_gps_int_data.rising_detect_reg);
116 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, RISINGDETECT reg value(before) = 0x%08X ", itr_ret);
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);
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);
128 #if GPS_INT_THREAD_DEBUG_SWITCH
129 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, RISINGDETECT reg value(after) = 0x%08X ", itr_ret);
133 /*******************************************************************************
134 * MODULE : DEVGpsIntIntRegClear
135 * ABSTRACT : Interrupt cause register clear processing
136 * FUNCTION : Clear the interrupt cause register
140 ******************************************************************************/
141 void DEVGpsIntIntRegClear(void) {
142 #if GPS_INT_THREAD_DEBUG_SWITCH
144 itr_ret = RD_REG32(g_gps_int_data.irq_status_reg);
146 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS reg value(before) = 0x%08X ", itr_ret);
149 /* Clear Interrupt Source Register */
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);
154 #if GPS_INT_THREAD_DEBUG_SWITCH
155 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "GpsInt.cpp, IRQSTATUS reg value(after) = 0x%08X ", itr_ret);
159 /*******************************************************************************
160 * MODULE : DEVGpsIntSndMsg
161 * ABSTRACT : Send GPS interrupt occurrence notification
162 * FUNCTION : Notify GPS communication management that an interrupt has occurred.
165 * RETURN : RET_NORMAL : Normal completion
166 * : Other than the above : Processing error
167 ******************************************************************************/
168 RET_API DEVGpsIntSndMsg(void) {