Init basesystem source codes.
[staging/basesystem.git] / stub / communication_subcpu / client / include / stub / CommSubCpu_API.h
1 /*
2  * @copyright Copyright (c) 2017-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 COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_
18 #define COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_
19
20 /**
21  * @file CommSubCpu_API.h
22  * @~english
23  * @brief communication_subcpu API header
24  */
25
26 /** @addtogroup BaseSystem
27  *  @{
28  */
29 /** @addtogroup peripheral_service
30  *  @ingroup BaseSystem
31  *  @{
32  */
33 /** @addtogroup communication_subcpu
34  *  @ingroup peripheral_service
35  *  @{
36  */
37
38 #include <sys/types.h>
39 #include <native_service/frameworkunified_types.h>
40 #include <agldd/moduleid.h>
41 #include <stub/com_message_header.h>
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /*__cplusplus*/
46
47 /*! @~english CommSubCpu I/F API return code  */
48 typedef int32_t     COMMSUBCPU_RET_API;
49
50 /*! @~english Thread name  */
51 #define LAN_SERVICE_SYSCOM_MAIN "DEV_SYSCOM_MAIN"
52
53 /**
54  * \~english The ICR command receive notification
55  */
56 #define CID_ICR_CMD_RCV     (0x0A00)
57
58 /**
59  * \~english The ICR command send result notification
60  */
61 #define CID_ICR_CMD_SND_CNF (0x0A01)
62
63 /*! @~english The MAX length of send command  */
64 #define ICRCMD_OPELAND_SND_MAX  (2048)
65 /*! @~english The MAX length of send ICR command  */
66 #define ICRCMD_OPELAND_MAX      (252)
67
68 /**
69  * \~english ICR command format
70  */
71 typedef struct {
72     uint16_t    phyadr_from;        //!< \~english Physical address
73     uint8_t service_type;           //!< \~english Communication type
74     uint8_t lgadr_from;             //!< \~english Source logical address
75     uint8_t lgadr_to;               //!< \~english Forwarding destination logical address
76     uint8_t opc;                    //!< \~english Operation code
77     uint8_t d_length;               //!< \~english Data size
78     uint8_t data[ICRCMD_OPELAND_MAX];   //!< \~english Command data
79     uint8_t reserve;                    //!< \~english Reserve
80 } T_ICR_CMD_DATA;
81
82 /**
83  * \~english Send command structure
84  */
85 typedef struct {
86     uint16_t    phyadr_from;        //!< \~english Physical address
87     uint8_t service_type;           //!< \~english Communication type
88     uint8_t lgadr_from;             //!< \~english Source logical address
89     uint8_t lgadr_to;               //!< \~english Forwarding destination logical address
90     uint8_t opc;                    //!< \~english Operation code
91     uint16_t    d_length;           //!< \~english Data size
92     uint8_t data[ICRCMD_OPELAND_SND_MAX];   //!< \~english Command data
93 } T_ICR_CMD_SND_DATA;
94
95 /**
96  * \~english ICR command data
97  */
98 typedef struct {
99     T_ICR_CMD_SND_DATA  cmd_data;       //!< \~english Command information
100 } T_ICR_CMD;
101
102 /**
103  * \~english The message of command receive notification
104  */
105 typedef struct {
106     /*! @~english The header of message  */
107     T_APIMSG_MSGBUF_HEADER_COMM msg_hdr;
108     /*! @~english The message data for send result  */
109     T_ICR_CMD_DATA          cmd_data;
110 } T_ICR_CMD_RCV;
111
112 /*!
113  * @~english Status of message send result
114  */
115 typedef enum {
116     /*! @~english Send success */
117     ICR_SND_SUCCESS = 0,
118     /*! @~english Initialize error */
119     ICR_SND_ERR_INIT,
120     /*! @~english Send error */
121     ICR_SND_ERR,
122     /*! @~english Send error(retry out) */
123     ICR_SND_ERR_RETRYOUT,
124     /*! @~english Send error(buffer full) */
125     ICR_SND_ERR_BUFFERFULL,
126     /*! @~english Send error(micon abnormal) */
127     ICR_SND_ERR_MC,
128     /*! @~english The MAX */
129     ICR_SND_ERR_MAX
130 } ICR_ERROR_CODE;
131
132 /*!
133  * @~english Structure for message send status data
134  */
135 typedef struct {
136   /*! @~english Result of send message */
137   ICR_ERROR_CODE  cnf_sts;
138 } T_ICR_CMDSNDCNF_STS;
139
140
141  /**
142  * \~english The send result notification
143  */
144 typedef struct {
145     /*! @~english The header of message  */
146     T_APIMSG_MSGBUF_HEADER_COMM msg_hdr;
147     /*! @~english The message data for send result  */
148     T_ICR_CMDSNDCNF_STS     sts;
149 } T_ICR_CMDSNDCNF;
150
151
152 #define COMMSUBCPU_RET_NORMAL               0   //!< \~english Normal termination
153 #define COMMSUBCPU_RET_ERROR_CANCEL         1   //!< \~english Abnormal termination
154 #define COMMSUBCPU_RET_ERROR_PARAM          2   //!< \~english Abnormality of parameter
155 #define COMMSUBCPU_RET_ERROR_BUFFULL        3   //!< \~english Buffer FULL
156 #define COMMSUBCPU_RET_ERROR_OVERLAPPED     4   //!< \~english Entry overlapped
157 #define COMMSUBCPU_RET_ERROR_CREATE_EVENT   5   //!< \~english Event generation failure
158
159 /**
160  * \ingroup CommSubCpu
161  * \~english @par Brief
162  *       CommSubCpu moudle init
163  * \~english @retval COMMSUBCPU_RET_NORMAL : Success
164  * \~english @par Prerequisite
165  *       None
166  * \~english @par Change of internal state
167  *       - Change of internal state according to the API does not occur.
168  * \~english @par Conditions of processing failure
169  *       None
170  * \~english @par Classification
171  *       Public
172  * \~english @par Type
173  *       Sync
174  * \~english @see
175  *       None
176  */
177 COMMSUBCPU_RET_API CommSubCpu_Init();
178
179 /**
180  * \ingroup CommSubCpu
181  * \~english @par Brief
182  *       CommSubCpu moudle deinitializes
183  * \~english @retval COMMSUBCPU_RET_NORMAL : Success
184  * \~english @par Prerequisite
185  *       CommSubCpu moudle init completely
186  * \~english @par Change of internal state
187  *       - Change of internal state according to the API does not occur.
188  * \~english @par Conditions of processing failure
189  *       None
190  * \~english @par Classification
191  *       Public
192  * \~english @par Type
193  *       Sync
194  * \~english @see
195  *       None
196  */
197 COMMSUBCPU_RET_API CommSubCpu_DeInit();
198
199 /**
200  * \ingroup CommSubCpu
201  * \~english @par Brief
202  *       Delivery registration of CommSubCpu command
203  * \~english @param [in] name
204  *       PCSTR - Receiver thread name
205  * \~english @param [in] from
206  *       uint8_t - Sender logical address
207  * \~english @param [in] to
208  *       uint8_t - Receiver logical address
209  * \~english @param [in] opc
210  *       uint8_t - Operation code
211  * \~english @param [in] callback_id
212  *       uint8_t - callback ID
213  * \~english @param [in] cid
214  *       uint16_t - CID
215  * \~english @retval COMMSUBCPU_RET_NORMAL : Success
216  * \~english @retval COMMSUBCPU_RET_ERROR_PARAM : Paramter error
217  * \~english @par Prerequisite
218  *       Availability of Communication is TRUE
219  * \~english @par Change of internal state
220  *       - Change of internal state according to the API does not occur.
221  * \~english @par Conditions of processing failure
222  * - Input parameter error
223  *       - COMMSUBCPU_RET_ERROR_PARAM
224  * \~english @par Classification
225  *       Public
226  * \~english @par Type
227  *       Async
228  * \~english @see
229  *       None
230  */
231 COMMSUBCPU_RET_API  CommSubCpu_DeliveryMsgEntry(PCSTR name, uint8_t from, uint8_t to, uint8_t opc,
232                                     uint8_t  callback_id, uint16_t cid);
233
234 /**
235  * \ingroup CommSubCpu
236  * \~english @par Brief
237  *       CommSubCpu command transmission request
238  * \~english @param [in] name
239  *       PCSTR - Sender thread name
240  * \~english @param [in] snd_cmd
241  *       T_ICR_CMD* - Pointer to send command
242  * \~english @param [in] req_id
243  *       uint8_t - RID of the results
244  * \~english @retval COMMSUBCPU_RET_NORMAL : Success
245  * \~english @retval COMMSUBCPU_RET_ERROR_PARAM : Paramter error
246  * \~english @par Prerequisite
247  *       Availability of Communication is TRUE
248  * \~english @par Change of internal state
249  *       - Change of internal state according to the API does not occur.
250  * \~english @par Conditions of processing failure
251  * - Input parameter error
252  *       - COMMSUBCPU_RET_ERROR_PARAM
253  * \~english @par Classification
254  *       Public
255  * \~english @par Type
256  *       Async
257  * \~english @see
258  *       None
259  */
260 COMMSUBCPU_RET_API CommSubCpu_Transmission(PCSTR name, T_ICR_CMD *snd_cmd, uint8_t req_id);
261
262 #ifdef __cplusplus
263 }
264 #endif /*__cplusplus    */
265
266 #endif  // COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_