Use latest version of conf.d/templates submodule.
[apps/agl-service-unicens.git] / ucs2-lib / src / ucs_inic_res.c
1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491                                                                            */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
4 /*                                                                                                */
5 /* This program is free software: you can redistribute it and/or modify                           */
6 /* it under the terms of the GNU General Public License as published by                           */
7 /* the Free Software Foundation, either version 2 of the License, or                              */
8 /* (at your option) any later version.                                                            */
9 /*                                                                                                */
10 /* This program is distributed in the hope that it will be useful,                                */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
13 /* GNU General Public License for more details.                                                   */
14 /*                                                                                                */
15 /* You should have received a copy of the GNU General Public License                              */
16 /* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
17 /*                                                                                                */
18 /* You may also obtain this software under a propriety license from Microchip.                    */
19 /* Please contact Microchip for further information.                                              */
20 /*------------------------------------------------------------------------------------------------*/
21
22 /*!
23  * \file
24  * \brief   Implementation of FBlock INIC (resource management parts of INIC management)
25  * \details Contains the resource management parts of INIC management
26  *
27  * \cond UCS_INTERNAL_DOC
28  * \addtogroup G_INIC
29  * @{
30  */
31
32 /*------------------------------------------------------------------------------------------------*/
33 /* Includes                                                                                       */
34 /*------------------------------------------------------------------------------------------------*/
35 #include "ucs_misc.h"
36 #include "ucs_ret_pb.h"
37 #include "ucs_inic.h"
38 #include "ucs_base.h"
39
40 /*------------------------------------------------------------------------------------------------*/
41 /* Internal macros                                                                                */
42 /*------------------------------------------------------------------------------------------------*/
43 /*! \brief API locking Bitmask for all INIC create methods. */
44 #define INIC_API_CREATE_CLASS               0x0001U
45 /*! \brief API locking Bitmask of method Inic_ResourceDestroy(). */
46 #define INIC_API_RESOURCE_DESTROY           0x0002U
47 /*! \brief API locking Bitmask of method Inic_ResourceInvalidList_Get(). */
48 #define INIC_API_RESOURCE_INVAL_LIST        0x0004U
49 /*! \brief API locking Bitmask of method Inic_Notification_Set(). */
50 #define INIC_API_NOTIFICATION               0x0008U
51 /*! \brief API locking Bitmask of method Inic_StreamPortConfig_Get(). */
52 #define INIC_API_STREAM_PORT_CONFIG         0x0010U
53 /*! \brief API locking Bitmask of method Inic_SyncMute(). */
54 #define INIC_API_SYNC_MUTE                  0x0020U
55 /*! \brief API locking Bitmask of method Inic_SyncDemute(). */
56 #define INIC_API_SYNC_DEMUTE                0x0040U
57 /*! \brief API locking Bitmask of method Inic_MostPortEnable(). */
58 #define INIC_API_MOST_PORT_ENABLE           0x0080U
59 /*! \brief API locking Bitmask of method Inic_MostPortEnFullStr(). */
60 #define INIC_API_MOST_PORT_EN_FULL_STR      0x0100U
61 /*! \brief API locking Bitmask of method Inic_GpioPortPinMode_SetGet(). */
62 #define INIC_API_GPIO_PIN_MODE              0x0200U
63 /*! \brief API locking Bitmask of method Inic_GpioPortPinState_SetGet(). */
64 #define INIC_API_GPIO_PIN_STATE             0x0400U
65 /*! \brief API locking Bitmask of methods Inic_I2cPortRead_StartResultAck() and Inic_I2cPortWrite_StartResultAck(). */
66 #define INIC_API_I2C_PORT_WR                0x0800U
67 /*! \brief Bitmask for API method Inic_DeviceSync() used by API locking manager */
68 #define INIC_API_DEVICE_SYNC                0x1000U
69
70 /*------------------------------------------------------------------------------------------------*/
71 /* Internal prototypes                                                                            */
72 /*------------------------------------------------------------------------------------------------*/
73 static void Inic_HandleResApiTimeout(void *self, void *method_mask_ptr);
74 static void Inic_ResMsgTxStatusCb(void *self, Msg_MostTel_t *tel_ptr, Ucs_MsgTxStatus_t status);
75
76 /*------------------------------------------------------------------------------------------------*/
77 /* Implementation                                                                                 */
78 /*------------------------------------------------------------------------------------------------*/
79 /*! \brief Initialization function of the INIC Resource Management part. Called by Inic_Ctor().
80  *  \param self    Instance pointer
81  */
82 void Inic_InitResourceManagement(CInic *self)
83 {
84     Sobs_Ctor(&self->lock.res_observer, self, &Inic_HandleResApiTimeout);
85     Al_Ctor(&self->lock.res_api, &self->lock.res_observer, self->base_ptr->ucs_user_ptr);
86     Alm_RegisterApi(&self->base_ptr->alm, &self->lock.res_api);
87
88     /* initializes the gpio report time status */
89     self->gpio_rt_status.first_report = true;
90 }
91
92 /*! \brief Handles an API timeout
93  *  \param self             Instance pointer
94  *  \param method_mask_ptr  Bitmask to signal which API method has caused the timeout
95  */
96 static void Inic_HandleResApiTimeout(void *self, void *method_mask_ptr)
97 {
98     CInic *self_ = (CInic *)self;
99     Alm_ModuleMask_t method_mask = *((Alm_ModuleMask_t *)method_mask_ptr);
100     Inic_StdResult_t res_data;
101
102     res_data.data_info       = NULL;
103     res_data.result.code     = UCS_RES_ERR_TIMEOUT;
104     res_data.result.info_ptr = NULL;
105
106     switch(method_mask)
107     {
108         case INIC_API_CREATE_CLASS:
109             Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
110             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for INIC create method.", 0U));
111             break;
112         case INIC_API_RESOURCE_DESTROY:
113             Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_DESTROY], &res_data, true);
114             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_ResourceDestroy().", 0U));
115             break;
116         case INIC_API_RESOURCE_INVAL_LIST:
117             Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST], &res_data, true);
118             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_ResourceInvalidList_Get().", 0U));
119             break;
120         case INIC_API_NOTIFICATION:
121             Ssub_Notify(&self_->ssubs[INIC_SSUB_NOTIFICATION], &res_data, true);
122             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_Notification_Get().", 0U));
123             break;
124         case INIC_API_STREAM_PORT_CONFIG:
125             Ssub_Notify(&self_->ssubs[INIC_SSUB_STREAM_PORT_CONFIG], &res_data, true);
126             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_StreamPortConfig_Get().", 0U));
127             break;
128         case INIC_API_SYNC_MUTE:
129             Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_MUTE], &res_data, true);
130             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_SyncMute().", 0U));
131             break;
132         case INIC_API_SYNC_DEMUTE:
133             Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_DEMUTE], &res_data, true);
134             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_SyncDemute().", 0U));
135             break;
136         case INIC_API_MOST_PORT_ENABLE:
137             Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_ENABLE], &res_data, true);
138             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_MostPortEnable().", 0U));
139             break;
140         case INIC_API_MOST_PORT_EN_FULL_STR:
141             Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_EN_FULL_STR], &res_data, true);
142             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_MostPortEnFullStr().", 0U));
143             break;
144         case INIC_API_GPIO_PIN_MODE:
145             Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_MODE], &res_data, true);
146             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_GpioPortPinMode_SetGet().", 0U));
147             break;
148         case INIC_API_GPIO_PIN_STATE:
149             Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_STATE], &res_data, true);
150             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_GpioPortPinState_SetGet().", 0U));
151             break;
152         case INIC_API_DEVICE_SYNC:
153             Ssub_Notify(&self_->ssubs[INIC_SSUB_DEVICE_SYNC], &res_data, true);
154             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "API locking timeout occurred for method Inic_DeviceSync_StartResult().", 0U));
155             break;
156         default:
157             TR_ERROR((self_->base_ptr->ucs_user_ptr, "[INIC_RES]", "Unknown API locking bitmask detected. Mask: 0x%02X", 1U, method_mask));
158             break;
159     }
160 }
161
162 /*! \brief Add an observer to the ResourceMonitor subject
163  *  \param self     Instance of CInic
164  *  \param obs_ptr  Pointer to observer to be informed
165  */
166 void Inic_AddObsrvResMonitor(CInic *self, CObserver *obs_ptr)
167 {
168     (void)Sub_AddObserver(&self->subs[INIC_SUB_RES_MONITOR], obs_ptr);
169 }
170
171 /*! \brief Delete an observer from the ResourceMonitor subject
172  *  \param self     Instance of CInic
173  *  \param obs_ptr  Pointer to observer to be informed
174  */
175 void Inic_DelObsrvResMonitor(CInic *self, CObserver *obs_ptr)
176 {
177     (void)Sub_RemoveObserver(&self->subs[INIC_SUB_RES_MONITOR], obs_ptr);
178 }
179
180 /*! \brief Add an observer to the MOSTPortStatus subject
181  *  \param self     Instance of CInic
182  *  \param obs_ptr  Pointer to observer to be informed
183  */
184 void Inic_AddObsrvMostPortStatus(CInic *self, CObserver *obs_ptr)
185 {
186     if (Sub_AddObserver(&self->subs[INIC_SUB_MOST_PORT_STATUS], obs_ptr) != SUB_UNKNOWN_OBSERVER)
187     {
188         Sub_Notify(&self->subs[INIC_SUB_MOST_PORT_STATUS], &self->most_port_status);
189     }
190 }
191
192 /*! \brief Delete an observer from the MOSTPortStatus subject
193  *  \param self     Instance of CInic
194  *  \param obs_ptr  Pointer to observer to be informed
195  */
196 void Inic_DelObsrvMostPortStatus(CInic *self, CObserver *obs_ptr)
197 {
198     (void)Sub_RemoveObserver(&self->subs[INIC_SUB_MOST_PORT_STATUS], obs_ptr);
199 }
200
201 /*! \brief Add an observer to the GpioTriggerEvent subject
202  *  \param self     Instance of CInic
203  *  \param obs_ptr  Pointer to observer to be informed
204  */
205 void Inic_AddObsrvGpioTriggerEvent(CInic *self, CObserver *obs_ptr)
206 {
207     (void)Sub_AddObserver(&self->subs[INIC_SUB_GPIO_TRIGGER_EVENT], obs_ptr);
208 }
209
210 /*! \brief Removes an observer from the GpioTriggerEvent subject
211  *  \param self     Instance of CInic
212  *  \param obs_ptr  Pointer to observer to be informed
213  */
214 void Inic_DelObsrvGpioTriggerEvent(CInic *self, CObserver *obs_ptr)
215 {
216     (void)Sub_RemoveObserver(&self->subs[INIC_SUB_GPIO_TRIGGER_EVENT], obs_ptr);
217 }
218
219 /*! \brief  Destroys the resources associated with the given resource handles
220  *  \param  self             Reference to CInic instance
221  *  \param  res_handle_list  resource handle list
222  *  \param  obs_ptr          Reference to an optional observer. The result must be casted into type
223  *                           Inic_StdResult_t.
224  *  \return UCS_RET_SUCCESS               message was created
225  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
226  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
227  *  \return UCS_RET_ERR_PARAM             Wrong length of resource handle list
228  */
229 Ucs_Return_t Inic_ResourceDestroy(CInic *self,
230                                   Inic_ResHandleList_t res_handle_list,
231                                   CSingleObserver *obs_ptr)
232 {
233     Ucs_Return_t result = UCS_RET_SUCCESS;
234     uint8_t len;
235
236     if(Al_Lock(&self->lock.res_api, INIC_API_RESOURCE_DESTROY) != false)
237     {
238         /* sender handle + number of resource handles */
239         len = 2U * res_handle_list.num_handles;
240
241         if ((len == 0U)  || ((MAX_INVALID_HANDLES_LIST << 1) < len))
242         {
243             Al_Release(&self->lock.res_api, INIC_API_RESOURCE_DESTROY);
244             result = UCS_RET_ERR_PARAM;
245         }
246         else
247         {
248             Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, len);
249
250             if (msg_ptr != NULL)
251             {
252                 uint8_t i;
253
254                 msg_ptr->destination_addr  = self->target_address;
255
256                 msg_ptr->id.fblock_id   = FB_INIC;
257                 msg_ptr->id.instance_id = 0U;
258                 msg_ptr->id.function_id = INIC_FID_RESOURCE_DESTROY;
259                 msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
260
261                 for (i=0U; i < res_handle_list.num_handles; ++i)
262                 {
263                     msg_ptr->tel.tel_data_ptr[2U*i]        = MISC_HB(res_handle_list.res_handles[i]);
264                     msg_ptr->tel.tel_data_ptr[1U + (2U*i)] = MISC_LB(res_handle_list.res_handles[i]);
265                 }
266
267                 self->ssubs[INIC_SSUB_RESOURCE_DESTROY].user_mask = INIC_API_RESOURCE_DESTROY;
268                 msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_RESOURCE_DESTROY];
269                 Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
270
271                 (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_RESOURCE_DESTROY], obs_ptr);
272             }
273             else
274             {
275                 Al_Release(&self->lock.res_api, INIC_API_RESOURCE_DESTROY);
276                 result = UCS_RET_ERR_BUFFER_OVERFLOW;
277             }
278         }
279     }
280     else
281     {
282         result = UCS_RET_ERR_API_LOCKED;
283     }
284
285     return result;
286 }
287
288 /*! \brief  Retrieves the list of invalid resources
289  *  \param  self            Reference to CInic instance
290  *  \param  obs_ptr         Reference to an optional observer. The result must be casted into type
291  *                          Inic_StdResult_t.
292  *  \return UCS_RET_SUCCESS               message was created
293  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
294  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
295  */
296 Ucs_Return_t Inic_ResourceInvalidList_Get(CInic *self, CSingleObserver *obs_ptr)
297 {
298     Ucs_Return_t result = UCS_RET_SUCCESS;
299
300     if(Al_Lock(&self->lock.res_api, INIC_API_RESOURCE_INVAL_LIST) != false)
301     {
302         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 0U);
303
304         if (msg_ptr != NULL)
305         {
306             msg_ptr->destination_addr = self->target_address;
307             msg_ptr->id.fblock_id   = FB_INIC;
308             msg_ptr->id.instance_id = 0U;
309             msg_ptr->id.function_id = INIC_FID_RESOURCE_INVALID_LIST;
310             msg_ptr->id.op_type     = UCS_OP_GET;
311
312             self->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST].user_mask = INIC_API_RESOURCE_INVAL_LIST;
313             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST];
314             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
315             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST], obs_ptr);
316         }
317         else
318         {
319             Al_Release(&self->lock.res_api, INIC_API_RESOURCE_INVAL_LIST);
320             result = UCS_RET_ERR_BUFFER_OVERFLOW;
321         }
322     }
323     else
324     {
325         result = UCS_RET_ERR_API_LOCKED;
326     }
327
328     return result;
329 }
330
331 /*! \brief  Resets the resource monitor back to its default state.
332  *  \param  self            Reference to CInic instance
333  *  \param  control         Used to reset the resource monitor
334  *  \return UCS_RET_SUCCESS               message was created
335  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
336  */
337 Ucs_Return_t Inic_ResourceMonitor_Set(CInic *self, Ucs_Resource_MonitorCtrl_t control)
338 {
339     Ucs_Return_t result = UCS_RET_SUCCESS;
340
341     Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 1U);
342
343     if (msg_ptr != NULL)
344     {
345         msg_ptr->destination_addr    = self->target_address;
346         msg_ptr->id.fblock_id        = FB_INIC;
347         msg_ptr->id.instance_id      = 0U;
348         msg_ptr->id.function_id      = INIC_FID_RESOURCE_MONITOR;
349         msg_ptr->id.op_type          = UCS_OP_SET;
350         msg_ptr->tel.tel_data_ptr[0] = (uint8_t)control;
351         Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
352     }
353     else
354     {
355         result = UCS_RET_ERR_BUFFER_OVERFLOW;
356     }
357
358     return result;
359 }
360
361 /*! \brief  Triggers notification of the given function_id list.
362  *  \param  self            Reference to CInic instance
363  *  \param  control         control command used
364  *  \param  device_id       Id of the sending device (local node address).
365  *  \param  fktid_list      function ids list.
366  *  \return UCS_RET_SUCCESS               message was created
367  *  \return UCS_RET_ERR_PARAM             parameter exceeds its admissible range was created
368  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
369  */
370 Ucs_Return_t Inic_Notification_Set(CInic *self, Ucs_Inic_NotificationCtrl_t control, uint16_t device_id, Inic_FktIdList_t fktid_list)
371 {
372     Ucs_Return_t result = UCS_RET_SUCCESS;
373
374     /* control + device_id + size of the funcids list */
375     uint8_t len = 1U + 2U + (2U * fktid_list.num_fktids);
376
377     if (len > MSG_MAX_SIZE_PAYLOAD)
378     {
379         result = UCS_RET_ERR_PARAM;
380     }
381     else
382     {
383         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, len);
384
385         if (msg_ptr != NULL)
386         {
387             uint8_t i;
388
389             msg_ptr->destination_addr  = self->target_address;
390
391             msg_ptr->id.fblock_id   = FB_INIC;
392             msg_ptr->id.instance_id = 0U;
393             msg_ptr->id.function_id = INIC_FID_NOTIFICATION;
394             msg_ptr->id.op_type     = UCS_OP_SET;
395
396             msg_ptr->tel.tel_data_ptr[0] = (uint8_t)control;
397             msg_ptr->tel.tel_data_ptr[1] = MISC_HB(device_id);
398             msg_ptr->tel.tel_data_ptr[2] = MISC_LB(device_id);
399
400             if ((len > 3U) && (fktid_list.fktids_ptr != NULL) )
401             {
402                 for (i=0U; i < fktid_list.num_fktids; ++i)
403                 {
404                     msg_ptr->tel.tel_data_ptr[3U+(2U*i)] = MISC_HB(fktid_list.fktids_ptr[i]);
405                     msg_ptr->tel.tel_data_ptr[4U+(2U*i)] = MISC_LB(fktid_list.fktids_ptr[i]);
406                 }
407             }
408
409             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_NOTIFICATION];
410             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
411         }
412         else
413         {
414             result = UCS_RET_ERR_BUFFER_OVERFLOW;
415         }
416     }
417
418     return result;
419 }
420
421 /*! \brief Gets the device id that has notified the given function_id
422  *  \param  self            Reference to CInic instance
423  *  \param  fktid           The function id to be looked for
424  *  \param  obs_ptr             Reference to an optional observer
425  *  \return UCS_RET_SUCCESS               message was created
426  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
427  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
428  */
429 Ucs_Return_t Inic_Notification_Get(CInic *self, uint16_t fktid, CSingleObserver *obs_ptr)
430 {
431     Ucs_Return_t result = UCS_RET_SUCCESS;
432
433     if(Al_Lock(&self->lock.res_api, INIC_API_NOTIFICATION) != false)
434     {
435         Msg_MostTel_t * msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
436
437         if (msg_ptr != NULL)
438         {
439             msg_ptr->destination_addr  = self->target_address;
440
441             msg_ptr->id.fblock_id   = FB_INIC;
442             msg_ptr->id.instance_id = 0U;
443             msg_ptr->id.function_id = INIC_FID_NOTIFICATION;
444             msg_ptr->id.op_type     = UCS_OP_GET;
445
446             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(fktid);
447             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(fktid);
448
449             self->ssubs[INIC_SSUB_NOTIFICATION].user_mask = INIC_API_NOTIFICATION;
450             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_NOTIFICATION];
451             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
452
453             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_NOTIFICATION], obs_ptr);
454         }
455         else
456         {
457             Al_Release(&self->lock.res_api, INIC_API_NOTIFICATION);
458             result = UCS_RET_ERR_BUFFER_OVERFLOW;
459         }
460     }
461     else
462     {
463         result = UCS_RET_ERR_API_LOCKED;
464     }
465
466     return result;
467 }
468
469 /*! \brief  Creates a synchronous data connection. The connection can be directly associated with
470  *          an input and output socket.
471  *  \param  self                Reference to CInic instance
472  *  \param  resource_handle_in  The ID number of the socket or splitter resource that is the
473  *                              starting point of the link.
474  *  \param  resource_handle_out The ID number of the socket or splitter resource that is the ending
475  *                              point of the link.
476  *  \param  default_mute        specifies if the connection is muted by default
477  *  \param  mute_mode           Configures how the resource monitor shall handle events that may
478  *                              the streamed data invalid.
479  *  \param  offset              Denotes the offset from/to where data from/to a socket should be
480  *                              routed from/to a splitter/combiner.
481  *  \param  obs_ptr             Reference to an optional observer
482  *  \return UCS_RET_SUCCESS               message was created
483  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
484  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
485  */
486 Ucs_Return_t Inic_SyncCreate(CInic *self,
487                              uint16_t resource_handle_in,
488                              uint16_t resource_handle_out,
489                              bool default_mute,
490                              Ucs_Sync_MuteMode_t mute_mode,
491                              uint16_t offset,
492                              CSingleObserver *obs_ptr)
493 {
494     Ucs_Return_t result = UCS_RET_SUCCESS;
495
496     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
497     {
498         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 8U);
499
500         if (msg_ptr != NULL)
501         {
502             msg_ptr->destination_addr  = self->target_address;
503
504             msg_ptr->id.fblock_id   = FB_INIC;
505             msg_ptr->id.instance_id = 0U;
506             msg_ptr->id.function_id = INIC_FID_SYNC_CREATE;
507             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
508
509             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(resource_handle_in);
510             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(resource_handle_in);
511             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(resource_handle_out);
512             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(resource_handle_out);
513             msg_ptr->tel.tel_data_ptr[4] = (default_mute != false) ? 1U : 0U;
514             msg_ptr->tel.tel_data_ptr[5] = (uint8_t)mute_mode;
515             msg_ptr->tel.tel_data_ptr[6] = MISC_HB(offset);
516             msg_ptr->tel.tel_data_ptr[7] = MISC_LB(offset);
517
518             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
519             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
520             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
521
522             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
523         }
524         else
525         {
526             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
527             result = UCS_RET_ERR_BUFFER_OVERFLOW;
528         }
529     }
530     else
531     {
532         result = UCS_RET_ERR_API_LOCKED;
533     }
534
535     return result;
536 }
537
538 /*! \brief  This function manually mutes a synchronous data connection.
539  *  \param  self             Reference to CInic instance
540  *  \param  sync_handle      Resource handle of the synchronous connection
541  *  \param  obs_ptr          Reference to an optional observer
542  *  \return UCS_RET_SUCCESS               message was created
543  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
544  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
545  */
546 Ucs_Return_t Inic_SyncMute(CInic *self,
547                            uint16_t sync_handle,
548                            CSingleObserver *obs_ptr)
549 {
550     Ucs_Return_t result = UCS_RET_SUCCESS;
551
552     if(Al_Lock(&self->lock.res_api, INIC_API_SYNC_MUTE) != false)
553     {
554         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
555
556         if (msg_ptr != NULL)
557         {
558             msg_ptr->destination_addr  = self->target_address;
559
560             msg_ptr->id.fblock_id   = FB_INIC;
561             msg_ptr->id.instance_id = 0U;
562             msg_ptr->id.function_id = INIC_FID_SYNC_MUTE;
563             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
564
565             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(sync_handle);
566             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(sync_handle);
567
568             self->ssubs[INIC_SSUB_SYNC_MUTE].user_mask = INIC_API_SYNC_MUTE;
569             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_SYNC_MUTE];
570             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
571
572             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_SYNC_MUTE], obs_ptr);
573         }
574         else
575         {
576             Al_Release(&self->lock.res_api, INIC_API_SYNC_MUTE);
577             result = UCS_RET_ERR_BUFFER_OVERFLOW;
578         }
579     }
580     else
581     {
582         result = UCS_RET_ERR_API_LOCKED;
583     }
584
585     return result;
586 }
587
588 /*! \brief  This function manually de-mutes a synchronous data connection.
589  *  \param  self             Reference to CInic instance
590  *  \param  sync_handle      Resource handle of the synchronous connection
591  *  \param  obs_ptr          Reference to an optional observer
592  *  \return UCS_RET_SUCCESS               message was created
593  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
594  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
595  */
596 Ucs_Return_t Inic_SyncDemute(CInic *self,
597                              uint16_t sync_handle,
598                              CSingleObserver *obs_ptr)
599 {
600     Ucs_Return_t result = UCS_RET_SUCCESS;
601
602     if(Al_Lock(&self->lock.res_api, INIC_API_SYNC_DEMUTE) != false)
603     {
604         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
605
606         if (msg_ptr != NULL)
607         {
608             msg_ptr->destination_addr  = self->target_address;
609
610             msg_ptr->id.fblock_id   = FB_INIC;
611             msg_ptr->id.instance_id = 0U;
612             msg_ptr->id.function_id = INIC_FID_SYNC_DEMUTE;
613             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
614
615             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(sync_handle);
616             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(sync_handle);
617
618             self->ssubs[INIC_SSUB_SYNC_DEMUTE].user_mask = INIC_API_SYNC_DEMUTE;
619             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_SYNC_DEMUTE];
620             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
621
622             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_SYNC_DEMUTE], obs_ptr);
623         }
624         else
625         {
626             Al_Release(&self->lock.res_api, INIC_API_SYNC_DEMUTE);
627             result = UCS_RET_ERR_BUFFER_OVERFLOW;
628         }
629     }
630     else
631     {
632         result = UCS_RET_ERR_API_LOCKED;
633     }
634
635     return result;
636 }
637
638 /*! \brief  Creates a DiscreteFrame Isochronous streaming phase connection. The connection can be
639  *          directly associated with an input and output socket.
640  *  \param  self                Reference to CInic instance
641  *  \param  resource_handle_in  The ID number of the socket or splitter resource that is the
642  *                              starting point of the link.
643  *  \param  resource_handle_out The ID number of the socket or splitter resource that is the ending
644  *                              point of the link.
645  *  \param  obs_ptr             Reference to an optional observer
646  *  \return UCS_RET_SUCCESS               message was created
647  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
648  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
649  */
650 Ucs_Return_t Inic_DfiPhaseCreate(CInic *self,
651                                  uint16_t resource_handle_in,
652                                  uint16_t resource_handle_out,
653                                  CSingleObserver *obs_ptr)
654 {
655     Ucs_Return_t result = UCS_RET_SUCCESS;
656
657     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
658     {
659         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
660
661         if (msg_ptr != NULL)
662         {
663             msg_ptr->destination_addr  = self->target_address;
664
665             msg_ptr->id.fblock_id   = FB_INIC;
666             msg_ptr->id.instance_id = 0U;
667             msg_ptr->id.function_id = INIC_FID_DFIPHASE_CREATE;
668             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
669
670             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(resource_handle_in);
671             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(resource_handle_in);
672             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(resource_handle_out);
673             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(resource_handle_out);
674
675             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
676             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
677             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
678
679             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
680         }
681         else
682         {
683             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
684             result = UCS_RET_ERR_BUFFER_OVERFLOW;
685         }
686     }
687     else
688     {
689         result = UCS_RET_ERR_API_LOCKED;
690     }
691
692     return result;
693 }
694
695 /*! \brief  Creates a combiner resource. A Combiner enables grouping of data from multiple network
696  *          sockets into the same port socket.
697  *  \param  self                Reference to CInic instance
698  *  \param  port_socket_handle  Only supported sockets are Streaming Port, MLB, USB (OS81118) or PCI
699  *                              (OS81160) sockets of data type Synchronous. Direction must be OUT.
700  *  \param  most_port_handle    When the splitter is created with a MOST socket, the socket must be
701  *                              created on the same port indicated by this handle.
702  *  \param  bytes_per_frame     Specifies the total number of data bytes that are to be transferred
703  *                              each MOST frame.
704  *  \param  obs_ptr             Reference to an optional observer
705  *  \return UCS_RET_SUCCESS               message was created
706  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
707  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
708  */
709 Ucs_Return_t Inic_CombinerCreate(CInic *self,
710                                  uint16_t port_socket_handle,
711                                  uint16_t most_port_handle,
712                                  uint16_t bytes_per_frame,
713                                  CSingleObserver *obs_ptr)
714 {
715     Ucs_Return_t result = UCS_RET_SUCCESS;
716
717     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
718     {
719         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
720
721         if (msg_ptr != NULL)
722         {
723             msg_ptr->destination_addr  = self->target_address;
724
725             msg_ptr->id.fblock_id   = FB_INIC;
726             msg_ptr->id.instance_id = 0U;
727             msg_ptr->id.function_id = INIC_FID_COMBINER_CREATE;
728             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
729
730             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(port_socket_handle);
731             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(port_socket_handle);
732             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(most_port_handle);
733             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(most_port_handle);
734             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(bytes_per_frame);
735             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(bytes_per_frame);
736
737             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
738             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
739             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
740
741             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
742         }
743         else
744         {
745             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
746             result = UCS_RET_ERR_BUFFER_OVERFLOW;
747         }
748     }
749     else
750     {
751         result = UCS_RET_ERR_API_LOCKED;
752     }
753
754     return result;
755 }
756
757 /*! \brief  Creates a splitter resource. A Splitter enables splitting up the data from a single
758  *          channel into multiple channels.
759  *  \param  self                Reference to CInic instance
760  *  \param  socket_handle_in    All sockets of data type Synchronous are supported, regardless of
761  *                              the port the socket is created on. The direction must be IN.
762  *  \param  most_port_handle    When the splitter is created with a MOST socket, the socket must be
763  *                              created on the same port indicated by this handle.
764  *  \param  bytes_per_frame     Specifies the total number of data bytes that are to be transferred
765  *                              each MOST frame.
766  *  \param  obs_ptr             Reference to an optional observer
767  *  \return UCS_RET_SUCCESS               message was created
768  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
769  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
770  */
771 Ucs_Return_t Inic_SplitterCreate(CInic *self,
772                                  uint16_t socket_handle_in,
773                                  uint16_t most_port_handle,
774                                  uint16_t bytes_per_frame,
775                                  CSingleObserver *obs_ptr)
776 {
777     Ucs_Return_t result = UCS_RET_SUCCESS;
778
779     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
780     {
781         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
782
783         if (msg_ptr != NULL)
784         {
785             msg_ptr->destination_addr  = self->target_address;
786
787             msg_ptr->id.fblock_id   = FB_INIC;
788             msg_ptr->id.instance_id = 0U;
789             msg_ptr->id.function_id = INIC_FID_SPLITTER_CREATE;
790             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
791
792             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(socket_handle_in);
793             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(socket_handle_in);
794             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(most_port_handle);
795             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(most_port_handle);
796             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(bytes_per_frame);
797             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(bytes_per_frame);
798
799             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
800             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
801             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
802
803             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
804         }
805         else
806         {
807             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
808             result = UCS_RET_ERR_BUFFER_OVERFLOW;
809         }
810     }
811     else
812     {
813         result = UCS_RET_ERR_API_LOCKED;
814     }
815
816     return result;
817 }
818
819 /*! \brief  Creates an Quality of Service IP Streaming data connection.
820  *  \param  self                Reference to CInic instance
821  *  \param  socket_in_handle    The ID number of the created socket that is the starting point of
822  *                              the link. Must be a socket of type Input.
823  *  \param  socket_out_handle   The ID number of the created socket that is the ending point of
824  *                              the link. Must be a socket of type Output.
825  *  \param  obs_ptr             Reference to an optional observer
826  *  \return UCS_RET_SUCCESS               message was created
827  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
828  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
829  */
830 Ucs_Return_t Inic_QoSCreate(CInic *self,
831                             uint16_t socket_in_handle,
832                             uint16_t socket_out_handle,
833                             CSingleObserver *obs_ptr)
834 {
835     Ucs_Return_t result = UCS_RET_SUCCESS;
836
837     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
838     {
839         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
840
841         if (msg_ptr != NULL)
842         {
843             msg_ptr->destination_addr  = self->target_address;
844
845             msg_ptr->id.fblock_id   = FB_INIC;
846             msg_ptr->id.instance_id = 0U;
847             msg_ptr->id.function_id = INIC_FID_QOS_CREATE;
848             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
849
850             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(socket_in_handle);
851             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(socket_in_handle);
852             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(socket_out_handle);
853             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(socket_out_handle);
854
855             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
856             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
857             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
858
859             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
860         }
861         else
862         {
863             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
864             result = UCS_RET_ERR_BUFFER_OVERFLOW;
865         }
866     }
867     else
868     {
869         result = UCS_RET_ERR_API_LOCKED;
870     }
871
872     return result;
873 }
874
875 /*! \brief  Creates an IPC (Inter-Processor Communication) packet connection.
876  *  \param  self                Reference to CInic instance
877  *  \param  socket_in_handle    The ID number of the created socket that is the starting point of
878  *                              the link. Must be a socket of type Input.
879  *  \param  socket_out_handle   The ID number of the created socket that is the ending point of
880  *                              the link. Must be a socket of type Output.
881  *  \param  obs_ptr             Reference to an optional observer
882  *  \return UCS_RET_SUCCESS               message was created
883  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
884  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
885  */
886 Ucs_Return_t Inic_IpcCreate(CInic *self,
887                             uint16_t socket_in_handle,
888                             uint16_t socket_out_handle,
889                             CSingleObserver *obs_ptr)
890 {
891     Ucs_Return_t result = UCS_RET_SUCCESS;
892
893     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
894     {
895         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
896
897         if (msg_ptr != NULL)
898         {
899             msg_ptr->destination_addr  = self->target_address;
900
901             msg_ptr->id.fblock_id   = FB_INIC;
902             msg_ptr->id.instance_id = 0U;
903             msg_ptr->id.function_id = INIC_FID_IPC_CREATE;
904             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
905
906             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(socket_in_handle);
907             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(socket_in_handle);
908             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(socket_out_handle);
909             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(socket_out_handle);
910
911             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
912             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
913             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
914
915             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
916         }
917         else
918         {
919             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
920             result = UCS_RET_ERR_BUFFER_OVERFLOW;
921         }
922     }
923     else
924     {
925         result = UCS_RET_ERR_API_LOCKED;
926     }
927
928     return result;
929 }
930
931 /*! \brief  Creates an A/V Packetized Isochronous Streaming data connection.
932  *  \param  self                Reference to CInic instance
933  *  \param  socket_in_handle    The ID number of the created socket that is the starting point of
934  *                              the link. Must be a socket of type Input.
935  *  \param  socket_out_handle   The ID number of the created socket that is the ending point of
936  *                              the link. Must be a socket of type Output.
937  *  \param  isoc_packet_size    Specifies the size of data packets that are to be transported over
938  *                              the isochronous channel.
939  *  \param  obs_ptr             Reference to an optional observer
940  *  \return UCS_RET_SUCCESS               message was created
941  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
942  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
943  */
944 Ucs_Return_t Inic_AvpCreate(CInic *self,
945                             uint16_t socket_in_handle,
946                             uint16_t socket_out_handle,
947                             Ucs_Avp_IsocPacketSize_t isoc_packet_size,
948                             CSingleObserver *obs_ptr)
949 {
950     Ucs_Return_t result = UCS_RET_SUCCESS;
951
952     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
953     {
954         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
955
956         if (msg_ptr != NULL)
957         {
958             msg_ptr->destination_addr  = self->target_address;
959
960             msg_ptr->id.fblock_id   = FB_INIC;
961             msg_ptr->id.instance_id = 0U;
962             msg_ptr->id.function_id = INIC_FID_AVP_CREATE;
963             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
964
965             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(socket_in_handle);
966             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(socket_in_handle);
967             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(socket_out_handle);
968             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(socket_out_handle);
969             msg_ptr->tel.tel_data_ptr[4] = MISC_HB((uint16_t)isoc_packet_size);
970             msg_ptr->tel.tel_data_ptr[5] = MISC_LB((uint16_t)isoc_packet_size);
971
972             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
973             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
974             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
975
976             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
977         }
978         else
979         {
980             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
981             result = UCS_RET_ERR_BUFFER_OVERFLOW;
982         }
983     }
984     else
985     {
986         result = UCS_RET_ERR_API_LOCKED;
987     }
988
989     return result;
990 }
991
992 /*! \brief  This function creates a MOST socket bound to the MOST Network Port.
993  *  \param  self                Reference to CInic instance
994  *  \param  most_port_handle    MOST Network Port resource handle
995  *  \param  direction           indicates the direction of the data stream from the perspective of
996  *                              the INIC
997  *  \param  data_type           Specifies the data type
998  *  \param  bandwidth           Required socket bandwidth in bytes. Maximum value depends on current
999  *                              free network resources.
1000  *  \param  connection_label    MOST network connection label. When used as parameter with direction
1001  *                              Input, the connection label is used to connect to the appropriate MOST
1002  *                              frame bytes. When used as parameter with direction Output, the
1003  *                              connection label is not used and must be set to 0xFFFF.
1004  *  \param  obs_ptr             Reference to an optional observer
1005  *  \return UCS_RET_SUCCESS               message was created
1006  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1007  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1008  */
1009 Ucs_Return_t Inic_MostSocketCreate(CInic *self,
1010                                    uint16_t most_port_handle,
1011                                    Ucs_SocketDirection_t direction,
1012                                    Ucs_Most_SocketDataType_t data_type,
1013                                    uint16_t bandwidth,
1014                                    uint16_t connection_label,
1015                                    CSingleObserver *obs_ptr)
1016 {
1017     Ucs_Return_t result = UCS_RET_SUCCESS;
1018
1019     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1020     {
1021         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 8U);
1022
1023         if (msg_ptr != NULL)
1024         {
1025             msg_ptr->destination_addr  = self->target_address;
1026
1027             msg_ptr->id.fblock_id   = FB_INIC;
1028             msg_ptr->id.instance_id = 0U;
1029             msg_ptr->id.function_id = INIC_FID_MOST_SOCKET_CREATE;
1030             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1031
1032             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(most_port_handle);
1033             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(most_port_handle);
1034             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)direction;
1035             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)data_type;
1036             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(bandwidth);
1037             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(bandwidth);
1038             msg_ptr->tel.tel_data_ptr[6] = MISC_HB(connection_label);
1039             msg_ptr->tel.tel_data_ptr[7] = MISC_LB(connection_label);
1040
1041             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1042             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1043             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1044
1045             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1046         }
1047         else
1048         {
1049             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1050             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1051         }
1052     }
1053     else
1054     {
1055         result = UCS_RET_ERR_API_LOCKED;
1056     }
1057
1058     return result;
1059 }
1060
1061 /*! \brief  Creates the MediaLB Port with its associated port instance identifier.
1062  *  \param  self            Reference to CInic instance
1063  *  \param  index           MediaLB Port instance
1064  *  \param  clock_config    Stores the clock speed configuration. The value is a multiple
1065  *                          of the MOST network frame rate Fs; this means the MediaLB Port
1066  *                          can only be frequency locked to the network's system clock.
1067  *  \param  obs_ptr         Reference to an optional observer
1068  *  \return UCS_RET_SUCCESS               message was created
1069  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1070  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1071  */
1072 Ucs_Return_t Inic_MlbPortCreate(CInic *self,
1073                                 uint8_t index,
1074                                 Ucs_Mlb_ClockConfig_t clock_config,
1075                                 CSingleObserver *obs_ptr)
1076 {
1077     Ucs_Return_t result = UCS_RET_SUCCESS;
1078
1079     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1080     {
1081         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
1082
1083         if (msg_ptr != NULL)
1084         {
1085             msg_ptr->destination_addr  = self->target_address;
1086
1087             msg_ptr->id.fblock_id   = FB_INIC;
1088             msg_ptr->id.instance_id = 0U;
1089             msg_ptr->id.function_id = INIC_FID_MLB_PORT_CREATE;
1090             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1091
1092             msg_ptr->tel.tel_data_ptr[0] = index;
1093             msg_ptr->tel.tel_data_ptr[1] = (uint8_t)clock_config;
1094
1095             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1096             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1097             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1098
1099             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1100         }
1101         else
1102         {
1103             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1104             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1105         }
1106     }
1107     else
1108     {
1109         result = UCS_RET_ERR_API_LOCKED;
1110     }
1111
1112     return result;
1113 }
1114
1115 /*! \brief  Creates a MediaLB socket bound to the MediaLB Port with the associated port instance
1116  *          identifier. If INIC enters Protected Mode, the MediaLB socket will be automatically
1117  *          destroyed.
1118  *  \param  self            Reference to CInic instance
1119  *  \param  mlb_port_handle MediaLB Port resource handle
1120  *  \param  direction       Indicates the direction of the data stream from the perspective of
1121  *                          the INIC
1122  *  \param  data_type       Specifies the data type
1123  *  \param  bandwidth       Required socket bandwidth in bytes
1124  *  \param  channel_address Indicates the MediaLB ChannelAddress where the socket is mapped to.
1125  *                          If the MediaLB Port is created by default, ChannelAddresses 0x0002
1126  *                          and 0x0004 are reserved and cannot be used.
1127  *  \param  obs_ptr         Reference to an optional observer
1128  *  \return UCS_RET_SUCCESS               message was created
1129  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1130  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1131  */
1132 Ucs_Return_t Inic_MlbSocketCreate(CInic *self,
1133                                   uint16_t mlb_port_handle,
1134                                   Ucs_SocketDirection_t direction,
1135                                   Ucs_Mlb_SocketDataType_t data_type,
1136                                   uint16_t bandwidth,
1137                                   uint16_t channel_address,
1138                                   CSingleObserver *obs_ptr)
1139 {
1140     Ucs_Return_t result = UCS_RET_SUCCESS;
1141
1142     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1143     {
1144         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 8U);
1145
1146         if (msg_ptr != NULL)
1147         {
1148             msg_ptr->destination_addr  = self->target_address;
1149
1150             msg_ptr->id.fblock_id   = FB_INIC;
1151             msg_ptr->id.instance_id = 0U;
1152             msg_ptr->id.function_id = INIC_FID_MLB_SOCKET_CREATE;
1153             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1154
1155             msg_ptr->tel.tel_data_ptr[0]  = MISC_HB(mlb_port_handle);
1156             msg_ptr->tel.tel_data_ptr[1]  = MISC_LB(mlb_port_handle);
1157             msg_ptr->tel.tel_data_ptr[2]  = (uint8_t)direction;
1158             msg_ptr->tel.tel_data_ptr[3]  = (uint8_t)data_type;
1159             msg_ptr->tel.tel_data_ptr[4]  = MISC_HB(bandwidth);
1160             msg_ptr->tel.tel_data_ptr[5]  = MISC_LB(bandwidth);
1161             msg_ptr->tel.tel_data_ptr[6]  = MISC_HB(channel_address);
1162             msg_ptr->tel.tel_data_ptr[7]  = MISC_LB(channel_address);
1163
1164             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1165             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1166             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1167
1168             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1169         }
1170         else
1171         {
1172             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1173             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1174         }
1175     }
1176     else
1177     {
1178         result = UCS_RET_ERR_API_LOCKED;
1179     }
1180
1181     return result;
1182 }
1183
1184 /*! \brief  Creates the USB Port with its associated port instance identifier. The instance
1185  *          identifier of an USB Port is always directly bound to a specific hardware port.
1186  *  \param  self                            Reference to CInic instance
1187  *  \param  index                           USB Port instance
1188  *  \param  physical_layer                  USB Port physical layer
1189  *  \param  devices_interfaces              USB Interfaces supported by the device
1190  *  \param  streaming_if_ep_out_count       number of USB OUT Endpoints being provided through the USB streaming interface
1191  *  \param  streaming_if_ep_in_count        number of USB IN Endpoints being provided through the USB Streaming interface
1192  *  \param  obs_ptr                 Reference to an optional observer
1193  *  \return UCS_RET_SUCCESS               message was created
1194  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1195  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1196  */
1197 Ucs_Return_t Inic_UsbPortCreate(CInic *self,
1198                                 uint8_t index,
1199                                 Ucs_Usb_PhysicalLayer_t physical_layer,
1200                                 uint16_t devices_interfaces,
1201                                 uint8_t streaming_if_ep_out_count,
1202                                 uint8_t streaming_if_ep_in_count,
1203                                 CSingleObserver *obs_ptr)
1204 {
1205     Ucs_Return_t result = UCS_RET_SUCCESS;
1206
1207     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1208     {
1209         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
1210
1211         if (msg_ptr != NULL)
1212         {
1213             msg_ptr->destination_addr  = self->target_address;
1214
1215             msg_ptr->id.fblock_id   = FB_INIC;
1216             msg_ptr->id.instance_id = 0U;
1217             msg_ptr->id.function_id = INIC_FID_USB_PORT_CREATE;
1218             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1219
1220             msg_ptr->tel.tel_data_ptr[0] = index;
1221             msg_ptr->tel.tel_data_ptr[1] = (uint8_t)physical_layer;
1222             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(devices_interfaces);
1223             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(devices_interfaces);
1224             msg_ptr->tel.tel_data_ptr[4] = streaming_if_ep_out_count;
1225             msg_ptr->tel.tel_data_ptr[5] = streaming_if_ep_in_count;
1226
1227             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1228             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1229             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1230
1231             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1232         }
1233         else
1234         {
1235             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1236             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1237         }
1238     }
1239     else
1240     {
1241         result = UCS_RET_ERR_API_LOCKED;
1242     }
1243
1244     return result;
1245 }
1246
1247 /*! \brief  Creates a USB socket bound to the USB port with its associated port instance identifier.
1248  *          If INIC enters Protected Mode, the USB socket will be automatically destroyed.
1249  *  \param  self                 Reference to CInic instance
1250  *  \param  usb_port_handle      USB Port resource handle
1251  *  \param  direction            Indicates the direction of the data stream from the perspective of
1252  *                               the INIC
1253  *  \param  data_type            Specifies the data type
1254  *  \param  end_point_addr       Denotes the address of a USB endpoint as per its description in the
1255  *                               USB 2.0 Specification
1256  *  \param  frames_per_transfer  Indicates the number of MOST frames per transfer per one USB
1257  *                               transaction
1258  *  \param  obs_ptr              Reference to an optional observer
1259  *  \return UCS_RET_SUCCESS               message was created
1260  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1261  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1262  */
1263 Ucs_Return_t Inic_UsbSocketCreate(CInic *self,
1264                                   uint16_t usb_port_handle,
1265                                   Ucs_SocketDirection_t direction,
1266                                   Ucs_Usb_SocketDataType_t data_type,
1267                                   uint8_t end_point_addr,
1268                                   uint16_t frames_per_transfer,
1269                                   CSingleObserver *obs_ptr)
1270 {
1271     Ucs_Return_t result = UCS_RET_SUCCESS;
1272
1273     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1274     {
1275         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 7U);
1276
1277         if (msg_ptr != NULL)
1278         {
1279             msg_ptr->destination_addr  = self->target_address;
1280
1281             msg_ptr->id.fblock_id   = FB_INIC;
1282             msg_ptr->id.instance_id = 0U;
1283             msg_ptr->id.function_id = INIC_FID_USB_SOCKET_CREATE;
1284             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1285
1286             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(usb_port_handle);
1287             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(usb_port_handle);
1288             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)direction;
1289             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)data_type;
1290             msg_ptr->tel.tel_data_ptr[4] = end_point_addr;
1291             msg_ptr->tel.tel_data_ptr[5] = MISC_HB(frames_per_transfer);
1292             msg_ptr->tel.tel_data_ptr[6] = MISC_LB(frames_per_transfer);
1293
1294             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1295             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1296             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1297
1298             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1299         }
1300         else
1301         {
1302             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1303             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1304         }
1305     }
1306     else
1307     {
1308         result = UCS_RET_ERR_API_LOCKED;
1309     }
1310
1311     return result;
1312 }
1313
1314 /*! \brief  This function is used to configure the Streaming Ports.
1315  *  \param  self                Reference to CInic instance
1316  *  \param  index               Streaming Port instance
1317  *  \param  op_mode             Streaming Port Operation mode
1318  *  \param  port_option         Streaming Port Options
1319  *  \param  clock_mode          Stream Port Clock Mode
1320  *  \param  clock_data_delay    Stream Port Clock Data Delay
1321  *  \param  obs_ptr             Reference to an optional observer
1322  *  \return UCS_RET_SUCCESS               message was created
1323  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1324  */
1325 Ucs_Return_t Inic_StreamPortConfig_SetGet(CInic *self,
1326                                           uint8_t index,
1327                                           Ucs_Stream_PortOpMode_t op_mode,
1328                                           Ucs_Stream_PortOption_t port_option,
1329                                           Ucs_Stream_PortClockMode_t clock_mode,
1330                                           Ucs_Stream_PortClockDataDelay_t clock_data_delay,
1331                                           CSingleObserver *obs_ptr)
1332 {
1333     Ucs_Return_t result = UCS_RET_SUCCESS;
1334
1335     if(Al_Lock(&self->lock.res_api, INIC_API_STREAM_PORT_CONFIG) != false)
1336     {
1337         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 5U);
1338
1339         if (msg_ptr != NULL)
1340         {
1341             msg_ptr->destination_addr    = self->target_address;
1342             msg_ptr->id.fblock_id        = FB_INIC;
1343             msg_ptr->id.instance_id      = 0U;
1344             msg_ptr->id.function_id      = INIC_FID_STREAM_PORT_CONFIG;
1345             msg_ptr->id.op_type          = UCS_OP_SETGET;
1346
1347             msg_ptr->tel.tel_data_ptr[0] = (uint8_t)index;
1348             msg_ptr->tel.tel_data_ptr[1] = (uint8_t)op_mode;
1349             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)port_option;
1350             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)clock_mode;
1351             msg_ptr->tel.tel_data_ptr[4] = (uint8_t)clock_data_delay;
1352
1353             self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG].user_mask = INIC_API_STREAM_PORT_CONFIG;
1354             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG];
1355             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1356
1357             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG], obs_ptr);
1358         }
1359         else
1360         {
1361             Al_Release(&self->lock.res_api, INIC_API_STREAM_PORT_CONFIG);
1362             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1363         }
1364     }
1365     else
1366     {
1367         result = UCS_RET_ERR_API_LOCKED;
1368     }
1369
1370     return result;
1371 }
1372
1373 /*! \brief  This function is used to request the configurations of the Streaming Ports.
1374  *  \param  self            Reference to CInic instance
1375  *  \param  index           Streaming Port Instance ID
1376  *  \param  obs_ptr         Reference to an optional observer
1377  *  \return UCS_RET_SUCCESS               message was created
1378  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1379  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1380  */
1381 Ucs_Return_t Inic_StreamPortConfig_Get(CInic *self,
1382                                        uint8_t index,
1383                                        CSingleObserver *obs_ptr)
1384 {
1385     Ucs_Return_t result = UCS_RET_SUCCESS;
1386
1387     if(Al_Lock(&self->lock.res_api, INIC_API_STREAM_PORT_CONFIG) != false)
1388     {
1389         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 1U);
1390
1391         if (msg_ptr != NULL)
1392         {
1393             msg_ptr->destination_addr    = self->target_address;
1394
1395             msg_ptr->id.fblock_id        = FB_INIC;
1396             msg_ptr->id.instance_id      = 0U;
1397             msg_ptr->id.function_id      = INIC_FID_STREAM_PORT_CONFIG;
1398             msg_ptr->id.op_type          = UCS_OP_GET;
1399
1400             msg_ptr->tel.tel_data_ptr[0] = (uint8_t)index;
1401
1402             self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG].user_mask = INIC_API_STREAM_PORT_CONFIG;
1403             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG];
1404             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1405
1406             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_STREAM_PORT_CONFIG], obs_ptr);
1407         }
1408         else
1409         {
1410             Al_Release(&self->lock.res_api, INIC_API_STREAM_PORT_CONFIG);
1411             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1412         }
1413     }
1414     else
1415     {
1416         result = UCS_RET_ERR_API_LOCKED;
1417     }
1418
1419     return result;
1420 }
1421
1422 /*! \brief  This function creates the Streaming Port with its associated port instance identifier.
1423  *  \param  self            Reference to CInic instance
1424  *  \param  index           Streaming Port instance
1425  *  \param  clock_config    Clock speed configuration of the  SCK  signal
1426  *  \param  data_alignment  Defines the alignment of the data bytes within the streaming port frame
1427  *  \param  obs_ptr         Reference to an optional observer
1428  *  \return UCS_RET_SUCCESS               message was created
1429  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1430  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1431  */
1432 Ucs_Return_t Inic_StreamPortCreate(CInic *self,
1433                                    uint8_t index,
1434                                    Ucs_Stream_PortClockConfig_t clock_config,
1435                                    Ucs_Stream_PortDataAlign_t data_alignment,
1436                                    CSingleObserver *obs_ptr)
1437 {
1438     Ucs_Return_t result = UCS_RET_SUCCESS;
1439
1440     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1441     {
1442         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 3U);
1443
1444         if (msg_ptr != NULL)
1445         {
1446             msg_ptr->destination_addr  = self->target_address;
1447
1448             msg_ptr->id.fblock_id   = FB_INIC;
1449             msg_ptr->id.instance_id = 0U;
1450             msg_ptr->id.function_id = INIC_FID_STREAM_PORT_CREATE;
1451             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1452
1453             msg_ptr->tel.tel_data_ptr[0] = index;
1454             msg_ptr->tel.tel_data_ptr[1] = (uint8_t)clock_config;
1455             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)data_alignment;
1456
1457             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1458             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1459             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1460
1461             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1462         }
1463         else
1464         {
1465             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1466             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1467         }
1468     }
1469     else
1470     {
1471         result = UCS_RET_ERR_API_LOCKED;
1472     }
1473
1474     return result;
1475 }
1476
1477 /*! \brief  This function creates a Synchronous or DiscreteFrame Isochronous Streaming data socket
1478  *          bound to the Streaming Port with the denoted port instance identifier.
1479  *  \param  self                Reference to CInic instance
1480  *  \param  stream_port_handle  Streaming Port resource handle
1481  *  \param  direction           Indicates the direction of the data stream, from the INIC's
1482  *                              perspective
1483  *  \param  data_type           Specifies the data type
1484  *  \param  bandwidth           Required socket bandwidth in bytes
1485  *  \param  stream_pin_id       ID of the serial interface pin of the addressed Streaming Port
1486  *                              instance
1487  *  \param  obs_ptr             Reference to an optional observer
1488  *  \return UCS_RET_SUCCESS               message was created
1489  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1490  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1491  */
1492 Ucs_Return_t Inic_StreamSocketCreate(CInic *self,
1493                                      uint16_t stream_port_handle,
1494                                      Ucs_SocketDirection_t direction,
1495                                      Ucs_Stream_SocketDataType_t data_type,
1496                                      uint16_t bandwidth,
1497                                      Ucs_Stream_PortPinId_t stream_pin_id,
1498                                      CSingleObserver *obs_ptr)
1499 {
1500     Ucs_Return_t result = UCS_RET_SUCCESS;
1501
1502     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1503     {
1504         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 7U);
1505
1506         if (msg_ptr != NULL)
1507         {
1508             msg_ptr->destination_addr  = self->target_address;
1509
1510             msg_ptr->id.fblock_id   = FB_INIC;
1511             msg_ptr->id.instance_id = 0U;
1512             msg_ptr->id.function_id = INIC_FID_STREAM_SOCKET_CREATE;
1513             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1514
1515             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(stream_port_handle);
1516             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(stream_port_handle);
1517             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)direction;
1518             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)data_type;
1519             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(bandwidth);
1520             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(bandwidth);
1521             msg_ptr->tel.tel_data_ptr[6] = (uint8_t)stream_pin_id;
1522
1523             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1524             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1525             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1526
1527             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1528         }
1529         else
1530         {
1531             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1532             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1533         }
1534     }
1535     else
1536     {
1537         result = UCS_RET_ERR_API_LOCKED;
1538     }
1539
1540     return result;
1541 }
1542
1543 /*! \brief  This function creates an RMCK Port with its associated port instance identifier.
1544  *  \param  self            Reference to CInic instance
1545  *  \param  index           RMCK Port instance
1546  *  \param  clock_source    Indicates the source of the RMCK clock
1547  *  \param  divisor         Divisor of the clock source
1548  *  \param  obs_ptr         Reference to an optional observer
1549  *  \return UCS_RET_SUCCESS               message was created
1550  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1551  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1552  */
1553 Ucs_Return_t Inic_RmckPortCreate(CInic *self,
1554                                     uint8_t index,
1555                                     Ucs_Rmck_PortClockSource_t clock_source,
1556                                     uint16_t divisor,
1557                                     CSingleObserver *obs_ptr)
1558 {
1559     Ucs_Return_t result = UCS_RET_SUCCESS;
1560
1561     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1562     {
1563         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
1564
1565         if (msg_ptr != NULL)
1566         {
1567             msg_ptr->destination_addr  = self->target_address;
1568
1569             msg_ptr->id.fblock_id   = FB_INIC;
1570             msg_ptr->id.instance_id = 0U;
1571             msg_ptr->id.function_id = INIC_FID_RMCK_PORT_CREATE;
1572             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1573
1574             msg_ptr->tel.tel_data_ptr[0] = index;
1575             msg_ptr->tel.tel_data_ptr[1] = (uint8_t)clock_source;
1576             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(divisor);
1577             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(divisor);
1578
1579             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1580             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1581             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1582
1583             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1584         }
1585         else
1586         {
1587             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1588             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1589         }
1590     }
1591     else
1592     {
1593         result = UCS_RET_ERR_API_LOCKED;
1594     }
1595
1596     return result;
1597 }
1598
1599 /*! \brief  This function creates an I2C Port with its associated port instance identifier.
1600  *  \param  self            Reference to CInic instance
1601  *  \param  index           I2C Port instance
1602  *  \param  address         The 7-bit I2C slave address of the peripheral to be read.
1603  *  \param  mode            The operation mode of the I2C Port
1604  *  \param  speed           The speed grade of the I2C Port
1605  *  \param  obs_ptr         Reference to an optional observer
1606  *  \return UCS_RET_SUCCESS               message was created
1607  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1608  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1609  */
1610 Ucs_Return_t Inic_I2cPortCreate(CInic *self,
1611                                 uint8_t index,
1612                                 uint8_t address,
1613                                 uint8_t mode,
1614                                 Ucs_I2c_Speed_t speed,
1615                                 CSingleObserver *obs_ptr)
1616 {
1617     Ucs_Return_t result = UCS_RET_SUCCESS;
1618
1619     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1620     {
1621         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
1622
1623         if (msg_ptr != NULL)
1624         {
1625             msg_ptr->destination_addr  = self->target_address;
1626
1627             msg_ptr->id.fblock_id   = FB_INIC;
1628             msg_ptr->id.instance_id = 0U;
1629             msg_ptr->id.function_id = INIC_FID_I2C_PORT_CREATE;
1630             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1631
1632             msg_ptr->tel.tel_data_ptr[0] = index;
1633             msg_ptr->tel.tel_data_ptr[1] = address;
1634             msg_ptr->tel.tel_data_ptr[2] = mode;
1635             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)speed;
1636
1637             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1638             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1639             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1640
1641             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1642         }
1643         else
1644         {
1645             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1646             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1647         }
1648     }
1649     else
1650     {
1651         result = UCS_RET_ERR_API_LOCKED;
1652     }
1653
1654     return result;
1655 }
1656
1657 /*! \brief  This function reads a block of bytes from an I2C device at a specified I2C address.
1658  *  \param  self            Reference to CInic instance
1659  *  \param  port_handle     Port resource handle
1660  *  \param  slave_address   The 7-bit I2C slave address of the peripheral to be read
1661  *  \param  data_len        Number of bytes to be read from the address
1662  *  \param  timeout         The timeout for the I2C Port read
1663  *  \param  obs_ptr         Reference to an optional observer
1664  *  \return UCS_RET_SUCCESS               message was created
1665  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1666  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1667  */
1668 Ucs_Return_t Inic_I2cPortRead(CInic *self,
1669                               uint16_t port_handle,
1670                               uint8_t slave_address,
1671                               uint8_t data_len,
1672                               uint16_t timeout,
1673                               CSingleObserver *obs_ptr)
1674 {
1675     Ucs_Return_t result = UCS_RET_SUCCESS;
1676
1677     if(Al_Lock(&self->lock.res_api, INIC_API_I2C_PORT_WR) != false)
1678     {
1679         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
1680
1681         if (msg_ptr != NULL)
1682         {
1683             msg_ptr->destination_addr  = self->target_address;
1684
1685             msg_ptr->id.fblock_id   = FB_INIC;
1686             msg_ptr->id.instance_id = 0U;
1687             msg_ptr->id.function_id = INIC_FID_I2C_PORT_READ;
1688             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1689
1690             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(port_handle);
1691             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(port_handle);
1692             msg_ptr->tel.tel_data_ptr[2] = slave_address;
1693             msg_ptr->tel.tel_data_ptr[3] = data_len;
1694             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(timeout);
1695             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(timeout);
1696
1697             self->ssubs[INIC_SSUB_I2C_PORT_WR].user_mask = INIC_API_I2C_PORT_WR;
1698             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_I2C_PORT_WR];
1699             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1700
1701             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_I2C_PORT_WR], obs_ptr);
1702         }
1703         else
1704         {
1705             Al_Release(&self->lock.res_api, INIC_API_I2C_PORT_WR);
1706             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1707         }
1708     }
1709     else
1710     {
1711         result = UCS_RET_ERR_API_LOCKED;
1712     }
1713
1714     return result;
1715 }
1716
1717 /*! \brief  This function writes a block of bytes to an I2C device at a specified I2C address.
1718  *  \param  self            Reference to CInic instance
1719  *  \param  port_handle     Port resource handle
1720  *  \param  mode            The write transfer mode
1721  *  \param  block_count     The number of blocks to be written to the I2C address.
1722  *  \param  slave_address   The 7-bit I2C slave address of the peripheral to be read
1723  *  \param  timeout         The timeout for the I2C Port write
1724  *  \param  data_len        Number of bytes to be written to the addressed I2C peripheral
1725  *  \param  data_list       Reference to the data list to be written
1726  *  \param  obs_ptr         Reference to an optional observer
1727  *  \return UCS_RET_SUCCESS               message was created
1728  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1729  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1730  */
1731 Ucs_Return_t Inic_I2cPortWrite(CInic *self,
1732                               uint16_t port_handle,
1733                               Ucs_I2c_TrMode_t mode,
1734                               uint8_t block_count,
1735                               uint8_t slave_address,
1736                               uint16_t timeout,
1737                               uint8_t data_len,
1738                               uint8_t data_list[],
1739                               CSingleObserver *obs_ptr)
1740 {
1741     Ucs_Return_t result = UCS_RET_SUCCESS;
1742
1743     if(Al_Lock(&self->lock.res_api, INIC_API_I2C_PORT_WR) != false)
1744     {
1745         uint8_t i;
1746         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, (8U + data_len));
1747
1748         if (msg_ptr != NULL)
1749         {
1750             msg_ptr->destination_addr  = self->target_address;
1751
1752             msg_ptr->id.fblock_id   = FB_INIC;
1753             msg_ptr->id.instance_id = 0U;
1754             msg_ptr->id.function_id = INIC_FID_I2C_PORT_WRITE;
1755             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1756
1757             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(port_handle);
1758             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(port_handle);
1759             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)mode;
1760             msg_ptr->tel.tel_data_ptr[3] = block_count;
1761             msg_ptr->tel.tel_data_ptr[4] = slave_address;
1762             msg_ptr->tel.tel_data_ptr[5] = (mode == UCS_I2C_BURST_MODE)  ? (data_len/block_count):data_len;
1763             msg_ptr->tel.tel_data_ptr[6] = MISC_HB(timeout);
1764             msg_ptr->tel.tel_data_ptr[7] = MISC_LB(timeout);
1765
1766             if (data_list != NULL)
1767             {
1768                 for (i = 0U; i < data_len; i++)
1769                 {
1770                     msg_ptr->tel.tel_data_ptr[8U + i] = data_list[i];
1771                 }
1772             }
1773
1774             self->ssubs[INIC_SSUB_I2C_PORT_WR].user_mask = INIC_API_I2C_PORT_WR;
1775             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_I2C_PORT_WR];
1776             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1777
1778             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_I2C_PORT_WR], obs_ptr);
1779         }
1780         else
1781         {
1782             Al_Release(&self->lock.res_api, INIC_API_I2C_PORT_WR);
1783             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1784         }
1785     }
1786     else
1787     {
1788         result = UCS_RET_ERR_API_LOCKED;
1789     }
1790
1791     return result;
1792 }
1793
1794 /*! \brief  This function creates an PCIe Port with its associated port instance identifier.
1795  *  \param  self            Reference to CInic instance
1796  *  \param  index           PCIe Port instance
1797  *  \param  obs_ptr         Reference to an optional observer
1798  *  \return UCS_RET_SUCCESS               message was created
1799  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1800  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1801  */
1802 Ucs_Return_t Inic_PciPortCreate(CInic *self,
1803                                 uint8_t index,
1804                                 CSingleObserver *obs_ptr)
1805 {
1806     Ucs_Return_t result = UCS_RET_SUCCESS;
1807
1808     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1809     {
1810         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 1U);
1811
1812         if (msg_ptr != NULL)
1813         {
1814             msg_ptr->destination_addr  = self->target_address;
1815
1816             msg_ptr->id.fblock_id   = FB_INIC;
1817             msg_ptr->id.instance_id = 0U;
1818             msg_ptr->id.function_id = INIC_FID_PCI_PORT_CREATE;
1819             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1820
1821             msg_ptr->tel.tel_data_ptr[0] = index;
1822
1823             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1824             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1825             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1826
1827             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1828         }
1829         else
1830         {
1831             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1832             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1833         }
1834     }
1835     else
1836     {
1837         result = UCS_RET_ERR_API_LOCKED;
1838     }
1839
1840     return result;
1841 }
1842
1843 /*! \brief  This function creates a PCIe socket bound to the PCIe Port with the associated port
1844  *          instance identifier. If the EHC detaches, the PCIe socket will be automatically
1845  *          destroyed.
1846  *  \param  self                 Reference to CInic instance
1847  *  \param  pci_port_handle      PCIe Port resource handle
1848  *  \param  direction            Indicates the direction of the data stream from the perspective of
1849  *                               the INIC
1850  *  \param  data_type            Specifies the data type
1851  *  \param  dma_channel          Specifies the DMA channel
1852  *  \param  obs_ptr              Reference to an optional observer
1853  *  \return UCS_RET_SUCCESS               message was created
1854  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1855  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1856  */
1857 Ucs_Return_t Inic_PciSocketCreate(CInic *self,
1858                                   uint16_t pci_port_handle,
1859                                   Ucs_SocketDirection_t direction,
1860                                   Ucs_Pci_SocketDataType_t data_type,
1861                                   uint8_t dma_channel,
1862                                   CSingleObserver *obs_ptr)
1863 {
1864     Ucs_Return_t result = UCS_RET_SUCCESS;
1865
1866     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1867     {
1868         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 5U);
1869
1870         if (msg_ptr != NULL)
1871         {
1872             msg_ptr->destination_addr  = self->target_address;
1873
1874             msg_ptr->id.fblock_id   = FB_INIC;
1875             msg_ptr->id.instance_id = 0U;
1876             msg_ptr->id.function_id = INIC_FID_PCI_SOCKET_CREATE;
1877             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1878
1879             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(pci_port_handle);
1880             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(pci_port_handle);
1881             msg_ptr->tel.tel_data_ptr[2] = (uint8_t)direction;
1882             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)data_type;
1883             msg_ptr->tel.tel_data_ptr[4] = dma_channel;
1884
1885             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1886             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1887             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1888
1889             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1890         }
1891         else
1892         {
1893             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1894             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1895         }
1896     }
1897     else
1898     {
1899         result = UCS_RET_ERR_API_LOCKED;
1900     }
1901
1902     return result;
1903 }
1904
1905 /*! \brief  This function creates a GPIO Port with its associated port instance identifier.
1906  *  \param  self            Reference to CInic instance
1907  *  \param  gpio_port_index GPIO Port instance
1908  *  \param  debounce_time   Timeout for the GPIO debounce timer
1909  *  \param  obs_ptr              Reference to an optional observer
1910  *  \return UCS_RET_SUCCESS               message was created
1911  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1912  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1913  */
1914 Ucs_Return_t Inic_GpioPortCreate(CInic *self,
1915                                   uint8_t gpio_port_index,
1916                                   uint16_t debounce_time,
1917                                   CSingleObserver *obs_ptr)
1918 {
1919     Ucs_Return_t result = UCS_RET_SUCCESS;
1920
1921     if(Al_Lock(&self->lock.res_api, INIC_API_CREATE_CLASS) != false)
1922     {
1923         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 3U);
1924
1925         if (msg_ptr != NULL)
1926         {
1927             msg_ptr->destination_addr  = self->target_address;
1928
1929             msg_ptr->id.fblock_id   = FB_INIC;
1930             msg_ptr->id.instance_id = 0U;
1931             msg_ptr->id.function_id = INIC_FID_GPIO_PORT_CREATE;
1932             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1933
1934             msg_ptr->tel.tel_data_ptr[0] = gpio_port_index;
1935             msg_ptr->tel.tel_data_ptr[1] = MISC_HB(debounce_time);
1936             msg_ptr->tel.tel_data_ptr[2] = MISC_LB(debounce_time);
1937
1938             self->ssubs[INIC_SSUB_CREATE_CLASS].user_mask = INIC_API_CREATE_CLASS;
1939             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_CREATE_CLASS];
1940             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1941
1942             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_CREATE_CLASS], obs_ptr);
1943         }
1944         else
1945         {
1946             Al_Release(&self->lock.res_api, INIC_API_CREATE_CLASS);
1947             result = UCS_RET_ERR_BUFFER_OVERFLOW;
1948         }
1949     }
1950     else
1951     {
1952         result = UCS_RET_ERR_API_LOCKED;
1953     }
1954
1955     return result;
1956 }
1957
1958 /*! \brief  This function enables or disables a specific MOST Network Port.
1959  *  \param  self                Reference to CInic instance
1960  *  \param  most_port_handle    Port resource handle
1961  *  \param  enabled             Indicates whether a MOST Network Port should be enabled or disabled
1962  *  \param  obs_ptr             Reference to an optional observer
1963  *  \return UCS_RET_SUCCESS               message was created
1964  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
1965  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
1966  */
1967 Ucs_Return_t Inic_MostPortEnable(CInic *self,
1968                                  uint16_t most_port_handle,
1969                                  bool enabled,
1970                                  CSingleObserver *obs_ptr)
1971 {
1972     Ucs_Return_t result = UCS_RET_SUCCESS;
1973
1974     if(Al_Lock(&self->lock.res_api, INIC_API_MOST_PORT_ENABLE) != false)
1975     {
1976         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 3U);
1977
1978         if (msg_ptr != NULL)
1979         {
1980             msg_ptr->destination_addr  = self->target_address;
1981
1982             msg_ptr->id.fblock_id   = FB_INIC;
1983             msg_ptr->id.instance_id = 0U;
1984             msg_ptr->id.function_id = INIC_FID_MOST_PORT_ENABLE;
1985             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
1986
1987             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(most_port_handle);
1988             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(most_port_handle);
1989             msg_ptr->tel.tel_data_ptr[2] = (enabled != false) ? 1U : 0U;
1990
1991             self->ssubs[INIC_SSUB_MOST_PORT_ENABLE].user_mask = INIC_API_MOST_PORT_ENABLE;
1992             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_MOST_PORT_ENABLE];
1993             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
1994
1995             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_MOST_PORT_ENABLE], obs_ptr);
1996         }
1997         else
1998         {
1999             Al_Release(&self->lock.res_api, INIC_API_MOST_PORT_ENABLE);
2000             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2001         }
2002     }
2003     else
2004     {
2005         result = UCS_RET_ERR_API_LOCKED;
2006     }
2007
2008     return result;
2009 }
2010
2011 /*! \brief  This function retrieves the current pin mode of the given GPIO Port.
2012  *  \param  self              Reference to CInic instance
2013  *  \param  gpio_handle       GPIO Port instance
2014  *  \param  obs_ptr           Reference to an optional observer
2015  *  \return UCS_RET_SUCCESS               message was created
2016  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
2017  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
2018  */
2019 Ucs_Return_t  Inic_GpioPortPinMode_Get(CInic *self, uint16_t gpio_handle, CSingleObserver *obs_ptr)
2020 {
2021     Ucs_Return_t result = UCS_RET_SUCCESS;
2022
2023     if(Al_Lock(&self->lock.res_api, INIC_API_GPIO_PIN_MODE) != false)
2024     {
2025         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
2026
2027         if (msg_ptr != NULL)
2028         {
2029             msg_ptr->destination_addr  = self->target_address;
2030
2031             msg_ptr->id.fblock_id   = FB_INIC;
2032             msg_ptr->id.instance_id = 0U;
2033             msg_ptr->id.function_id = INIC_FID_GPIO_PORT_PIN_MODE;
2034             msg_ptr->id.op_type     = UCS_OP_GET;
2035
2036             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(gpio_handle);
2037             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(gpio_handle);
2038
2039             self->ssubs[INIC_SSUB_GPIO_PIN_MODE].user_mask = INIC_API_GPIO_PIN_MODE;
2040             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_GPIO_PIN_MODE];
2041             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2042
2043             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_GPIO_PIN_MODE], obs_ptr);
2044         }
2045         else
2046         {
2047             Al_Release(&self->lock.res_api, INIC_API_GPIO_PIN_MODE);
2048             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2049         }
2050     }
2051     else
2052     {
2053         result = UCS_RET_ERR_API_LOCKED;
2054     }
2055
2056     return result;
2057 }
2058
2059 /*! \brief  This function sets and retrieves the mode of a pin on the GPIO Port
2060  *  \param  self              Reference to CInic instance
2061  *  \param  gpio_handle       GPIO Port instance
2062  *  \param  pin               The GPIO pin that is to be configured
2063  *  \param  mode              The mode of the GPIO pin
2064  *  \param  obs_ptr           Reference to an optional observer
2065  *  \return UCS_RET_SUCCESS               message was created
2066  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
2067  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
2068  */
2069 Ucs_Return_t  Inic_GpioPortPinMode_SetGet(CInic *self, uint16_t gpio_handle, uint8_t pin, Ucs_Gpio_PinMode_t mode, CSingleObserver *obs_ptr)
2070 {
2071     Ucs_Return_t result = UCS_RET_SUCCESS;
2072
2073     if(Al_Lock(&self->lock.res_api, INIC_API_GPIO_PIN_MODE) != false)
2074     {
2075         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 4U);
2076
2077         if (msg_ptr != NULL)
2078         {
2079             msg_ptr->destination_addr  = self->target_address;
2080
2081             msg_ptr->id.fblock_id   = FB_INIC;
2082             msg_ptr->id.instance_id = 0U;
2083             msg_ptr->id.function_id = INIC_FID_GPIO_PORT_PIN_MODE;
2084             msg_ptr->id.op_type     = UCS_OP_SETGET;
2085
2086             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(gpio_handle);
2087             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(gpio_handle);
2088             msg_ptr->tel.tel_data_ptr[2] = pin;
2089             msg_ptr->tel.tel_data_ptr[3] = (uint8_t)mode;
2090
2091             self->ssubs[INIC_SSUB_GPIO_PIN_MODE].user_mask = INIC_API_GPIO_PIN_MODE;
2092             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_GPIO_PIN_MODE];
2093             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2094
2095             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_GPIO_PIN_MODE], obs_ptr);
2096         }
2097         else
2098         {
2099             Al_Release(&self->lock.res_api, INIC_API_GPIO_PIN_MODE);
2100             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2101         }
2102     }
2103     else
2104     {
2105         result = UCS_RET_ERR_API_LOCKED;
2106     }
2107
2108     return result;
2109 }
2110
2111 /*! \brief  This function retrieves the pin state of the given GPIO Port.
2112  *  \param  self              Reference to CInic instance
2113  *  \param  gpio_handle       GPIO Port instance
2114  *  \param  obs_ptr           Reference to an optional observer
2115  *  \return UCS_RET_SUCCESS               message was created
2116  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
2117  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
2118  */
2119 Ucs_Return_t  Inic_GpioPortPinState_Get(CInic *self, uint16_t gpio_handle, CSingleObserver *obs_ptr)
2120 {
2121     Ucs_Return_t result = UCS_RET_SUCCESS;
2122
2123     if(Al_Lock(&self->lock.res_api, INIC_API_GPIO_PIN_STATE) != false)
2124     {
2125         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 2U);
2126
2127         if (msg_ptr != NULL)
2128         {
2129             msg_ptr->destination_addr  = self->target_address;
2130
2131             msg_ptr->id.fblock_id   = FB_INIC;
2132             msg_ptr->id.instance_id = 0U;
2133             msg_ptr->id.function_id = INIC_FID_GPIO_PORT_PIN_STATE;
2134             msg_ptr->id.op_type     = UCS_OP_GET;
2135
2136             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(gpio_handle);
2137             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(gpio_handle);
2138
2139             self->ssubs[INIC_SSUB_GPIO_PIN_STATE].user_mask = INIC_API_GPIO_PIN_STATE;
2140             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_GPIO_PIN_STATE];
2141             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2142
2143             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_GPIO_PIN_STATE], obs_ptr);
2144         }
2145         else
2146         {
2147             Al_Release(&self->lock.res_api, INIC_API_GPIO_PIN_STATE);
2148             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2149         }
2150     }
2151     else
2152     {
2153         result = UCS_RET_ERR_API_LOCKED;
2154     }
2155
2156     return result;
2157 }
2158
2159 /*! \brief  This function sets and retrieves the state of a pin on the GPIO Port
2160  *  \param  self              Reference to CInic instance
2161  *  \param  gpio_handle       GPIO Port instance
2162  *  \param  mask              The GPIO pins to be written
2163  *  \param  data              The state of the GPIO pins to be written
2164  *  \param  obs_ptr           Reference to an optional observer
2165  *  \return UCS_RET_SUCCESS               message was created
2166  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
2167  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
2168  */
2169 Ucs_Return_t  Inic_GpioPortPinState_SetGet(CInic *self, uint16_t gpio_handle, uint16_t mask, uint16_t data, CSingleObserver *obs_ptr)
2170 {
2171     Ucs_Return_t result = UCS_RET_SUCCESS;
2172
2173     if(Al_Lock(&self->lock.res_api, INIC_API_GPIO_PIN_STATE) != false)
2174     {
2175         Msg_MostTel_t *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 6U);
2176
2177         if (msg_ptr != NULL)
2178         {
2179             msg_ptr->destination_addr  = self->target_address;
2180
2181             msg_ptr->id.fblock_id   = FB_INIC;
2182             msg_ptr->id.instance_id = 0U;
2183             msg_ptr->id.function_id = INIC_FID_GPIO_PORT_PIN_STATE;
2184             msg_ptr->id.op_type     = UCS_OP_SETGET;
2185
2186             msg_ptr->tel.tel_data_ptr[0] = MISC_HB(gpio_handle);
2187             msg_ptr->tel.tel_data_ptr[1] = MISC_LB(gpio_handle);
2188             msg_ptr->tel.tel_data_ptr[2] = MISC_HB(mask);
2189             msg_ptr->tel.tel_data_ptr[3] = MISC_LB(mask);
2190             msg_ptr->tel.tel_data_ptr[4] = MISC_HB(data);
2191             msg_ptr->tel.tel_data_ptr[5] = MISC_LB(data);
2192
2193             self->ssubs[INIC_SSUB_GPIO_PIN_STATE].user_mask = INIC_API_GPIO_PIN_STATE;
2194             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_GPIO_PIN_STATE];
2195             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2196
2197             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_GPIO_PIN_STATE], obs_ptr);
2198         }
2199         else
2200         {
2201             Al_Release(&self->lock.res_api, INIC_API_GPIO_PIN_STATE);
2202             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2203         }
2204     }
2205     else
2206     {
2207         result = UCS_RET_ERR_API_LOCKED;
2208     }
2209
2210     return result;
2211 }
2212
2213 /*! \brief  This function enables full streaming for a specific MOST Network Port.
2214  *  \param  self                Reference to CInic instance
2215  *  \param  most_port_handle    Port resource handle
2216  *  \param  enabled             Indicates whether full streaming is enabled or disabled
2217  *  \param  obs_ptr             Reference to an optional observer
2218  *  \return UCS_RET_SUCCESS               message was created
2219  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available
2220  *  \return UCS_RET_ERR_API_LOCKED        Resource API is already used by another command
2221  */
2222 Ucs_Return_t Inic_MostPortEnFullStr(CInic *self,
2223                                     uint16_t most_port_handle,
2224                                     bool enabled,
2225                                     CSingleObserver *obs_ptr)
2226 {
2227     MISC_UNUSED(self);
2228     MISC_UNUSED(most_port_handle);
2229     MISC_UNUSED(enabled);
2230     MISC_UNUSED(obs_ptr);
2231
2232     return UCS_RET_ERR_NOT_SUPPORTED;
2233 }
2234
2235 /*! \brief  Allows remote synchronization of the given device
2236  *  \param  self            Reference to CInic instance
2237  *  \param  obs_ptr         Reference to an optional observer
2238  *  \return UCS_RET_SUCCESS               message was created 
2239  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available 
2240  */
2241 Ucs_Return_t Inic_DeviceSync(CInic *self, CSingleObserver *obs_ptr)
2242 {
2243     Ucs_Return_t     result = UCS_RET_SUCCESS;
2244
2245     if(Al_Lock(&self->lock.res_api, INIC_API_DEVICE_SYNC) != false)
2246     {
2247         Msg_MostTel_t   *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 1U);
2248
2249         if (msg_ptr != NULL)
2250         {
2251             msg_ptr->destination_addr  = self->target_address;
2252
2253             msg_ptr->id.fblock_id   = FB_INIC;
2254             msg_ptr->id.instance_id = 0U;
2255             msg_ptr->id.function_id = INIC_FID_DEVICE_SYNC;
2256             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
2257
2258             msg_ptr->tel.tel_data_ptr[0] = 0x01U;
2259
2260             self->ssubs[INIC_SSUB_DEVICE_SYNC].user_mask = INIC_API_DEVICE_SYNC;
2261             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_DEVICE_SYNC];
2262             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2263
2264             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_DEVICE_SYNC], obs_ptr);
2265         }
2266         else
2267         {
2268             Al_Release(&self->lock.res_api, INIC_API_DEVICE_SYNC);
2269             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2270         }
2271     }
2272     else
2273     {
2274         result = UCS_RET_ERR_API_LOCKED;
2275     }
2276
2277     return result;
2278 }
2279
2280 /*! \brief  Un-synchronizes to the given remote device
2281  *  \param  self            Reference to CInic instance
2282  *  \param  obs_ptr         Reference to an optional observer
2283  *  \return UCS_RET_SUCCESS               message was created 
2284  *  \return UCS_RET_ERR_BUFFER_OVERFLOW   no message buffer available 
2285  */
2286 Ucs_Return_t Inic_DeviceUnsync(CInic *self, CSingleObserver *obs_ptr)
2287 {
2288     Ucs_Return_t     result = UCS_RET_SUCCESS;
2289     Msg_MostTel_t   *msg_ptr = Trcv_TxAllocateMsg(self->xcvr_ptr, 1U);
2290
2291     if(Al_Lock(&self->lock.res_api, INIC_API_DEVICE_SYNC) != false)
2292     {
2293         if (msg_ptr != NULL)
2294         {
2295             msg_ptr->destination_addr  = self->target_address;
2296
2297             msg_ptr->id.fblock_id   = FB_INIC;
2298             msg_ptr->id.instance_id = 0U;
2299             msg_ptr->id.function_id = INIC_FID_DEVICE_SYNC;
2300             msg_ptr->id.op_type     = UCS_OP_STARTRESULT;
2301
2302             msg_ptr->tel.tel_data_ptr[0] = 0U;
2303
2304             self->ssubs[INIC_SSUB_DEVICE_SYNC].user_mask = INIC_API_DEVICE_SYNC;
2305             msg_ptr->info_ptr = &self->ssubs[INIC_SSUB_DEVICE_SYNC];
2306             Trcv_TxSendMsgExt(self->xcvr_ptr, msg_ptr, &Inic_ResMsgTxStatusCb, self);
2307
2308             (void)Ssub_AddObserver(&self->ssubs[INIC_SSUB_DEVICE_SYNC], obs_ptr);
2309         }
2310         else
2311         {
2312             Al_Release(&self->lock.res_api, INIC_API_DEVICE_SYNC);
2313             result = UCS_RET_ERR_BUFFER_OVERFLOW;
2314         }
2315     }
2316     else
2317     {
2318         result = UCS_RET_ERR_API_LOCKED;
2319     }
2320
2321     return result;
2322 }
2323
2324 /*------------------------------------------------------------------------------------------------*/
2325 /* Handler functions                                                                              */
2326 /*------------------------------------------------------------------------------------------------*/
2327 /*! \brief Handle message Tx status, Unlock the API and free the message objects
2328  *  \param self     The instance
2329  *  \param tel_ptr  Reference to transmitted message
2330  *  \param status   Status of the transmitted message
2331  */
2332 static void Inic_ResMsgTxStatusCb(void *self, Msg_MostTel_t *tel_ptr, Ucs_MsgTxStatus_t status)
2333 {
2334     CInic *self_ = (CInic *)self;
2335     CSingleSubject *ssub_ptr = (CSingleSubject *)tel_ptr->info_ptr;
2336
2337     if ((status != UCS_MSG_STAT_OK) && (tel_ptr->info_ptr != NULL))
2338     {
2339         Inic_StdResult_t res_data;
2340
2341         res_data.data_info        = &status;
2342         res_data.result.code      = UCS_RES_ERR_TRANSMISSION;
2343         res_data.result.info_ptr  = NULL;
2344         res_data.result.info_size = 0U;
2345         Ssub_Notify(ssub_ptr, &res_data, true);
2346
2347         if ((ssub_ptr != NULL) && (ssub_ptr->user_mask != 0U))
2348         {
2349             Al_Release(&self_->lock.res_api, (Alm_ModuleMask_t)ssub_ptr->user_mask);
2350         }
2351     }
2352     Trcv_TxReleaseMsg(tel_ptr);
2353     /* Reset user mask of the single subject if available */
2354     if (ssub_ptr != NULL)
2355     {
2356         ssub_ptr->user_mask = 0U;
2357     }
2358
2359     /* ICM messages pending? */
2360     if (Sub_GetNumObservers(&self_->subs[INIC_SUB_TX_MSG_OBJ_AVAIL]) > 0U)
2361     {
2362         Sub_Notify(&self_->subs[INIC_SUB_TX_MSG_OBJ_AVAIL], NULL);
2363     }
2364 }
2365
2366 /*! \brief Handler function for INIC.ResourceDestroy.ErrorAck
2367  *  \param self     reference to INIC object
2368  *  \param msg_ptr  received message
2369  */
2370 void Inic_ResourceDestroy_Error(void *self, Msg_MostTel_t *msg_ptr)
2371 {
2372     CInic *self_ = (CInic *)self;
2373     Inic_StdResult_t res_data;
2374     res_data.data_info = NULL;
2375     res_data.result = Inic_TranslateError(self_,
2376                                           &msg_ptr->tel.tel_data_ptr[0],
2377                                           (msg_ptr->tel.tel_len));
2378     Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_DESTROY], &res_data, true);
2379     Al_Release(&self_->lock.res_api, INIC_API_RESOURCE_DESTROY);
2380 }
2381
2382 /*! \brief Handler function for INIC.ResourceDestroy.ResultAck
2383  *  \param self     reference to INIC object
2384  *  \param msg_ptr  received message
2385  */
2386 void Inic_ResourceDestroy_Result(void *self, Msg_MostTel_t *msg_ptr)
2387 {
2388     CInic *self_ = (CInic *)self;
2389     Inic_StdResult_t res_data;
2390     MISC_UNUSED(msg_ptr);
2391
2392     res_data.data_info       = NULL;
2393     res_data.result.code     = UCS_RES_SUCCESS;
2394     res_data.result.info_ptr = NULL;
2395     Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_DESTROY], &res_data, true);
2396     Al_Release(&self_->lock.res_api, INIC_API_RESOURCE_DESTROY);
2397 }
2398
2399 /*! \brief Handler function for INIC.ResourceInvalidList.Status
2400  *  \param self     reference to INIC object
2401  *  \param msg_ptr  received message
2402  */
2403 void Inic_ResourceInvalidList_Status(void *self, Msg_MostTel_t *msg_ptr)
2404 {
2405     CInic *self_ = (CInic *)self;
2406     Inic_StdResult_t res_data;
2407     Inic_ResHandleList_t result;
2408     uint8_t i;
2409     uint16_t inv_res_handles[22];   /* Max. ICM message size is 45 -> max. 22 16-bit values */
2410
2411     res_data.data_info       = &result;
2412     res_data.result.code     = UCS_RES_SUCCESS;
2413     res_data.result.info_ptr = NULL;
2414
2415     /* Length of message must be even, since 16-Bit values are transmitted via two 8-bit fields. */
2416     TR_ASSERT(self_->base_ptr->ucs_user_ptr, "[INIC_RES]", ((msg_ptr->tel.tel_len % 2U) == 0U));
2417
2418     for(i=0U; (i < (uint8_t)(msg_ptr->tel.tel_len >> 1)); i++)
2419     {
2420         MISC_DECODE_WORD(&inv_res_handles[i],
2421                          &(msg_ptr->tel.tel_data_ptr[(uint8_t)((uint8_t)i << 1)]));
2422     }
2423     result.res_handles = &inv_res_handles[0];
2424     result.num_handles = (uint8_t)((uint8_t)msg_ptr->tel.tel_len >> 1);
2425     Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST], &res_data, true);
2426     Al_Release(&self_->lock.res_api, INIC_API_RESOURCE_INVAL_LIST);
2427 }
2428
2429 /*! \brief Handler function for INIC.ResourceInvalidList.Error
2430  *  \param self     reference to INIC object
2431  *  \param msg_ptr  received message
2432  */
2433 void Inic_ResourceInvalidList_Error(void *self, Msg_MostTel_t *msg_ptr)
2434 {
2435     CInic *self_ = (CInic *)self;
2436     Inic_StdResult_t res_data;
2437
2438     res_data.data_info = NULL;
2439     res_data.result = Inic_TranslateError(self_,
2440                                           &msg_ptr->tel.tel_data_ptr[0],
2441                                           msg_ptr->tel.tel_len);
2442     Ssub_Notify(&self_->ssubs[INIC_SSUB_RESOURCE_INVAL_LIST], &res_data, true);
2443     Al_Release(&self_->lock.res_api, INIC_API_RESOURCE_INVAL_LIST);
2444 }
2445
2446 /*! \brief Handler function for INIC.ResourceMonitor.Status
2447  *  \param self     reference to INIC object
2448  *  \param msg_ptr  received message
2449  */
2450 void Inic_ResourceMonitor_Status(void *self, Msg_MostTel_t *msg_ptr)
2451 {
2452     CInic *self_ = (CInic *)self;
2453     Inic_StdResult_t res_data;
2454     Ucs_Resource_MonitorState_t state;
2455
2456     res_data.data_info       = &state;
2457     res_data.result.code     = UCS_RES_SUCCESS;
2458     res_data.result.info_ptr = NULL;
2459     state = (Ucs_Resource_MonitorState_t)msg_ptr->tel.tel_data_ptr[0];
2460     Sub_Notify(&self_->subs[INIC_SUB_RES_MONITOR], &res_data);
2461 }
2462
2463 /*! \brief Handler function for INIC.ResourceMonitor.Error
2464  *  \param self     reference to INIC object
2465  *  \param msg_ptr  received message
2466  */
2467 void Inic_ResourceMonitor_Error(void *self, Msg_MostTel_t *msg_ptr)
2468 {
2469     CInic *self_ = (CInic *)self;
2470     Inic_StdResult_t res_data;
2471
2472     res_data.data_info = NULL;
2473     res_data.result = Inic_TranslateError(self_,
2474                                           &msg_ptr->tel.tel_data_ptr[0],
2475                                           msg_ptr->tel.tel_len);
2476     Sub_Notify(&self_->subs[INIC_SUB_RES_MONITOR], &res_data);
2477 }
2478
2479 /*! \brief Handler function for INIC.SyncCreate.ErrorAck
2480  *  \param self     reference to INIC object
2481  *  \param msg_ptr  received message
2482  */
2483 void Inic_SyncCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2484 {
2485     CInic *self_ = (CInic *)self;
2486     Inic_StdResult_t res_data;
2487
2488     res_data.data_info = NULL;
2489     res_data.result = Inic_TranslateError(self_,
2490                                           &msg_ptr->tel.tel_data_ptr[0],
2491                                           (msg_ptr->tel.tel_len));
2492     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2493     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2494 }
2495
2496 /*! \brief Handler function for INIC.SyncCreate.ResultAck. res_data.data_info points to the
2497  *         resource handle of the synchronous connection which was created.
2498  *  \param self     reference to INIC object
2499  *  \param msg_ptr  received message
2500  */
2501 void Inic_SyncCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2502 {
2503     CInic *self_ = (CInic *)self;
2504     uint16_t handle;
2505     Inic_StdResult_t res_data;
2506
2507     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2508     res_data.data_info       = &handle;
2509     res_data.result.code     = UCS_RES_SUCCESS;
2510     res_data.result.info_ptr = NULL;
2511     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2512     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2513 }
2514
2515
2516 /*! \brief Handler function for INIC.SyncMute.ErrorAck
2517  * \param  self     reference to INIC object
2518  * \param  msg_ptr  received message
2519  */
2520 void Inic_SyncMute_Error(void *self, Msg_MostTel_t *msg_ptr)
2521 {
2522     CInic *self_ = (CInic *)self;
2523     Inic_StdResult_t res_data;
2524
2525     res_data.data_info  = NULL;
2526     res_data.result = Inic_TranslateError(self_,
2527                                           &msg_ptr->tel.tel_data_ptr[0],
2528                                           (msg_ptr->tel.tel_len));
2529     Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_MUTE], &res_data, true);
2530     Al_Release(&self_->lock.res_api, INIC_API_SYNC_MUTE);
2531 }
2532
2533 /*! \brief Handler function for INIC.SyncMute.ResultAck
2534  * \param  self     reference to INIC object
2535  * \param  msg_ptr  received message
2536  */
2537 void Inic_SyncMute_Result(void *self, Msg_MostTel_t *msg_ptr)
2538 {
2539     CInic *self_ = (CInic *)self;
2540     Inic_StdResult_t res_data;
2541
2542     MISC_UNUSED(msg_ptr);
2543
2544     res_data.data_info       = NULL;
2545     res_data.result.code     = UCS_RES_SUCCESS;
2546     res_data.result.info_ptr = NULL;
2547     Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_MUTE], &res_data, true);
2548     Al_Release(&self_->lock.res_api, INIC_API_SYNC_MUTE);
2549 }
2550
2551 /*! \brief Handler function for INIC.SyncDemute.ErrorAck
2552  * \param  self     reference to INIC object
2553  * \param  msg_ptr  received message
2554  */
2555 void Inic_SyncDemute_Error(void *self, Msg_MostTel_t *msg_ptr)
2556 {
2557     CInic *self_ = (CInic *)self;
2558     Inic_StdResult_t res_data;
2559
2560     res_data.data_info  = NULL;
2561     res_data.result = Inic_TranslateError(self_,
2562                                           &msg_ptr->tel.tel_data_ptr[0],
2563                                           (msg_ptr->tel.tel_len));
2564     Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_DEMUTE], &res_data, true);
2565     Al_Release(&self_->lock.res_api, INIC_API_SYNC_DEMUTE);
2566 }
2567
2568 /*! \brief Handler function for INIC.SyncDemute.ResultAck
2569  * \param  self     reference to INIC object
2570  * \param  msg_ptr  received message
2571  */
2572 void Inic_SyncDemute_Result(void *self, Msg_MostTel_t *msg_ptr)
2573 {
2574     CInic *self_ = (CInic *)self;
2575     Inic_StdResult_t res_data;
2576
2577     MISC_UNUSED(msg_ptr);
2578
2579     res_data.data_info       = NULL;
2580     res_data.result.code     = UCS_RES_SUCCESS;
2581     res_data.result.info_ptr = NULL;
2582     Ssub_Notify(&self_->ssubs[INIC_SSUB_SYNC_DEMUTE], &res_data, true);
2583     Al_Release(&self_->lock.res_api, INIC_API_SYNC_DEMUTE);
2584 }
2585
2586 /*! \brief Handler function for INIC.DFIPhaseCreate.ErrorAck
2587  *  \param self     reference to INIC object
2588  *  \param msg_ptr  received message
2589  */
2590 void Inic_DfiPhaseCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2591 {
2592     CInic *self_ = (CInic *)self;
2593     Inic_StdResult_t res_data;
2594
2595     res_data.data_info = NULL;
2596     res_data.result = Inic_TranslateError(self_,
2597                                           &msg_ptr->tel.tel_data_ptr[0],
2598                                           (msg_ptr->tel.tel_len));
2599     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2600     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2601 }
2602
2603 /*! \brief Handler function for INIC.DFIPhaseCreate.ResultAck. res_data.data_info points to the
2604  *         resource handle of the DFIPhase streaming phase connection which was created.
2605  *  \param self     reference to INIC object
2606  *  \param msg_ptr  received message
2607  */
2608 void Inic_DfiPhaseCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2609 {
2610     CInic *self_ = (CInic *)self;
2611     uint16_t handle;
2612     Inic_StdResult_t res_data;
2613
2614     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2615     res_data.data_info       = &handle;
2616     res_data.result.code     = UCS_RES_SUCCESS;
2617     res_data.result.info_ptr = NULL;
2618     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2619     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2620 }
2621
2622 /*! \brief Handler function for INIC.CombinerCreate.ErrorAck
2623  * \param  self     reference to INIC object
2624  * \param  msg_ptr  received message
2625  */
2626 void Inic_CombinerCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2627 {
2628     CInic *self_ = (CInic *)self;
2629     Inic_StdResult_t res_data;
2630
2631     res_data.data_info = NULL;
2632     res_data.result = Inic_TranslateError(self_,
2633                                           &msg_ptr->tel.tel_data_ptr[0],
2634                                           (msg_ptr->tel.tel_len));
2635     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2636     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2637 }
2638
2639 /*! \brief Handler function for INIC.CombinerCreate.ResultAck
2640  * \param  self     reference to INIC object
2641  * \param  msg_ptr  received message
2642  */
2643 void Inic_CombinerCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2644 {
2645     CInic *self_ = (CInic *)self;
2646     uint16_t handle;
2647     Inic_StdResult_t res_data;
2648
2649     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2650     res_data.data_info       = &handle;
2651     res_data.result.code     = UCS_RES_SUCCESS;
2652     res_data.result.info_ptr = NULL;
2653     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2654     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2655 }
2656
2657 /*! \brief Handler function for INIC.SplitterCreate.ErrorAck
2658  * \param  self     reference to INIC object
2659  * \param  msg_ptr  received message
2660  */
2661 void Inic_SplitterCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2662 {
2663     CInic *self_ = (CInic *)self;
2664     Inic_StdResult_t res_data;
2665
2666     res_data.data_info = NULL;
2667     res_data.result = Inic_TranslateError(self_,
2668                                           &msg_ptr->tel.tel_data_ptr[0],
2669                                           (msg_ptr->tel.tel_len));
2670     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2671     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2672 }
2673
2674 /*! \brief Handler function for INIC.SplitterCreate.ResultAck
2675  * \param  self     reference to INIC object
2676  * \param  msg_ptr  received message
2677  */
2678 void Inic_SplitterCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2679 {
2680     CInic *self_ = (CInic *)self;
2681     uint16_t handle;
2682     Inic_StdResult_t res_data;
2683
2684     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2685     res_data.data_info       = &handle;
2686     res_data.result.code     = UCS_RES_SUCCESS;
2687     res_data.result.info_ptr = NULL;
2688     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2689     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2690 }
2691
2692 /*! \brief Handler function for INIC.QoSCreate.ErrorAck
2693  *  \param self     reference to INIC object
2694  *  \param msg_ptr  received message
2695  */
2696 void Inic_QoSCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2697 {
2698     CInic *self_ = (CInic *)self;
2699     Inic_StdResult_t res_data;
2700
2701     res_data.data_info = NULL;
2702     res_data.result = Inic_TranslateError(self_,
2703                                           &msg_ptr->tel.tel_data_ptr[0],
2704                                           (msg_ptr->tel.tel_len));
2705     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2706     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2707 }
2708
2709 /*! \brief Handler function for INIC.QoSCreate.ResultAck.res_data.data_info points to the Resource
2710  *         handle of the Quality of Service IP Streaming data connection which was created.
2711  *  \param self     reference to INIC object
2712  *  \param msg_ptr  received message
2713  */
2714 void Inic_QoSCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2715 {
2716     CInic *self_ = (CInic *)self;
2717     uint16_t handle;
2718     Inic_StdResult_t res_data;
2719
2720     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2721     res_data.data_info       = &handle;
2722     res_data.result.code     = UCS_RES_SUCCESS;
2723     res_data.result.info_ptr = NULL;
2724     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2725     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2726 }
2727
2728 /*! \brief Handler function for INIC.IPCPacketCreate.ErrorAck
2729  *  \param self     reference to INIC object
2730  *  \param msg_ptr  received message
2731  */
2732 void Inic_IpcCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2733 {
2734     CInic *self_ = (CInic *)self;
2735     Inic_StdResult_t res_data;
2736
2737     res_data.data_info = NULL;
2738     res_data.result = Inic_TranslateError(self_,
2739                                           &msg_ptr->tel.tel_data_ptr[0],
2740                                           (msg_ptr->tel.tel_len));
2741     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2742     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2743 }
2744
2745 /*! \brief Handler function for INIC.IPCPacketCreate.ResultAck.res_data.data_info points to the resource
2746  *         handle of the Inter-Processor Communication packet connection which was created.
2747  *  \param self     reference to INIC object
2748  *  \param msg_ptr  received message
2749  */
2750 void Inic_IpcCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2751 {
2752     CInic *self_ = (CInic *)self;
2753     uint16_t handle;
2754     Inic_StdResult_t res_data;
2755
2756     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2757     res_data.data_info       = &handle;
2758     res_data.result.code     = UCS_RES_SUCCESS;
2759     res_data.result.info_ptr = NULL;
2760     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2761     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2762 }
2763
2764 /*! \brief Handler function for INIC.AVPCreate.ErrorAck
2765  *  \param self     reference to INIC object
2766  *  \param msg_ptr  received message
2767  */
2768 void Inic_AvpCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2769 {
2770     CInic *self_ = (CInic *)self;
2771     Inic_StdResult_t res_data;
2772
2773     res_data.data_info = NULL;
2774     res_data.result = Inic_TranslateError(self_,
2775                                           &msg_ptr->tel.tel_data_ptr[0],
2776                                           (msg_ptr->tel.tel_len));
2777     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2778     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2779 }
2780
2781 /*! \brief Handler function for INIC.AVPCreate.ResultAck. res_data.data_info points to the Resource
2782  *         handle of the A/V Packetized Isochronous Streaming connection which was created.
2783  *  \param self     reference to INIC object
2784  *  \param msg_ptr  received message
2785  */
2786 void Inic_AvpCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2787 {
2788     CInic *self_ = (CInic *)self;
2789     uint16_t handle;
2790     Inic_StdResult_t res_data;
2791
2792     MISC_DECODE_WORD(&handle, &(msg_ptr->tel.tel_data_ptr[0]));
2793     res_data.data_info       = &handle;
2794     res_data.result.code     = UCS_RES_SUCCESS;
2795     res_data.result.info_ptr = NULL;
2796     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2797     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2798 }
2799
2800 /*! \brief Handler function for INIC.MOSTPortStatus.Status
2801  *  \param self      Reference to CInic instance
2802  *  \param msg_ptr   Pointer to received message
2803  */
2804 void Inic_MostPortStatus_Status(void *self, Msg_MostTel_t *msg_ptr)
2805 {
2806     CInic *self_ = (CInic *)self;
2807     Inic_MostPortStatus_t result;
2808
2809     MISC_DECODE_WORD(&(result.most_port_handle), &(msg_ptr->tel.tel_data_ptr[0]));
2810     result.availability          = (Ucs_Most_PortAvail_t)msg_ptr->tel.tel_data_ptr[2];
2811     result.avail_info            = (Ucs_Most_PortAvailInfo_t)msg_ptr->tel.tel_data_ptr[3];
2812     result.fullstreaming_enabled = (msg_ptr->tel.tel_data_ptr[4] != 0U) ? true : false;
2813     MISC_DECODE_WORD(&(result.freestreaming_bw), &(msg_ptr->tel.tel_data_ptr[5]));
2814
2815     self_->most_port_status = result;
2816
2817     Sub_Notify(&self_->subs[INIC_SUB_MOST_PORT_STATUS], &result);
2818 }
2819
2820 /*! \brief Handler function for INIC.MOSTPortStatus.Error
2821  *  \param self      Reference to CInic instance
2822  *  \param msg_ptr   Pointer to received message
2823  */
2824 void Inic_MostPortStatus_Error(void *self, Msg_MostTel_t *msg_ptr)
2825 {
2826     CInic *self_ = (CInic *)self;
2827     Inic_StdResult_t res_data;
2828
2829     res_data.data_info = NULL;
2830     res_data.result = Inic_TranslateError(self_,
2831                                           &msg_ptr->tel.tel_data_ptr[0],
2832                                           msg_ptr->tel.tel_len);
2833
2834     Sub_Notify(&self_->subs[INIC_SUB_MOST_PORT_STATUS], &res_data);
2835 }
2836
2837 /*! \brief Handler function for INIC.MOSTSocketCreate.ErrorAck. Result is delivered via the
2838  *         SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2839  *  \param self     Reference to CInic instance
2840  *  \param msg_ptr  Pointer to received message
2841  */
2842 void Inic_MostSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2843 {
2844     CInic *self_ = (CInic *)self;
2845     Inic_StdResult_t res_data;
2846
2847     res_data.data_info = NULL;
2848     res_data.result = Inic_TranslateError(self_,
2849                                           &msg_ptr->tel.tel_data_ptr[0],
2850                                           (msg_ptr->tel.tel_len));
2851     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2852     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2853 }
2854
2855 /*! \brief   Handler function for INIC.MOSTSocketCreate.ResultAck
2856  *  \details Result is delivered via the SingleObserver element ssubs[INIC_SSUB_CREATE_CLASS]. Element
2857  *           res_data.data_info points to a variable of type Inic_MostSocketCreate_Result_t
2858  *           which holds the results of the MOSTSocketCreate command.
2859  *  \param   self      Reference to CInic instance
2860  *  \param   msg_ptr   Pointer to received message
2861  */
2862 void Inic_MostSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2863 {
2864     CInic *self_ = (CInic *)self;
2865     Inic_StdResult_t res_data;
2866     Inic_MostSocketCreate_Result_t  res;
2867
2868     MISC_DECODE_WORD(&(res.most_socket_handle), &(msg_ptr->tel.tel_data_ptr[0]));
2869     MISC_DECODE_WORD(&(res.conn_label),         &(msg_ptr->tel.tel_data_ptr[2]));
2870     res_data.data_info       = &res;
2871     res_data.result.code     = UCS_RES_SUCCESS;
2872     res_data.result.info_ptr = NULL;
2873     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2874     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2875 }
2876
2877
2878 /*! \brief   Handler function for INIC.MLBPortCreate.ErrorAck
2879  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2880  *  \param   self      Reference to CInic instance
2881  *  \param   msg_ptr   Pointer to received message
2882  */
2883 void Inic_MlbPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2884 {
2885     CInic *self_ = (CInic *)self;
2886     Inic_StdResult_t res_data;
2887
2888     res_data.data_info      = NULL;
2889     res_data.result = Inic_TranslateError(self_,
2890                                           &msg_ptr->tel.tel_data_ptr[0],
2891                                           (msg_ptr->tel.tel_len));
2892     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2893     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2894 }
2895
2896 /*! \brief   Handler function for INIC.MLBPortCreate.ResultAck
2897  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2898  *           Element res_data.data_info points to the variable mlb_port_handle which holds the
2899  *           MediaLB Port resource handle.
2900  *  \param   self      Reference to CInic instance
2901  *  \param   msg_ptr   Pointer to received message
2902  */
2903 void Inic_MlbPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2904 {
2905     CInic *self_ = (CInic *)self;
2906     uint16_t mlb_port_handle;
2907     Inic_StdResult_t res_data;
2908
2909     MISC_DECODE_WORD(&mlb_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
2910     res_data.data_info       = &mlb_port_handle;
2911     res_data.result.code     = UCS_RES_SUCCESS;
2912     res_data.result.info_ptr = NULL;
2913     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2914     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2915 }
2916
2917 /*! \brief   Handler function for INIC.MLBSocketCreate.ErrorAck
2918  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2919  *  \param   self      Reference to CInic instance
2920  *  \param   msg_ptr   Pointer to received message
2921  */
2922 void Inic_MlbSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2923 {
2924     CInic *self_ = (CInic *)self;
2925     Inic_StdResult_t res_data;
2926
2927     res_data.data_info = NULL;
2928     res_data.result = Inic_TranslateError(self_,
2929                                           &msg_ptr->tel.tel_data_ptr[0],
2930                                           (msg_ptr->tel.tel_len));
2931     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2932     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2933 }
2934
2935 /*! \brief   Handler function for INIC.MLBSocketCreate.ResultAck
2936  *  \details Element res_data.data_info points to the variable mlb_socket_handle which holds the
2937  *           MediaLB Socket resource handle of the created socket. Result is delivered via the
2938  *           SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2939  *  \param   self      Reference to CInic instance
2940  *  \param   msg_ptr   Pointer to received message
2941  */
2942 void Inic_MlbSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2943 {
2944     CInic *self_ = (CInic *)self;
2945     uint16_t mlb_socket_handle;
2946     Inic_StdResult_t res_data;
2947
2948     MISC_DECODE_WORD(&mlb_socket_handle, &(msg_ptr->tel.tel_data_ptr[0]));
2949     res_data.data_info       = &mlb_socket_handle;
2950     res_data.result.code     = UCS_RES_SUCCESS;
2951     res_data.result.info_ptr = NULL;
2952     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2953     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2954 }
2955
2956 /*! \brief   Handler function for INIC.USBPortCreate.ErrorAck
2957  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2958  *  \param   self      Reference to CInic instance
2959  *  \param   msg_ptr   Pointer to received message
2960  */
2961 void Inic_UsbPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
2962 {
2963     CInic *self_ = (CInic *)self;
2964     Inic_StdResult_t res_data;
2965
2966     res_data.data_info = NULL;
2967     res_data.result = Inic_TranslateError(self_,
2968                                           &msg_ptr->tel.tel_data_ptr[0],
2969                                           (msg_ptr->tel.tel_len));
2970     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2971     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2972 }
2973
2974 /*! \brief   Handler function for INIC.USBPortCreate.ResultAck
2975  *  \details Element res_data.data_info points to the variable usb_port_handle which holds the USB
2976  *           Port resource handle.
2977  *  \param   self      Reference to CInic instance
2978  *  \param   msg_ptr   Pointer to received message
2979  */
2980 void Inic_UsbPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
2981 {
2982     CInic *self_ = (CInic *)self;
2983     uint16_t usb_port_handle;
2984     Inic_StdResult_t res_data;
2985
2986     MISC_DECODE_WORD(&usb_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
2987     res_data.data_info       = &usb_port_handle;
2988     res_data.result.code     = UCS_RES_SUCCESS;
2989     res_data.result.info_ptr = NULL;
2990     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
2991     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
2992 }
2993
2994 /*! \brief   Handler function for INIC.USBSocketCreate.ErrorAck
2995  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
2996  *  \param   self      Reference to CInic instance
2997  *  \param   msg_ptr   Pointer to received message
2998  */
2999 void Inic_UsbSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3000 {
3001     CInic *self_ = (CInic *)self;
3002     Inic_StdResult_t res_data;
3003
3004     res_data.data_info = NULL;
3005     res_data.result = Inic_TranslateError(self_,
3006                                           &msg_ptr->tel.tel_data_ptr[0],
3007                                           (msg_ptr->tel.tel_len));
3008     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3009     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3010 }
3011
3012 /*! \brief   Handler function for INIC.USBSocketCreate.ResultAck
3013  *  \details Element res_data.data_info points to the variable usb_socket_handle which holds the
3014  *           Socket resource handle of the created socket. Result is delivered via the
3015  *           SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3016  *  \param   self      Reference to CInic instance
3017  *  \param   msg_ptr   Pointer to received message
3018  */
3019 void Inic_UsbSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3020 {
3021     CInic *self_ = (CInic *)self;
3022     uint16_t usb_socket_handle;
3023     Inic_StdResult_t res_data;
3024
3025     MISC_DECODE_WORD(&usb_socket_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3026     res_data.data_info       = &usb_socket_handle;
3027     res_data.result.code     = UCS_RES_SUCCESS;
3028     res_data.result.info_ptr = NULL;
3029     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3030     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3031 }
3032
3033 /*! \brief   Handler function for INIC.StreamPortConfiguration.Status
3034  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_STREAM_PORT_CONFIG].
3035  *           Element res_data.data_info points to a variable of type Inic_StreamPortConfigStatus_t
3036  *           which holds the results of the INIC.StreamPortConfiguration.Get command.
3037  *  \param   self      Reference to CInic instance
3038  *  \param   msg_ptr   Pointer to received message
3039  */
3040 void Inic_StreamPortConfig_Status(void *self, Msg_MostTel_t *msg_ptr)
3041 {
3042     CInic *self_ = (CInic *)self;
3043     Inic_StreamPortConfigStatus_t res;
3044     Inic_StdResult_t res_data;
3045
3046     res_data.data_info       = &res;
3047     res_data.result.code     = UCS_RES_SUCCESS;
3048     res_data.result.info_ptr = NULL;
3049
3050     res.index            = msg_ptr->tel.tel_data_ptr[0];
3051     res.op_mode          = (Ucs_Stream_PortOpMode_t)msg_ptr->tel.tel_data_ptr[1];
3052     res.port_option      = (Ucs_Stream_PortOption_t)msg_ptr->tel.tel_data_ptr[2];
3053     res.clock_mode       = (Ucs_Stream_PortClockMode_t)msg_ptr->tel.tel_data_ptr[3];
3054     res.clock_data_delay = (Ucs_Stream_PortClockDataDelay_t)msg_ptr->tel.tel_data_ptr[4];
3055
3056     Ssub_Notify(&self_->ssubs[INIC_SSUB_STREAM_PORT_CONFIG], &res_data, true);
3057     Al_Release(&self_->lock.res_api, INIC_API_STREAM_PORT_CONFIG);
3058 }
3059
3060 /*! \brief   Handler function for INIC.StreamPortConfiguration.Error
3061  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_STREAM_PORT_CONFIG].
3062  *  \param   self      Reference to CInic instance
3063  *  \param   msg_ptr   Pointer to received message
3064  */
3065 void Inic_StreamPortConfig_Error(void *self, Msg_MostTel_t *msg_ptr)
3066 {
3067     CInic *self_ = (CInic *)self;
3068     Inic_StdResult_t res_data;
3069
3070     res_data.data_info = NULL;
3071     res_data.result = Inic_TranslateError(self_,
3072                                           &msg_ptr->tel.tel_data_ptr[0],
3073                                           msg_ptr->tel.tel_len);
3074     Ssub_Notify(&self_->ssubs[INIC_SSUB_STREAM_PORT_CONFIG], &res_data, true);
3075     Al_Release(&self_->lock.res_api, INIC_API_STREAM_PORT_CONFIG);
3076 }
3077
3078 /*! \brief   Handler function for INIC.StreamPortCreate.ErrorAck
3079  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3080  *  \param   self      Reference to CInic instance
3081  *  \param   msg_ptr   Pointer to received message
3082  */
3083 void Inic_StreamPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3084 {
3085     CInic *self_ = (CInic *)self;
3086     Inic_StdResult_t res_data;
3087
3088     res_data.data_info = NULL;
3089     res_data.result = Inic_TranslateError(self_,
3090                                           &msg_ptr->tel.tel_data_ptr[0],
3091                                           (msg_ptr->tel.tel_len));
3092     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3093     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3094 }
3095
3096 /*! \brief   Handler function for INIC.StreamPortCreate.ResultAck
3097  *  \details Element res_data.data_info points to the variable stream_port_handle which holds the
3098  *           Streaming Port resource handle. Result is delivered via the SingleObserver object
3099  *           ssubs[INIC_SSUB_CREATE_CLASS].
3100  *  \param   self      Reference to CInic instance
3101  *  \param   msg_ptr   Pointer to received message
3102  */
3103 void Inic_StreamPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3104 {
3105     CInic *self_ = (CInic *)self;
3106     uint16_t stream_port_handle;
3107     Inic_StdResult_t res_data;
3108
3109     MISC_DECODE_WORD(&stream_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3110     res_data.data_info       = &stream_port_handle;
3111     res_data.result.code     = UCS_RES_SUCCESS;
3112     res_data.result.info_ptr = NULL;
3113     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3114     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3115 }
3116
3117 /*! \brief   Handler function for INIC.StreamSocketCreate.ErrorAck
3118  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3119  *  \param   self      Reference to CInic instance
3120  *  \param   msg_ptr   Pointer to received message
3121  */
3122 void Inic_StreamSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3123 {
3124     CInic *self_ = (CInic *)self;
3125     Inic_StdResult_t res_data;
3126
3127     res_data.data_info = NULL;
3128     res_data.result = Inic_TranslateError(self_,
3129                                           &msg_ptr->tel.tel_data_ptr[0],
3130                                           (msg_ptr->tel.tel_len));
3131     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3132     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3133 }
3134
3135 /*! \brief   Handler function for INIC.StreamSocketCreate.ResultAck
3136  *  \details Element res_data.data_info points to the variable stream_socket_handle which holds
3137  *           the Socket resource handle of the created socket. Result is delivered via the
3138  *           SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3139  *  \param   self      Reference to CInic instance
3140  *  \param   msg_ptr   Pointer to received message
3141  */
3142 void Inic_StreamSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3143 {
3144     CInic *self_ = (CInic *)self;
3145     uint16_t stream_socket_handle;
3146     Inic_StdResult_t res_data;
3147
3148     MISC_DECODE_WORD(&stream_socket_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3149     res_data.data_info       = &stream_socket_handle;
3150     res_data.result.code     = UCS_RES_SUCCESS;
3151     res_data.result.info_ptr = NULL;
3152     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3153     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3154 }
3155
3156 /*! \brief   Handler function for INIC.RMCKOutPortCreate.ErrorAck
3157  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3158  *  \param   self      Reference to CInic instance
3159  *  \param   msg_ptr   Pointer to received message
3160  */
3161 void Inic_RmckPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3162 {
3163     CInic *self_ = (CInic *)self;
3164     Inic_StdResult_t res_data;
3165
3166     res_data.data_info = NULL;
3167     res_data.result = Inic_TranslateError(self_,
3168                                           &msg_ptr->tel.tel_data_ptr[0],
3169                                           (msg_ptr->tel.tel_len));
3170     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3171     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3172 }
3173
3174 /*! \brief   Handler function for INIC.RMCKOutPortCreate.ResultAck
3175  *  \details Element res_data.data_info points to the variable rmck_port_handle which holds the
3176  *           RMCK Port resource handle. Result is delivered via the SingleObserver object
3177  *           ssubs[INIC_SSUB_CREATE_CLASS].
3178  *  \param   self      Reference to CInic instance
3179  *  \param   msg_ptr   Pointer to received message
3180  */
3181 void Inic_RmckPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3182 {
3183     CInic *self_ = (CInic *)self;
3184     uint16_t rmck_port_handle;
3185     Inic_StdResult_t res_data;
3186
3187     MISC_DECODE_WORD(&rmck_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3188     res_data.data_info       = &rmck_port_handle;
3189     res_data.result.code     = UCS_RES_SUCCESS;
3190     res_data.result.info_ptr = NULL;
3191     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3192     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3193 }
3194
3195 /*! \brief   Handler function for INIC.I2CPortCreate.ErrorAck
3196  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3197  *  \param   self      Reference to CInic instance
3198  *  \param   msg_ptr   Pointer to received message
3199  */
3200 void Inic_I2cPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3201 {
3202     CInic *self_ = (CInic *)self;
3203     Inic_StdResult_t res_data;
3204
3205     res_data.data_info = NULL;
3206     res_data.result = Inic_TranslateError(self_,
3207                                           &msg_ptr->tel.tel_data_ptr[0],
3208                                           (msg_ptr->tel.tel_len));
3209     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3210     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3211 }
3212
3213 /*! \brief   Handler function for INIC.I2CPortCreate.ResultAck
3214  *  \details Element res_data.data_info points to the variable i2c_port_handle which holds the
3215  *           I2C Port resource handle. Result is delivered via the SingleObserver object
3216  *           ssubs[INIC_SSUB_CREATE_CLASS].
3217  *  \param   self      Reference to CInic instance
3218  *  \param   msg_ptr   Pointer to received message
3219  */
3220 void Inic_I2cPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3221 {
3222     CInic *self_ = (CInic *)self;
3223     uint16_t i2c_port_handle;
3224     Inic_StdResult_t res_data;
3225
3226     MISC_DECODE_WORD(&i2c_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3227     res_data.data_info       = &i2c_port_handle;
3228     res_data.result.code     = UCS_RES_SUCCESS;
3229     res_data.result.info_ptr = NULL;
3230     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3231     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3232 }
3233
3234 /*! \brief   Handler function for INIC.I2CPortRead.ErrorAck
3235  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_I2C_PORT_WR].
3236  *  \param   self      Reference to CInic instance
3237  *  \param   msg_ptr   Pointer to received message
3238  */
3239 void Inic_I2cPortRead_Error(void *self, Msg_MostTel_t *msg_ptr)
3240 {
3241     CInic *self_ = (CInic *)self;
3242     Inic_StdResult_t res_data;
3243
3244     res_data.data_info = NULL;
3245     res_data.result = Inic_TranslateError(self_,
3246                                           &msg_ptr->tel.tel_data_ptr[0],
3247                                           (msg_ptr->tel.tel_len));
3248     Ssub_Notify(&self_->ssubs[INIC_SSUB_I2C_PORT_WR], &res_data, true);
3249     Al_Release(&self_->lock.res_api, INIC_API_I2C_PORT_WR);
3250 }
3251
3252 /*! \brief   Handler function for INIC.I2CPortRead.ResultAck
3253  *  \details Element res_data.data_info points to a variable of type Inic_I2cReadResStatus_t which holds the
3254  *          the results of the INIC.I2CPortRead.StartResultAck command.
3255  *          Result is delivered via the SingleObserver object ssubs[INIC_SSUB_I2C_PORT_WR].
3256  *  \param   self      Reference to CInic instance
3257  *  \param   msg_ptr   Pointer to received message
3258  */
3259 void Inic_I2cPortRead_Result(void *self, Msg_MostTel_t *msg_ptr)
3260 {
3261     CInic *self_ = (CInic *)self;
3262     Inic_I2cReadResStatus_t i2c_read_res;
3263     Inic_StdResult_t res_data;
3264
3265     res_data.data_info       = &i2c_read_res;
3266     res_data.result.code     = UCS_RES_SUCCESS;
3267     res_data.result.info_ptr = NULL;
3268
3269     MISC_DECODE_WORD(&i2c_read_res.port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3270     i2c_read_res.slave_address = msg_ptr->tel.tel_data_ptr[2];
3271     i2c_read_res.data_len      = msg_ptr->tel.tel_data_ptr[3];
3272     i2c_read_res.data_ptr      = &msg_ptr->tel.tel_data_ptr[4];
3273
3274     Ssub_Notify(&self_->ssubs[INIC_SSUB_I2C_PORT_WR], &res_data, true);
3275     Al_Release(&self_->lock.res_api, INIC_API_I2C_PORT_WR);
3276 }
3277
3278 /*! \brief   Handler function for INIC.I2CPortWrite.ErrorAck
3279  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_I2C_PORT_WR].
3280  *  \param   self      Reference to CInic instance
3281  *  \param   msg_ptr   Pointer to received message
3282  */
3283 void Inic_I2cPortWrite_Error(void *self, Msg_MostTel_t *msg_ptr)
3284 {
3285     CInic *self_ = (CInic *)self;
3286     Inic_StdResult_t res_data;
3287
3288     res_data.data_info = NULL;
3289     res_data.result = Inic_TranslateError(self_,
3290                                           &msg_ptr->tel.tel_data_ptr[0],
3291                                           (msg_ptr->tel.tel_len));
3292     Ssub_Notify(&self_->ssubs[INIC_SSUB_I2C_PORT_WR], &res_data, true);
3293     Al_Release(&self_->lock.res_api, INIC_API_I2C_PORT_WR);
3294 }
3295
3296 /*! \brief   Handler function for INIC.I2CPortWrite.ResultAck
3297  *  \details Element res_data.data_info points to a variable of type Inic_I2cWriteResStatus_t which holds the
3298  *          the results of the INIC.I2CPortWrite.StartResultAck command.
3299  *          Result is delivered via the SingleObserver object ssubs[INIC_SSUB_I2C_PORT_WR].
3300  *  \param   self      Reference to CInic instance
3301  *  \param   msg_ptr   Pointer to received message
3302  */
3303 void Inic_I2cPortWrite_Result(void *self, Msg_MostTel_t *msg_ptr)
3304 {
3305     CInic *self_ = (CInic *)self;
3306     Inic_I2cWriteResStatus_t i2c_write_res;
3307     Inic_StdResult_t res_data;
3308
3309     res_data.data_info       = &i2c_write_res;
3310     res_data.result.code     = UCS_RES_SUCCESS;
3311     res_data.result.info_ptr = NULL;
3312
3313     MISC_DECODE_WORD(&i2c_write_res.port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3314     i2c_write_res.slave_address = msg_ptr->tel.tel_data_ptr[2];
3315     i2c_write_res.data_len      = msg_ptr->tel.tel_data_ptr[3];
3316
3317     Ssub_Notify(&self_->ssubs[INIC_SSUB_I2C_PORT_WR], &res_data, true);
3318     Al_Release(&self_->lock.res_api, INIC_API_I2C_PORT_WR);
3319 }
3320
3321 /*! \brief   Handler function for INIC.PCIPortCreate.ErrorAck
3322  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3323  *  \param   self      Reference to CInic instance
3324  *  \param   msg_ptr   Pointer to received message
3325  */
3326 void Inic_PciPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3327 {
3328     CInic *self_ = (CInic *)self;
3329     Inic_StdResult_t res_data;
3330
3331     res_data.data_info = NULL;
3332     res_data.result = Inic_TranslateError(self_,
3333                                           &msg_ptr->tel.tel_data_ptr[0],
3334                                           (msg_ptr->tel.tel_len));
3335     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3336     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3337 }
3338
3339 /*! \brief   Handler function for INIC.PCIPortCreate.ResultAck
3340  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3341  *  \param   self      Reference to CInic instance
3342  *  \param   msg_ptr   Pointer to received message
3343  */
3344 void Inic_PciPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3345 {
3346     CInic *self_ = (CInic *)self;
3347     uint16_t pci_port_handle;
3348     Inic_StdResult_t res_data;
3349
3350     MISC_DECODE_WORD(&pci_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3351     res_data.data_info       = &pci_port_handle;
3352     res_data.result.code     = UCS_RES_SUCCESS;
3353     res_data.result.info_ptr = NULL;
3354     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3355     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3356 }
3357
3358 /*! \brief   Handler function for INIC.PCISocketCreate.ErrorAck
3359  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3360  *  \param   self      Reference to CInic instance
3361  *  \param   msg_ptr   Pointer to received message
3362  */
3363 void Inic_PciSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3364 {
3365     CInic *self_ = (CInic *)self;
3366     Inic_StdResult_t res_data;
3367
3368     res_data.data_info = NULL;
3369     res_data.result = Inic_TranslateError(self_,
3370                                           &msg_ptr->tel.tel_data_ptr[0],
3371                                           (msg_ptr->tel.tel_len));
3372     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3373     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3374 }
3375
3376 /*! \brief   Handler function for INIC.PCISocketCreate.ResultAck
3377  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3378  *  \param   self      Reference to CInic instance
3379  *  \param   msg_ptr   Pointer to received message
3380  */
3381 void Inic_PciSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3382 {
3383     CInic *self_ = (CInic *)self;
3384     uint16_t pci_socket_port_handle;
3385     Inic_StdResult_t res_data;
3386
3387     MISC_DECODE_WORD(&pci_socket_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3388     res_data.data_info       = &pci_socket_port_handle;
3389     res_data.result.code     = UCS_RES_SUCCESS;
3390     res_data.result.info_ptr = NULL;
3391     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3392     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3393 }
3394
3395 /*! \brief   Handler function for INIC.GPIOPortCreate.ErrorAck
3396  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3397  *  \param   self      Reference to CInic instance
3398  *  \param   msg_ptr   Pointer to received message
3399  */
3400 void Inic_GpioPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr)
3401 {
3402     CInic *self_ = (CInic *)self;
3403     Inic_StdResult_t res_data;
3404
3405     res_data.data_info = NULL;
3406     res_data.result = Inic_TranslateError(self_,
3407                                           &msg_ptr->tel.tel_data_ptr[0],
3408                                           (msg_ptr->tel.tel_len));
3409     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3410     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3411 }
3412
3413 /*! \brief   Handler function for INIC.GPIOPortCreate.ResultAck
3414  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_CREATE_CLASS].
3415  *  \param   self      Reference to CInic instance
3416  *  \param   msg_ptr   Pointer to received message
3417  */
3418 void Inic_GpioPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr)
3419 {
3420     CInic *self_ = (CInic *)self;
3421     uint16_t gpio_port_handle;
3422     Inic_StdResult_t res_data;
3423
3424     MISC_DECODE_WORD(&gpio_port_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3425     res_data.data_info       = &gpio_port_handle;
3426     res_data.result.code     = UCS_RES_SUCCESS;
3427     res_data.result.info_ptr = NULL;
3428     Ssub_Notify(&self_->ssubs[INIC_SSUB_CREATE_CLASS], &res_data, true);
3429     Al_Release(&self_->lock.res_api, INIC_API_CREATE_CLASS);
3430 }
3431
3432 /*! \brief   Handler function for INIC.MOSTPortEnable.ErrorAck
3433  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_MOST_PORT_ENABLE].
3434  *  \param   self      Reference to CInic instance
3435  *  \param   msg_ptr   Pointer to received message
3436  */
3437 void Inic_MostPortEnable_Error(void *self, Msg_MostTel_t *msg_ptr)
3438 {
3439     CInic *self_ = (CInic *)self;
3440     Inic_StdResult_t res_data;
3441
3442     res_data.data_info = NULL;
3443     res_data.result = Inic_TranslateError(self_,
3444                                           &msg_ptr->tel.tel_data_ptr[0],
3445                                           (msg_ptr->tel.tel_len));
3446     Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_ENABLE], &res_data, true);
3447     Al_Release(&self_->lock.res_api, INIC_API_MOST_PORT_ENABLE);
3448 }
3449
3450 /*! \brief   Handler function for INIC.MOSTPortEnable.ResultAck
3451  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_MOST_PORT_ENABLE].
3452  *  \param   self      Reference to CInic instance
3453  *  \param   msg_ptr   Pointer to received message
3454  */
3455 void Inic_MostPortEnable_Result(void *self, Msg_MostTel_t *msg_ptr)
3456 {
3457     CInic *self_ = (CInic *)self;
3458     Inic_StdResult_t res_data;
3459     MISC_UNUSED(msg_ptr);
3460
3461     res_data.data_info       = NULL;
3462     res_data.result.code     = UCS_RES_SUCCESS;
3463     res_data.result.info_ptr = NULL;
3464     Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_ENABLE], &res_data, true);
3465     Al_Release(&self_->lock.res_api, INIC_API_MOST_PORT_ENABLE);
3466 }
3467
3468 /*! \brief   Handler function for INIC.GPIOPortPinMode.Status
3469  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_PIN_MODE].
3470  *           Element res_data.data_info points to a variable of type Inic_GpioPortPinModeStatus_t
3471  *           which holds the results of the INIC.GPIOPortPinMode.Get command.
3472  *  \param   self      Reference to CInic instance
3473  *  \param   msg_ptr   Pointer to received message
3474  */
3475 void Inic_GpioPortPinMode_Status(void *self, Msg_MostTel_t *msg_ptr)
3476 {
3477     CInic *self_ = (CInic *)self;
3478     Inic_GpioPortPinModeStatus_t res;
3479     Inic_StdResult_t res_data;
3480     uint8_t i = 2U, j = 0U;
3481     Ucs_Gpio_PinConfiguration_t pin_ls[16U];
3482
3483     res.cfg_list             = &pin_ls[0];
3484     res.len                  = (msg_ptr->tel.tel_len - 2U) >> 1U;
3485     res_data.data_info       = &res;
3486     res_data.result.code     = UCS_RES_SUCCESS;
3487     res_data.result.info_ptr = NULL;
3488
3489     MISC_DECODE_WORD(&res.gpio_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3490     for (; (i < msg_ptr->tel.tel_len) && (j < 16U); i=i+2U)
3491     {
3492         pin_ls[j].pin  = msg_ptr->tel.tel_data_ptr[i];
3493         pin_ls[j].mode = (Ucs_Gpio_PinMode_t)msg_ptr->tel.tel_data_ptr[i+1U];
3494         j++;
3495     }
3496
3497     Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_MODE], &res_data, true);
3498     Al_Release(&self_->lock.res_api, INIC_API_GPIO_PIN_MODE);
3499 }
3500
3501 /*! \brief   Handler function for INIC.GPIOPortPinMode.Error
3502  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_PIN_MODE].
3503  *  \param   self      Reference to CInic instance
3504  *  \param   msg_ptr   Pointer to received message
3505  */
3506 void Inic_GpioPortPinMode_Error(void *self, Msg_MostTel_t *msg_ptr)
3507 {
3508     CInic *self_ = (CInic *)self;
3509     Inic_StdResult_t res_data;
3510
3511     res_data.data_info = NULL;
3512     res_data.result = Inic_TranslateError(self_,
3513                                           &msg_ptr->tel.tel_data_ptr[0],
3514                                           msg_ptr->tel.tel_len);
3515     Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_MODE], &res_data, true);
3516     Al_Release(&self_->lock.res_api, INIC_API_GPIO_PIN_MODE);
3517 }
3518
3519 /*! \brief   Handler function for INIC.GPIOPortPinState.Status
3520  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_PIN_STATE].
3521  *           Element res_data.data_info points to a variable of type Inic_GpioPortPinStateStatus_t
3522  *           which holds the results of the INIC.GPIOPortPinState.Get command.
3523  *  \param   self      Reference to CInic instance
3524  *  \param   msg_ptr   Pointer to received message
3525  */
3526 void Inic_GpioPortPinState_Status(void *self, Msg_MostTel_t *msg_ptr)
3527 {
3528     CInic *self_ = (CInic *)self;
3529     Inic_GpioPortPinStateStatus_t res;
3530     Inic_StdResult_t res_data;
3531
3532     res_data.data_info       = &res;
3533     res_data.result.code     = UCS_RES_SUCCESS;
3534     res_data.result.info_ptr = NULL;
3535
3536     MISC_DECODE_WORD(&res.gpio_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3537     MISC_DECODE_WORD(&res.current_state, &(msg_ptr->tel.tel_data_ptr[2]));
3538     MISC_DECODE_WORD(&res.sticky_state, &(msg_ptr->tel.tel_data_ptr[4]));
3539
3540     Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_STATE], &res_data, true);
3541     Al_Release(&self_->lock.res_api, INIC_API_GPIO_PIN_STATE);
3542 }
3543
3544 /*! \brief   Handler function for INIC.GPIOPortPinState.Error
3545  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_PIN_STATE].
3546  *  \param   self      Reference to CInic instance
3547  *  \param   msg_ptr   Pointer to received message
3548  */
3549 void Inic_GpioPortPinState_Error(void *self, Msg_MostTel_t *msg_ptr)
3550 {
3551     CInic *self_ = (CInic *)self;
3552     Inic_StdResult_t res_data;
3553
3554     res_data.data_info = NULL;
3555     res_data.result = Inic_TranslateError(self_,
3556                                           &msg_ptr->tel.tel_data_ptr[0],
3557                                           msg_ptr->tel.tel_len);
3558     Ssub_Notify(&self_->ssubs[INIC_SSUB_GPIO_PIN_STATE], &res_data, true);
3559     Al_Release(&self_->lock.res_api, INIC_API_GPIO_PIN_STATE);
3560 }
3561
3562 /*! \brief   Handler function for INIC.GPIOPortTriggerEvent.Status
3563  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_TRIGGER_EVENT].
3564  *           Element res_data.data_info points to a variable of type Inic_GpioTriggerEventStatus_t
3565  *  \param   self      Reference to CInic instance
3566  *  \param   msg_ptr   Pointer to received message
3567  */
3568 void Inic_GpioPortTrigger_Status(void *self, Msg_MostTel_t *msg_ptr)
3569 {
3570     CInic *self_ = (CInic *)self;
3571     Inic_GpioTriggerEventStatus_t res;
3572     Inic_StdResult_t res_data;
3573
3574     res_data.data_info       = &res;
3575     res_data.result.code     = UCS_RES_SUCCESS;
3576     res_data.result.info_ptr = NULL;
3577
3578     MISC_DECODE_WORD(&res.gpio_handle, &(msg_ptr->tel.tel_data_ptr[0]));
3579     MISC_DECODE_WORD(&res.rising_edges, &(msg_ptr->tel.tel_data_ptr[2]));
3580     MISC_DECODE_WORD(&res.falling_edges, &(msg_ptr->tel.tel_data_ptr[4]));
3581     MISC_DECODE_WORD(&res.levels, &(msg_ptr->tel.tel_data_ptr[6]));
3582     res.is_first_report = self_->gpio_rt_status.first_report;
3583     if (self_->gpio_rt_status.first_report)
3584     {
3585         self_->gpio_rt_status.first_report = false;
3586     }
3587
3588     Sub_Notify(&self_->subs[INIC_SUB_GPIO_TRIGGER_EVENT], &res_data);
3589 }
3590
3591 /*! \brief   Handler function for INIC.GPIOPortTriggerEvent.Error
3592  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_GPIO_TRIGGER_EVENT].
3593  *  \param   self      Reference to CInic instance
3594  *  \param   msg_ptr   Pointer to received message
3595  */
3596 void Inic_GpioPortTrigger_Error(void *self, Msg_MostTel_t *msg_ptr)
3597 {
3598     CInic *self_ = (CInic *)self;
3599     Inic_StdResult_t res_data;
3600
3601     res_data.data_info = NULL;
3602     res_data.result = Inic_TranslateError(self_,
3603                                           &msg_ptr->tel.tel_data_ptr[0],
3604                                           msg_ptr->tel.tel_len);
3605     Sub_Notify(&self_->subs[INIC_SUB_GPIO_TRIGGER_EVENT], &res_data);
3606 }
3607
3608 /*! \brief   Handler function for INIC.MOSTPortEnableFullStreaming.ErrorAck
3609  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_MOST_PORT_EN_FULL_STR].
3610  *  \param   self      Reference to CInic instance
3611  *  \param   msg_ptr   Pointer to received message
3612  */
3613 void Inic_MostPortEnFullStr_Error(void *self, Msg_MostTel_t *msg_ptr)
3614 {
3615     CInic *self_ = (CInic *)self;
3616     Inic_StdResult_t res_data;
3617
3618     res_data.data_info = NULL;
3619     res_data.result = Inic_TranslateError(self_,
3620                                           &msg_ptr->tel.tel_data_ptr[0],
3621                                           (msg_ptr->tel.tel_len));
3622     Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_EN_FULL_STR], &res_data, true);
3623     Al_Release(&self_->lock.res_api, INIC_API_MOST_PORT_EN_FULL_STR);
3624 }
3625
3626 /*! \brief   Handler function for INIC.MOSTPortEnableFullStreaming.ResultAck
3627  *  \details Result is delivered via the SingleObserver object ssubs[INIC_SSUB_MOST_PORT_EN_FULL_STR].
3628  *  \param   self      Reference to CInic instance
3629  *  \param   msg_ptr   Pointer to received message
3630  */
3631 void Inic_MostPortEnFullStr_Result(void *self, Msg_MostTel_t *msg_ptr)
3632 {
3633     CInic *self_ = (CInic *)self;
3634     Inic_StdResult_t res_data;
3635     MISC_UNUSED(msg_ptr);
3636
3637     res_data.data_info       = NULL;
3638     res_data.result.code     = UCS_RES_SUCCESS;
3639     res_data.result.info_ptr = NULL;
3640     Ssub_Notify(&self_->ssubs[INIC_SSUB_MOST_PORT_EN_FULL_STR], &res_data, true);
3641     Al_Release(&self_->lock.res_api, INIC_API_MOST_PORT_EN_FULL_STR);
3642 }
3643
3644 /*! \brief Handler function for INIC.Notification.Error
3645  *  \param  self     reference to INIC object
3646  *  \param  msg_ptr  received message
3647  */
3648 void Inic_Notification_Error(void *self, Msg_MostTel_t *msg_ptr)
3649 {
3650     CInic *self_ = (CInic *)self;
3651     Inic_StdResult_t res_data;
3652
3653     res_data.data_info  = NULL;
3654     res_data.result = Inic_TranslateError(self_,
3655                                           &msg_ptr->tel.tel_data_ptr[0],
3656                                           (msg_ptr->tel.tel_len));
3657
3658     Ssub_Notify(&self_->ssubs[INIC_SSUB_NOTIFICATION], &res_data, true);
3659     Al_Release(&self_->lock.res_api, INIC_API_NOTIFICATION);
3660 }
3661
3662 /*! \brief Handler function for INIC.Notification.ResultAck
3663  *  \param  self     reference to INIC object
3664  *  \param  msg_ptr  received message
3665  */
3666 void Inic_Notification_Status(void *self, Msg_MostTel_t *msg_ptr)
3667 {
3668     CInic *self_ = (CInic *)self;
3669     Inic_StdResult_t res_data;
3670     Inic_NotificationResult_t notif_res;
3671
3672     res_data.data_info       = &notif_res;
3673     res_data.result.code     = UCS_RES_SUCCESS;
3674     res_data.result.info_ptr = NULL;
3675
3676     MISC_DECODE_WORD(&notif_res.func_id, &(msg_ptr->tel.tel_data_ptr[0]));
3677     if (msg_ptr->tel.tel_len == 4U)
3678     {
3679         MISC_DECODE_WORD(&notif_res.device_id, &(msg_ptr->tel.tel_data_ptr[2]));
3680     }
3681     else
3682     {
3683         notif_res.device_id = 0U;
3684     }
3685
3686     Ssub_Notify(&self_->ssubs[INIC_SSUB_NOTIFICATION], &res_data, true);
3687     Al_Release(&self_->lock.res_api, INIC_API_NOTIFICATION);
3688 }
3689
3690 /*! \brief Handler  function for INIC.DeviceSync.Error
3691  *  \param  self    reference to INIC object
3692  *  \param  msg_ptr received message
3693  */
3694 void Inic_DeviceSync_Error(void *self, Msg_MostTel_t *msg_ptr)
3695 {
3696     CInic *self_ = (CInic *)self;
3697     Inic_StdResult_t res_data;
3698  
3699     res_data.data_info  = NULL;
3700     res_data.result = Inic_TranslateError(self_,
3701                                           &msg_ptr->tel.tel_data_ptr[0], 
3702                                           (msg_ptr->tel.tel_len));
3703
3704     Ssub_Notify(&self_->ssubs[INIC_SSUB_DEVICE_SYNC], &res_data, true);
3705     Al_Release(&self_->lock.res_api, INIC_API_DEVICE_SYNC);
3706 }
3707
3708 /*! \brief Handler  function for INIC.DeviceSync.Result
3709  *  \param  self    reference to INIC object
3710  *  \param  msg_ptr received message
3711  */
3712 void Inic_DeviceSync_Result(void *self, Msg_MostTel_t *msg_ptr)
3713 {
3714     CInic *self_ = (CInic *)self;
3715     Inic_StdResult_t res_data;
3716
3717     MISC_UNUSED(msg_ptr);
3718
3719     res_data.data_info       = NULL;
3720     res_data.result.code     = UCS_RES_SUCCESS;
3721     res_data.result.info_ptr = NULL;
3722
3723     Ssub_Notify(&self_->ssubs[INIC_SSUB_DEVICE_SYNC], &res_data, true);
3724     Al_Release(&self_->lock.res_api, INIC_API_DEVICE_SYNC);
3725 }
3726
3727 /*!
3728  * @}
3729  * \endcond
3730  */
3731
3732 /*------------------------------------------------------------------------------------------------*/
3733 /* End of file                                                                                    */
3734 /*------------------------------------------------------------------------------------------------*/
3735