common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / can_hal / src / inc / can_mng_api.h
1 /*
2  * @copyright Copyright (c) 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 __CAN_MNG_API_H__
18 #define __CAN_MNG_API_H__
19
20 /** @includes
21  *
22  */
23
24 /** @define
25  *
26  */
27 #ifndef UINT8
28 #define UINT8    unsigned char
29 #endif
30 #ifndef UINT16
31 #define UINT16   unsigned short
32 #endif
33 #ifndef INT32
34 #define INT32    int
35 #endif
36 #ifndef UINT32
37 #define UINT32   unsigned int
38 #endif
39
40 /*------------------------------------------*/
41 /*  Log                                     */
42 /*------------------------------------------*/
43 #if defined(CAN_MNG_API_FORCE_DEBUG)
44   #define CAN_MNG_API_LOGT(fmt,...) fprintf(stderr, "[T][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__)
45   #define CAN_MNG_API_LOGD(fmt,...) fprintf(stderr, "[D][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__)
46   #define CAN_MNG_API_LOGE(fmt,...) fprintf(stderr, "[E][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__)
47 #else
48   #define CAN_MNG_API_LOGT(fmt,...)
49   #define CAN_MNG_API_LOGD(fmt,...)
50   #define CAN_MNG_API_LOGE(fmt,...)
51 #endif
52 /*------------------------------------------*/
53 /* API return value                         */
54 /*------------------------------------------*/
55 #define CAN_CTL_RET_SUCCESS     0  /* Normal end             */
56 #define CAN_CTL_RET_ERR_PARAM  -1  /* Parameter error        */
57 #define CAN_CTL_RET_ERR_NOSVC  -2  /* Service not open error */
58 #define CAN_CTL_RET_ERR_ERR    -3  /* Other error            */
59
60 /*------------------------------------------*/
61 /* Received command information             */
62 /*------------------------------------------*/
63 #define CAN_CTL_CMD_LEN_MAX        255       /* Maximum data length                      */
64 #define CAN_DAT_LEN_MAX CAN_CTL_CMD_LEN_MAX  /* Maximum data length                      */
65 #define CAN_CTL_CMD_ID_HI_NUM      128       /* Number of higher CAN-ID(8bit) (00 to 7F) */
66
67 #define CAN_CTL_MAX_RCV_CAN_SIZE   23
68
69 /** @typedefs
70  *
71  */
72 /* Object for CAN communication control API */
73 typedef struct _CanCtlApiObj {
74   /* ID assigned to the command reception notification callback */
75   INT32 call_id;
76 } CanCtlApiObj ;
77
78 /* CAN command structure */
79 typedef struct _CanCtlApiCmd { 
80   UINT8 len;                    /* Data length */
81   UINT8 data[CAN_DAT_LEN_MAX];  /* Data        */
82 } CanCtlApiCmd;
83
84 /* Received ID MAP information */
85 typedef struct _CanCtlRcvId {
86   UINT16  id[CAN_CTL_CMD_ID_HI_NUM];  /* CAN ID MAP(000~7FF) */
87 } CanCtlRcvId;
88
89
90 /* CAN Frame structure */
91 typedef union {
92   UINT8   Data[2];
93 } CanId;
94
95 #define LCN_SRV_MSB_FRAME_DAT_SIZE  (8)         /* MSB send/receive frame data size */
96
97 typedef struct _CanData {
98   CanId   id;                                 /* CAN Frame structure */
99   UINT8   dlc;                                /* Valid bytes of DATA#1~#8. DLC is 1 to 8. */
100   UINT8   Data[LCN_SRV_MSB_FRAME_DAT_SIZE];   /* Receive data */
101                                               /* Data of DLC size is valid, otherwise set to 0 as invalid value. */
102 } CanData;
103
104 /** @forward declarations
105  *
106  */
107 /* API prototype */
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111 UINT32 CanCtlApiOpen(CanCtlApiObj* pClientObj);
112 UINT32 CanCtlApiClose(CanCtlApiObj* pClientObj);
113 UINT32 CanCtlApiSndCmd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pSndCmd);
114 UINT32 CanCtlApiSetRcvId(CanCtlApiObj* pClientObj, CanCtlRcvId* pRcvId);
115 UINT32 CanCtlApiRcvCmd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pRcvCmd);
116 UINT32 CanCtlApiRcvSpd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pRcvCmd);
117 #ifdef __cplusplus
118 }
119 #endif
120 #endif /* __CAN_MNG_API_H__ */