Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / vehicleservice / positioning / client / include / Sensor_API_private.h
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 #ifndef POSITIONING_CLIENT_INCLUDE_SENSOR_API_PRIVATE_H_
18 #define POSITIONING_CLIENT_INCLUDE_SENSOR_API_PRIVATE_H_
19 /******************************************************************************
20  * File name        :Sensor_API_private.h
21  * System name        :GPF
22  * Subsystem name    Vehicle I/F library
23  ******************************************************************************/
24
25 /************************************************************************
26 *            Macro definitions                                          *
27 ************************************************************************/
28 #define SENSOR_PUBLIC_DID_NUM                31
29
30 /*----------------------------------------------------------------------*
31  *    Shared Memory Related Extensions                                                     *
32  *----------------------------------------------------------------------*/
33 #define SENSOR_SHARE_LOCK                    0xFF           /* Locking */
34 #define SENSOR_SHARE_UNLOCK                  0x00           /* Unlocking */
35
36 #define SENSOR_SHARE_BLOCK_MNUM              1              /* Number of shared memory control blocks */
37 #define SENSOR_SHARE_BLOCK_DNUM              10             /* Number of shared memory data blocks */
38 /* Number of shared memory blocks */
39 #define SENSOR_SHARE_BLOCK_NUM               (SENSOR_SHARE_BLOCK_MNUM+SENSOR_SHARE_BLOCK_DNUM)
40
41 #define SENSOR_SHARE_BLOCK_SIZE              512            /* Shared Memory Block Size(byte) */
42 #define SENSOR_SHARE_HEAD_SIZE               40             /* Vehicle Sensor Information Header( (4)+1+3+16*2) */
43 /* Shared Memory Data Size */
44 #define SENSOR_SHARE_BLOCK_DSIZE             (SENSOR_SHARE_BLOCK_SIZE - SENSOR_SHARE_HEAD_SIZE)
45 /* Size of shared memory allocation area */
46 #define SENSOR_SHARE_SIZE                    (SENSOR_SHARE_BLOCK_SIZE * SENSOR_SHARE_BLOCK_NUM)
47
48 #define SENSOR_SEMAPHO_NAME                  ("SENSOR_SHARE_SEMAPHO")            /* Semaphore name */
49 #define GPS_INTERRUPT_SIGNAL_SEMAPHO_NAME    ("GPS_INT_SIGNAL_SHARE_SEMAPHO")    /* Semaphore name(MAX 32Byte) */
50 #define GYRO_CONNECT_STATUS_SEMAPHO_NAME     ("GYRO_CONNECT_STTS_SHARE_SEMAPHO") /* Semaphore name(MAX 32Byte) */
51 #define EPHEMERIS_NUM_SEMAPHO_NAME           ("EPHEMERIS_NUM_SHARE_SEMAPHO")     /* Semaphore name(MAX 32Byte) */
52 #define LOCALTIME_SEMAPHO_NAME               ("LOCALTIME_SHARE_SEMAPHO")         /* Semaphore name(MAX 32Byte) */
53
54 /*----------------------------------------------------------------------*
55  *    Event Related Extensions                                                       *
56  *----------------------------------------------------------------------*/
57 #define SENSOR_EVENT_VAL_INIT                (SENSOR_RET_ERROR_MIN - 1)    /* Event initial value */
58
59 /*----------------------------------------------------------------------*
60  *    Shared Memory Related Extensions                                                     *
61  *----------------------------------------------------------------------*/
62 #define SENSOR_SHARE_NAME                    ("SENSOR_SHARE_MEMORY")            /* Shared memory name */
63 #define GPS_INTERRUPT_SIGNAL_SHARE_NAME      ("GPS_INT_SIGNAL_SHARE_MEMORY")    /* Shared memory name(MAX 32Byte) */
64 #define GYRO_CONNECT_STATUS_SHARE_NAME       ("GYRO_CONNECT_STTS_SHARE_MEMORY") /* Shared memory name(MAX 32Byte) */
65 #define EPHEMERIS_NUM_SHARE_NAME             ("EPHEMERIS_NUM_SHARE_MEMORY")     /* Shared memory name(MAX 32Byte) */
66 #define LOCALTIME_SHARE_NAME                 ("LOCALTIME_SHARE_MEMORY")         /* Shared memory name(MAX 32Byte) */
67
68 /*-----------------------------------------------------------------------------
69  * GPS local CID define
70  *----------------------------------------------------------------------------*/
71 #define CID_DEV_REQGPS                       MAKECID(CID_DEVHIGH, 0x00)    /* GPS request          */
72 #define CID_DEV_REQRST                       MAKECID(CID_DEVHIGH, 0x01)    /* GPS reset request */
73
74 #define CID_GPS_SERIAL0                      (CID)0x0100    /* GPS reset request function definition    */
75 /* GPS reset request CID        */
76
77 /*---------------------------------------------------------------------------
78  * GPS error log output
79  ---------------------------------------------------------------------------*/
80 #define GPS_DBGMSG                           0         /* Product Shipping Log Output(WPF_DEBUGMSG)            */
81 #define GPS_RTLMSG                           1         /* Development test log output(WPF_RETAILMSG)        */
82
83 /*----------------------------------------------------------------------*
84  *    for message                                                       *
85  *----------------------------------------------------------------------*/
86 #define CID_SENSORIF_PKG_DELIVERY_ENTRY_EXT  0x0602    /* sensor extra package register command ID        */
87
88 /*----------------------------------------------------------------------*
89  *    for JudgeDid                                                      *
90  *----------------------------------------------------------------------*/
91 #define MODE_REGISTER_LISTENER_PKG_SENS_DATA 0         /* POS_RegisterListenerPkgSensData        */
92 #define MODE_REGISTER_LISTENER_SENSDATA      1         /* POS_RegisterListenerSensData        */
93 #define MODE_GET_SENSDATA                    2         /* POS_GetSensData        */
94
95 /************************************************************************
96 *            Typedef definitions                                                *
97 ************************************************************************/
98
99 /************************************************************************
100 *            Struct definitions                                                 *
101 ************************************************************************/
102
103 /************************************************************************
104 * TAG       : SENSOR_SHARE_MNG
105 * ABSTRACT  : Shared memory management area
106 ************************************************************************/
107 typedef struct {
108     uint8_t                        lock_info[SENSOR_SHARE_BLOCK_NUM];    /* Usages    */
109     uint8_t                        reserve[501];                         /* 512-11    */
110 } SENSOR_SHARE_MNG;
111
112 /************************************************************************
113 * TAG       : SENSOR_SHARE_BLOCK_DAT_DAT
114 * ABSTRACT  : Shared memory data area(Data section details)
115 ************************************************************************/
116 typedef struct {
117     uint8_t                        pkg_num;                              /* Number of packages    */
118     uint8_t                        reserve[3];
119     uint16_t                       offset[SENSOR_PKG_DELIVERY_MAX];      /* Offset value */
120     uint8_t                        data[SENSOR_SHARE_BLOCK_DSIZE];       /* Data portion        */
121 } SENSOR_SHARE_BLOCK_DAT_DAT;
122
123 /************************************************************************
124 * TAG       : SENSOR_SHARE_BLOCK_DAT
125 * ABSTRACT  : Shared memory data area(One block)
126 ************************************************************************/
127 typedef struct {
128     uint16_t                       size;                                 /* Size of the data    */
129     uint8_t                        reserve[2];
130     SENSOR_SHARE_BLOCK_DAT_DAT    data;                                 /* Data portion        */
131 } SENSOR_SHARE_BLOCK_DAT;
132
133 /************************************************************************
134 * TAG       : SENSOR_SHARE_BLOCK_MNG
135 * ABSTRACT  : Areas of memory that are shared
136 ************************************************************************/
137 typedef struct {
138     SENSOR_SHARE_MNG              mng;                                  /* Shared memory management information */
139     SENSOR_SHARE_BLOCK_DAT        data[SENSOR_SHARE_BLOCK_DNUM];        /* Shared memory data portion */
140 } SENSOR_SHARE;
141
142 /**
143  * @brief Return code list structure
144  */
145 typedef struct {
146 /*
147  *  Note.
148  *  This feature needs to be defined according to the unit type.
149  */
150     BOOL                          GRADE2_ret;    /**< Return code in GRADE2 */
151     BOOL                          GRADE1_ret;    /**< Return code in GARDE1 */
152     DID                           did;           /**< DID                   */
153 } SENSOR_RET_PKG;
154
155
156 /************************************************************************
157 *            Function prototype                                            *
158 ************************************************************************/
159 RET_API PosDeleteEvent(EventID event_id);
160 RET_API SensorLinkShareData(void **share_top, uint32_t *share_size, uint16_t *offset);
161 RET_API SensorUnLinkShareData(SENSOR_SHARE *share_top, uint16_t offset);
162
163 EventID PosCreateEvent(PNO pno);
164 void SensorSetShareData(void *share_top, uint16_t offset, const void *data_src, uint16_t size_src);
165 RET_API PosSndMsg(PNO pno_src, PNO pno_dest, CID cid, uint16_t msg_len, const void *msg_data);
166
167 BOOL SensorJudgeDid(DID did, uint8_t mode);
168
169 /* Function macro */
170 #define SENSOR_DID_JUDGE_REGLIS_PKG(did)    SensorJudgeDid(did, MODE_REGISTER_LISTENER_PKG_SENS_DATA)
171 #define SENSOR_DID_JUDGE_REGLIS(did)        SensorJudgeDid(did, MODE_REGISTER_LISTENER_SENSDATA)
172 #define SENSOR_DID_JUDGE_GET(did)           SensorJudgeDid(did, MODE_GET_SENSDATA)
173
174 #endif  // POSITIONING_CLIENT_INCLUDE_SENSOR_API_PRIVATE_H_ */