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 * @file LineSensDrv_Thread.cpp
20 /*---------------------------------------------------------------------------*/
23 #include "LineSensDrv_Thread.h"
24 #include <native_service/frameworkunified_types.h>
25 #include <native_service/frameworkunified_framework_if.h>
26 #include "positioning_def.h"
27 #include "positioning_common.h"
28 /*---------------------------------------------------------------------------*/
31 static u_int8 g_sys_recv_flg = 0; // For debugging
32 char g_threadname[] = "POS_Sens";
33 uint8_t g_uc_vehicle_reverse = 0;
34 uint8_t g_uc_reverse_state = 0;
35 static BOOL g_line_sens_thread_stop = FALSE;
37 #define POS_REV_STATE_PROCESSING 0
38 #define POS_REV_STATE_IDLE 1
40 /*******************************************************************************
41 * MODULE : LineSensDrv_Thread
42 * ABSTRACT : LineSensor driver thread main process
43 * FUNCTION : Main processing
44 * ARGUMENT : lpvPara :
47 ******************************************************************************/
48 EFrameworkunifiedStatus LineSensDrvThread(HANDLE h_app) {
49 int32 l_ret = RET_LSDRV_SUCCESS;
50 EFrameworkunifiedStatus l_status = eFrameworkunifiedStatusOK;
53 (void)PosSetupThread(h_app, ETID_POS_SENS);
55 /* Execute the initialization processes */
56 l_ret = LineSensDrvMainThreadInit(h_app);
57 if (RET_LSDRV_SUCCESS != l_ret) {
58 l_status = eFrameworkunifiedStatusFail;
64 /*******************************************************************************
65 * MODULE : LineSensDrv_MainThread_Init
66 * ABSTRACT : Thread initialization process
67 * FUNCTION : Initialize thread
70 * RETURN : RET_LSDRV_SUCCESS:Success in initialization
71 * RET_LSDRV_ERROR :Initialization failed
72 ******************************************************************************/
73 int32 LineSensDrvMainThreadInit(HANDLE h_app) {
74 int32 l_ret = RET_LSDRV_SUCCESS;
77 /****** Global variable initialization **********/
78 LineSensDrvParamInit();
80 /****** LineSensDrvApi initialization **********/
81 b_ret = LineSensDrvApiInitialize();
84 l_ret = RET_LSDRV_ERROR;
90 /*******************************************************************************
91 * MODULE : LineSensDrv_Param_Init
92 * ABSTRACT : Global variable initialization processing
93 * FUNCTION : Initialize global variables
97 ******************************************************************************/
98 void LineSensDrvParamInit(void) {
99 LineSensDrvSpeedKmphDataInit(); // Data table initialization process for vehicle speed calculation
104 * Pos_Sens thread stop processing
106 void LineSensDrvThreadStopProcess(void) {
107 g_line_sens_thread_stop = TRUE;
109 if (POS_REV_STATE_IDLE == g_uc_reverse_state) {
110 PosTeardownThread(ETID_POS_SENS);
118 * Get initial sensor data reception flag
120 u_int8 LineSensDrvGetSysRecvFlag(void) {
121 return g_sys_recv_flg;
124 /*---------------------------------------------------------------------------*/