2 * @copyright Copyright (c) 2017-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 #ifndef COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_
18 #define COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_
21 * @file CommSubCpu_API.h
23 * @brief communication_subcpu API header
26 /** @addtogroup BaseSystem
29 /** @addtogroup peripheral_service
33 /** @addtogroup communication_subcpu
34 * @ingroup peripheral_service
38 #include <sys/types.h>
39 #include <native_service/frameworkunified_types.h>
40 #include <agldd/moduleid.h>
41 #include <stub/com_message_header.h>
45 #endif /*__cplusplus*/
47 /*! @~english CommSubCpu I/F API return code */
48 typedef int32_t COMMSUBCPU_RET_API;
50 /*! @~english Thread name */
51 #define LAN_SERVICE_SYSCOM_MAIN "DEV_SYSCOM_MAIN"
54 * \~english The ICR command receive notification
56 #define CID_ICR_CMD_RCV (0x0A00)
59 * \~english The ICR command send result notification
61 #define CID_ICR_CMD_SND_CNF (0x0A01)
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)
69 * \~english ICR command format
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
83 * \~english Send command structure
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
96 * \~english ICR command data
99 T_ICR_CMD_SND_DATA cmd_data; //!< \~english Command information
103 * \~english The message of command receive notification
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;
113 * @~english Status of message send result
116 /*! @~english Send success */
118 /*! @~english Initialize error */
120 /*! @~english Send error */
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) */
128 /*! @~english The MAX */
133 * @~english Structure for message send status data
136 /*! @~english Result of send message */
137 ICR_ERROR_CODE cnf_sts;
138 } T_ICR_CMDSNDCNF_STS;
142 * \~english The send result notification
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;
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
160 * \ingroup CommSubCpu
161 * \~english @par Brief
162 * CommSubCpu moudle init
163 * \~english @retval COMMSUBCPU_RET_NORMAL : Success
164 * \~english @par Prerequisite
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
170 * \~english @par Classification
172 * \~english @par Type
177 COMMSUBCPU_RET_API CommSubCpu_Init();
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
190 * \~english @par Classification
192 * \~english @par Type
197 COMMSUBCPU_RET_API CommSubCpu_DeInit();
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
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
226 * \~english @par Type
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);
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
255 * \~english @par Type
260 COMMSUBCPU_RET_API CommSubCpu_Transmission(PCSTR name, T_ICR_CMD *snd_cmd, uint8_t req_id);
264 #endif /*__cplusplus */
266 #endif // COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_