summaryrefslogtreecommitdiffstats
path: root/positioning_hal/src/LineSensDrv/LineSensDrv_Thread.cpp
blob: 9fb1c2999eace80b95cbd85d514d01a5eeab3b63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
* @file LineSensDrv_Thread.cpp
*/

/*---------------------------------------------------------------------------*/
// Include files

#include "LineSensDrv_Thread.h"
#include <native_service/frameworkunified_types.h>
#include <native_service/frameworkunified_framework_if.h>
#include "positioning_def.h"
#include "positioning_common.h"
/*---------------------------------------------------------------------------*/
// Global variable

static u_int8   g_sys_recv_flg = 0;         // For debugging
char g_threadname[] = "POS_Sens";
uint8_t g_uc_vehicle_reverse = 0;
uint8_t g_uc_reverse_state = 0;
static BOOL g_line_sens_thread_stop = FALSE;

#define POS_REV_STATE_PROCESSING 0
#define POS_REV_STATE_IDLE 1

/*******************************************************************************
 * MODULE   : LineSensDrv_Thread
 * ABSTRACT : LineSensor driver thread main process
 * FUNCTION : Main processing
 * ARGUMENT : lpvPara  :
 * NOTE     :
 * RETURN   :
 ******************************************************************************/
EFrameworkunifiedStatus LineSensDrvThread(HANDLE h_app) {
  int32           l_ret      = RET_LSDRV_SUCCESS;
  EFrameworkunifiedStatus l_status = eFrameworkunifiedStatusOK;


  (void)PosSetupThread(h_app, ETID_POS_SENS);

  /* Execute the initialization processes */
  l_ret = LineSensDrvMainThreadInit(h_app);
  if (RET_LSDRV_SUCCESS != l_ret) {
    l_status = eFrameworkunifiedStatusFail;
  }

  return l_status;
}

/*******************************************************************************
 * MODULE    : LineSensDrv_MainThread_Init
 * ABSTRACT  : Thread initialization process
 * FUNCTION  : Initialize thread
 * ARGUMENT  : None
 * NOTE      :
 * RETURN    : RET_LSDRV_SUCCESS:Success in initialization
 *         RET_LSDRV_ERROR  :Initialization failed
 ******************************************************************************/
int32 LineSensDrvMainThreadInit(HANDLE h_app) {
  int32   l_ret  = RET_LSDRV_SUCCESS;
  BOOL    b_ret  = TRUE;

  /****** Global variable initialization **********/
  LineSensDrvParamInit();

  /****** LineSensDrvApi initialization **********/
  b_ret = LineSensDrvApiInitialize();

  if (TRUE != b_ret) {
    l_ret = RET_LSDRV_ERROR;
  }

  return l_ret;
}

/*******************************************************************************
 * MODULE    : LineSensDrv_Param_Init
 * ABSTRACT  : Global variable initialization processing
 * FUNCTION  : Initialize global variables
 * ARGUMENT  : None
 * NOTE      :
 * RETURN    : None
 ******************************************************************************/
void LineSensDrvParamInit(void) {
  LineSensDrvSpeedKmphDataInit();   // Data table initialization process for vehicle speed calculation
}

/**
 * @brief
 *   Pos_Sens thread stop processing
 */
void LineSensDrvThreadStopProcess(void) {
  g_line_sens_thread_stop = TRUE;

  if (POS_REV_STATE_IDLE == g_uc_reverse_state) {
    PosTeardownThread(ETID_POS_SENS);
  }

  return;
}

/**
 * @brief
 *   Get initial sensor data reception flag
 */
u_int8 LineSensDrvGetSysRecvFlag(void) {
  return g_sys_recv_flg;
}

/*---------------------------------------------------------------------------*/
/*EOF*/