summaryrefslogtreecommitdiffstats
path: root/stub/communication_subcpu/client/include/stub/CommSubCpu_API.h
blob: 020c3614d3633ec9c60fd544bbae84e1f9651bb8 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
 * @copyright Copyright (c) 2017-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.
 */

#ifndef COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_
#define COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_

/**
 * @file CommSubCpu_API.h
 * @~english
 * @brief communication_subcpu API header
 */

/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup peripheral_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup communication_subcpu
 *  @ingroup peripheral_service
 *  @{
 */

#include <sys/types.h>
#include <native_service/frameworkunified_types.h>
#include <agldd/moduleid.h>
#include <stub/com_message_header.h>

#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/

/*! @~english CommSubCpu I/F API return code  */
typedef int32_t     COMMSUBCPU_RET_API;

/*! @~english Thread name  */
#define LAN_SERVICE_SYSCOM_MAIN "DEV_SYSCOM_MAIN"

/**
 * \~english The ICR command receive notification
 */
#define CID_ICR_CMD_RCV     (0x0A00)

/**
 * \~english The ICR command send result notification
 */
#define CID_ICR_CMD_SND_CNF (0x0A01)

/*! @~english The MAX length of send command  */
#define ICRCMD_OPELAND_SND_MAX  (2048)
/*! @~english The MAX length of send ICR command  */
#define ICRCMD_OPELAND_MAX      (252)

/**
 * \~english ICR command format
 */
typedef struct {
    uint16_t    phyadr_from;        //!< \~english Physical address
    uint8_t service_type;           //!< \~english Communication type
    uint8_t lgadr_from;             //!< \~english Source logical address
    uint8_t lgadr_to;               //!< \~english Forwarding destination logical address
    uint8_t opc;                    //!< \~english Operation code
    uint8_t d_length;               //!< \~english Data size
    uint8_t data[ICRCMD_OPELAND_MAX];   //!< \~english Command data
    uint8_t reserve;                    //!< \~english Reserve
} T_ICR_CMD_DATA;

/**
 * \~english Send command structure
 */
typedef struct {
    uint16_t    phyadr_from;        //!< \~english Physical address
    uint8_t service_type;           //!< \~english Communication type
    uint8_t lgadr_from;             //!< \~english Source logical address
    uint8_t lgadr_to;               //!< \~english Forwarding destination logical address
    uint8_t opc;                    //!< \~english Operation code
    uint16_t    d_length;           //!< \~english Data size
    uint8_t data[ICRCMD_OPELAND_SND_MAX];   //!< \~english Command data
} T_ICR_CMD_SND_DATA;

/**
 * \~english ICR command data
 */
typedef struct {
    T_ICR_CMD_SND_DATA  cmd_data;       //!< \~english Command information
} T_ICR_CMD;

/**
 * \~english The message of command receive notification
 */
typedef struct {
    /*! @~english The header of message  */
    T_APIMSG_MSGBUF_HEADER_COMM msg_hdr;
    /*! @~english The message data for send result  */
    T_ICR_CMD_DATA          cmd_data;
} T_ICR_CMD_RCV;

/*!
 * @~english Status of message send result
 */
typedef enum {
    /*! @~english Send success */
    ICR_SND_SUCCESS = 0,
    /*! @~english Initialize error */
    ICR_SND_ERR_INIT,
    /*! @~english Send error */
    ICR_SND_ERR,
    /*! @~english Send error(retry out) */
    ICR_SND_ERR_RETRYOUT,
    /*! @~english Send error(buffer full) */
    ICR_SND_ERR_BUFFERFULL,
    /*! @~english Send error(micon abnormal) */
    ICR_SND_ERR_MC,
    /*! @~english The MAX */
    ICR_SND_ERR_MAX
} ICR_ERROR_CODE;

/*!
 * @~english Structure for message send status data
 */
typedef struct {
  /*! @~english Result of send message */
  ICR_ERROR_CODE  cnf_sts;
} T_ICR_CMDSNDCNF_STS;


 /**
 * \~english The send result notification
 */
typedef struct {
    /*! @~english The header of message  */
    T_APIMSG_MSGBUF_HEADER_COMM msg_hdr;
    /*! @~english The message data for send result  */
    T_ICR_CMDSNDCNF_STS     sts;
} T_ICR_CMDSNDCNF;


#define COMMSUBCPU_RET_NORMAL               0   //!< \~english Normal termination
#define COMMSUBCPU_RET_ERROR_CANCEL         1   //!< \~english Abnormal termination
#define COMMSUBCPU_RET_ERROR_PARAM          2   //!< \~english Abnormality of parameter
#define COMMSUBCPU_RET_ERROR_BUFFULL        3   //!< \~english Buffer FULL
#define COMMSUBCPU_RET_ERROR_OVERLAPPED     4   //!< \~english Entry overlapped
#define COMMSUBCPU_RET_ERROR_CREATE_EVENT   5   //!< \~english Event generation failure

/**
 * \ingroup CommSubCpu
 * \~english @par Brief
 *       CommSubCpu moudle init
 * \~english @retval COMMSUBCPU_RET_NORMAL : Success
 * \~english @par Prerequisite
 *       None
 * \~english @par Change of internal state
 *       - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *       None
 * \~english @par Classification
 *       Public
 * \~english @par Type
 *       Sync
 * \~english @see
 *       None
 */
COMMSUBCPU_RET_API CommSubCpu_Init();

/**
 * \ingroup CommSubCpu
 * \~english @par Brief
 *       CommSubCpu moudle deinitializes
 * \~english @retval COMMSUBCPU_RET_NORMAL : Success
 * \~english @par Prerequisite
 *       CommSubCpu moudle init completely
 * \~english @par Change of internal state
 *       - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 *       None
 * \~english @par Classification
 *       Public
 * \~english @par Type
 *       Sync
 * \~english @see
 *       None
 */
COMMSUBCPU_RET_API CommSubCpu_DeInit();

/**
 * \ingroup CommSubCpu
 * \~english @par Brief
 *       Delivery registration of CommSubCpu command
 * \~english @param [in] name
 *       PCSTR - Receiver thread name
 * \~english @param [in] from
 *       uint8_t - Sender logical address
 * \~english @param [in] to
 *       uint8_t - Receiver logical address
 * \~english @param [in] opc
 *       uint8_t - Operation code
 * \~english @param [in] callback_id
 *       uint8_t - callback ID
 * \~english @param [in] cid
 *       uint16_t - CID
 * \~english @retval COMMSUBCPU_RET_NORMAL : Success
 * \~english @retval COMMSUBCPU_RET_ERROR_PARAM : Paramter error
 * \~english @par Prerequisite
 *       Availability of Communication is TRUE
 * \~english @par Change of internal state
 *       - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 * - Input parameter error
 *       - COMMSUBCPU_RET_ERROR_PARAM
 * \~english @par Classification
 *       Public
 * \~english @par Type
 *       Async
 * \~english @see
 *       None
 */
COMMSUBCPU_RET_API  CommSubCpu_DeliveryMsgEntry(PCSTR name, uint8_t from, uint8_t to, uint8_t opc,
                                    uint8_t  callback_id, uint16_t cid);

/**
 * \ingroup CommSubCpu
 * \~english @par Brief
 *       CommSubCpu command transmission request
 * \~english @param [in] name
 *       PCSTR - Sender thread name
 * \~english @param [in] snd_cmd
 *       T_ICR_CMD* - Pointer to send command
 * \~english @param [in] req_id
 *       uint8_t - RID of the results
 * \~english @retval COMMSUBCPU_RET_NORMAL : Success
 * \~english @retval COMMSUBCPU_RET_ERROR_PARAM : Paramter error
 * \~english @par Prerequisite
 *       Availability of Communication is TRUE
 * \~english @par Change of internal state
 *       - Change of internal state according to the API does not occur.
 * \~english @par Conditions of processing failure
 * - Input parameter error
 *       - COMMSUBCPU_RET_ERROR_PARAM
 * \~english @par Classification
 *       Public
 * \~english @par Type
 *       Async
 * \~english @see
 *       None
 */
COMMSUBCPU_RET_API CommSubCpu_Transmission(PCSTR name, T_ICR_CMD *snd_cmd, uint8_t req_id);

#ifdef __cplusplus
}
#endif /*__cplusplus    */

#endif  // COMMUNICATION_SUBCPU_CLIENT_INCLUDE_PERIPHERAL_SERVICE_COMMSUBCPU_API_H_