aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-lib/inc
diff options
context:
space:
mode:
Diffstat (limited to 'ucs2-lib/inc')
-rw-r--r--ucs2-lib/inc/ucs_alm.h111
-rw-r--r--ucs2-lib/inc/ucs_amd.h141
-rw-r--r--ucs2-lib/inc/ucs_ams.h161
-rw-r--r--ucs2-lib/inc/ucs_ams_pb.h224
-rw-r--r--ucs2-lib/inc/ucs_amsallocator.h104
-rw-r--r--ucs2-lib/inc/ucs_amsmessage.h206
-rw-r--r--ucs2-lib/inc/ucs_amspool.h98
-rw-r--r--ucs2-lib/inc/ucs_amtp.h83
-rw-r--r--ucs2-lib/inc/ucs_api.h72
-rw-r--r--ucs2-lib/inc/ucs_attach.h102
-rw-r--r--ucs2-lib/inc/ucs_base.h93
-rw-r--r--ucs2-lib/inc/ucs_bc_diag.h104
-rw-r--r--ucs2-lib/inc/ucs_class.h297
-rw-r--r--ucs2-lib/inc/ucs_class_pb.h2063
-rw-r--r--ucs2-lib/inc/ucs_cmd.h93
-rw-r--r--ucs2-lib/inc/ucs_cmd_pb.h124
-rw-r--r--ucs2-lib/inc/ucs_dec.h126
-rw-r--r--ucs2-lib/inc/ucs_dl.h130
-rw-r--r--ucs2-lib/inc/ucs_eh.h128
-rw-r--r--ucs2-lib/inc/ucs_eh_pb.h66
-rw-r--r--ucs2-lib/inc/ucs_encoder.h116
-rw-r--r--ucs2-lib/inc/ucs_epm.h110
-rw-r--r--ucs2-lib/inc/ucs_epm_pv.h103
-rw-r--r--ucs2-lib/inc/ucs_exc.h323
-rw-r--r--ucs2-lib/inc/ucs_factory.h167
-rw-r--r--ucs2-lib/inc/ucs_fsm.h118
-rw-r--r--ucs2-lib/inc/ucs_gpio.h144
-rw-r--r--ucs2-lib/inc/ucs_gpio_pb.h143
-rw-r--r--ucs2-lib/inc/ucs_i2c.h147
-rw-r--r--ucs2-lib/inc/ucs_i2c_pb.h142
-rw-r--r--ucs2-lib/inc/ucs_inic.h858
-rw-r--r--ucs2-lib/inc/ucs_inic_pb.h932
-rw-r--r--ucs2-lib/inc/ucs_jobs.h173
-rw-r--r--ucs2-lib/inc/ucs_lld_pb.h222
-rw-r--r--ucs2-lib/inc/ucs_lldpool.h110
-rw-r--r--ucs2-lib/inc/ucs_memory.h110
-rw-r--r--ucs2-lib/inc/ucs_memory_pb.h70
-rw-r--r--ucs2-lib/inc/ucs_message.h182
-rw-r--r--ucs2-lib/inc/ucs_message_pb.h181
-rw-r--r--ucs2-lib/inc/ucs_mgr.h121
-rw-r--r--ucs2-lib/inc/ucs_misc.h153
-rw-r--r--ucs2-lib/inc/ucs_net.h179
-rw-r--r--ucs2-lib/inc/ucs_nodedis.h197
-rw-r--r--ucs2-lib/inc/ucs_nodeobserver.h101
-rw-r--r--ucs2-lib/inc/ucs_nodeobserver_pb.h105
-rw-r--r--ucs2-lib/inc/ucs_nsm.h200
-rw-r--r--ucs2-lib/inc/ucs_nsm_pb.h136
-rw-r--r--ucs2-lib/inc/ucs_obs.h195
-rw-r--r--ucs2-lib/inc/ucs_pmchannel.h175
-rw-r--r--ucs2-lib/inc/ucs_pmcmd.h90
-rw-r--r--ucs2-lib/inc/ucs_pmevent.h85
-rw-r--r--ucs2-lib/inc/ucs_pmfifo.h230
-rw-r--r--ucs2-lib/inc/ucs_pmfifos.h128
-rw-r--r--ucs2-lib/inc/ucs_pmp.h209
-rw-r--r--ucs2-lib/inc/ucs_pool.h80
-rw-r--r--ucs2-lib/inc/ucs_prog.h114
-rw-r--r--ucs2-lib/inc/ucs_ret_pb.h141
-rw-r--r--ucs2-lib/inc/ucs_rm_pb.h112
-rw-r--r--ucs2-lib/inc/ucs_rm_pv.h69
-rw-r--r--ucs2-lib/inc/ucs_rsm.h161
-rw-r--r--ucs2-lib/inc/ucs_rsm_pv.h145
-rw-r--r--ucs2-lib/inc/ucs_rtm.h127
-rw-r--r--ucs2-lib/inc/ucs_rtm_pv.h116
-rw-r--r--ucs2-lib/inc/ucs_rules.h59
-rw-r--r--ucs2-lib/inc/ucs_scheduler.h146
-rw-r--r--ucs2-lib/inc/ucs_segmentation.h144
-rw-r--r--ucs2-lib/inc/ucs_smm.h149
-rw-r--r--ucs2-lib/inc/ucs_smm_pb.h114
-rw-r--r--ucs2-lib/inc/ucs_sys_diag.h143
-rw-r--r--ucs2-lib/inc/ucs_telqueue.h91
-rw-r--r--ucs2-lib/inc/ucs_timer.h144
-rw-r--r--ucs2-lib/inc/ucs_trace.h237
-rw-r--r--ucs2-lib/inc/ucs_trace_pb.h52
-rw-r--r--ucs2-lib/inc/ucs_transceiver.h133
-rw-r--r--ucs2-lib/inc/ucs_xrm.h219
-rw-r--r--ucs2-lib/inc/ucs_xrm_pb.h578
-rw-r--r--ucs2-lib/inc/ucs_xrm_pv.h210
-rw-r--r--ucs2-lib/inc/ucs_xrmpool.h154
78 files changed, 14819 insertions, 0 deletions
diff --git a/ucs2-lib/inc/ucs_alm.h b/ucs2-lib/inc/ucs_alm.h
new file mode 100644
index 0000000..df9deec
--- /dev/null
+++ b/ucs2-lib/inc/ucs_alm.h
@@ -0,0 +1,111 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the API locking module.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_ALM
+ * @{
+ */
+
+#ifndef UCS_ALM_H
+#define UCS_ALM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_eh.h"
+#include "ucs_timer.h"
+#include "ucs_obs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Bitmask used to store locked API methods */
+typedef uint32_t Alm_ModuleMask_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class structure of the API locking manager */
+typedef struct CApiLockingManager_
+{
+ CTimerManagement *tm_ptr; /*!< \brief Reference to timer management instance */
+ CEventHandler *eh_ptr; /*!< \brief Reference to event handler instance */
+ CTimer garbage_collector; /*!< \brief Timer for garbage collection */
+ CDlList api_list; /*!< \brief List of registered APIs */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+ CMaskedObserver internal_error_obs; /*!< \brief Error observer to handle internal errors and
+ events */
+
+} CApiLockingManager;
+
+/*! \brief Class structure of the API locking */
+typedef struct CApiLocking_
+{
+ CDlNode node; /*!< \brief Node of the doubly linked (API-) list */
+ CApiLockingManager *alm_ptr; /*!< \brief Reference to CApiLockingManager instance */
+ Alm_ModuleMask_t method_mask; /*!< \brief Bitmask which holds locked API methods */
+ Alm_ModuleMask_t timeout_mask; /*!< \brief Bitmask to report timeouts */
+ CSingleSubject subject; /*!< \brief Subject to update registered observer */
+ void * ucs_user_ptr; /*!< \brief UNICENS instance ID */
+
+} CApiLocking;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CApiLockingManager */
+/*------------------------------------------------------------------------------------------------*/
+extern void Alm_Ctor(CApiLockingManager *self,
+ CTimerManagement *tm_ptr,
+ CEventHandler *eh_ptr,
+ void * ucs_user_ptr);
+extern void Alm_RegisterApi(CApiLockingManager *self, CApiLocking *al_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CApiLocking */
+/*------------------------------------------------------------------------------------------------*/
+extern void Al_Ctor(CApiLocking *self, CSingleObserver *obs_ptr, void * ucs_user_ptr);
+extern bool Al_Lock(CApiLocking *self, Alm_ModuleMask_t method);
+extern void Al_Release(CApiLocking *self, Alm_ModuleMask_t method);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_ALM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_amd.h b/ucs2-lib/inc/ucs_amd.h
new file mode 100644
index 0000000..069b92f
--- /dev/null
+++ b/ucs2-lib/inc/ucs_amd.h
@@ -0,0 +1,141 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Application Message Distributor
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMD
+ * @{
+ */
+#ifndef UCS_AMD_H
+#define UCS_AMD_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_ams.h"
+#include "ucs_base.h"
+#include "ucs_amsmessage.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Assignable function which is invoked as soon as an application message is received
+ * completely and available in the Rx message queue
+ * \param self The instance
+ */
+typedef void (*Amd_RxMsgCompleteCb_t)(void *self);
+
+/*! \brief Assignable callback function which is able to read and modify the Rx message
+ * \param self The instance
+ * \param msg_ptr Reference to the Rx message object
+ */
+typedef void (*Amd_RxModificationCb_t)(void *self, Ucs_AmsRx_Msg_t *msg_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Application Message Service Class
+ * \details Allows transmission and reception of MOST Application Messages
+ */
+typedef struct CAmd_
+{
+ CBase *base_ptr; /*!< \brief Reference to basic services */
+ CAms *ams_ptr; /*!< \brief Reference to AMS */
+#ifdef AMD_TX_DISTRIB
+ CAmsMsgPool *pool_ptr; /*!< \brief Reference to AMS message pool */
+ CInic *inic_ptr; /*!< \brief Reference to INIC */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to network management */
+#endif
+ CService service; /*!< \brief Service object */
+ bool started; /*!< \brief Is \c true if the AMD is allowed
+ * to distribute messages
+ */
+ CMaskedObserver event_observer; /*!< \brief Observes init complete event */
+ CMaskedObserver terminate_observer; /*!< \brief Observes events leading to termination */
+
+ void *preprocess_inst_ptr; /*!< \brief Reference to the message preprocessor */
+ Amd_RxMsgCompleteCb_t preprocess_fptr; /*!< \brief Callback function which is invoked first
+ * on completed message reception
+ */
+
+ void *receive_inst_ptr; /*!< \brief Reference to the message receiver */
+ Amd_RxMsgCompleteCb_t receive_fptr; /*!< \brief Callback function which is invoked after
+ * the preprocessor has finished
+ */
+#ifdef AMD_TX_DISTRIB
+ CDlList tx_notify_queue; /*!< \brief Queue to notify asynchronously a failed transmission */
+#endif
+ CDlList pre_queue; /*!< \brief Queue of messages for the preprocessor */
+ CDlList rx_queue; /*!< \brief Queue of messages for the receiver */
+
+ CDlList *first_q_ptr; /*!< \brief Reference where to queue the messages first */
+ Amd_RxMsgCompleteCb_t first_receive_fptr; /*!< \brief Reference of the callback to be fired first */
+ void *first_receive_inst_ptr; /*!< \brief Reference to the first receiver */
+
+ Amd_RxModificationCb_t rx_modification_fptr; /*!< \brief Callback function for message modification */
+ void *rx_modification_inst_ptr; /*!< \brief Callback reference for message modification */
+
+} CAmd;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Amd_Ctor(CAmd *self, CBase *base_ptr, CAms *ams_ptr);
+extern void Amd_AssignPreprocessor(CAmd *self, Amd_RxMsgCompleteCb_t callback_fptr, void *inst_ptr);
+extern void Amd_AssignReceiver(CAmd *self, Amd_RxMsgCompleteCb_t callback_fptr, void *inst_ptr);
+extern void Amd_RxAssignModificator(CAmd *self, Amd_RxModificationCb_t callback_fptr, void *inst_ptr);
+
+extern Ucs_AmsRx_Msg_t* Amd_PrePeekMsg(CAmd *self);
+extern void Amd_PreReleaseMsg(CAmd *self);
+extern void Amd_PreForwardMsg(CAmd *self);
+
+extern Ucs_AmsRx_Msg_t* Amd_RxPeekMsg(CAmd *self);
+extern void Amd_RxReleaseMsg(CAmd *self);
+extern uint16_t Amd_RxGetMsgCnt(CAmd *self);
+
+#ifdef AMD_TX_DISTRIB
+Ucs_Return_t Amd_TxSendMsg(CAmd *self, Ucs_AmsTx_Msg_t *msg_ptr, Amsg_TxCompleteSiaCb_t tx_complete_sia_fptr,
+ Amsg_TxCompleteCb_t tx_complete_fptr, void* tx_complete_inst_ptr);
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMD_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_ams.h b/ucs2-lib/inc/ucs_ams.h
new file mode 100644
index 0000000..662cc43
--- /dev/null
+++ b/ucs2-lib/inc/ucs_ams.h
@@ -0,0 +1,161 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Application Message Service
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMSC
+ * @{
+ */
+
+#ifndef UCS_AMS_H
+#define UCS_AMS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_ams_pb.h"
+#include "ucs_amsmessage.h"
+#include "ucs_amspool.h"
+#include "ucs_pool.h"
+#include "ucs_transceiver.h"
+#include "ucs_pmchannel.h"
+#include "ucs_ret_pb.h"
+#include "ucs_segmentation.h"
+#include "ucs_message.h"
+#include "ucs_telqueue.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Defines the default LLR number for Application Messages */
+#define AMS_LLRBC_DEFAULT (MSG_LLRBC_DEFAULT)
+/*! \brief Defines the maximum LLR number for Application Messages */
+#define AMS_LLRBC_MAX (MSG_LLRBC_MAX)
+/*! \brief Default memory size that is allocated when receiving segmented messages
+ * without size prefix */
+#define AMS_RX_DEF_SIZE_PAYLOAD 400U
+/*! \brief Maximum destination address which is reserved for internal transmission */
+#define AMS_ADDR_RSVD_RANGE 0x000FU
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback function type to request FIFO routing for a Tx message.
+ * \param msg_ptr Reference to a Tx message object
+ * \return Returns \c true if a Tx message shall be routed to RCM FIFO, otherwise returns \c false.
+ */
+typedef bool (*Ams_TxIsRcmMsgCb_t)(Ucs_AmsTx_Msg_t *msg_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Application Message Service Class
+ * \details Allows transmission and reception of MOST Application Messages
+ */
+typedef struct CAms_
+{
+ CService service; /*!< \brief Service object */
+ CSegmentation segmentation; /*!< \brief Segmentation object */
+ CMaskedObserver unsync_result_observer; /*!< \brief Observes un-sync result */
+
+ CBase *base_ptr; /*!< \brief Reference to basic services */
+ CAmsMsgPool *pool_ptr; /*!< \brief Pool providing Rx and Tx objects/payload */
+ CTransceiver *trcv_mcm_ptr; /*!< \brief Reference to MCM transceiver */
+ CTransceiver *trcv_rcm_ptr; /*!< \brief Reference to RCM transceiver */
+
+ struct Ams_tx_
+ {
+ CDlList queue; /*!< \brief Input queue of Tx Application Messages */
+ uint8_t default_llrbc; /*!< \brief Default LowLevelRetryBlockCount. Valid values: 0..100 */
+ Ams_TxIsRcmMsgCb_t is_rcm_fptr; /*!< \brief Assignable callback function to request the correct transceiver */
+ uint8_t next_follower_id; /*!< \brief The follower id for the next segmented
+ * message
+ */
+ } tx;
+
+ struct Ams_rx_
+ {
+ CObserver message_freed_observer; /*!< \brief Observes message freed event */
+
+ Amsg_RxCompleteCb_t complete_fptr; /*!< \brief Callback function which is invoked on
+ * message reception
+ */
+ void *complete_inst_ptr; /*!< \brief Instance which is notified on
+ * message reception
+ */
+ CTelQueue waiting_queue; /*!< \brief Queue of unprocessed single telegrams */
+
+ } rx;
+
+} CAms;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Initialization Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ams_Ctor(CAms *self, CBase *base_ptr, CTransceiver *mcm_trcv_ptr, CTransceiver *rcm_trcv_ptr,
+ CAmsMsgPool *pool_ptr, uint16_t rx_def_payload_sz);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Public methods / Tx */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ams_TxSetDefaultRetries(CAms *self, uint8_t llrbc);
+extern void Ams_TxAssignMsgFreedObs(CAms *self, CObserver *observer_ptr);
+extern void Ams_TxAssignTrcvSelector(CAms *self, Ams_TxIsRcmMsgCb_t cb_fptr);
+extern Ucs_AmsTx_Msg_t* Ams_TxGetMsg(CAms *self, uint16_t size);
+extern void Ams_TxFreeUnusedMsg(CAms *self, Ucs_AmsTx_Msg_t *msg_ptr);
+extern uint16_t Ams_TxGetMsgCnt(CAms *self);
+extern bool Ams_TxIsValidMessage(Ucs_AmsTx_Msg_t *msg_ptr);
+extern void Ams_TxSendMsgDirect(CAms *self, Ucs_AmsTx_Msg_t *msg_ptr);
+extern Ucs_Return_t Ams_TxSendMsg(CAms *self, Ucs_AmsTx_Msg_t *msg_ptr, Amsg_TxCompleteSiaCb_t tx_complete_sia_fptr,
+ Amsg_TxCompleteCb_t tx_complete_fptr, void* tx_complete_inst_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Public methods / Rx */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ams_RxAssignReceiver(CAms *self, Amsg_RxCompleteCb_t cb_fptr, void *inst_ptr);
+extern void Ams_RxFreeMsg(CAms *self, Ucs_AmsRx_Msg_t *msg_ptr);
+extern void Ams_RxOnMcmTelComplete(void *self, Msg_MostTel_t *tel_ptr);
+extern void Ams_RxOnRcmTelComplete(void *self, Msg_MostTel_t *tel_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMS_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_ams_pb.h b/ucs2-lib/inc/ucs_ams_pb.h
new file mode 100644
index 0000000..866a516
--- /dev/null
+++ b/ucs2-lib/inc/ucs_ams_pb.h
@@ -0,0 +1,224 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of Application Message Service
+ */
+/*!
+ * \addtogroup G_UCS_AMS_TYPES
+ * @{
+ */
+
+#ifndef UCS_AMS_PB_H
+#define UCS_AMS_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_message_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*! \brief Defines which address type was used by the transmitter of a message. */
+typedef enum Ucs_AmsRx_ReceiveType_
+{
+ UCS_AMSRX_RCT_SINGLECAST = 0U, /*!< \brief Message was transmitted as singlecast */
+ UCS_AMSRX_RCT_GROUPCAST = 1U, /*!< \brief Message was transmitted as groupcast */
+ UCS_AMSRX_RCT_BROADCAST = 2U /*!< \brief Message was transmitted as broadcast */
+
+} Ucs_AmsRx_ReceiveType_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Application message Tx type */
+typedef struct Ucs_AmsTx_Msg_
+{
+ uint16_t destination_address; /*!< \brief Destination address. Find some predefined addresses \ref G_UCS_AMS "here". */
+ uint16_t msg_id; /*!< \brief 16bit message descriptor */
+ uint8_t llrbc; /*!< \brief Specifies the "Low-Level Retry Block Count" (LLRBC)
+ * \details Valid values: 0..100. Default value: configurable via \ref Ucs_AmsTx_InitData_t "default_llrbc"
+ * of the initialization structure \ref Ucs_AmsTx_InitData_t.
+ */
+ uint8_t *data_ptr; /*!< \brief Payload data */
+ uint16_t data_size; /*!< \brief The size of payload data in bytes */
+ void *custom_info_ptr; /*!< \brief Customer specific reference
+ * \details The application is allowed to use this attribute to assign an
+ * own reference to the message object. The reference is initialized
+ * by the UNICENS library with \c NULL and will not alter until the
+ * transmission has finished.
+ */
+} Ucs_AmsTx_Msg_t;
+
+/*! \brief Application message Rx type */
+typedef struct Ucs_AmsRx_Msg_
+{
+ uint16_t source_address; /*!< \brief Source address */
+ uint16_t msg_id; /*!< \brief 16bit message descriptor */
+ uint8_t *data_ptr; /*!< \brief Reference to payload */
+ uint16_t data_size; /*!< \brief Payload size in bytes */
+ void *custom_info_ptr; /*!< \brief Customer specific reference */
+ Ucs_AmsRx_ReceiveType_t receive_type; /*!< \brief Defines which address type was used by the transmitter of this message */
+
+} Ucs_AmsRx_Msg_t;
+
+/*! \brief Transmission result of an application message */
+typedef enum Ucs_AmsTx_Result_
+{
+ UCS_AMSTX_RES_SUCCESS = 0x00U,/*!< \brief The transmission succeeded. */
+
+ UCS_AMSTX_RES_ERR_RETRIES_EXP = 0x01U,/*!< \brief The transmission including all retries have failed.
+ * \details The following issues may have caused the failure:
+ * - message corruption
+ * - transmission timeouts
+ * - full receive buffers of the destination device
+ * - full receive buffers of the local device if the
+ * destination was the own address, own group or broadcast
+ * address
+ * .
+ */
+ UCS_AMSTX_RES_ERR_INVALID_TGT = 0x02U,/*!< \brief The transmission failed because the specified destination
+ * address is not found or not valid.
+ * \details The following issues may have caused the failure:
+ * - device with the given destination address is not found
+ * - destination address is reserved (for future use)
+ * - destination address is 0xFFFF (un-initialized logical
+ * node address is not supported)
+ * .
+ */
+ UCS_AMSTX_RES_ERR_NOT_AVAILABLE = 0x03U,/*!< \brief The transmission failed since the network or the INIC
+ * is not available.
+ */
+ UCS_AMSTX_RES_ERR_BUF_INTERNAL = 0xFEU,/*!< \brief The transmission failed because the allocation of an Rx message object failed.
+ * The Rx message object is required to receive the message via the own Rx message queue.
+ * \details This is possible in the following cases:
+ * - A message is transmitted to the own node address and the allocation
+ * of an Rx message object failed.
+ * - The network transmission to the own group address or broadcast address
+ * succeeded but the allocation of an Rx message object failed. The application
+ * has to decide whether to retransmit the message to the own address again.
+ */
+ UCS_AMSTX_RES_ERR_UNEXPECTED = 0xFFU /*!< \brief The transmission failed due to an unexpected error.
+ * The cause of this failure may be an invalid INIC configuration,
+ * or an INIC to UNICENS incompatibility issue.
+ */
+} Ucs_AmsTx_Result_t;
+
+
+/*! \brief Detailed INIC transmission information which might be useful for debugging purposes. */
+typedef enum Ucs_AmsTx_Info_
+{
+ UCS_AMSTX_I_SUCCESS = 0x00U, /*!< \brief The transmission succeeded.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_SUCCESS.
+ */
+ UCS_AMSTX_I_ERR_CFG_NORECEIVER = 0x01U, /*!< \brief The transmission failed because the MOST network is not accessible for
+ * MCM in the current attach state or for ICM in general.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_UNEXPECTED.
+ */
+ UCS_AMSTX_I_ERR_BF = 0x08U, /*!< \brief The transmission failed because the receivers buffer is full.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_RETRIES_EXP.
+ */
+ UCS_AMSTX_I_ERR_CRC = 0x09U, /*!< \brief The transmission failed because of a failed CRC.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_RETRIES_EXP.
+ */
+ UCS_AMSTX_I_ERR_ID = 0x0AU, /*!< \brief The transmission failed because of corrupted identifiers.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_RETRIES_EXP.
+ */
+ UCS_AMSTX_I_ERR_ACK = 0x0BU, /*!< \brief The transmission failed because of corrupted PACK or CACK.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_RETRIES_EXP.
+ */
+ UCS_AMSTX_I_ERR_TIMEOUT = 0x0CU, /*!< \brief The transmission failed because of a transmission timeout.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_RETRIES_EXP.
+ */
+ UCS_AMSTX_I_ERR_FATAL_WT = 0x10U, /*!< \brief The transmission failed because of destination is not available.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_INVALID_TGT.
+ */
+ UCS_AMSTX_I_ERR_FATAL_OA = 0x11U, /*!< \brief The transmission failed because of the destination is the own node address.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_INVALID_TGT.
+ */
+ UCS_AMSTX_I_ERR_UNAVAIL_TRANS = 0x18U, /*!< \brief The transmission canceled during the transition from network interface state
+ * "available" to "not available".
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_NOT_AVAILABLE.
+ */
+ UCS_AMSTX_I_ERR_UNAVAIL_OFF = 0x19U, /*!< \brief The transmission failed because the network interface state is "not available".
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_NOT_AVAILABLE.
+ */
+ UCS_AMSTX_I_ERR_UNKNOWN = 0xFEU, /*!< \brief The transmission failed because of an unknown INIC error code.
+ * \details The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_UNEXPECTED.
+ * Please check if the MNS version is compatible with the applied INIC firmware version.
+ */
+ UCS_AMSTX_I_ERR_UNSYNCED = 0xFFU /*!< \brief The transmission failed because the communication between the EHC
+ * and the INIC is lost.
+ * \details The reason can be a communication error between the EHC and the INIC or that
+ * the application has called Ucs_Stop().\n
+ * The corresponding transmission result is \ref UCS_AMSTX_RES_ERR_NOT_AVAILABLE.
+ */
+} Ucs_AmsTx_Info_t;
+
+/*! \brief Type of a callback function that is invoked as soon as a
+ * message transmission was finished
+ * \details The callback function notifies the result of a completed transmission. If
+ * the message has external payload, the application must decide whether
+ * to re-use or to free the external payload.
+ * \param msg_ptr Reference to the related Tx message object. When the callback function returns
+ * the reference is no longer valid.
+ * \param result The transmission result.
+ * \param info Detailed INIC transmission result, which might be helpful for debug purposes.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_AmsTx_CompleteCb_t)(Ucs_AmsTx_Msg_t* msg_ptr, Ucs_AmsTx_Result_t result, Ucs_AmsTx_Info_t info, void *user_ptr);
+
+/*!
+ * @}
+ * \addtogroup G_UCS_AMS
+ * @{
+ */
+
+/*! \brief Type of a callback function that is invoked to notify that
+ * a Tx application message object is available again while a previous
+ * allocation using Ucs_AmsTx_AllocMsg() has failed.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_AmsTx_MsgFreedCb_t)(void *user_ptr);
+
+/*! \brief Callback function type that is invoked if UNICENS has received a message
+ * completely and appended to the Rx message queue.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_AmsRx_MsgReceivedCb_t)(void *user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* ifndef UCS_AMS_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_amsallocator.h b/ucs2-lib/inc/ucs_amsallocator.h
new file mode 100644
index 0000000..b22db9d
--- /dev/null
+++ b/ucs2-lib/inc/ucs_amsallocator.h
@@ -0,0 +1,104 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of AMS Allocator Interface
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMSC
+ * @{
+ */
+
+#ifndef UCS_AMSALLOCATOR_H
+#define UCS_AMSALLOCATOR_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Defines the usage of a requested memory chunk */
+typedef enum Ams_MemUsage_
+{
+ AMS_MU_RX_OBJECT, /*!< \brief Memory is required to allocate an Rx message object */
+ AMS_MU_RX_PAYLOAD, /*!< \brief Memory is required to allocate Rx message payload */
+ AMS_MU_TX_OBJECT, /*!< \brief Memory is required to allocate a Tx message object */
+ AMS_MU_TX_PAYLOAD /*!< \brief Memory is required to allocate Tx message payload */
+
+} Ams_MemUsage_t;
+
+/*! \brief Callback function type that is invoked to allocate external payload for a segmented Rx message
+ * \param inst_ptr Reference to the (external) memory management
+ * \param mem_size Reference to the required memory size in bytes. Valid values: 0..65535.
+ * \param type Declares how the memory is used by UNICENS
+ * \param custom_info_pptr Reference which is related to the memory chunk and can be set by
+ * the application.
+ * \return Pointer to the provided memory chunk. The application has to guarantee that the memory size
+ * is equal or greater than \c mem_size. The application has to return \c NULL if it is not able
+ * to allocate the required memory at this moment.
+ */
+typedef void* (*Ams_AllocMemCb_t)(void *inst_ptr, uint16_t mem_size, Ams_MemUsage_t type, void** custom_info_pptr);
+
+/*! \brief Callback function type that is invoked to free external payload for a segmented Rx message
+ * \param inst_ptr Reference to the (external) memory management
+ * \param mem_ptr Reference to the external payload memory
+ * \param type Declares how the memory is used by UNICENS
+ * \param custom_info_ptr Reference to memory related information which was set by the application
+ * during memory allocation
+ */
+typedef void (*Ams_FreeMemCb_t)(void *inst_ptr, void *mem_ptr, Ams_MemUsage_t type, void* custom_info_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Allocator interface */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Keeps callback functions to an external memory management for Rx payload */
+typedef struct Ams_MemAllocator_
+{
+ void *inst_ptr; /*!< \brief The instance of the (external) memory management */
+ Ams_AllocMemCb_t alloc_fptr; /*!< \brief This function is invoked to allocate Rx user payload */
+ Ams_FreeMemCb_t free_fptr; /*!< \brief This function is invoked to free Rx user payload */
+
+} Ams_MemAllocator_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMSALLOCATOR_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_amsmessage.h b/ucs2-lib/inc/ucs_amsmessage.h
new file mode 100644
index 0000000..8e49e8f
--- /dev/null
+++ b/ucs2-lib/inc/ucs_amsmessage.h
@@ -0,0 +1,206 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Application Message Classes
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMSMSG
+ * @{
+ */
+
+#ifndef UCS_AMSMESSAGE_H
+#define UCS_AMSMESSAGE_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_ams_pb.h"
+#include "ucs_message.h"
+#include "ucs_dl.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants */
+/*------------------------------------------------------------------------------------------------*/
+#define AMSG_TX_OBJECT_SZ (sizeof(Amsg_IntMsgTx_t))
+#define AMSG_RX_OBJECT_SZ (sizeof(Amsg_IntMsgRx_t))
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Internal transmission result of an application message */
+typedef enum Amsg_TxIntStatus_
+{
+ AMSG_TX_INTRES_NONE = 0x00U, /*!< \brief The internal transmission is not applicable. */
+ AMSG_TX_INTRES_SUCCESS = 0x01U, /*!< \brief The internal transmission succeeded. */
+ AMSG_TX_INTRES_ERRBUF = 0x02U /*!< \brief The internal transmission failed. */
+
+} Amsg_TxIntStatus_t;
+
+/*! \brief Assignable function which is invoked as soon as an application message is received
+ * completely and available in the Rx message queue
+ * \param self The instance (optional)
+ * \param msg_ptr Reference to the received message
+ */
+typedef void (*Amsg_RxCompleteCb_t)(void* self, Ucs_AmsRx_Msg_t* msg_ptr);
+
+/*! \brief Callback function type which is fired as soon as an AMS transmission was finished
+ * \param msg_ptr Reference to the related message object
+ * \param result Transmission result
+ * \param info Detailed INIC transmission result
+ * \param self The instance (optional)
+ */
+typedef void (*Amsg_TxCompleteCb_t)(Ucs_AmsTx_Msg_t* msg_ptr, Ucs_AmsTx_Result_t result, Ucs_AmsTx_Info_t info, void* self);
+
+/*! \brief Single instance API callback function type which is fired as soon as an AMS transmission was finished
+ * \param msg_ptr Reference to the related message object
+ * \param result Transmission result
+ * \param info Detailed INIC transmission result
+ */
+typedef void (*Amsg_TxCompleteSiaCb_t)(Ucs_AmsTx_Msg_t* msg_ptr, Ucs_AmsTx_Result_t result, Ucs_AmsTx_Info_t info);
+
+/*! \brief Callback function which is invoked to free a Tx message object to the owning pool
+ * \param owner_ptr The owning pool of the message object
+ * \param msg_ptr Reference to the related message object
+ */
+typedef void (*Amsg_TxFreedCb_t)(void *owner_ptr, Ucs_AmsTx_Msg_t* msg_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Internal Tx message structure */
+typedef struct Amsg_IntMsgTx_
+{
+ Ucs_AmsTx_Msg_t pb_msg; /*!< \brief Public message struct must be the first member */
+ void *info_ptr; /*!< \brief Custom object information required by memory management */
+
+ void *free_inst_ptr; /*!< \brief Reference which is passed to free_ptr */
+ Amsg_TxFreedCb_t free_fptr; /*!< \brief Callback function which is called to free the object */
+
+ uint8_t *memory_ptr; /*!< \brief Reference to payload provided by memory management */
+ void *memory_info_ptr; /*!< \brief Custom payload information required by memory management */
+ uint16_t memory_sz; /*!< \brief Size of the payload that is provided by memory management */
+
+ uint16_t next_segment_cnt; /*!< \brief Specifies the next segment count. '0xFF' means size prefixed */
+ uint8_t follower_id; /*!< \brief Identifier of segmented messages and corresponding telegrams */
+ Ucs_MsgTxStatus_t temp_result; /*!< \brief Stores the temporary result that is notified when then transmission
+ * has completed
+ */
+ uint16_t backup_dest_address; /*!< \brief Backup of replaced target address. */
+ Amsg_TxIntStatus_t internal_status; /*!< \brief Stores the internal transmission status */
+ bool ignore_wrong_target; /*!< \brief Forces the message to report transmission result "success", although
+ * the INIC has reported transmission error "wrong target"
+ */
+ CDlNode node; /*!< \brief Node required for message pool */
+
+ Amsg_TxCompleteSiaCb_t complete_sia_fptr; /*!< \brief Single instance API Callback function which is invoked
+ * after transmission completed
+ */
+ Amsg_TxCompleteCb_t complete_fptr; /*!< \brief Callback function which is invoked after transmission
+ * completed
+ */
+ void *complete_inst_ptr; /*!< \brief Instance pointer which is required to invoke complete_fptr */
+
+} Amsg_IntMsgTx_t;
+
+/*! \brief Internal Rx message structure */
+typedef struct Amsg_IntMsgRx_
+{
+ Ucs_AmsRx_Msg_t pb_msg; /*!< \brief Public message structure must be the first member */
+ void *info_ptr; /*!< \brief Custom object information required by memory management */
+
+ uint8_t *memory_ptr; /*!< \brief Reference to payload provided by memory management */
+ void *memory_info_ptr; /*!< \brief Custom payload information required by memory management */
+ uint16_t memory_sz; /*!< \brief The size of the allocated user payload in bytes */
+
+ CDlNode node; /*!< \brief Node required for message pool */
+
+ uint8_t exp_tel_cnt; /*!< \brief The expected TelCnt used for segmented transfer */
+ bool gc_marker; /*!< \brief Identifies message objects that were already
+ * marked by the garbage collector.
+ */
+} Amsg_IntMsgRx_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class methods */
+/*------------------------------------------------------------------------------------------------*/
+/* Tx */
+extern void Amsg_TxCtor(Ucs_AmsTx_Msg_t *self, void *info_ptr, Amsg_TxFreedCb_t free_fptr, void *free_inst_ptr);
+extern void Amsg_TxSetInternalPayload(Ucs_AmsTx_Msg_t *self, uint8_t *mem_ptr, uint16_t mem_size, void *mem_info_ptr);
+extern void Amsg_TxReuse(Ucs_AmsTx_Msg_t *self);
+extern void Amsg_TxSetCompleteCallback(Ucs_AmsTx_Msg_t *self, Amsg_TxCompleteSiaCb_t compl_sia_fptr,
+ Amsg_TxCompleteCb_t compl_fptr, void* compl_inst_ptr);
+extern void Amsg_TxNotifyComplete(Ucs_AmsTx_Msg_t *self, Ucs_AmsTx_Result_t result, Ucs_AmsTx_Info_t info);
+extern void Amsg_TxFreeUnused(Ucs_AmsTx_Msg_t *self);
+extern void Amsg_TxUpdateInternalResult(Ucs_AmsTx_Msg_t *self, Amsg_TxIntStatus_t result);
+extern void Amsg_TxUpdateResult(Ucs_AmsTx_Msg_t *self, Ucs_MsgTxStatus_t result);
+extern Ucs_AmsTx_Result_t Amsg_TxGetResultCode(Ucs_AmsTx_Msg_t *self);
+extern Ucs_AmsTx_Info_t Amsg_TxGetResultInfo(Ucs_AmsTx_Msg_t *self);
+extern uint16_t Amsg_TxGetNextSegmCnt(Ucs_AmsTx_Msg_t *self);
+extern void Amsg_TxIncrementNextSegmCnt(Ucs_AmsTx_Msg_t *self);
+extern uint8_t Amsg_TxGetFollowerId(Ucs_AmsTx_Msg_t *self);
+extern void Amsg_TxSetFollowerId(Ucs_AmsTx_Msg_t *self, uint8_t id);
+extern void Amsg_TxReplaceDestinationAddr(Ucs_AmsTx_Msg_t *self, uint16_t new_destination);
+extern void Amsg_TxRemoveFromQueue(Ucs_AmsTx_Msg_t *self, CDlList *list_ptr);
+extern void Amsg_TxEnqueue(Ucs_AmsTx_Msg_t* self, CDlList* list_ptr);
+extern Ucs_AmsTx_Msg_t* Amsg_TxPeek(CDlList* list_ptr);
+extern Ucs_AmsTx_Msg_t* Amsg_TxDequeue(CDlList* list_ptr);
+
+/* Rx */
+extern void Amsg_RxCtor(Ucs_AmsRx_Msg_t *self, void *info_ptr);
+extern void Amsg_RxBuildFromTx(Ucs_AmsRx_Msg_t *self, Ucs_AmsTx_Msg_t *tx_ptr, uint16_t source_address);
+extern void Amsg_RxHandleSetup(Ucs_AmsRx_Msg_t *self);
+extern void Amsg_RxHandleSetMemory(Ucs_AmsRx_Msg_t *self, uint8_t *mem_ptr, uint16_t mem_size, void *info_ptr);
+extern bool Amsg_RxHandleIsIdentical(Ucs_AmsRx_Msg_t *self, Msg_MostTel_t *tel_ptr);
+extern void Amsg_RxCopySignatureFromTel(Ucs_AmsRx_Msg_t *self, Msg_MostTel_t* src_ptr);
+extern void Amsg_RxCopySignatureToTel(Ucs_AmsRx_Msg_t *self, Msg_MostTel_t* target_ptr);
+extern void Amsg_RxCopyToPayload(Ucs_AmsRx_Msg_t *self, uint8_t data[], uint8_t data_sz);
+extern bool Amsg_RxAppendPayload(Ucs_AmsRx_Msg_t *self, Msg_MostTel_t* src_ptr);
+extern bool Amsg_RxHasExternalPayload(Ucs_AmsRx_Msg_t *self);
+extern void Amsg_RxEnqueue(Ucs_AmsRx_Msg_t* self, CDlList* list_ptr);
+extern void Amsg_RxSetGcMarker(Ucs_AmsRx_Msg_t* self, bool value);
+extern bool Amsg_RxGetGcMarker(Ucs_AmsRx_Msg_t* self);
+extern uint8_t Amsg_RxGetExpTelCnt(Ucs_AmsRx_Msg_t* self);
+/* Rx helpers */
+extern Ucs_AmsRx_Msg_t* Amsg_RxPeek(CDlList* list_ptr);
+extern Ucs_AmsRx_Msg_t* Amsg_RxDequeue(CDlList* list_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMSMESSAGE_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_amspool.h b/ucs2-lib/inc/ucs_amspool.h
new file mode 100644
index 0000000..41d262c
--- /dev/null
+++ b/ucs2-lib/inc/ucs_amspool.h
@@ -0,0 +1,98 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Application Message Pools
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMSPOOL
+ * @{
+ */
+
+#ifndef UCS_AMSPOOL_H
+#define UCS_AMSPOOL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_ams_pb.h"
+#include "ucs_obs.h"
+#include "ucs_amsallocator.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Classes */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class members of AMS Pool */
+typedef struct CAmsMsgPool_
+{
+ Ams_MemAllocator_t *allocator_ptr; /*!< \brief Interface to memory allocator */
+ Ucs_AmsRx_Msg_t *rx_rsvd_msg_ptr; /*!< \brief Pre-allocated Rx message or NULL if no
+ * reserved message is available */
+ Ucs_AmsRx_Msg_t *rx_rsvd_msg_ref; /*!< \brief Stores the reference of the reserved message
+ * to identify it and restore the
+ * \c rx_rsvd_msg_ptr. */
+ CSubject tx_freed_subject; /*!< \brief Allows to observe freed Tx message event */
+ CSubject rx_freed_subject; /*!< \brief Allows to observe freed Rx message event */
+ bool tx_notify_freed; /*!< \brief Is \c true when to notify the next Tx freed object */
+ bool rx_notify_freed; /*!< \brief Is \c true when to notify the next Rx freed object */
+ bool terminated; /*!< \brief Is \c true if a cleanup was done. Helps to release the
+ * pre-allocated message after the first cleanup attempt. */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CAmsMsgPool;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Amsp_Ctor(CAmsMsgPool *self, Ams_MemAllocator_t *mem_allocator_ptr, void *ucs_user_ptr);
+extern void Amsp_Cleanup(CAmsMsgPool *self);
+/* Tx */
+extern void Amsp_AssignTxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
+extern Ucs_AmsTx_Msg_t* Amsp_AllocTxObj(CAmsMsgPool *self, uint16_t payload_sz);
+/* Rx */
+extern void Amsp_AssignRxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
+extern Ucs_AmsRx_Msg_t* Amsp_AllocRxObj(CAmsMsgPool *self, uint16_t payload_sz);
+extern Ucs_AmsRx_Msg_t* Amsp_AllocRxRsvd(CAmsMsgPool *self);
+extern bool Amsp_AllocRxPayload(CAmsMsgPool *self, uint16_t payload_sz, Ucs_AmsRx_Msg_t* msg_ptr);
+extern void Amsp_FreeRxObj(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
+extern void Amsp_FreeRxPayload(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMSPOOL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_amtp.h b/ucs2-lib/inc/ucs_amtp.h
new file mode 100644
index 0000000..b2a22a5
--- /dev/null
+++ b/ucs2-lib/inc/ucs_amtp.h
@@ -0,0 +1,83 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Application Message Tx Pool
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMTP
+ * @{
+ */
+
+#ifndef UCS_AMSP_H
+#define UCS_AMSP_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_amsmessage.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Application Message Tx Pool Class
+ * \details Provides a predefined number of Tx message objects to an internal class
+ */
+typedef struct CAmtp_
+{
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+ CDlList msg_queue; /*!< \brief Queue of messages for the receiver */
+
+} CAmtp;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Amtp_Ctor(CAmtp *self, Amsg_IntMsgTx_t msg_ptr[], uint8_t data_ptr[], uint8_t msg_cnt, uint16_t payload_sz, void *ucs_user_ptr);
+extern Ucs_AmsTx_Msg_t* Amtp_AllocMsg(CAmtp *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_AMD_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_api.h b/ucs2-lib/inc/ucs_api.h
new file mode 100644
index 0000000..c11b2e8
--- /dev/null
+++ b/ucs2-lib/inc/ucs_api.h
@@ -0,0 +1,72 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief UNICENSV2 API include file
+ */
+
+#ifndef UCS_API_H
+#define UCS_API_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Version */
+/*------------------------------------------------------------------------------------------------*/
+/* parasoft suppress item MISRA2004-19_4 reason "No message in public version (PPP issue)" */
+
+/*! \brief UNICENS Major Version Number
+ * \ingroup G_UCS_MISC
+ */
+#define UCS_VERSION_MAJOR 2
+
+/*! \brief UNICENS Minor Version Number
+ * \ingroup G_UCS_MISC
+ */
+#define UCS_VERSION_MINOR 1
+
+/*! \brief UNICENS Release Version Number
+ * \ingroup G_UCS_MISC
+ */
+#define UCS_VERSION_RELEASE 0
+
+/*! \brief UNICENS Build Number
+ * \ingroup G_UCS_MISC
+ */
+#define UCS_VERSION_BUILD 3491
+
+/* parasoft unsuppress item MISRA2004-19_4 reason "No message in public version (PPP issue)" */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_ret_pb.h"
+#include "ucs_lld_pb.h"
+#include "ucs_trace_pb.h"
+
+#include "ucs_eh_pb.h"
+#include "ucs_class_pb.h"
+
+#endif /* UCS_API_H */
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_attach.h b/ucs2-lib/inc/ucs_attach.h
new file mode 100644
index 0000000..e775c0b
--- /dev/null
+++ b/ucs2-lib/inc/ucs_attach.h
@@ -0,0 +1,102 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of CAttachService class
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_ATS
+ * @{
+ */
+
+#ifndef UCS_ATTACH_H
+#define UCS_ATTACH_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_obs.h"
+#include "ucs_fsm.h"
+#include "ucs_base.h"
+#include "ucs_pmfifos.h"
+#include "ucs_pmevent.h"
+#include "ucs_inic.h"
+#include "ucs_ret_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the attach service. */
+typedef struct Ats_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to UCS base instance */
+ CPmFifos *fifos_ptr; /*!< \brief Reference to PMS FIFOs */
+ CPmEventHandler *pme_ptr; /*!< \brief Reference to PMS Event Handler */
+ CInic *inic_ptr; /*!< \brief Reference to INIC Management instance */
+
+} Ats_InitData_t;
+
+/*! \brief Class structure of the attach service. */
+typedef struct CAttachService_
+{
+ Ats_InitData_t init_data; /*!< \brief Objects required for attach process */
+ CFsm fsm; /*!< \brief Attach state machine */
+ CService ats_srv; /*!< \brief Service instance for the scheduler */
+ CObserver obs; /*!< \brief Observer used for asynchronous events */
+ CObserver obs2; /*!< \brief Observer used for asynchronous events */
+ CSingleObserver sobs; /*!< \brief Single-observer used for asynchronous
+ results */
+ CMaskedObserver internal_error_obs; /*!< \brief Error observer to handle INIC errors
+ during the attach process */
+ CTimer timer; /*!< \brief Timer to check for init timeout */
+ CSingleSubject ats_result_subject; /*!< \brief Subject to report the result of the
+ attach process */
+ Ucs_InitResult_t report_result; /*!< \brief Internal result/error code memory */
+
+} CAttachService;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CAttach */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ats_Ctor(CAttachService *self, Ats_InitData_t *init_ptr);
+extern void Ats_Start(void *self, CSingleObserver *obs_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_ATTACH_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_base.h b/ucs2-lib/inc/ucs_base.h
new file mode 100644
index 0000000..08e7908
--- /dev/null
+++ b/ucs2-lib/inc/ucs_base.h
@@ -0,0 +1,93 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Base class.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_BASE
+ * @{
+ */
+
+#ifndef UCS_BASE_H
+#define UCS_BASE_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_timer.h"
+#include "ucs_scheduler.h"
+#include "ucs_trace.h"
+#include "ucs_eh.h"
+#include "ucs_alm.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the Base class. */
+typedef struct Base_InitData_
+{
+ void *ucs_user_ptr; /*!< \brief User reference for API callback functions */
+ uint8_t ucs_inst_id; /*!< \brief UNICENS instance ID */
+ Scd_InitData_t scd; /*!< \brief Initialization data of the scheduler */
+ Tm_InitData_t tm; /*!< \brief Initialization data of the timer management */
+
+} Base_InitData_t;
+
+/*! \brief Class structure of the Base class. */
+typedef struct CBase_
+{
+ CScheduler scd; /*!< \brief Scheduler instance */
+ CTimerManagement tm; /*!< \brief Timer management instance */
+ CEventHandler eh; /*!< \brief Event handler instance */
+ CApiLockingManager alm; /*!< \brief API locking manager instance */
+ uint8_t ucs_inst_id; /*!< \brief UNICENS instance ID */
+ void *ucs_user_ptr; /*!< \brief User reference for API callback functions */
+
+} CBase;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+void Base_Ctor(CBase *self, Base_InitData_t *init_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_BASE_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_bc_diag.h b/ucs2-lib/inc/ucs_bc_diag.h
new file mode 100644
index 0000000..2ffe282
--- /dev/null
+++ b/ucs2-lib/inc/ucs_bc_diag.h
@@ -0,0 +1,104 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CBackChannelDiag.
+ *
+ * \cond UCS_INTERNAL_DOC
+ */
+
+#ifndef UCS_BC_DIAG_H
+#define UCS_BC_DIAG_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_exc.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Structure of class CBackChannelDiag. */
+typedef struct CBackChannelDiag_
+{
+ CInic *inic; /*!< \brief Reference to CInic object */
+ CExc *exc; /*!< \brief Reference to CExc object */
+ CBase *base; /*!< \brief Reference to CBase object */
+
+ CSingleObserver bcd_inic_bcd_start; /*!< \brief Observes the INIC.BCDiag result */
+ CSingleObserver bcd_inic_bcd_end; /*!< \brief Observes the INIC.BCDiagEnd result*/
+ CSingleObserver bcd_enabletx; /*!< \brief Observes the EXC.BCEnableTx result */
+ CSingleObserver bcd_diagnosis; /*!< \brief Observes the EXC.BCDiag result */
+ CSingleObserver bcd_switchback; /*!< \brief Observes the EXC.Switchback result. */
+
+
+ CMaskedObserver bcd_terminate; /*!< \brief Observes events leading to termination */
+
+ CObserver bcd_nwstatus; /*!< \brief Observes the MOST Network status */
+
+ CFsm fsm; /*!< \brief Node Discovery state machine */
+ CService service; /*!< \brief Service instance for the scheduler */
+ CTimer timer; /*!< \brief timer for monitoring messages */
+
+ Exc_WelcomeResult_t welcome_result; /*!< \brief buffer for welcome result */
+ bool neton; /*!< \brief indicates Network availability */
+
+ Ucs_Bcd_ReportCb_t report_fptr; /*!< \brief Report callback function */
+
+ uint8_t current_segment; /*!< \brief segment which is currently tested, starts with 0. */
+ Exc_BCDiagResult bcd_result; /*!< \brief Result of current tested segment. */
+
+}CBackChannelDiag;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+void Bcd_Ctor(CBackChannelDiag *self,
+ CInic *inic,
+ CBase *base,
+ CExc *exc);
+
+extern void Bcd_Start(CBackChannelDiag *self, Ucs_Bcd_ReportCb_t report_fptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_BC_DIAG_H */
+/*!
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_class.h b/ucs2-lib/inc/ucs_class.h
new file mode 100644
index 0000000..8cfa5b9
--- /dev/null
+++ b/ucs2-lib/inc/ucs_class.h
@@ -0,0 +1,297 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of UNICENS API class
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_CLASS
+ * @{
+ */
+#ifndef UCS_CLASS_H
+#define UCS_CLASS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_class_pb.h"
+#include "ucs_base.h"
+#include "ucs_pmfifo.h"
+#include "ucs_pmchannel.h"
+#include "ucs_pmevent.h"
+#include "ucs_transceiver.h"
+#include "ucs_factory.h"
+#include "ucs_rtm.h"
+#include "ucs_epm.h"
+#include "ucs_net.h"
+#include "ucs_attach.h"
+#include "ucs_nodedis.h"
+#include "ucs_bc_diag.h"
+#include "ucs_sys_diag.h"
+#include "ucs_prog.h"
+#include "ucs_exc.h"
+#include "ucs_smm.h"
+#include "ucs_amd.h"
+#include "ucs_cmd.h"
+#include "ucs_mgr.h"
+#include "ucs_nodeobserver.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Assignable callback function which is invoked to filter Rx messages
+ * \details Filtering is a synchronous operation. Hence, it is not possible to keep a message
+ * object for delayed processing. The invoked function has to decide whether a
+ * message shall be discarded and freed to the Rx pool. Therefore, it has to return
+ * \c true. By returning \ false, the message will be received in the usual way.
+ * \param tel_ptr Reference to the message object
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \return Returns \c true to discard the message and free it to the pool (no-pass). Otherwise, returns
+ * \c false (pass).
+ */
+typedef bool (*Ucs_RxFilterCb_t)(Msg_MostTel_t *tel_ptr, void *user_ptr);
+
+/*! \brief This structure holds instance and related parameters of the base component */
+typedef struct Ucs_GeneralData_
+{
+ /*! \brief Instance of the Base component */
+ CBase base;
+ /*! \brief Application callback to request UNICENS service calls */
+ Ucs_RequestServiceCb_t request_service_fptr;
+ /*! \brief Observer to proxy callback request_service_fptr() */
+ CSingleObserver service_request_obs;
+ /*! \brief Application callback to report general errors */
+ Ucs_ErrorCb_t general_error_fptr;
+ /*! \brief Observer to proxy callback general_error_fptr() */
+ CSingleObserver general_error_obs;
+ /*! \brief Application callback to request the current tick count value */
+ Ucs_GetTickCountCb_t get_tick_count_fptr;
+ /*! \brief Observer to proxy callback get_tick_count_fptr() */
+ CSingleObserver get_tick_count_obs;
+ /*! \brief Application callback to start the application timer needed for UNICENS event triggered service call. */
+ Ucs_SetAppTimerCb_t set_application_timer_fptr;
+ /*! \brief Observer to proxy callback set_application_timer_fptr() */
+ CSingleObserver set_application_timer_obs;
+
+} Ucs_GeneralData_t;
+
+/*! \brief This structure holds the reference to the local FBlock INIC instance and related parameters */
+typedef struct Ucs_InicData_
+{
+ /*! \brief Reference to the local Instance of the FBlock INIC component */
+ CInic* local_inic;
+ /*! \brief Instance of the Attach service */
+ CAttachService attach;
+ /*! \brief Observer to proxy callback power_state_fptr() */
+ CObserver device_status_obs;
+ /*! \brief The last known power state, required since no masked observer is available */
+ Ucs_Inic_PowerState_t power_state;
+
+} Ucs_InicData_t;
+
+/*! \brief This structure holds the Resources Management callback functions */
+typedef struct Ucs_UcsXrm_
+{
+ /*! \brief Callback function that reports streaming-related information for the MOST Network
+ * Port, including the state of the port and available streaming bandwidth.
+ */
+ Ucs_Xrm_Most_PortStatusCb_t most_port_status_fptr;
+ /*! \brief Observer to proxy callback most_port_status_fptr() */
+ CObserver most_port_status_obs;
+
+} Ucs_UcsXrm_t;
+
+/*! \brief This structure holds the Network Management instance and related parameters */
+typedef struct Ucs_NetData_
+{
+ /*! \brief Instance of the Network Management */
+ CNetworkManagement inst;
+ /*! \brief Application callback for NetworkStartup() */
+ Ucs_StdResultCb_t startup_fptr;
+ /*! \brief Observer to proxy callback startup_fptr() */
+ CSingleObserver startup_obs;
+ /*! \brief Application callback for NetworkShutdown() */
+ Ucs_StdResultCb_t shutdown_fptr;
+ /*! \brief Observer to proxy callback shutdown_fptr() */
+ CSingleObserver shutdown_obs;
+ /*! \brief Application callback for NetworkForceNotAvailable() */
+ Ucs_StdResultCb_t force_na_fptr;
+ /*! \brief Observer to proxy callback force_na_fptr() */
+ CSingleObserver force_na_obs;
+ /*! \brief Application callback for NetworkFrameCounterGet() */
+ Ucs_Network_FrameCounterCb_t frame_counter_fptr;
+ /*! \brief Observer to proxy callback frame_counter_fptr() */
+ CSingleObserver frame_counter_obs;
+ /*! \brief Application callback to report network status */
+ Ucs_Network_StatusCb_t status_fptr;
+ /*! \brief Observer to proxy callback status_fptr() */
+ CMaskedObserver status_obs;
+#if 0
+ /*! \brief Application callback for NetworkForceNotAvailable() */
+ Ucs_StdResultCb_t force_na_fptr;
+ /*! \brief Observer to proxy callback force_na_fptr() */
+ CSingleObserver force_na_obs;
+#endif
+
+} Ucs_NetData_t;
+
+#if 0
+/*! \brief This structure holds attach process related parameters */
+typedef struct Ucs_AtsData_
+{
+ /*! \brief Instance of the Attach service */
+ CAttachService inst;
+ /*! \brief Function pointer to start the attach process */
+ /* Ucs_StartAttachCb_t start_attach_fptr; */
+ /*! \brief Reference to instance used during the attach process */
+ /*void *attach_inst_ptr;*/
+
+} Ucs_AtsData_t;
+#endif
+
+typedef struct Ucs_MsgData_
+{
+ /*! \brief The MCM FIFO */
+ CPmFifo mcm_fifo;
+ /*! \brief The MCM communication module */
+ CTransceiver mcm_transceiver;
+ /*! \brief Application message distributor */
+ CAmd amd;
+ /*! \brief Memory allocator required for the application message service */
+ Ams_MemAllocator_t ams_allocator;
+ /*! \brief Application message pool */
+ CAmsMsgPool ams_pool;
+ /*! \brief Application message service */
+ CAms ams;
+ /*! \brief Static memory management */
+ CStaticMemoryManager smm;
+ /*! \brief Observer to proxy callback tx_message_freed_fptr() */
+ CObserver ams_tx_freed_obs;
+ /*! \brief Signals that tx_message_freed_fptr() must be called as soon as
+ * a Tx message object is freed the next time.
+ */
+ bool ams_tx_alloc_failed;
+ /*! \brief Command Interpreter */
+ CCmd cmd;
+
+} Ucs_MsgData_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief The class CUcs representing the UNICENS API */
+typedef struct CUcs_
+{
+ /*! \brief Stores the instance id, which is generated by Ucs_CreateInstance() */
+ uint8_t ucs_inst_id;
+ /*! \brief User reference that needs to be passed in every callback function */
+ void *ucs_user_ptr;
+ /*! \brief Backup of initialization data */
+ Ucs_InitData_t init_data;
+ /*! \brief Stores the init result callback function */
+ Ucs_InitResultCb_t init_result_fptr;
+ /*! \brief Observer to proxy callback init_result_fptr() */
+ CSingleObserver init_result_obs;
+ /*! \brief Stores the result callback function for Ucs_Stop() */
+ Ucs_StdResultCb_t uninit_result_fptr;
+ /*! \brief Observer to proxy callback uninit_result_fptr() */
+ CMaskedObserver uninit_result_obs;
+ /*! \brief General data required for base component */
+ Ucs_GeneralData_t general;
+
+ /*! \brief Instance of port message channel (service) */
+ CPmChannel pmch;
+ /*! \brief Instance of port message event handler */
+ CPmEventHandler pme;
+ /*! \brief Instance of port message FIFOs */
+ CPmFifos fifos;
+ /*! \brief The ICM FIFO */
+ CPmFifo icm_fifo;
+ /*! \brief The RCM FIFO */
+ CPmFifo rcm_fifo;
+ /*! \brief The ICM communication module */
+ CTransceiver icm_transceiver;
+ /*! \brief The RCM communication module */
+ CTransceiver rcm_transceiver;
+ /*! \brief Factory component instance */
+ CFactory factory;
+ /*! \brief INIC Resources Management callbacks functions */
+ Ucs_UcsXrm_t xrm;
+ /*!< \brief The XRM Pool instance */
+ CXrmPool xrmp;
+ /*!< \brief The Routes Management instance */
+ CRouteManagement rtm;
+ /*!< \brief The EndPoints Management instance */
+ CEndpointManagement epm;
+ /*! \brief FBlock INIC instance and related parameters */
+ Ucs_InicData_t inic;
+ /*! \brief Network Management instance and related parameters */
+ Ucs_NetData_t net;
+ /*! \brief FBlock EXC component instance and related parameters */
+ CExc exc;
+ /*! \brief System diagnosis component instance and related parameters */
+ CSysDiag sys_diag;
+ /*! \brief Node Discovery instance and related parameters */
+ CNodeDiscovery nd;
+ /*! \brief BackChannel Diagnosis instance and related parameters */
+ CBackChannelDiag bcd;
+ /*! \brief Programming Interface instance and parameters */
+ CProgramming prg;
+ /*! \brief Application Message related Data */
+ Ucs_MsgData_t msg;
+ /*! \brief The manager instance */
+ CManager mgr;
+ /*! \brief The node observer instance */
+ CNodeObserver nobs;
+ /*! \brief Filter callback required for unit testing*/
+ Ucs_RxFilterCb_t rx_filter_fptr;
+
+ /*! \brief Is \c true if initialization completed successfully */
+ bool init_complete;
+
+} CUcs;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Unit tests only */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ucs_AssignRxFilter(Ucs_Inst_t *self, Ucs_RxFilterCb_t callback_fptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_CLASS_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_class_pb.h b/ucs2-lib/inc/ucs_class_pb.h
new file mode 100644
index 0000000..2e82598
--- /dev/null
+++ b/ucs2-lib/inc/ucs_class_pb.h
@@ -0,0 +1,2063 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of UNICENS API class
+ *
+ */
+#ifndef UCS_CLASS_PB_H
+#define UCS_CLASS_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_ret_pb.h"
+#include "ucs_lld_pb.h"
+#include "ucs_trace_pb.h"
+#include "ucs_eh_pb.h"
+#include "ucs_rm_pb.h"
+#include "ucs_inic_pb.h"
+#include "ucs_gpio_pb.h"
+#include "ucs_i2c_pb.h"
+#include "ucs_ams_pb.h"
+#include "ucs_cmd_pb.h"
+#include "ucs_nodeobserver_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/* Ucs_Inst_t requires incomplete forward declaration, to hide internal data type.
+ * The Ucs_Inst_t object is allocated internally, the application must access only the pointer to Ucs_Inst_t. */
+struct Ucs_Inst_;
+
+/*!\brief UNICENS instance
+ * \ingroup G_UCS_INIT_AND_SRV_TYPES
+ */
+typedef struct Ucs_Inst_ Ucs_Inst_t;
+
+/*! \brief Function signature used for service request callback.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+typedef void (*Ucs_RequestServiceCb_t)(void *user_ptr);
+
+/*! \brief Function signature used for the general error callback function
+ * \param error_code Reported error code
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+typedef void (*Ucs_ErrorCb_t)(Ucs_Error_t error_code, void *user_ptr);
+
+/*! \brief Optional callback function used to debug received raw messages with OpType UCS_OP_ERROR
+ * and UCS_OP_ERRORACK.
+ * \param msg_ptr Reference to an error messages received from network or the local INIC.
+ * It is not allowed to modify the message. The reference becomes invalid when the
+ * callback function returns.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_TRACE
+ */
+typedef void (*Ucs_DebugErrorMsgCb_t)(Msg_MostTel_t *msg_ptr, void *user_ptr);
+
+/*! \brief Function signature used for callback function to get system tick count.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \return Tick count in milliseconds
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+typedef uint16_t (*Ucs_GetTickCountCb_t)(void *user_ptr);
+
+/*! \brief Function signature used for timer callback function.
+ * \param timeout The specified time-out value.
+ * If timeout value is greater than 0, the application has to start the timer associated with the specified timeout value.
+ * If timeout value is equal to 0, the application has to stop the application timer.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \note <b>The application should only dedicate one timer to UNICENS. Thus, whenever this callback function is called
+ * and the associated timeout value is greater than 0, the application should restart the timer with the new specified timeout value !</b>
+ * <!--\ucs_ic_started{ See <i>Getting Started</i>, section \ref P_UM_ADVANCED_SERVICE "Event Driven Service". }-->
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+typedef void (*Ucs_SetAppTimerCb_t)(uint16_t timeout, void *user_ptr);
+
+/*! \brief Function signature used for the results and reports of the Routing Manager.
+ * \param route_ptr Reference to the route to be looked for
+ * \param route_infos Information about the current route id.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_ROUTING
+ */
+typedef void (*Ucs_Rm_ReportCb_t)(Ucs_Rm_Route_t* route_ptr, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr);
+
+/*! \brief Function signature used for monitoring the XRM resources.
+ * \param resource_type The XRM resource type to be looked for
+ * \param resource_ptr Reference to the resource to be looked for
+ * \param resource_infos Resource information
+ * \param endpoint_inst_ptr Reference to the endpoint object that encapsulates the resource.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_ROUTING
+ */
+typedef void (*Ucs_Rm_XrmResDebugCb_t)(Ucs_Xrm_ResourceType_t resource_type, Ucs_Xrm_ResObject_t *resource_ptr, Ucs_Xrm_ResourceInfos_t resource_infos, Ucs_Rm_EndPoint_t *endpoint_inst_ptr, void *user_ptr);
+
+/*! \brief Function signature used to monitor the INICs power state.
+ * \param power_state The current state of the INICs power management interface.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef void (*Ucs_Inic_PowerStateCb_t)(Ucs_Inic_PowerState_t power_state, void *user_ptr);
+
+/*! \brief Function signature used for the Network Status callback function
+ * \mns_res_inic{MOSTNetworkStatus,MNSH3-MOSTNetworkStatus520}
+ * \param change_mask Indicates which parameters have been changed since the
+ * last function call. If a bit is set the corresponding
+ * parameter has been changed since the last update.
+ * Bit Index | Value (Hex) | Parameter
+ * :-------: | :---------: | --------------------
+ * 0 | 0x01 | events
+ * 1 | 0x02 | availability
+ * 2 | 0x04 | avail_info
+ * 3 | 0x08 | avail_trans_cause
+ * 4 | 0x10 | node_address
+ * 5 | 0x20 | node_position
+ * 6 | 0x40 | max_position
+ * 7 | 0x80 | packet_bw
+ *
+ * \param events The occurred network events. Events are only indicated once they occurred.
+ * I.e., the value is not handled as a continuous state.
+ * You can use the bitmask \ref UCS_NETWORK_EVENT_NCE to identify received events.
+ * \mns_name_inic{Events}
+ * \param availability The network availability.\mns_name_inic{Availability}
+ * \param avail_info The availability information.\mns_name_inic{AvailabilityInfo}
+ * \param avail_trans_cause The availability transition cause.\mns_name_inic{AvailabilityTransitionCause}
+ * \param node_address The current node address.\mns_name_inic{NodeAddress}
+ * \param node_position The current node position.\mns_name_inic{NodePosition}
+ * \param max_position The number of available nodes.\mns_name_inic{MaxPosition}
+ * \param packet_bw The packet bandwidth.\mns_name_inic{PacketBW}
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_NET
+ */
+typedef void (*Ucs_Network_StatusCb_t)(uint16_t change_mask,
+ uint16_t events,
+ Ucs_Network_Availability_t availability,
+ Ucs_Network_AvailInfo_t avail_info,
+ Ucs_Network_AvailTransCause_t avail_trans_cause,
+ uint16_t node_address,
+ uint8_t node_position,
+ uint8_t max_position,
+ uint16_t packet_bw,
+ void *user_ptr
+ );
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief The general section of initialization data
+ * \ingroup G_UCS_INIT_AND_SRV_TYPES
+ */
+typedef struct Ucs_General_InitData_
+{
+ /*! \brief Mandatory callback function notifying an error that terminates the API. */
+ Ucs_ErrorCb_t error_fptr;
+ /*! \brief Mandatory callback function querying the actual system tick count */
+ Ucs_GetTickCountCb_t get_tick_count_fptr;
+ /*! \brief Callback function requesting the application to call Ucs_ReportTimeout() after a certain time.
+ * Mandatory callback function in event driven mode.
+ */
+ Ucs_SetAppTimerCb_t set_application_timer_fptr;
+ /*! \brief Callback function requesting the application to call Ucs_Service().
+ * Mandatory callback function in event driven mode.
+ */
+ Ucs_RequestServiceCb_t request_service_fptr;
+ /*! \brief Optional setting for debugging. Set to \c
+ * false to disable the watchdog, set to \c true (default value) to enable the watchdog.
+ * \note The INIC watchdog may only be disabled for debugging purpose. It must not be disabled
+ * in production systems.
+ */
+ bool inic_watchdog_enabled;
+ /*! \brief Optional callback function to debug incoming raw messages of operation type UCS_OP_ERROR
+ * and UCS_OP_ERRORACK.
+ */
+ Ucs_DebugErrorMsgCb_t debug_error_msg_fptr;
+
+} Ucs_General_InitData_t;
+
+/*! \brief The INIC section of initialization data
+ * \ingroup G_UCS_INIC
+ */
+typedef struct Ucs_Inic_InitData_
+{
+ /*! \brief Callback function to monitor the state of the INIC's power management interface. */
+ Ucs_Inic_PowerStateCb_t power_state_fptr;
+
+} Ucs_Inic_InitData_t;
+
+/*! \brief Structure holds parameters for the notification of the Network Status
+ * \ingroup G_UCS_NET_TYPES
+ */
+typedef struct Ucs_Network_Status_
+{
+ /*! \brief Network Status callback function. This function reports information on the
+ * whole network. */
+ Ucs_Network_StatusCb_t cb_fptr;
+ /*! \brief Notification mask (optional parameter; default value: 0xFFFF)
+ * Indicates for which parameters the notification shall be enabled. If such a
+ * bit is set and the corresponding parameter has been changed the notification
+ * callback is invoked.
+ * This is an optional parameter. If the mask is not modified notifications for
+ * all of the parameters are enabled.
+ * Bit Index | Value (Hex) | Parameter
+ * :-------: | :---------: | --------------------
+ * 0 | 0x01 | events
+ * 1 | 0x02 | availability
+ * 2 | 0x04 | avail_info
+ * 3 | 0x08 | avail_trans_cause
+ * 4 | 0x10 | node_address
+ * 5 | 0x20 | node_position
+ * 6 | 0x40 | max_position
+ * 7 | 0x80 | packet_bw
+ */
+ uint16_t notification_mask;
+
+} Ucs_Network_Status_t;
+
+/*! \brief The network section of the UNICENS initialization data
+ * \ingroup G_UCS_NET
+ */
+typedef struct Ucs_Network_InitData_
+{
+ /*! \brief Network Status */
+ Ucs_Network_Status_t status;
+
+} Ucs_Network_InitData_t;
+
+/*! \brief The initialization structure of the Low-Level Driver */
+typedef Ucs_Lld_Callbacks_t Ucs_Lld_InitData_t;
+
+/*! \brief The initialization structure of the Extended Resource Manager
+ * \ingroup G_UCS_XRM_TYPES
+ */
+typedef struct Ucs_Xrm_InitData_
+{
+ /*! \brief Callback function that reports streaming-related information for the MOST Network
+ * Port, including the state of the port and available streaming bandwidth.
+ */
+ Ucs_Xrm_Most_PortStatusCb_t most_port_status_fptr;
+
+ /*! \brief Callback function that signals the EHC to check the mute pin state of devices before attempting unmute.
+ * \details Whenever this callback function is called and the EHC has devices muted by the mute signal (INIC's MUTE pin),
+ * the EHC should ensure that the mute pin is not asserted and if so, unmute the corresponding devices.
+ */
+ Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr;
+
+} Ucs_Xrm_InitData_t;
+
+/*! \brief The initialization structure of the GPIO Module
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data)
+ *
+ * // Resources Management init section.
+ * ucs_init_data.gpio.trigger_event_status_fptr = &App_GpioTriggerEventStatusCb;
+ *
+ *
+ * // Handle the GPIO trigger events here
+ * void App_GpioTriggerEventStatusCb(uint16_t node_address,
+ * uint16_t gpio_port_handle,
+ * uint16_t rising_edges,
+ * uint16_t falling_edges,
+ * uint16_t levels,
+ * void * user_ptr)
+ * {
+ * // Do what needs to be..
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+typedef struct Ucs_Gpio_InitData_
+{
+ /*! \brief Callback function that reports trigger events information of the GPIO Port. */
+ Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr;
+
+} Ucs_Gpio_InitData_t;
+
+/*! \brief The initialization structure of the I2C Module
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data)
+ *
+ * // Resources Management init section.
+ * ucs_init_data.i2c.interrupt_status_fptr = &App_I2cIntStatusCb;
+ *
+ * // Handle the I2C interrupt event here
+ * void App_I2cIntStatusCb (uint16_t node_address, void * user_ptr)
+ * {
+ * // Do what needs to be..
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_I2C
+ */
+typedef struct Ucs_I2c_InitData_
+{
+ /*! \brief Callback function that reports the I2C interrupt. */
+ Ucs_I2c_IntEventReportCb_t interrupt_status_fptr;
+
+} Ucs_I2c_InitData_t;
+
+/*! \brief The initialization structure of the Routing Management.
+ * \ingroup G_UCS_ROUTING
+ */
+typedef struct Ucs_Rm_InitData_
+{
+ /*! \brief Initialization structure of the Extended Resource Manager
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data);
+ *
+ * // Routing Management init section.
+ * ucs_init_data.rm.xrm.most_port_status_fptr = &App_MostPortStatusCb;
+ * ucs_init_data.rm.xrm.check_unmute_fptr = &App_CheckUnmuteStatusCb;
+ * ucs_init_data.rm.xrm.debug_resource_status_fptr = &App_OnDebuggingXrmResources;
+ *
+ * // Handle MOST Port Status event here
+ * void App_MostPortStatusCb(uint16_t most_port_handle,
+ * Ucs_Most_PortAvail_t availability,
+ * Ucs_Most_PortAvailInfo_t avail_info,
+ * uint16_t free_streaming_bw)
+ * {
+ * // Do what needs to be..
+ * }
+ *
+ * // Handle the Mute Pin check here
+ * void App_CheckUnmuteStatusCb (uint16_t node_address)
+ * {
+ * // Check the state of the mute pin here before unmuting
+ * }
+ *
+ * // Debug interface for the XRM resources
+ * void App_OnDebuggingXrmResources (Ucs_Xrm_ResourceType_t resource_type, Ucs_Xrm_ResObject_t *resource_ptr, Ucs_Xrm_ResourceInfos_t resource_infos, void *user_ptr)
+ * {
+ * switch (resource_infos)
+ * {
+ * case UCS_XRM_INFOS_BUILT:
+ * // Resource has been built
+ * break;
+ * case UCS_XRM_INFOS_DESTROYED:
+ * // resource has been destroyed
+ * break;
+ * case UCS_XRM_INFOS_ERR_BUILT:
+ * //Resource cannot be built
+ * break;
+ * default:
+ * // Resource cannot be destroyed
+ * break;
+ * }
+ * }
+ * \endcode
+ *
+ */
+ Ucs_Xrm_InitData_t xrm;
+ /*! \brief Optional report callback function pointer for all routes
+ *
+ * \note The passed result callback function does not only report the result of the build operation but also monitors
+ * the status of the created routes during their whole lifetime.
+ * That is, the callback function also reports the various states of a route (Refer to \ref Ucs_Rm_RouteInfos_t for more infos).
+ * Furthermore the result of \ref Ucs_Rm_SetRouteActive() function call is reported by this result callback function.
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data);
+ *
+ * // Routing Management init section.
+ * ucs_init_data.rm.report_fptr = &App_OnRoutingResult;
+ *
+ * // The report callback function for all routes
+ * static void App_OnRoutingResult(uint16_t route_id, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr)
+ * {
+ * // Do whatever is necessary here
+ *
+ * switch (route_infos)
+ * {
+ * case UCS_RM_ROUTE_INFOS_BUILT:
+ * // Route has been built
+ * break;
+ * case UCS_RM_ROUTE_INFOS_DESTROYED:
+ * // Route has been destroyed
+ * break;
+ * case UCS_RM_ROUTE_INFOS_PROCESS_STOP:
+ * // Route cannot be processed anymore due to UNICENS Termination
+ * break;
+ * default:
+ * // Route has been suspended
+ * break;
+ * }
+ * }
+ * \endcode
+ *
+ */
+ Ucs_Rm_ReportCb_t report_fptr;
+ /*! \brief Callback function that acts as a debug interface for XRM resources.
+ * The user application has the possibility to monitor the specified XRM resources.
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data);
+ *
+ * // Routing Management init section.
+ * ucs_init_data.rm.debug_resource_status_fptr = &App_OnDebuggingXrmResources;
+ *
+ * // Debug interface for the XRM resources
+ * void App_OnDebuggingXrmResources (Ucs_Xrm_ResourceType_t resource_type, Ucs_Xrm_ResObject_t *resource_ptr, Ucs_Xrm_ResourceInfos_t resource_infos, Ucs_Rm_EndPoint_t * endpoint_inst_ptr, void *user_ptr)
+ * {
+ * switch (resource_infos)
+ * {
+ * case UCS_XRM_INFOS_BUILT:
+ * // Resource has been built
+ * break;
+ * case UCS_XRM_INFOS_DESTROYED:
+ * // resource has been destroyed
+ * break;
+ * case UCS_XRM_INFOS_ERR_BUILT:
+ * //Resource cannot be built
+ * break;
+ * default:
+ * // Resource cannot be destroyed
+ * break;
+ * }
+ * }
+ * \endcode
+ */
+ Ucs_Rm_XrmResDebugCb_t debug_resource_status_fptr;
+
+} Ucs_Rm_InitData_t;
+
+
+/*! \brief The initialization data of the Node Discovery service
+ * \ingroup G_UCS_INIT_AND_SRV_TYPES
+ */
+typedef struct Ucs_Nd_InitData_
+{
+ /*! \brief Callback function reporting the results of the Node Discovery service. */
+ Ucs_Nd_ReportCb_t report_fptr;
+ /*! \brief Callback function asking for evaluation of the found signature. */
+ Ucs_Nd_EvalCb_t eval_fptr;
+
+} Ucs_Nd_InitData_t;
+
+/*! \brief The Rx initialization data of the Application Message Service
+ * \ingroup G_UCS_AMS_TYPES
+ */
+typedef struct Ucs_AmsRx_InitData_
+{
+ /*! \brief Callback function that is invoked if the UNICENS library has received a message
+ * completely and appended to the Rx message queue.
+ */
+ Ucs_AmsRx_MsgReceivedCb_t message_received_fptr;
+
+} Ucs_AmsRx_InitData_t;
+
+/*! \brief The Tx initialization data of the Application Message Service
+ * \ingroup G_UCS_AMS_TYPES
+ */
+typedef struct Ucs_AmsTx_InitData_
+{
+ /*! \brief Callback function which is invoked by the UNICENS library to notify that
+ * memory of a Tx message object was freed after a previous
+ * allocation using Ucs_AmsTx_AllocMsg() has failed. The application might
+ * attempt to call Ucs_AmsTx_AllocMsg() again.
+ */
+ Ucs_AmsTx_MsgFreedCb_t message_freed_fptr;
+
+ /*! \brief Specifies the low-level retry block count which is pre-selected in an allocated
+ * Tx message object. Valid values: 0..100. Default value: 10.
+ */
+ uint8_t default_llrbc;
+
+} Ucs_AmsTx_InitData_t;
+
+/*! \brief The initialization data of the Application Message Service
+ * \ingroup G_UCS_AMS
+ */
+typedef struct Ucs_Ams_InitData_
+{
+ Ucs_AmsRx_InitData_t rx; /*!< \brief Rx related initialization parameters */
+ Ucs_AmsTx_InitData_t tx; /*!< \brief Tx related initialization parameters */
+ bool enabled; /*!< \brief If set to \c false the AMS and CMD modules are
+ * not initialized and the related features are
+ * not available.
+ */
+} Ucs_Ams_InitData_t;
+
+/*! \brief UNICENS initialization structure used by function Ucs_Init().
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+typedef struct Ucs_InitData_
+{
+ /*! \brief Optional reference to a user context which is provided within API callback functions.
+ * \details Please note that \ref Ucs_Lld_Callbacks_t "Ucs_Lld_InitData_t" provides a separate \c lld_user_ptr which is
+ * provided for LLD callback functions.
+ */
+ void *user_ptr;
+ /*! \brief General initialization data */
+ Ucs_General_InitData_t general;
+ /*! \brief Comprises assignment to low-level driver communication interfaces */
+ Ucs_Lld_InitData_t lld;
+ /*! \brief The initialization data of the Routing Management */
+ Ucs_Rm_InitData_t rm;
+ /*! \brief Initialization structure of the GPIO */
+ Ucs_Gpio_InitData_t gpio;
+ /*! \brief Initialization structure of the I2C */
+ Ucs_I2c_InitData_t i2c;
+ /*! \brief The initialization data of the Node Discovery */
+ Ucs_Nd_InitData_t nd;
+ /*! \brief The initialization data of the Application Message Service */
+ Ucs_Ams_InitData_t ams;
+ /*! \brief Network initialization data */
+ Ucs_Network_InitData_t network;
+ /*! \brief INIC initialization data */
+ Ucs_Inic_InitData_t inic;
+ /*! \brief The initialization data of the Manager */
+ Ucs_Mgr_InitData_t mgr;
+
+} Ucs_InitData_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Functions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Retrieves a UNICENS API instance
+ * \details One API instance is used to communicate with one local INIC. In this case the application
+ * is connected to one network.
+ * It is possible access multiple networks by having multiple API instances. Each API instance
+ * requires communication with an exclusive INIC.
+ * \return Returns a reference to new instance of UNICENS or \c NULL, if it is not
+ * possible to create a further instance. The returned instance must be used
+ * as argument \c self.
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+extern Ucs_Inst_t* Ucs_CreateInstance(void);
+
+/*! \brief Assigns default values to a provided UNICENS init structure
+ * \param init_ptr Reference to a provided MNS init structure. Must not be \c NULL.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ----------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | Parameter \c init_ptr is \c NULL
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+Ucs_Return_t Ucs_SetDefaultConfig(Ucs_InitData_t *init_ptr);
+
+/*! \brief UNICENS initialization function.
+ * \details This function must be called by the application for initializing the complete MOST
+ * NetServices library.
+ * \note <b>Do not call this function within any of the UNICENS callbacks!</b>
+ * \param self The instance
+ * \param init_ptr Reference to UNICENS initialization data
+ * \param init_result_fptr Callback that reports the result of the initialization
+ * Possible result values are shown in the table below.
+ * Result Code | Description
+ * ----------------------------- | ----------------------------------------
+ * UCS_INIT_RES_SUCCESS | Initialization succeeded
+ * UCS_INIT_RES_ERR_BUF_OVERFLOW | No message buffer available
+ * UCS_INIT_RES_ERR_PMS_INIT | PMS cannot establish INIC synchronization within 2 seconds
+ * UCS_INIT_RES_ERR_INIC_VERSION | INIC device version check failed
+ * UCS_INIT_RES_ERR_DEV_ATT_CFG | Device attach failed due to an configuration error
+ * UCS_INIT_RES_ERR_DEV_ATT_PROC | Device attach failed due to a system error
+ * UCS_INIT_RES_ERR_NET_CFG | Network configuration failed
+ * UCS_INIT_RES_ERR_TIMEOUT | Initialization was not successful within 2 seconds
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ----------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error.
+ * UCS_RET_ERR_PARAM | Parameter \c init_ptr or one of its attributes is not set correctly.
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+extern Ucs_Return_t Ucs_Init(Ucs_Inst_t* self, const Ucs_InitData_t *init_ptr, Ucs_InitResultCb_t init_result_fptr);
+
+/*! \brief Terminates the execution of UNICENS.
+ * \details This function stops further communication with the INIC, forces the INIC to protected
+ * mode and releases external resources, e.g. calls \c tx_complete_fptr
+ * for previously transmitted application messages. After the termination is complete
+ * UNICENS will call stopped_fptr() and will no longer invoke the
+ * request_service_fptr. \n\n
+ * The application shall no longer call any API function. Any previously retrieved
+ * UNICENS objects (e.g. messages) become invalid.
+ * \note <b>Do not call this function within any of the UNICENS callbacks!</b>
+ * \param self The instance
+ * \param stopped_fptr Mandatory callback function which is invoked as soon as the termination has
+ * been completed.
+ * Possible result values are shown in the table below.
+ * Result Code | Description
+ * ------------------- | ----------------------------------------
+ * UCS_RES_SUCCESS | Termination succeeded
+ * UCS_RES_ERR_TIMEOUT | The termination was forced after a definite time. A communication error or INIC reset may be the reason.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ---------------------- | -----------------------------------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | Mandatory callback function not provided
+ * UCS_RET_ERR_API_LOCKED | Initialization was not completed or termination has been started before
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+extern Ucs_Return_t Ucs_Stop(Ucs_Inst_t *self, Ucs_StdResultCb_t stopped_fptr);
+
+/*! \brief The application must call this function cyclically to drive UNICENS.
+ * \param self The instance
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+extern void Ucs_Service(Ucs_Inst_t *self);
+
+/*! \brief The application must call this function if the application timer expires.
+ * \param self The instance
+ * \ingroup G_UCS_INIT_AND_SRV
+ */
+extern void Ucs_ReportTimeout(Ucs_Inst_t *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Routing Management */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initializes the routing process with the given routes list information and starts the process to handle the route(s).
+ *
+ * When calling this function the routing management will be initialized and the process to handle the given routes list started.
+ * The result of each route is reported via the reference to the user callback function \ref Ucs_Rm_InitData_t::report_fptr "report_fptr" in Ucs_InitData_t (if It has been set by user).
+ *
+ * \param self The UNICENS instance pointer.
+ * \param routes_list List of routes to be handled.
+ * \param list_size Size of the given routes list.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | -------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \note This function must be called once and can only be called once. Otherwise, the function returns the error code \ref UCS_RET_ERR_API_LOCKED.
+ * \note The build up of routes can take some times in case the routing process may need to perform retries when uncritical errors occur (e.g.: transmission error, processing error, etc.) or when
+ * certain conditions are not met yet (e.g. network not available, node not available, etc.). By the way, the maximum number of retries is \c 0xFF and the minimum time between the retries is \c 50ms.
+ *
+ * \attention To suit your specific system needs and setup, change the default values of the following Resources Management macros:
+ * - \ref UCS_NUM_REMOTE_DEVICES in \c ucs_cfg.h
+ * - \ref UCS_XRM_NUM_JOBS in \c ucs_xrm_cfg.h
+ * - \ref UCS_XRM_NUM_RESOURCES in \c ucs_xrm_cfg.h
+ *
+ * \attention Use the \c UCS_ADDR_LOCAL_DEV macro to address the local device when specifying connection routes to or from this device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ *
+ * \n\n\b Example
+ * \code
+ *
+ * // Forward declaration of result callback function
+ * static void App_OnRoutingResult(uint16_t route_id, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr);
+ *
+ * // Set route Activity Flag
+ * static uint8_t is_active = 0x01U;
+ *
+ * // XRM jobs lists
+ * static Ucs_Xrm_ResObject_t * xrm_job_out[] = { &Xrm_Most_Sckt_Out, &Xrm_Usb_Port_1, &Xrm_Usb_Sckt_In, &Xrm_Sync_Conn_1, NULL };
+ * static Ucs_Xrm_ResObject_t * xrm_job_in [] = { &Xrm_Most_Sckt_In, &Xrm_Usb_Port_2, &Xrm_Usb_Sckt_Out, &Xrm_Sync_Conn_2, NULL };
+ *
+ * // Signatures specification
+ * Ucs_Signature_t src_sig = { 0x555U };
+ * Ucs_Signature_t sink_sig = { 0x556U };
+ *
+ * // Nodes objects
+ * static Ucs_Rm_Node_t node_src = { &src_sig };
+ * static Ucs_Rm_Node_t node_sink = { &sink_sig };
+ *
+ * // Source and Sink Endpoints
+ * static Ucs_Rm_EndPoint_t endpoint_src = { UCS_RM_EP_SOURCE, &xrm_job_out[0], &node_src };
+ * static Ucs_Rm_EndPoint_t endpoint_sink = { UCS_RM_EP_SINK, &xrm_job_in[0], &node_sink };
+ *
+ * // Routes Specification
+ * static Ucs_Rm_Route_t route_66[] = { {&endpoint_src, &endpoint_sink, is_active, 66U} };
+ *
+ * // Main function
+ * void main ()
+ * {
+ *
+ * Ucs_InitData_t ucs_init_data;
+ * (void)Ucs_SetDefaultConfig(&ucs_init_data);
+ * ucs_init_data.rm.report_fptr = &App_OnRoutingResult;
+ *
+ * // Starts routes processing
+ * Ucs_Return_t ret_value = Ucs_Rm_Start(ucs_inst_ptr, &route_66[0], 1U);
+ * if (ret_value != UCS_RET_SUCCESS)
+ * {
+ * // Do whatever is necessary here
+ * }
+ *
+ * // Set corresponding Nodes to "available" if they are ready
+ * // (void)Ucs_Rm_SetNodeAvailable(ucs_inst_ptr, &node_src, true);
+ * // (void)Ucs_Rm_SetNodeAvailable(ucs_inst_ptr, &node_sink, true);
+ *
+ * }
+ *
+ * // The report callback function for all routes
+ * static void App_OnRoutingResult(Ucs_Rm_Route_t* route_ptr, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr)
+ * {
+ * // Do whatever is necessary here
+ *
+ * switch (route_infos)
+ * {
+ * case UCS_RM_ROUTE_INFOS_BUILT:
+ * // Route has been built
+ * break;
+ * case UCS_RM_ROUTE_INFOS_DESTROYED:
+ * // Route has been destroyed
+ * break;
+ * case UCS_RM_ROUTE_INFOS_PROCESS_STOP:
+ * // Route cannot be processed anymore due to UNICENS Termination
+ * break;
+ * default:
+ * // Route has been suspended.
+ * break;
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern Ucs_Return_t Ucs_Rm_Start(Ucs_Inst_t *self, Ucs_Rm_Route_t *routes_list, uint16_t list_size);
+
+/*! \brief Sets the given route to \c active respectively \c inactive and triggers the routing process to handle the route.
+ *
+ * When setting a route to \c active the routing process will start building the route and all related resources and return the result to the user callback function (Refer to Routing Management Init Structure).
+ * When setting a route to \c inactive the routing process will start destroying the route and all related resources and return the result to the user callback function.
+ * \param self The UNICENS instance.
+ * \param route_ptr Reference to the routes to be destroyed.
+ * \param active Specifies whether the route should be activated or not. \c true is active and \c false inactive.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ---------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL.
+ * UCS_RET_ERR_ALREADY_SET | The given route is already active or inactive
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ *
+ * \note The build up or the destruction of a route can take some times in case the routing process may need to perform retries when uncritical errors occur (e.g.: transmission error, processing error, etc.)
+ * or when certain conditions are not met yet (e.g. network not available, node not available, etc.). By the way, the maximum number of retries is 0xFF and the minimum time between the retries is 50ms.
+ * This results in a minimum time of ca. 13s to get a route built or suspended (if the maximum retries are reached).
+ *
+ * \attention To suit your specific system needs and setup, change the default values of the following Resources Management macros:
+ * - \ref UCS_NUM_REMOTE_DEVICES in \c ucs_cfg.h
+ * - \ref UCS_XRM_NUM_JOBS in \c ucs_xrm_cfg.h
+ * - \ref UCS_XRM_NUM_RESOURCES in \c ucs_xrm_cfg.h
+ *
+ * \attention Use the \c UCS_ADDR_LOCAL_DEV macro to address the local device when specifying connection routes to or from this device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ * // The report callback function for all routes
+ * static void App_OnRoutingResult(uint16_t route_id, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr)
+ * {
+ * // Print whatever needs to be printed here
+ * }
+ *
+ * // Activates or deactivates the route with Index 2 of the routes list.
+ * static void App_SetRouteId2_OnOff(bool active)
+ * {
+ * Ucs_Return_t ret_value;
+ *
+ * ret_value = Ucs_Rm_SetRouteActive(ucs_inst_ptr, &routes_list[2], active);
+ * if (ret_value != UCS_RET_SUCCESS)
+ * {
+ * // Do whatever is necessary
+ * }
+ * }
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ *
+ * // Starts routes processing
+ * Ucs_Rm_Start(ucs_inst_ptr, &routes_list[0], routes_list_size);
+ *
+ * // ...
+ *
+ * if (mic2_btn_pressed)
+ * {
+ * App_SetRouteId2_OnOff(true);
+ * }
+ * else
+ * {
+ * App_SetRouteId2_OnOff(false);
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern Ucs_Return_t Ucs_Rm_SetRouteActive(Ucs_Inst_t *self, Ucs_Rm_Route_t *route_ptr, bool active);
+
+/*! \brief Sets the availability attribute (\c available or \c not \c available) of the given node and triggers the routing process to handle attached route(s).
+ * \details In case of \c available the function starts the routing process that checks whether there are endpoints to build on this node.
+ * In case of \c unavailable the function informs sub modules like XRM to check whether there are resources to release and simultaneously unlock \c suspended routes that
+ * link to this node.
+ * \param self The UNICENS instance
+ * \param node_ptr Reference to the node to be looked for.
+ * \param available Specifies whether the node is available or not
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ---------------------------------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_ALREADY_SET | Node is already set to "available" or "not available"
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL.
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * UCS_RET_ERR_NOT_AVAILABLE | The function cannot be processed because the network is not available
+ *
+ * \note All nodes present in the routing system will be automatically set to \c Unavailable after the network has been shutdown respectively after
+ * transition from \c Available to \c Not \c available. This in turn means that the user has to set the corresponding nodes to \c Available
+ * after network started up respectively after the network transition from \c NotAvailable to \c Available.
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ * // Sets the amplifier node to "available" or "not available"
+ * static void App_SetAmplNodeAvailability(bool available)
+ * {
+ * Ucs_Return_t ret_value;
+ *
+ * ret_value = Ucs_Rm_SetNodeAvailable(ucs_inst_ptr, &ampl_node, available);
+ * if (ret_value != UCS_RET_SUCCESS)
+ * {
+ * // Do whatever is necessary here
+ * }
+ * }
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ * // ...
+ *
+ * if (amplifier_programming_completed)
+ * {
+ * App_SetAmplNodeAvailability(true);
+ * }
+ *
+ * // ...
+ *
+ * if (amplifier_is_unavailable)
+ * {
+ * App_SetAmplNodeAvailability(false);
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern Ucs_Return_t Ucs_Rm_SetNodeAvailable(Ucs_Inst_t *self, Ucs_Rm_Node_t *node_ptr, bool available);
+
+/*! \brief Retrieves the \c "available" flag information of the given node.
+ *
+ * This function can be used to check whether the given node has been set to \c "available" or \c "not available".
+ *
+ * \param self The UNICENS instance pointer.
+ * \param node_ptr Reference to the node to be looked for.
+ * \return The \c "availability" flag of the given node.
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ * // ...
+ * if (Ucs_Rm_GetNodeAvailable(ucs_inst_ptr, &slim_mic_node))
+ * {
+ * // Do whatever is necessary to be done
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern bool Ucs_Rm_GetNodeAvailable(Ucs_Inst_t *self, Ucs_Rm_Node_t *node_ptr);
+
+/*! \brief Retrieves the reference(s) of the route(s) currently attached to the given endpoint and stores It into the (external) table provided by user application.
+ *
+ * Thus, User application should provide an external reference to an empty routes table where the potential routes will be stored.
+ * That is, user application is responsible to allocate enough space to store the found routes. Refer to the \b Note below for more details.
+ *
+ * \param self The UNICENS instance pointer.
+ * \param ep_inst Reference to the endpoint instance to be looked for.
+ * \param ls_found_routes List to store references to the found routes. It should be allocated by user application.
+ * \param ls_size Size of the provided list.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | -------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL.
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \note The function will add a \b NULL \b pointer to the external table (provided by user application) to mark the end of the found routes. This can be helpful when user application doesn't exactly known the
+ * number of routes referred to the endpoint. That is, User application should allocate enough space to store the found routes plus the NULL-terminated pointer.
+ * Otherwise, the number of associated routes found will \b precisely \b equal the size of the list.
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ * // Source and Sink Endpoints
+ * static Ucs_Rm_EndPoint_t endpoint_src = { UCS_RM_EP_SOURCE, &xrm_job_out[0], &node_src };
+ * static Ucs_Rm_EndPoint_t endpoint_sink_west = { UCS_RM_EP_SINK, &xrm_job_in_w[0], &node_west };
+ * static Ucs_Rm_EndPoint_t endpoint_sink_east = { UCS_RM_EP_SINK, &xrm_job_in_e[0], &node_east };
+ *
+ * // Routes Specification
+ * static Ucs_Rm_Route_t route_66_west[] = { {&endpoint_src, &endpoint_sink_west, is_active, 0x066U} };
+ * static Ucs_Rm_Route_t route_66_east[] = { {&endpoint_src, &endpoint_sink_east, is_active, 0xE66U} };
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ * Ucs_Rm_Route_t * found_routes_ls[3];
+ * Ucs_Return_t ret_value;
+ *
+ * // Starts routes processing
+ * (void)Ucs_Rm_Start(ucs_inst_ptr, &routes_list[0], routes_list_size);
+ *
+ * // ...
+ *
+ * // Retrieve routes references to the given endpoint
+ * ret_value = Ucs_Rm_GetAttachedRoutes(ucs_inst_ptr, &endpoint_src, found_routes_ls, 3U);
+ * if (ret_value == UCS_RET_SUCCESS)
+ * {
+ * uint8_t k = 0U;
+ *
+ * //printf("\rEp{0x%X}: Related route id(s) --> ", &endpoint_src);
+ * do
+ * {
+ * //printf("{0x%X} ", found_routes_ls[k]->route_id);
+ * k++;
+ *
+ * } while ((k < 3U) && (found_routes_ls[k] != NULL));
+ * //printf("\r\n");
+ * }
+ * else
+ * {
+ * // Do whatever is necessary to be done
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern Ucs_Return_t Ucs_Rm_GetAttachedRoutes(Ucs_Inst_t *self, Ucs_Rm_EndPoint_t * ep_inst,
+ Ucs_Rm_Route_t * ls_found_routes[], uint16_t ls_size);
+
+/*! \brief Retrieves the \c ConnectionLabel of the given route.
+ * \param self The UNICENS instance pointer.
+ * \param route_ptr Reference to the route to be looked for.
+ * \return The \c ConnectionLabel of the route. The \c ConnectionLabel value falls within the range [0x000C...0x017F] when route is built. Otherwise, 0 is returned.
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ * // Source and Sink Endpoints
+ * static Ucs_Rm_EndPoint_t endpoint_src = { UCS_RM_EP_SOURCE, &xrm_job_out[0], &node_src };
+ * static Ucs_Rm_EndPoint_t endpoint_sink = { UCS_RM_EP_SINK, &xrm_job_in[0], &node_sink };
+ *
+ * // Routes Specification
+ * static Ucs_Rm_Route_t route_66[] = { {&endpoint_src, &endpoint_sink, is_active, 0x066U} };
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ * uint16_t rt66_cl;
+ * bool rt66_is_built;
+ *
+ * // Starts routes processing
+ * (void)Ucs_Rm_Start(ucs_inst_ptr, &route_66[0], 1U);
+ *
+ * // ...
+ *
+ * // Retrieve "ConnectionLabel" of route_66.
+ * if (rt66_is_built)
+ * {
+ * rt66_cl = Ucs_Rm_GetConnectionLabel(ucs_inst_ptr, &route_66[0]);
+ * //printf("CL:route_0x%02X --> {0x%X}\r\n", (&route_66[0])->route_id, rt66_cl);
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_ROUTING
+ */
+extern uint16_t Ucs_Rm_GetConnectionLabel(Ucs_Inst_t *self, Ucs_Rm_Route_t *route_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Extended Resources Management (XRM) */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This function is used to configure a Streaming Port.
+ * \mns_func_inic{StreamPortConfiguration,MNSH3-StreamPortConfiguration680}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Device address of the target. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param index Streaming Port instance. \mns_name_inic{Index}
+ * \param op_mode Operation mode of the Streaming Port. \mns_name_inic{OperationMode}
+ * \param port_option Direction of the Streaming Port. \mns_name_inic{PortOptions}
+ * \param clock_mode Configuration of the FSY/SCK signals. \mns_name_inic{ClockMode}
+ * \param clock_data_delay Configuration of the FSY/SCK signals for Generic Streaming. \mns_name_inic{ClockDataDelay}
+ * \param result_fptr Required result callback
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | The given UNICENS instance pointer is NULL
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * // ...
+ *
+ * Ucs_Xrm_Stream_SetPortConfig (ucs_inst_ptr,
+ * 0x555U,
+ * 0x0U,
+ * UCS_STREAM_PORT_OP_MODE_GENERIC,
+ * UCS_STREAM_PORT_OPT_IN_OUT,
+ * UCS_STREAM_PORT_CLK_MODE_OUTPUT,
+ * UCS_STREAM_PORT_CLK_DLY_NONE,
+ * &App_XrmStreamPortCfgResCb);
+ * // ...
+ *
+ * }
+ *
+ *
+ * // The streaming port result callback function
+ * static void App_XrmStreamPortCfgResCb(uint16_t node_address,
+ * uint8_t index,
+ * Ucs_Stream_PortOpMode_t op_mode,
+ * Ucs_Stream_PortOption_t port_option,
+ * Ucs_Stream_PortClockMode_t clock_mode,
+ * Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ * Ucs_StdResult_t result,
+ * void *user_ptr)
+ * {
+ * if (result.code != UCS_RES_SUCCESS)
+ * {
+ * // Do whatever is necessary here...
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_XRM_STREAM
+ */
+extern Ucs_Return_t Ucs_Xrm_Stream_SetPortConfig(Ucs_Inst_t *self,
+ uint16_t destination_address,
+ uint8_t index,
+ Ucs_Stream_PortOpMode_t op_mode,
+ Ucs_Stream_PortOption_t port_option,
+ Ucs_Stream_PortClockMode_t clock_mode,
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
+
+/*! \brief This function requests the configurations of a Streaming Port.
+ * \mns_func_inic{StreamPortConfiguration,MNSH3-StreamPortConfiguration680}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Device address of the target. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param index Streaming Port instance. \mns_name_inic{Index}
+ * \param result_fptr Required result callback
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ----------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ * // Main function
+ * void main()
+ * {
+ * (void)Ucs_Xrm_Stream_GetPortConfig(ucs_inst_ptr, 0x555U, 0x0U, &App_XrmStreamPortCfgResCb);
+ * }
+ *
+ * // The streaming port result callback function
+ * static void App_XrmStreamPortCfgResCb(uint16_t node_address,
+ * uint8_t index,
+ * Ucs_Stream_PortOpMode_t op_mode,
+ * Ucs_Stream_PortOption_t port_option,
+ * Ucs_Stream_PortClockMode_t clock_mode,
+ * Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ * Ucs_StdResult_t result,
+ * void *user_ptr)
+ * {
+ * if (result.code == UCS_RES_SUCCESS)
+ * {
+ * // Read Streaming ports configuration here...
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_XRM_STREAM
+ */
+extern Ucs_Return_t Ucs_Xrm_Stream_GetPortConfig(Ucs_Inst_t *self, uint16_t destination_address, uint8_t index,
+ Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Node Scripting Management */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Runs the script(s) contained in the given node.
+ * \details The function starts the process to transmit the script(s) contained in
+ * the given node and checks for the expected results (specified by customer).
+ * The Node Scripting module will start a timer of 2600ms before sending the Tx command of each script. That is,
+ * if no incoming messages match the expected result of the script during this time the result code
+ * \ref UCS_NS_RES_ERROR is returned via the \ref Ucs_Ns_ResultCb_t user callback function. This error code is also get when the script
+ * module couldn't perform the device synchronization of the remote device. Otherwise, if an
+ * incoming message matches the expected result, \ref UCS_NS_RES_SUCCESS is returned.
+ * \n The function will return \ref UCS_RET_ERR_API_LOCKED when attempting to execute a script
+ * in a node that is currently busy with other(s) previous script(s). Ucs_Ns_Run() is namely locked for a Node
+ * when running script(s) on this node and unlocked after reporting the operation's result.
+ * However processing scripts can be executed on different nodes in parallel.
+ *
+ * \param self The UNICENS instance
+ * \param node_ptr Reference to the node instance.
+ * \param result_fptr Reference to the result function pointer
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_NOT_AVAILABLE | No internal resources allocated for the given node. \n Check if value of \ref UCS_NUM_REMOTE_DEVICES is less than \n the current number of remote devices in network.
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL.
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No TxBuffer Handles available
+ * UCS_RET_ERR_API_LOCKED | The API is locked.
+ *
+ *
+ * \attention The Node Scripting module is designed and intended for the use of \b I2C and \b GPIO commands only. That is, using the Scripting for any other FBlock INIC commands
+ * (for example MOST, MediaLB, USB, Streaming, Connections, etc.) is expressly \b prohibited.
+ *
+ * \n\n\b Example
+ * \code{.c}
+ *
+ * // Forward declaration of result callback function
+ * static void App_OnScriptingResult(uint16_t node_address, Ucs_Ns_ResultCode_t result, void *user_ptr);
+ *
+ * // Configuration Msg specification
+ * static uint8_t tx_data [] = { 0x00, 0x40, 0x01, 0x01 };
+ * static uint8_t rx_data [] = { 0x0F, 0x00 };
+ * static Ucs_Ns_ConfigMsg_t tx_msg = { 0x00, 0x00, 0x6C1, 0x2, 4U, &tx_data };
+ * static Ucs_Ns_ConfigMsg_t rx_msg = { 0x00, 0x01, 0x6C1, 0xC, 2U, &rx_data };
+ *
+ * // Scripts specification
+ * static Ucs_Ns_Script_t script_x = { 100U, &tx_msg, &rx_msg };
+ *
+ * // Signature specification
+ * Ucs_Signature_t sig_200 = { 200U };
+ *
+ * // Nodes objects Specification
+ * static Ucs_Rm_Node_t node_200 = { &sig_200, &script_x, 1U, 0U };
+ *
+ * // Main function
+ * void main(uint8_t argc, char *argv[])
+ * {
+ *
+ * // ...
+ *
+ * if (node200_discovered)
+ * {
+ * (void)Ucs_Ns_Run(ucs_inst_ptr, &node_200, &App_OnScriptingResult);
+ * }
+ *
+ * // ...
+ * }
+ *
+ * // The result callback function
+ * static void App_OnScriptingResult(Ucs_Rm_Node_t * node_ptr, Ucs_Ns_ResultCode_t result, void *user_ptr)
+ * {
+ * switch (result)
+ * {
+ * case UCS_NS_RES_SUCCESS:
+ * // Node can be set to "Available" for example
+ * Ucs_Rm_SetNodeAvailable(ucs_inst_ptr, node_ptr, true);
+ * break;
+ *
+ * case UCS_NS_RES_ERROR:
+ * default:
+ * // Do whatever is necessary here
+ * break;
+ * }
+ * }
+ *
+ * \endcode
+ * \ingroup G_UCS_SCRIPTING
+ */
+extern Ucs_Return_t Ucs_Ns_Run(Ucs_Inst_t *self, Ucs_Rm_Node_t * node_ptr, Ucs_Ns_ResultCb_t result_fptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* GPIO and I2C Peripheral Bus Interfaces */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Creates the GPIO port with its associated port instance identifier
+ * \mns_func_inic{GPIOPortCreate,MNSH3-GPIOPortCreate701}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param index The index of the GPIO Port instance. \mns_name_inic{Index}
+ * \param debounce_time The timeout for the GPIO debounce timer (in ms). \mns_name_inic{DebounceTime}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_Gpio_CreatePort(UCS_ADDR_LOCAL_DEV, 0x00U, 0x0003U, &App_GpioCreatePortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The GPIO CreatePort event handler function
+ * // Handle GpioCreatePort event
+ * static void App_GpioCreatePortResCb(uint16_t device_id, uint16_t port_handle, Ucs_Gpio_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_GPIO_RES_SUCCESS)
+ * {
+ * // Store received port handle
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+extern Ucs_Return_t Ucs_Gpio_CreatePort(Ucs_Inst_t *self, uint16_t destination_address, uint8_t index,
+ uint16_t debounce_time, Ucs_Gpio_CreatePortResCb_t result_fptr);
+
+/*! \brief Configures the pin mode of the given GPIO port
+ * \mns_func_inic{GPIOPortPinMode,MNSH3-GPIOPortPinMode703}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param gpio_port_handle The GPIO Port resource handle. \mns_name_inic{GPIOPortHandle}
+ * \param pin The GPIO pin that is to be configured. \mns_name_inic{Pin}
+ * \param mode The mode of the GPIO pin. \mns_name_inic{Mode}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * // Set configuration of GPIO pin no. 3
+ * Ucs_Return_t result = Ucs_Gpio_SetPinMode(0x221U, 0x1D00, 0x03U, UCS_GPIO_OUT_DEFAULT_LOW, &App_GpioConfigPinModeResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle GpioConfigPinMode event
+ * static void App_GpioConfigPinModeResCb(uint16_t device_id, uint16_t port_handle, Ucs_Gpio_PinConfiguration_t pin_cfg_list[], uint8_t list_sz, Ucs_Gpio_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_GPIO_RES_SUCCESS)
+ * {
+ * uint8_t i;
+ * for (i = 0U; i < list_sz; i++)
+ * {
+ * // Configuration list of all GPIO pins
+ * // Check configuration of GPIO pin no. 3 here
+ * if (pin_cfg_list[i].pin == 3 && pin_cfg_list[i].mode != UCS_GPIO_OUT_DEFAULT_LOW)
+ * {
+ * // Error handling
+ * }
+ * }
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+extern Ucs_Return_t Ucs_Gpio_SetPinMode(Ucs_Inst_t *self, uint16_t destination_address, uint16_t gpio_port_handle,
+ uint8_t pin, Ucs_Gpio_PinMode_t mode, Ucs_Gpio_ConfigPinModeResCb_t result_fptr);
+
+/*! \brief Retrieves the pin mode configuration of the given GPIO port
+ * \mns_func_inic{GPIOPortPinMode,MNSH3-GPIOPortPinMode703}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param gpio_port_handle The GPIO Port resource handle. \mns_name_inic{GPIOPortHandle}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * // Read configuration of GPIO pins
+ * Ucs_Return_t result = Ucs_Gpio_GetPinMode(0x222U, 0x1D00, &App_GpioConfigPinModeResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle GpioConfigPinMode event
+ * static void App_GpioConfigPinModeResCb(uint16_t device_id, uint16_t port_handle, Ucs_Gpio_PinConfiguration_t pin_cfg_list[], uint8_t list_sz, Ucs_Gpio_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_GPIO_RES_SUCCESS)
+ * {
+ * uint8_t i;
+ * for (i = 0U; i < list_sz; i++)
+ * {
+ * // Configuration list of all GPIO pins
+ * // Do what needs to be..
+ * }
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+extern Ucs_Return_t Ucs_Gpio_GetPinMode(Ucs_Inst_t *self, uint16_t destination_address, uint16_t gpio_port_handle, Ucs_Gpio_ConfigPinModeResCb_t result_fptr);
+
+/*! \brief Writes data to the given GPIO port.
+ * \mns_func_inic{GPIOPortPinState,MNSH3-GPIOPortPinState704}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param gpio_port_handle The GPIO Port resource handle. \mns_name_inic{GPIOPortHandle}
+ * \param mask The GPIO pin to be written. \mns_name_inic{Mask}
+ * \param data The state of the GPIO pin to be written. \mns_name_inic{Data}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_Gpio_WritePort(0x555U, 0x1D00, 0x0039U, 0x0038U, &App_GpioWritePortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle GpioWritePort event
+ * static void App_GpioWritePortResCb(uint16_t device_id, uint16_t port_handle, uint16_t current_state, uint16_t sticky_state, Ucs_Gpio_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_GPIO_RES_SUCCESS)
+ * {
+ * // Do what needs to be..
+ * }
+ * else
+ * {
+ * // Error handling here
+ * switch(result.details.result_type)
+ * {
+ * case UCS_GPIO_RESULT_TYPE_TGT:
+ * // Handle the target results
+ * break;
+ *
+ * case UCS_GPIO_RESULT_TYPE_TX:
+ * // Handle transmission error
+ * break;
+ * }
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+extern Ucs_Return_t Ucs_Gpio_WritePort(Ucs_Inst_t *self, uint16_t destination_address, uint16_t gpio_port_handle,
+ uint16_t mask, uint16_t data, Ucs_Gpio_PinStateResCb_t result_fptr);
+
+/*! \brief Reads the pin state of the given GPIO port.
+ * \mns_func_inic{GPIOPortPinState,MNSH3-GPIOPortPinState704}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param gpio_port_handle The GPIO Port resource handle. \mns_name_inic{GPIOPortHandle}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_Gpio_ReadPort(UCS_ADDR_LOCAL_DEV, 0x1D00, &App_GpioReadPortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle GpioReadPort event
+ * static void App_GpioReadPortResCb(uint16_t device_id, uint16_t port_handle, uint16_t current_state, uint16_t sticky_state, Ucs_Gpio_Result_t result)
+ * {
+ * if (result.code == UCS_GPIO_RES_SUCCESS)
+ * {
+ * // Do what needs to be..
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_GPIO
+ */
+extern Ucs_Return_t Ucs_Gpio_ReadPort(Ucs_Inst_t *self, uint16_t destination_address, uint16_t gpio_port_handle, Ucs_Gpio_PinStateResCb_t result_fptr);
+
+/*! \brief Creates an I2C Port with its associated parameter.
+ * \mns_func_inic{I2CPortCreate,MNSH3-I2CPortCreate6C1}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param index I2C Port instance. \mns_name_inic{Index}
+ * \param speed The speed grade of the I2C Port. \mns_name_inic{Speed}
+ * \param i2c_int_mask The bit mask corresponding to the I2C-interrupt on the GPIO Port.
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is NULL
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \attention The below points should be considered in order to receive the notification of the I2C interrupt:
+ * - The \ref Ucs_I2c_IntEventReportCb_t callback function should be registered in the Ucs_InitData_t init structure.
+ * - The GPIO port has to be be opened and the I2C interrupt pin associated with that port configured correctly.
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * #define I2C_INT_PIN_MASK ((uint8_t)0x01)
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_I2c_CreatePort(0x556U, 0x00U, UCS_I2C_FAST_MODE, I2C_INT_PIN_MASK, &App_I2cCreatePortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // Handle I2cCreatePort event
+ * static void App_I2cCreatePortResCb(uint16_t device_id, uint16_t port_handle, Ucs_I2c_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_I2C_RES_SUCCESS)
+ * {
+ * // Store received port handle
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_I2C
+ */
+extern Ucs_Return_t Ucs_I2c_CreatePort(Ucs_Inst_t *self, uint16_t destination_address, uint8_t index, Ucs_I2c_Speed_t speed,
+ uint8_t i2c_int_mask, Ucs_I2c_CreatePortResCb_t result_fptr);
+
+/*! \brief Writes a block of bytes to an I2C device at a specified I2C address.
+ * \mns_func_inic{I2CPortWrite,MNSH3-I2CPortWrite6C4}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param port_handle Port resource handle. \mns_name_inic{I2CPortHandle}
+ * \param mode The write transfer mode. \mns_name_inic{Mode}
+ * \param block_count The number of blocks to be written to the I2C address. If parameter \em mode is \b not set to Burst Mode, the value of \em block_count has to be set to \b 0.
+ * Otherwise the valid range of this parameter goes from 1 to 30. \mns_name_inic{BlockCount}
+ * \param slave_address The 7-bit I2C slave address of the peripheral to be read. \mns_name_inic{SlaveAddress}
+ * \param timeout The timeout for the I2C Port write. \mns_name_inic{Timeout}
+ * \param data_len The total number of bytes to be written to the addressed I2C peripheral. Even if parameter \em mode is set to Burst Mode, the \em data_len shall correspond to the whole size of the burst
+ * transfer. That is, the \em data_len shall equal the size of a block \b times the \em block_count value.
+ * \param data_ptr Reference to the data to be written.
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * uint8_t myData[] = {0x4U, 0x3U, 0x2U, 0x1U, 0x0U, 0x4U, 0x3U, 0x2U, 0x1U, 0x0U, 0x05U, 0x05U};
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_I2c_WritePort(0x15U, 0x0F00U, UCS_I2C_BURST_MODE, 4U, 0x20U, 0x0FU, 12U, myData, &App_I2cWritePortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle I2cWritePort event
+ * static void App_I2cWritePortResCb(uint16_t device_id, uint16_t port_handle, uint8_t i2c_slave_address, uint8_t data_len, Ucs_I2c_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_I2C_RES_SUCCESS)
+ * {
+ * // Do what needs to be..
+ * }
+ * else
+ * {
+ * // Error handling here
+ * switch(result.details.result_type)
+ * {
+ * case UCS_I2C_RESULT_TYPE_TGT:
+ * // Handle the target results
+ * break;
+ *
+ * case UCS_I2C_RESULT_TYPE_TX:
+ * default:
+ * // Handle transmission error
+ * break;
+ * }
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_I2C
+ */
+extern Ucs_Return_t Ucs_I2c_WritePort(Ucs_Inst_t *self, uint16_t destination_address, uint16_t port_handle, Ucs_I2c_TrMode_t mode, uint8_t block_count,
+ uint8_t slave_address, uint16_t timeout, uint8_t data_len, uint8_t * data_ptr,
+ Ucs_I2c_WritePortResCb_t result_fptr);
+
+/*! \brief Reads a block of bytes from an I2C device at a specified I2C address.
+ * \mns_func_inic{I2CPortRead,MNSH3-I2CPortRead6C3}
+ * \param self The UNICENS instance pointer
+ * \param destination_address Address of the target device. Use the \c UCS_ADDR_LOCAL_DEV macro to target the local device.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \param port_handle Port resource handle. \mns_name_inic{I2CPortHandle}
+ * \param slave_address The 7-bit I2C slave address of the peripheral to be read. \mns_name_inic{SlaveAddress}
+ * \param data_len Number of bytes to be read from the address. \mns_name_inic{Length}
+ * \param timeout The timeout for the I2C Port read. \mns_name_inic{Timeout}
+ * \param result_fptr Required result callback function pointer.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_PARAM | At least one parameter is wrong
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \n \b Example
+ * \code{.c}
+ *
+ * // Main function
+ * void main()
+ * {
+ * Ucs_Return_t result = Ucs_I2c_ReadPort(0x14U, 0x0F00U, 0x20U, 5U, 0x0FU, &App_I2cReadPortResCb);
+ * if (result != UCS_RET_SUCCESS)
+ * {
+ * // Error handling here
+ * }
+ * }
+ *
+ * // The event handler function
+ * // Handle I2cReadPort event
+ * static void App_I2cReadPortResCb(uint16_t device_id, uint16_t port_handle, uint8_t slave_address, uint8_t data_len, uint8_t data_ptr[], Ucs_I2c_Result_t result, void * user_ptr)
+ * {
+ * if (result.code == UCS_I2C_RES_SUCCESS)
+ * {
+ * // Do what needs to be..
+ * }
+ * else
+ * {
+ * // Error handling here
+ * }
+ * }
+ * \endcode
+ * \ingroup G_UCS_I2C
+ */
+extern Ucs_Return_t Ucs_I2c_ReadPort(Ucs_Inst_t *self, uint16_t destination_address, uint16_t port_handle, uint8_t slave_address, uint8_t data_len,
+ uint16_t timeout, Ucs_I2c_ReadPortResCb_t result_fptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Network Management */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Starts up the MOST Network
+ * \note There is no predefined timeout for this operation. I.e., the startup process is
+ * performed by the INIC until \c result_fptr is invoked or the application calls
+ * Ucs_Network_Shutdown() to abort the startup process.
+ * \param self The instance
+ * \param packet_bw The desired packet bandwidth.\mns_name_inic{PacketBW}
+ * \param forced_na_timeout The delay time in milliseconds to shutdown the network after the INIC has entered the
+ * protected mode.\mns_name_inic{AutoForcedNotAvailable}
+ * \param result_fptr Optional result callback.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * \ingroup G_UCS_NET
+ */
+extern Ucs_Return_t Ucs_Network_Startup(Ucs_Inst_t *self, uint16_t packet_bw, uint16_t forced_na_timeout,
+ Ucs_StdResultCb_t result_fptr);
+
+
+
+/*! \brief Switches of the MOST Network
+ * \param self The instance
+ * \param result_fptr Optional result callback
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * \ingroup G_UCS_NET
+ */
+extern Ucs_Return_t Ucs_Network_Shutdown(Ucs_Inst_t *self, Ucs_StdResultCb_t result_fptr);
+
+/*! \brief Triggers the INIC to force the NotAvailable state
+ * \param self The instance
+ * \param force Is \c true if the INIC shall force the network in NotAvailable state.
+ * If \c false the INIC shall no no longer force the network to NotAvailable state.
+ * \param result_fptr Optional result callback
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * UCS_RET_ERR_API_LOCKED | API is currently locked
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * \ingroup G_UCS_NET
+ */
+extern Ucs_Return_t Ucs_Network_ForceNotAvailable(Ucs_Inst_t *self, bool force, Ucs_StdResultCb_t result_fptr);
+
+/*! \brief Retrieves the Network Frame Counter, which is the number of frames since reset.
+ * \mns_func_inic{MOSTNetworkFrameCounter,MNSH3-MOSTNetworkFrameCounter523}
+ * \param self The instance
+ * \param reference Reference value that shall be delivered by \c result_fptr.\mns_name_inic{Reference}
+ * \param result_fptr Result callback.
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * MNS_RET_SUCCESS | No error
+ * MNS_RET_ERR_BUFFER_OVERFLOW | No message buffer available
+ * MNS_RET_ERR_API_LOCKED | API is currently locked
+ * MNS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ * \ingroup G_UCS_NET
+ */
+extern Ucs_Return_t Ucs_Network_GetFrameCounter(Ucs_Inst_t *self, uint32_t reference, Ucs_Network_FrameCounterCb_t result_fptr);
+
+/*! \brief Retrieves the number of nodes within the MOST network
+ * \param self The instance
+ * \return Returns the number of nodes within the MOST network.
+ * \ingroup G_UCS_NET
+ */
+extern uint8_t Ucs_Network_GetNodesCount(Ucs_Inst_t *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Node Discovery */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Starts the Node Discovery service
+ *
+ * \param self The instance
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_API_LOCKED | Node Discovery was already started
+ *
+ *
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+Ucs_Return_t Ucs_Nd_Start(Ucs_Inst_t *self);
+
+
+/*! \brief Stops the Node Discovery service
+ *
+ * \param self The instance
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_NOT_AVAILABLE | Node Discovery not running
+ *
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+extern Ucs_Return_t Ucs_Nd_Stop(Ucs_Inst_t *self);
+
+
+/*! \brief Initializes all nodes.
+ * \note <b>Must not be used when Node Discovery service is started.</b>
+ * \param self The instance
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+extern Ucs_Return_t Ucs_Nd_InitAll(Ucs_Inst_t *self);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* BackChannel Diagnosis */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Starts the BackChannel Diagnosis
+ *
+ * \param self The instance
+ * \param report_fptr Callback function presenting reports of the diagnosis
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * --------------------------- | ------------------------------------
+ * UCS_RET_SUCCESS | No error
+ * UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized
+ *
+ *
+ * \ingroup G_UCS_BC_DIAG
+ */
+Ucs_Return_t Ucs_Bcd_Start(Ucs_Inst_t* self, Ucs_Bcd_ReportCb_t report_fptr);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Programming service */
+/*------------------------------------------------------------------------------------------------*/
+/*! Starts the Programming service and processes the command list
+ *
+ * \param *self The instance
+ * \param node_id The node position address of the the node to be programmed
+ * \param signature Signature of the the node to be programmed
+ * \param session_type Memory access type
+ * \param command_list List of programming tasks. It has to end with a NULL entry.
+ * \param result_fptr Result callback
+ * \return
+ * \ingroup G_UCS_PROG_MODE
+ */
+Ucs_Return_t Ucs_Prog_Start(Ucs_Inst_t *self,
+ uint16_t node_id,
+ Ucs_Signature_t *signature,
+ Ucs_Prg_SessionType_t session_type,
+ Ucs_Prg_Command_t* command_list,
+ Ucs_Prg_ReportCb_t result_fptr);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Application Message Service */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Allocates an application message object for transmission
+ * \details This function retrieves a Tx message object with a payload buffer of the given size.
+ * The application must take care that Ucs_AmsTx_Msg_t::data_size of the resulting message
+ * object does not exceed the amount of provided payload.\n
+ * The application is also allowed to provide own payload to the message object.
+ * In this case the application is allowed to call this function and pass data_size "0".
+ * The application can set Ucs_AmsTx_Msg_t::data_ptr and Ucs_AmsTx_Msg_t::data_size of
+ * the returned message object to the application provided payload.
+ * \param self The instance
+ * \param data_size Required payload size which needs to be allocated. Valid values: 0..65535.
+ * \return The allocated Tx message object or \c NULL if no Tx message object is available.
+ * If the function returns \c NULL the application can use
+ * \ref Ucs_AmsTx_InitData_t::message_freed_fptr "ams.tx.message_freed_fptr"
+ * as trigger to request a message object again.
+ * \note The application may also allocate a certain number of message objects without transmitting
+ * in one go. In this case the message object is handed over to the application which is now
+ * responsible to transmit or free the object. When UNICENS terminates it is
+ * possible that user allocated memory is still dedicated to such a message buffer. In this
+ * case the application must do the following steps for every retained Tx message object:
+ * - Free application provided payload
+ * - Call Ucs_AmsTx_FreeUnusedMsg() to release the message to UNICENS
+ * - Guarantee to access the Tx message object never again
+ * .
+ * After performing these steps the application is allowed to call Ucs_Init() again.
+ * \ingroup G_UCS_AMS
+ */
+Ucs_AmsTx_Msg_t* Ucs_AmsTx_AllocMsg(Ucs_Inst_t *self, uint16_t data_size);
+
+/*! \brief Transmits an application message
+ * \param self The instance
+ * \param msg_ptr Reference to the related Tx message object
+ * \param tx_complete_fptr Callback function that is invoked as soon as the transmission was
+ * finished and the transmission result is available. The application
+ * must assign a callback function if the transmission result is required
+ * or the Tx message object uses external payload which needs to be
+ * reused or freed by the application. Otherwise the application is
+ * allowed to pass \c NULL.
+ * \note It is important that \c msg_ptr is the reference to an object which was previously obtained
+ * from Ucs_AmsTx_AllocMsg(). The application must not pass the reference of a \em self-created
+ * Tx message object to this function.
+ * \return Possible return values are shown in the table below.
+ * <table>
+ * <tr><th>Value</th><th>Description</th></tr>
+ * <tr><td>UCS_RET_SUCCESS</td><td>No error</td></tr>
+ * <tr>
+ * <td>UCS_RET_ERR_PARAM</td>
+ * <td>Invalid parameter is given. Possible reasons are:
+ * - \c msg_ptr is \c NULL
+ * - \c destination_address is smaller than \c 0x10 (reserved for internal communication)
+ * - \c data_size of a broad or group-cast message is larger than \c 45
+ * .
+ * Either the application must modify the message and retry the function call, or must free the message
+ * object via Ucs_AmsTx_FreeUnusedMsg().</td>
+ * </tr>
+ * <tr><td>UCS_RET_ERR_NOT_INITIALIZED</td><td>UNICENS is not initialized. \n Message
+ * objects that have been allocated during initialized state are no longer valid.</td>
+ * </tr>
+ * </table>
+ * \ingroup G_UCS_AMS
+ */
+Ucs_Return_t Ucs_AmsTx_SendMsg(Ucs_Inst_t *self, Ucs_AmsTx_Msg_t *msg_ptr, Ucs_AmsTx_CompleteCb_t tx_complete_fptr);
+
+/*! \brief Frees an unused Tx message object
+ * \param self The instance
+ * \param msg_ptr Reference to the Tx message object
+ * \details It is important that the application is responsible to free external payload, which is
+ * associated with the message object.
+ * \ingroup G_UCS_AMS
+ */
+void Ucs_AmsTx_FreeUnusedMsg(Ucs_Inst_t *self, Ucs_AmsTx_Msg_t *msg_ptr);
+
+/*! \brief Retrieves a reference to the front-most message in the Rx queue
+ * \details The Application Message Service already provides a queue of
+ * completed Rx messages. Ucs_AmsRx_PeekMsg() always returns a reference
+ * to the front-most message in the Rx queue.
+ * The function call does not dequeue the message handle. Thus, multiple
+ * subsequent calls of Ucs_AmsRx_PeekMsg() will always return the same
+ * reference. After processing the front-most message, the application
+ * must call Ucs_AmsRx_ReleaseMsg(). \n
+ * Typically, an application will process the front-most Rx message and call
+ * Ucs_AmsRx_ReleaseMsg(), which dequeues and frees the Rx message.
+ * Hence, the application must not access this this reference anymore.
+ * The next call of Ucs_AmsRx_PeekMsg() returns a reference of the following
+ * Rx message, or \c NULL if no further message is available. \n
+ * However, it is possible that an application cannot process an Rx message.
+ * In that case that application must not call Ucs_AmsRx_ReleaseMsg() so that
+ * the next call of Ucs_AmsRx_PeekMsg() returns again the reference to the
+ * un-processed message.
+ * \param self The instance
+ * \return Reference to the front-most message in the Rx queue or \c NULL
+ * if the Rx queue is empty.
+ * \warning It is important that the application takes care about the life time of the
+ * Rx message object. The returned reference is valid if the application
+ * performs the peek, processing and release operation in one go.
+ * A reference returned by Ucs_AmsRx_PeekMsg() might become invalid during a
+ * call of Ucs_Service(). The reason is that the UNICENS library might process
+ * an event which will flush the AMS Rx queue.
+ * \ingroup G_UCS_AMS
+ */
+Ucs_AmsRx_Msg_t* Ucs_AmsRx_PeekMsg(Ucs_Inst_t *self);
+
+/*! \brief Removes and frees the front-most message from the Rx queue
+ * \details The application must not access the removed message any longer.
+ * \param self The instance
+ * \ingroup G_UCS_AMS
+ */
+void Ucs_AmsRx_ReleaseMsg(Ucs_Inst_t *self);
+
+/*! \brief Retrieves the number of messages that are located in the Rx queue
+ * \param self The instance
+ * \return The number of messages in the Rx queue
+ * \ingroup G_UCS_AMS
+ */
+uint16_t Ucs_AmsRx_GetMsgCnt(Ucs_Inst_t *self);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Command Interpreter */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Add a MessageId Table to the Command Interpreter.
+ * \param self The Ucs instance
+ * \param msg_id_tab_ptr Reference to MessageId Table
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ------------------------------- | ------------------------------------
+ * UCS_CMD_RET_SUCCESS | MessageId Table was successfully added
+ * UCS_CMD_RET_ERR_ALREADY_ENTERED | MessageId Table already added
+ * UCS_CMD_RET_ERR_NULL_PTR | NULL pointer used as argument for MessageId Table reference
+ *
+ * \ingroup G_UCS_CMD
+ */
+extern Ucs_Cmd_Return_t Ucs_Cmd_AddMsgIdTable(Ucs_Inst_t *self, Ucs_Cmd_MsgId_t *msg_id_tab_ptr);
+
+
+/*! \brief Remove a MessageId Table from the Command Interpreter
+ *
+ * \param self pointer to the Ucs instance
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ---------------------------- | ------------------------------------
+ * UCS_CMD_RET_SUCCESS | MessageId Table was successfully removed
+ *
+ * \ingroup G_UCS_CMD
+ */
+extern Ucs_Cmd_Return_t Ucs_Cmd_RemoveMsgIdTable(Ucs_Inst_t *self);
+
+/*! \brief Decode an MCM message
+ * \details Function expects that the MessageId Table ends with a termination entry
+ * (handler_function_ptr == NULL). If this entry is not present, the search may end in an
+ * endless loop.
+ * \param self Pointer to the Ucs instance
+ * \param msg_rx_ptr Reference to the message to decode
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ------------------------------- | ------------------------------------
+ * UCS_CMD_RET_SUCCESS | Decoding was successful
+ * UCS_CMD_RET_ERR_MSGID_NOTAVAIL | MessageId not found
+ * UCS_CMD_RET_ERR_TX_BUSY | No Tx Buffer available
+ * UCS_CMD_RET_ERR_APPL | Error happened in handler function
+ * UCS_CMD_RET_ERR_NULL_PTR | NULL pointer used as argument for message reference or MessageId Table not available.
+ *
+ * \ingroup G_UCS_CMD
+ */
+extern Ucs_Cmd_Return_t Ucs_Cmd_DecodeMsg(Ucs_Inst_t *self, Ucs_AmsRx_Msg_t *msg_rx_ptr);
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_CLASS_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_cmd.h b/ucs2-lib/inc/ucs_cmd.h
new file mode 100644
index 0000000..e7d1694
--- /dev/null
+++ b/ucs2-lib/inc/ucs_cmd.h
@@ -0,0 +1,93 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Command Interpreter Add-On.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_CMD_INT
+ * @{
+ */
+
+
+
+#ifndef UCS_CMD_H
+#define UCS_CMD_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_cmd_pb.h"
+#include "ucs_base.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Class structure of the Command Interpreter
+ */
+typedef struct CCmd_
+{
+ Ucs_Cmd_MsgId_t *msg_id_tab_ptr; /*!< \brief Pointer to table of MessageIds */
+
+ void *ucs_user_ptr; /*!< \brief User reference for API callback functions */
+
+
+} CCmd;
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+void Cmd_Ctor(CCmd *self, CBase *base_ptr);
+Ucs_Cmd_Return_t Cmd_AddMsgIdTable(CCmd *self, Ucs_Cmd_MsgId_t *msg_id_tab_ptr);
+Ucs_Cmd_Return_t Cmd_RemoveMsgIdTable(CCmd *self);
+Ucs_Cmd_Return_t Cmd_DecodeMsg(CCmd *self, Ucs_AmsRx_Msg_t *msg_rx_ptr);
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+/*!
+ * @}
+ * \endcond
+ */
+
+#endif /* #ifndef UCS_CMD_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_cmd_pb.h b/ucs2-lib/inc/ucs_cmd_pb.h
new file mode 100644
index 0000000..a4ac8a4
--- /dev/null
+++ b/ucs2-lib/inc/ucs_cmd_pb.h
@@ -0,0 +1,124 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Header file of the Command Interpreter.
+ *
+ */
+
+
+#ifndef UCS_CMD_PB_H
+#define UCS_CMD_PB_H
+
+#include "ucs_ams_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Constants */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Denotes the end of an MessageId Table
+ * \ingroup G_UCS_CMD_TYPES
+ */
+#define UCS_CMD_MSGID_TERMINATION 0xFFFFU
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes used for Command Interpreter API functions
+ * \ingroup G_UCS_CMD_TYPES
+ */
+typedef enum Ucs_Cmd_Return_
+{
+ UCS_CMD_RET_SUCCESS = 0x00, /*!< Operation successfully completed */
+ UCS_CMD_RET_ERR_MSGID_NOTAVAIL = 0x01, /*!< MessageId not found */
+ UCS_CMD_RET_ERR_TX_BUSY = 0x02, /*!< No free Tx buffer available */
+ UCS_CMD_RET_ERR_APPL = 0x03, /*!< Application handler function reports custom error */
+ UCS_CMD_RET_ERR_ALREADY_ENTERED = 0x04, /*!< MessageId Table already connected */
+ UCS_CMD_RET_ERR_NULL_PTR = 0x05 /*!< NULL pointer used as argument */
+} Ucs_Cmd_Return_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Type definition of user handler functions
+ * \param msg_rx_ptr Reference to the received message
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \return Possible return values are shown in the table below.
+ * Value | Description
+ * ------------------------------- | ------------------------------------
+ * UCS_CMD_RET_SUCCESS | The handler function succeeded.
+ * UCS_CMD_RET_ERR_TX_BUSY | The handler function could not send an answer because no free Tx Buffer was available.
+ * UCS_CMD_RET_ERR_APPL | An error happened in handler function.
+ * \note The application must not return other values than the ones listed above.
+ * \ingroup G_UCS_CMD_TYPES
+ */
+typedef Ucs_Cmd_Return_t (*Ucs_Cmd_Handler_Function_t)(Ucs_AmsRx_Msg_t *msg_rx_ptr, void *user_ptr);
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Structure of a single element of the MessageId Table
+ * \details The application provides a MessageId Table which contains all supported MessageIds
+ * with their belonging handler functions. The MessageId Table is an array of several
+ * Ucs_Cmd_MsgId_t elements. It has to end with a termination entry with the
+ * value {\ref UCS_CMD_MSGID_TERMINATION, NULL}.
+ * \ingroup G_UCS_CMD_TYPES
+ */
+typedef struct Ucs_Cmd_MsgId_
+{
+ /*! \brief MessageId */
+ uint16_t msg_id;
+ /*! \brief Pointer to the belonging handler function */
+ Ucs_Cmd_Handler_Function_t handler_function_ptr;
+
+} Ucs_Cmd_MsgId_t;
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_CMD_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_dec.h b/ucs2-lib/inc/ucs_dec.h
new file mode 100644
index 0000000..5e5ddbb
--- /dev/null
+++ b/ucs2-lib/inc/ucs_dec.h
@@ -0,0 +1,126 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Command Decoder Module.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_DEC_INT
+ * @{
+ */
+
+#ifndef UCS_DEC_H
+#define UCS_DEC_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_dl.h"
+#include "ucs_message.h"
+/*#include "ucs_ams.h"*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Constants */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores FktID and OPType in one 16 bit value */
+#define DEC_FKTOP(a,b) ((uint16_t)((((uint16_t)((a)<<4)) & (uint16_t)0xFFF0)) | ((uint16_t)(((uint16_t)(b)) & (uint16_t)0x000F))) /* parasoft-suppress MISRA2004-19_7 "Is used in arrays and therefore cannot be converted to inline function." */
+
+/*! \brief Denotes the end of an FktOp table */
+#define DEC_FKTOP_TERMINATION 0xFFFFU
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Return codes used for decoding functions */
+/* Attention: these values are used as error descriptor in error messages and
+ must therefore not changed!
+*/
+typedef enum Dec_Return_
+{
+ DEC_RET_SUCCESS = 0x00, /*!< \brief Operation successfully completed */
+ DEC_RET_FKTID_NOT_FOUND = 0x03, /*!< \brief FunctionID not found */
+ DEC_RET_OPTYPE_NOT_FOUND = 0x04 /*!< \brief Operation Type not found */
+
+} Dec_Return_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+typedef void (*Dec_IcmCb_t)(void *self, Msg_MostTel_t *msg_ptr);
+typedef void (*Dec_RcmCb_t)(void *self, Msg_MostTel_t *msg_ptr);
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure of an FktID_OpType element for FBlock INIC */
+typedef struct Dec_FktOpIcm_
+{
+ /*!< \brief FktID and OPType (combined to a 16-bit value) */
+ uint16_t fkt_op;
+ /*!< \brief pointer to the belonging handler function */
+ Dec_IcmCb_t handler_function_ptr;
+
+} Dec_FktOpIcm_t;
+
+/*! \brief Structure of an FktID_OpType element for internal INIC Shadow FBlocks e.g. FBlock EXC*/
+typedef struct Dec_FktOpIsh_
+{
+ /*! \brief FktID and OPType (combined to a 16-bit value) */
+ uint16_t fkt_op;
+ /*! \brief pointer to the belonging handler function */
+ Dec_RcmCb_t handler_function_ptr;
+
+} Dec_FktOpIsh_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern Dec_Return_t Dec_SearchFktOpIcm(Dec_FktOpIcm_t const list[], uint16_t *index_ptr,
+ uint16_t function_id, Ucs_OpType_t op_type);
+extern Dec_Return_t Dec_SearchFktOpIsh(Dec_FktOpIsh_t const list[], uint16_t *index_ptr,
+ uint16_t function_id, Ucs_OpType_t op_type);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_DEC_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_dl.h b/ucs2-lib/inc/ucs_dl.h
new file mode 100644
index 0000000..390034c
--- /dev/null
+++ b/ucs2-lib/inc/ucs_dl.h
@@ -0,0 +1,130 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the doubly linked list.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_DL
+ * @{
+ */
+
+#ifndef UCS_DL_H
+#define UCS_DL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback signature used by foreach-function
+ * \param d_ptr Reference to the data of the current node
+ * \param up_ptr Reference to the user data
+ * \return true: Stop the for-each-loop
+ * \return false: Continue the for-each-loop
+ */
+typedef bool(*Dl_ForeachFunc_t)(void *d_ptr, void *ud_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Standard return values of the list module. */
+typedef enum Dl_Ret_
+{
+ DL_OK, /*!< \brief No error */
+ DL_UNKNOWN_NODE, /*!< \brief Unknown node */
+ DL_STOPPED /*!< \brief Search process stopped */
+
+} Dl_Ret_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class structure of doubly linked list node. */
+typedef struct DlNode_
+{
+ struct DlNode_ *prev; /*!< \brief Reference to previous node in list */
+ struct DlNode_ *next; /*!< \brief Reference to next node in list */
+ void *data_ptr; /*!< \brief Reference to optional data */
+ bool in_use; /*!< \brief Flag which signals that the node is in use */
+
+} CDlNode;
+
+/*! \brief Class structure of the doubly linked list. */
+typedef struct CDlList_
+{
+ struct DlNode_ *head; /*!< \brief Reference to head of the list */
+ struct DlNode_ *tail; /*!< \brief Reference to tail of the list */
+ uint16_t size; /*!< \brief Number of nodes in the list */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CDlList;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CDlList */
+/*------------------------------------------------------------------------------------------------*/
+extern void Dl_Ctor(CDlList *self, void *ucs_user_ptr);
+extern void Dl_InsertAfter(CDlList *self, CDlNode *node, CDlNode *new_node);
+extern void Dl_InsertBefore(CDlList *self, CDlNode *node, CDlNode *new_node);
+extern void Dl_InsertHead(CDlList *self, CDlNode *new_node);
+extern void Dl_InsertTail(CDlList *self, CDlNode *new_node);
+extern Dl_Ret_t Dl_Remove(CDlList *self, CDlNode *node);
+extern CDlNode * Dl_PopHead(CDlList *self);
+extern CDlNode * Dl_PopTail(CDlList *self);
+extern CDlNode * Dl_PeekHead(CDlList *self);
+extern CDlNode * Dl_PeekTail(CDlList *self);
+extern CDlNode * Dl_Foreach(CDlList *self, Dl_ForeachFunc_t func_ptr, void *user_data_ptr);
+extern bool Dl_IsNodeInList(CDlList *self, const CDlNode *node);
+extern void Dl_AppendList(CDlList *self, CDlList *list_ptr);
+extern uint16_t Dl_GetSize(CDlList *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CDlNode */
+/*------------------------------------------------------------------------------------------------*/
+extern void Dln_Ctor(CDlNode *self, void *data_ptr);
+extern void Dln_SetData(CDlNode *self, void *data_ptr);
+extern void * Dln_GetData(CDlNode *self);
+extern bool Dln_IsNodePartOfAList(CDlNode *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_DL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_eh.h b/ucs2-lib/inc/ucs_eh.h
new file mode 100644
index 0000000..8491c27
--- /dev/null
+++ b/ucs2-lib/inc/ucs_eh.h
@@ -0,0 +1,128 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the event handler.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_EH
+ * @{
+ */
+
+#ifndef UCS_EH_H
+#define UCS_EH_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_eh_pb.h"
+#include "ucs_obs.h"
+#include "ucs_trace.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief A control FIFO synchronization is lost. When this event occurs the PMS still waits
+ * until all FIFOs are unsynchronized. So this event is no termination event.
+ */
+#define EH_E_SYNC_LOST 0x0001U
+/*! \brief INIC Build-In-Self-Test failed
+ */
+#define EH_E_BIST_FAILED 0x0002U
+/*! \brief Notifies completed un-synchronization of Port Message FIFOs
+ */
+#define EH_E_UNSYNC_COMPLETE 0x0004U
+/*! \brief Notifies that the Port Message Channel was not able to un-synchronize its FIFOs
+ * within a definite time
+ */
+#define EH_E_UNSYNC_FAILED 0x0008U
+/*! \brief UNICENS initialization succeeded
+ */
+#define EH_E_INIT_SUCCEEDED 0x0010U
+/*! \brief UNICENS initialization failed
+ */
+#define EH_E_INIT_FAILED 0x0020U
+
+/*! \brief Mask including all events that lead to the termination of the UCS
+ */
+#define EH_M_TERMINATION_EVENTS (EH_E_UNSYNC_COMPLETE | EH_E_UNSYNC_FAILED | \
+ EH_E_BIST_FAILED | EH_E_INIT_FAILED)
+
+/*! \brief Bitmask to identify all internal event codes
+ */
+#define EH_M_ALL_EVENTS (EH_M_TERMINATION_EVENTS | EH_E_INIT_SUCCEEDED | EH_E_SYNC_LOST)
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for callback functions which notifies the event handler
+ * observers.
+ * \param self Instance pointer
+ * \param event_code Reported event code
+ */
+typedef void (*Ehobs_UpdateCb_t)(void *self, uint32_t event_code);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class structure of the event handler. */
+typedef struct CEventHandler_
+{
+ /*! \brief Subject used for internal events */
+ CSubject internal_event_subject;
+ /*! \brief Single subject to report error to application */
+ CSingleSubject public_error_subject;
+ /*! \brief UNICENS instance ID */
+ void * ucs_user_ptr;
+
+} CEventHandler;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CEventHandler */
+/*------------------------------------------------------------------------------------------------*/
+extern void Eh_Ctor(CEventHandler *self, void *ucs_user_ptr);
+extern void Eh_AddObsrvPublicError(CEventHandler *self, CSingleObserver *obs_ptr);
+extern void Eh_DelObsrvPublicError(CEventHandler *self);
+extern void Eh_ReportEvent(CEventHandler *self, uint32_t event_code);
+extern void Eh_AddObsrvInternalEvent(CEventHandler *self, CMaskedObserver *obs_ptr);
+extern void Eh_DelObsrvInternalEvent(CEventHandler *self, CMaskedObserver *obs_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_EH_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_eh_pb.h b/ucs2-lib/inc/ucs_eh_pb.h
new file mode 100644
index 0000000..8a049d3
--- /dev/null
+++ b/ucs2-lib/inc/ucs_eh_pb.h
@@ -0,0 +1,66 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the event handler.
+ */
+/*!
+ * \addtogroup G_UCS_INIT_AND_SRV_TYPES
+ * @{
+ */
+
+#ifndef UCS_EH_PB_H
+#define UCS_EH_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief UNICENS general error codes */
+typedef enum Ucs_Error_
+{
+ UCS_GEN_ERR_COMMUNICATION = 1, /*!< \brief Fatal communication error between EHC and INIC */
+ UCS_GEN_ERR_INIC = 2 /*!< \brief INIC internal error */
+
+} Ucs_Error_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_EH_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_encoder.h b/ucs2-lib/inc/ucs_encoder.h
new file mode 100644
index 0000000..346fd21
--- /dev/null
+++ b/ucs2-lib/inc/ucs_encoder.h
@@ -0,0 +1,116 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of message encoder
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_ENCODER
+ * @{
+ */
+
+#ifndef UCS_ENCODER_H
+#define UCS_ENCODER_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Defines */
+/*------------------------------------------------------------------------------------------------*/
+#define ENC_MAX_SIZE_CONTENT 16U /*!< \brief Maximum content size in bytes, quadlet aligned */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Retrieves the size of a MOST message header
+ * \return The size of the MOST message header in bytes.
+ */
+typedef uint8_t (*Enc_GetSize_t)(void);
+
+/*! \brief Retrieves the content type of a MOST message header
+ * \return The content type of the MOST message header in bytes.
+ */
+typedef uint8_t (*Enc_GetContType_t)(void);
+
+/*! \brief Encodes a message telegram to the MOST message header
+ * \param tel_ptr Reference to the Msg_MostTel_t structure
+ * \param header The header buffer
+ */
+typedef void (*Enc_Encode_t)(Msg_MostTel_t *tel_ptr, uint8_t header[]);
+
+/*! \brief Decodes a MOST message header to a message telegram structure
+ * \param tel_ptr Reference to the Msg_MostTel_t structure
+ * \param header The header buffer
+ */
+typedef void (*Enc_Decode_t)(Msg_MostTel_t *tel_ptr, uint8_t header[]);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Identifier for a MOST Message Content */
+typedef enum Enc_MsgContent_
+{
+ ENC_CONTENT_00 = 0x00, /*!< \brief Content Type "0x00": Uncompressed, excluding retry values */
+ ENC_CONTENT_80 = 0x80, /*!< \brief Content Type "0x80": Compressed, excluding retry values */
+ ENC_CONTENT_81 = 0x81 /*!< \brief Content Type "0x81": Compressed, including retry values */
+
+} Enc_MsgContent_t;
+
+/*! \brief Interface for message encoder */
+typedef struct IEncoder_
+{
+ Enc_MsgContent_t content_type; /*!< \brief Retrieves the content type of the MOST message header */
+ uint8_t pm_hdr_sz; /*!< \brief Retrieves the size of the Port Message header */
+ uint8_t msg_hdr_sz; /*!< \brief Retrieves the size of the MOST message header */
+ Enc_Encode_t encode_fptr; /*!< \brief Function required to encode a MOST message header */
+ Enc_Decode_t decode_fptr; /*!< \brief Function required to decode a MOST message header */
+
+} IEncoder;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Function prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern IEncoder *Enc_GetEncoder(Enc_MsgContent_t type);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_ENCODER_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_epm.h b/ucs2-lib/inc/ucs_epm.h
new file mode 100644
index 0000000..d84dc1e
--- /dev/null
+++ b/ucs2-lib/inc/ucs_epm.h
@@ -0,0 +1,110 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the EndPoint Manager.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_EPM
+ * @{
+ */
+
+
+#ifndef UCS_EPM_H
+#define UCS_EPM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_ret_pb.h"
+#include "ucs_rm_pb.h"
+#include "ucs_xrm.h"
+#include "ucs_factory.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*!< \brief Stores data required by EPM during initialization. */
+typedef struct Epm_InitData_
+{
+ CBase * base_ptr; /*!< \brief Reference to a base instance */
+ CFactory * fac_ptr; /*!< \brief Reference to factory instance */
+ Ucs_Rm_XrmResDebugCb_t res_debugging_fptr; /*!< \brief Reference to the observer callback function for XRM resources */
+ Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr; /*!< \brief Reference to the callback function pointer to signal "check unmute" of devices */
+
+} Epm_InitData_t;
+
+/*! \brief Class structure of the EndPoint Management. */
+typedef struct CEndpointManagement_
+{
+ /*!< \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*!< \brief Reference to factory instance */
+ CFactory * fac_ptr;
+ /*!< \brief Reference to the application debugging callback function for XRM resources */
+ Ucs_Rm_XrmResDebugCb_t res_debugging_fptr;
+ /*!< \brief Reference to the callback function pointer to signal "check unmute" of devices */
+ Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr;
+
+} CEndpointManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CEndpointManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Epm_Ctor(CEndpointManagement * self, Epm_InitData_t * init_ptr);
+extern void Epm_InitInternalInfos (CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern void Epm_ClearIntInfos(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern void Epm_AddObserver(Ucs_Rm_EndPoint_t * ep_ptr, CObserver * obs_ptr);
+extern void Epm_DelObserver(Ucs_Rm_EndPoint_t * ep_ptr, CObserver * obs_ptr);
+extern Ucs_Return_t Epm_SetBuildProcess(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern Ucs_Return_t Epm_SetDestroyProcess(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern uint16_t Epm_GetConnectionLabel(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern void Epm_SetConnectionLabel(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr, uint16_t conn_label);
+extern Ucs_Rm_EndPointState_t Epm_GetState(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern void Epm_ResetState(CEndpointManagement * self, Ucs_Rm_EndPoint_t * ep_ptr);
+extern void Epm_ReportShutDown(CEndpointManagement * self);
+extern void Epm_ReportInvalidDevice(CEndpointManagement *self, uint16_t destination_address);
+extern void Epm_XrmResDebugCb(Ucs_Xrm_ResourceType_t resource_type, Ucs_Xrm_ResObject_t *resource_ptr,
+ Ucs_Xrm_ResourceInfos_t resource_infos, void *endpoint_inst_ptr, void *user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_EPM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_epm_pv.h b/ucs2-lib/inc/ucs_epm_pv.h
new file mode 100644
index 0000000..482ebea
--- /dev/null
+++ b/ucs2-lib/inc/ucs_epm_pv.h
@@ -0,0 +1,103 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Extended Resource Manager.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_EPM
+ * @{
+ */
+
+#ifndef UCS_EPM_PB_H
+#define UCS_EPM_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_xrm_pb.h"
+#include "ucs_obs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This enumerator specifies the state of EndPoint objects. */
+typedef enum Ucs_Rm_EndPointState_
+{
+ UCS_RM_EP_IDLE = 0x00U, /*!< \brief Specifies the "Idle" state of the endpoint. This means that the endpoint has not been handled yet */
+ UCS_RM_EP_XRMPROCESSING = 0x01U, /*!< \brief Specifies that the EndPoint is under "XRM process". */
+ UCS_RM_EP_BUILT = 0x02U /*!< \brief Specifies that the EndPoint is "Built". */
+
+} Ucs_Rm_EndPointState_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/* Epm_Inst_t requires incomplete forward declaration, to hide internal data type.
+ * The Epm_Inst_t object is allocated internally, the core library must access only the pointer to Epm_Inst_t. */
+struct Epm_Inst_;
+
+/*!\brief EndpointManagement instance */
+typedef struct Epm_Inst_ Epm_Inst_t;
+
+/*! \brief Internal configuration structure of a Connection EndPoint. */
+typedef struct Ucs_Rm_EndPointInt_
+{
+ /*! \brief Stores the current number of retries in case of error. */
+ uint8_t num_retries;
+ /*! \brief State of the endpoint object. */
+ Ucs_Rm_EndPointState_t endpoint_state;
+ /*! \brief connection label. */
+ uint16_t connection_label;
+ /*! \brief object counter. */
+ uint8_t reference_cnt;
+ /*! \brief last XRM result. */
+ Ucs_Xrm_Result_t xrm_result;
+ /*! \brief A subject object for this endpoint. */
+ CSubject subject_obj;
+ /*! \brief Reference to the EndPointManagement that handles this endpoint */
+ Epm_Inst_t * epm_inst;
+ /*! \brief magic number to signal that endpoint has already been initialized */
+ uint32_t magic_number;
+
+} Ucs_Rm_EndPointInt_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_EPM_PB_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_exc.h b/ucs2-lib/inc/ucs_exc.h
new file mode 100644
index 0000000..e703f6a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_exc.h
@@ -0,0 +1,323 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CExc.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_EXC
+ * @{
+ */
+
+#ifndef UCS_EXC_H
+#define UCS_EXC_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_inic_pb.h"
+#include "ucs_obs.h"
+#include "ucs_fsm.h"
+#include "ucs_dec.h"
+#include "ucs_base.h"
+#include "ucs_inic.h"
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+
+
+
+#define EXC_FID_HELLO 0x200U
+#define EXC_FID_WELCOME 0x201U
+#define EXC_FID_SIGNATURE 0x202U
+#define EXC_FID_DEVICE_INIT 0x203U
+#define EXC_FID_ENABLEPORT 0x210U
+#define EXC_FID_CABLE_LINK_DIAG 0x211U
+#define EXC_FID_PHY_LAY_TEST 0x220U
+#define EXC_FID_PHY_LAY_TEST_RES 0x221U
+#define EXC_FID_BC_DIAG 0x222U
+#define EXC_FID_BC_ENABLE_TX 0x223U
+#define EXC_FID_MEM_SESSION_OPEN 0x300U
+#define EXC_FID_MEM_SESSION_CLOSE 0x301U
+#define EXC_FID_MEMORY_READ 0x302U
+#define EXC_FID_MEMORY_WRITE 0x303U
+
+
+
+#define EXC_WELCOME_SUCCESS 0U /*!< \brief Welcome.Result reports success */
+
+
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure holds parameters for API locking */
+typedef struct Exc_ApiLock_
+{
+ /*! \brief API locking instance for EXC functions */
+ CApiLocking api;
+ /*! \brief Observer used for locking timeouts for EXC functions */
+ CSingleObserver observer;
+
+} Exc_ApiLock_t;
+
+/*! \brief Structure ExcSingleSubjects */
+typedef struct Exc_Ssubjects_
+{
+ CSingleSubject hello; /*!< \brief Subject for the Hello.Status and Hello.Error messages */
+ CSingleSubject welcome; /*!< \brief Subject for the Welcome.ResultAck and Welcome.ErrorAck messages */
+ CSingleSubject signature; /*!< \brief Subject for the Signature.Status and Signature.Error messages */
+ CSingleSubject deviceinit; /*!< \brief Subject for the DeviceInit.Error message */
+ CSingleSubject enableport; /*!< \brief Subject for the EnablePort.ResultAck and EnablePort.ErrorAck messages */
+ CSingleSubject cablelinkdiag; /*!< \brief Subject for the CableLinkDiagnosis.ResultAck and CableLinkDiagnosis.ErrorAck messages */
+ CSingleSubject phylaytest; /*!< \brief Subject for the PhysicalLayerTestResult.Status and PhysicalLayerTest.Error messages */
+ CSingleSubject phylaytestresult; /*!< \brief Subject for the PhysicalLayerTestResult.Status and PhysicalLayerTestResult.Error messages */
+ CSingleSubject memsessionopen; /*!< \brief Subject for the MemorySessionOpen.Result and MemorySessionOpen.Error messages */
+ CSingleSubject memsessionclose; /*!< \brief Subject for the MemorySessionClose.Result and MemorySessionClose.Error messages */
+ CSingleSubject memoryread; /*!< \brief Subject for the MemoryRead.Result and MemoryRead.Error messages */
+ CSingleSubject memorywrite; /*!< \brief Subject for the MemoryWrite.Result and MemoryWrite.Error messages */
+ CSingleSubject bcdiag; /*!< \brief Subject for the BCdiag.Result and Error messages */
+ CSingleSubject enabletx; /*!< \brief Subject for the BC_EnableTx.Status and Error messages */
+} Exc_Ssubjects_t;
+
+
+
+
+/*! \brief Structure of class CExc. */
+typedef struct CExc_
+{
+ /*! \brief pointer to the FktID/OPType list */
+ Dec_FktOpIsh_t const *fkt_op_list_ptr;
+
+ /*! \brief Subjects for single-observer */
+ Exc_Ssubjects_t ssubs;
+
+ /*! \brief Parameters for API locking */
+ Exc_ApiLock_t lock;
+
+ /*! \brief Reference to base instance */
+ CBase *base_ptr;
+
+ /*! \brief Reference to a Transceiver instance */
+ CTransceiver *xcvr_ptr;
+
+} CExc;
+
+/*! \brief Structure used for returning method results/errors
+ *
+ * Either the data_info or the error part of the structure contain the information.
+ * In case an error happened, data_info will be NULL. If no error happened,
+ * error.code is 0 and error.info is NULL.
+*/
+typedef struct Exc_StdResult_
+{
+ Ucs_StdResult_t result; /*!< \brief Result code and info byte stream */
+ void *data_info; /*!< \brief Reference to result values */
+
+} Exc_StdResult_t;
+
+
+/*! \brief This structure provides information on the Physical layer test result */
+typedef struct Exc_PhyTestResult_
+{
+ uint8_t port_number; /*!< \brief Port Number */
+ bool lock_status; /*!< \brief Lock status */
+ uint16_t err_count; /*!< \brief Number of Coding Errors */
+
+} Exc_PhyTestResult_t;
+
+
+/*! \brief Result values of the BCDiag command*/
+typedef enum Exc_BCDiagResValue_
+{
+ DUT_SLAVE = 0x01U, /*!< \brief Slave answered. No break on this segment. */
+ DUT_MASTER = 0x02U, /*!< \brief TimingMaster answered: ring is closed. */
+ DUT_NO_ANSWER = 0x03U, /*!< \brief Ring break found. */
+ DUT_TIMEOUT = 0x04U /*!< \brief No answer on back channel */
+
+} Exc_BCDiagResValue;
+
+/*! \brief Provides BackChannel Diagnosis result */
+typedef struct Exc_BCDiagResult_
+{
+ Exc_BCDiagResValue diag_result;
+ uint16_t admin_addr;
+} Exc_BCDiagResult;
+
+
+/*! \brief This structure provides information on the Coax Diagnosis */
+typedef struct Exc_CableLinkDiagResult_
+{
+ uint8_t port_number;
+ uint8_t result;
+
+} Exc_CableLinkDiagResult_t;
+
+
+/*! \brief This structure provides information on the Hello.Status message */
+typedef struct Exc_HelloStatus_t_
+{
+ uint8_t version;
+ Ucs_Signature_t signature;
+
+} Exc_HelloStatus_t;
+
+/*! \brief This structure provides information on the Welcome.Result message */
+typedef struct Exc_WelcomeResult_t_
+{
+ uint8_t res;
+ uint8_t version;
+ Ucs_Signature_t signature;
+
+} Exc_WelcomeResult_t;
+
+/*! \brief This structure provides information on the Signature.Status message */
+typedef struct Exc_SignatureStatus_t_
+{
+ uint8_t version;
+ Ucs_Signature_t signature;
+
+} Exc_SignatureStatus_t;
+
+/*! \brief This structure provides information on the MemoryRead.Result message */
+typedef struct Exc_MemReadResult_
+{
+ uint16_t session_handle;
+ uint8_t mem_id;
+ uint32_t address;
+ uint8_t unit_len;
+ uint8_t unit_data[18];
+
+} Exc_MemReadResult_t;
+
+/*! \brief This structure provides information on the MemoryWrite.Result message */
+typedef struct Exc_MemWriteResult_
+{
+ uint16_t session_handle;
+ uint8_t mem_id;
+
+} Exc_MemWriteResult_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Exc_Ctor(CExc *self, CBase *base_ptr, CTransceiver *rcm_ptr);
+extern void Exc_OnRcmRxFilter(void *self, Msg_MostTel_t *tel_ptr);
+
+extern Ucs_Return_t Exc_Hello_Get(CExc *self,
+ uint16_t target_address,
+ uint8_t version_limit,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_Welcome_Sr(CExc *self,
+ uint16_t target_address,
+ uint16_t admin_node_address,
+ uint8_t version,
+ Ucs_Signature_t signature,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_Signature_Get(CExc *self,
+ uint16_t target_address,
+ uint8_t version_limit,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_DeviceInit_Start(CExc *self,
+ uint16_t target_address,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_EnablePort_Sr(CExc *self,
+ uint16_t target_address,
+ uint8_t port_number,
+ bool enabled,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_CableLinkDiagnosis_Start (CExc *self,
+ uint16_t target_address,
+ uint8_t port_number,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_PhyTest_Start(CExc *self,
+ uint8_t port_number,
+ Ucs_Diag_PhyTest_Type_t type,
+ uint16_t lead_in,
+ uint32_t duration,
+ uint16_t lead_out,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_PhyTestResult_Get(CExc *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_BCDiag_Start(CExc *self,
+ uint8_t position,
+ uint16_t admin_na,
+ uint16_t t_send,
+ uint16_t t_wait4dut,
+ uint16_t t_switch,
+ uint16_t t_back,
+ bool autoback,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_BCEnableTx_StartResult(CExc *self,
+ uint8_t port,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_MemSessionOpen_Sr(CExc *self,
+ uint16_t target_address,
+ uint8_t session_type,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_MemSessionClose_Sr(CExc *self,
+ uint16_t target_address,
+ uint16_t session_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_MemoryRead_Sr(CExc *self,
+ uint16_t target_address,
+ uint16_t session_handle,
+ uint8_t mem_id,
+ uint32_t address,
+ uint8_t unit_len,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Exc_MemoryWrite_Sr(CExc *self,
+ uint16_t target_address,
+ uint16_t session_handle,
+ uint8_t mem_id,
+ uint32_t address,
+ uint8_t unit_len,
+ uint8_t unit_data[],
+ CSingleObserver *obs_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_EXC_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_factory.h b/ucs2-lib/inc/ucs_factory.h
new file mode 100644
index 0000000..227753c
--- /dev/null
+++ b/ucs2-lib/inc/ucs_factory.h
@@ -0,0 +1,167 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the MNS Factory.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_FAC
+ * @{
+ */
+
+
+#ifndef UCS_FAC_H
+#define UCS_FAC_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_net.h"
+#include "ucs_base.h"
+#include "ucs_inic.h"
+#include "ucs_ret_pb.h"
+#include "ucs_rsm.h"
+#include "ucs_xrm.h"
+#include "ucs_i2c.h"
+#include "ucs_gpio.h"
+#include "ucs_nsm.h"
+#include "ucs_xrmpool.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \def FAC_NUM_DEVICES
+ * \brief Defines the number of remote devices.
+ * \details The number of remote devices required by the application for remote jobs. The
+ * default value is 0 in MNS configuration file ucs_cfg.h. The user can adjust this
+ * value by defining the macro \ref UCS_NUM_REMOTE_DEVICES. Valid values are in
+ * the range from 0 to 63.
+ * \ingroup G_FAC
+ */
+#define FAC_NUM_DEVICES ((uint8_t)UCS_NUM_REMOTE_DEVICES + 1U)
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Factory Instances type. */
+typedef enum Fac_Inst_
+{
+ FAC_INST_INIC, /*!< \brief Corresponds to the INIC Instance type */
+ FAC_INST_RSM, /*!< \brief Corresponds to the RSM Instance type */
+ FAC_INST_XRM, /*!< \brief Corresponds to the XRM Instance type */
+ FAC_INST_GPIO, /*!< \brief Corresponds to the GPIO Instance type */
+ FAC_INST_I2C, /*!< \brief Corresponds to the I2C Instance type */
+ FAC_INST_NSM /*!< \brief Corresponds to the NSM Instance type */
+} Fac_Inst_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback signature used by the foreach-function of the factory class.
+ * \param inst_type The instance type to be looked for.
+ * \param inst_ptr Reference to the current instance.
+ * \param ud_ptr Reference to the user data
+ * \return true: Stop the for-each-loop
+ * \return false: Continue the for-each-loop
+ */
+typedef bool (*Fac_ForeachFunc_t)(Fac_Inst_t inst_type, void *inst_ptr, void *ud_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by the Factory during initialization. */
+typedef struct Fac_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
+ CXrmPool * xrmp_ptr; /*!< \brief Reference to the XRM Pool instance */
+ CTransceiver * icm_transceiver; /*!< \brief Reference to ICM transceiver */
+ CTransceiver * rcm_transceiver; /*!< \brief Reference to MCM transceiver */
+
+} Fac_InitData_t;
+
+/*! \brief Class structure of the MNS Factory. */
+typedef struct CFactory_
+{
+ /*! \brief FBlock INIC list */
+ CInic fbi_list[FAC_NUM_DEVICES];
+ /*! \brief XRM list */
+ CExtendedResourceManager xrm_list[FAC_NUM_DEVICES];
+ /*! \brief RSM list */
+ CRemoteSyncManagement rsm_list[FAC_NUM_DEVICES];
+ /*! \brief GPIO list */
+ CGpio gpio_list[FAC_NUM_DEVICES];
+ /*! \brief I2C list */
+ CI2c i2c_list[FAC_NUM_DEVICES];
+ /*! \brief Node Scripting list */
+ CNodeScriptManagement nsm_list[FAC_NUM_DEVICES];
+ /*! \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*! \brief Reference to a network instance */
+ CNetworkManagement *net_ptr;
+ /*!< \brief Reference to the XRM Pool instance */
+ CXrmPool * xrmp_ptr;
+ /*! \brief The ICM transceiver */
+ CTransceiver * icm_transceiver;
+ /*! \brief The RCM transceiver */
+ CTransceiver * rcm_transceiver;
+
+} CFactory;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CFactory */
+/*------------------------------------------------------------------------------------------------*/
+extern void Fac_Ctor(CFactory * self, Fac_InitData_t * init_ptr);
+extern CExtendedResourceManager * Fac_GetXrm(CFactory * self, uint16_t address, Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr);
+extern CExtendedResourceManager * Fac_GetXrmByJobList(CFactory * self, UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
+extern CExtendedResourceManager * Fac_GetXrmLegacy(CFactory * self, uint16_t address, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr);
+extern CInic * Fac_GetInic(CFactory * self, uint16_t address);
+extern CInic * Fac_FindInic(CFactory * self, uint16_t address);
+extern CNodeScriptManagement * Fac_GetNsm(CFactory * self, uint16_t address);
+extern CNodeScriptManagement * Fac_FindNsm(CFactory * self, uint16_t address);
+extern CRemoteSyncManagement * Fac_GetRsm(CFactory * self, uint16_t address);
+extern CRemoteSyncManagement * Fac_FindRsm(CFactory * self, uint16_t address);
+extern CGpio * Fac_GetGpio(CFactory * self, uint16_t address, Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr);
+extern CI2c * Fac_GetI2c(CFactory * self, uint16_t address, Ucs_I2c_IntEventReportCb_t i2c_interrupt_report_fptr);
+extern void Fac_Foreach(CFactory * self, Fac_Inst_t inst_type, Fac_ForeachFunc_t func_ptr, void *user_data_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RSM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_fsm.h b/ucs2-lib/inc/ucs_fsm.h
new file mode 100644
index 0000000..d4b5f77
--- /dev/null
+++ b/ucs2-lib/inc/ucs_fsm.h
@@ -0,0 +1,118 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Finite State Machine.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_FSM
+ * @{
+ */
+
+#ifndef UCS_FSM_H
+#define UCS_FSM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Internal state machine states which are also used as return values for method
+ * Fsm_Service().
+ */
+typedef enum Fsm_State_
+{
+ FSM_STATE_IDLE, /*!< \brief The state machine is in idle mode */
+ FSM_STATE_SERVICE, /*!< \brief An event is pending and the state machine must be serviced */
+ FSM_STATE_WAIT, /*!< \brief Waiting for asynchronous data/signal/event */
+ FSM_STATE_END, /*!< \brief The state machine is finished */
+ FSM_STATE_ERROR /*!< \brief An error occurred while processing the state machine */
+
+} Fsm_State_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for state machine actions */
+typedef void (*Fsm_Act_t)(void *self);
+
+/*! \brief Structure is used to define state elements */
+typedef struct Fsm_StateElem_
+{
+ /*! \brief Function pointer to the action that shall be executed */
+ Fsm_Act_t action_fptr;
+ /*! \brief Next state */
+ int8_t next_state;
+
+} Fsm_StateElem_t;
+
+/*! \brief Class structure of the finite state machine */
+typedef struct CFsm_
+{
+ /*! \brief Reference to transition table */
+ const Fsm_StateElem_t *transition_table_ptr;
+ /*! \brief Instance pointer used for actions */
+ void *inst_ptr;
+ /*! \brief Current event */
+ int8_t event_occured;
+ /*! \brief Current state */
+ int8_t current_state;
+ /*! \brief Maximum number of events */
+ uint8_t num_events;
+ /*! \brief Internal state of the state machine */
+ Fsm_State_t internal_state;
+
+} CFsm;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Fsm_Ctor(CFsm *self, void *inst_ptr, const Fsm_StateElem_t *trans_table_ptr,
+ uint8_t num_events, int8_t init_state);
+extern Fsm_State_t Fsm_Service(CFsm *self);
+extern void Fsm_SetEvent(CFsm *self, int8_t e);
+extern void Fsm_Wait(CFsm *self);
+extern void Fsm_End(CFsm *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_FSM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_gpio.h b/ucs2-lib/inc/ucs_gpio.h
new file mode 100644
index 0000000..7b755ea
--- /dev/null
+++ b/ucs2-lib/inc/ucs_gpio.h
@@ -0,0 +1,144 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the GPIO module.
+ *
+ * \defgroup G_UCS_GPIO_TYPES GPIO Referred Types
+ * \brief Referred types used by the Extended Resource Manager.
+ * \ingroup G_UCS_GPIO
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_GPIO
+ * @{
+ */
+
+
+#ifndef UCS_GPIO_H
+#define UCS_GPIO_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_nsm.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_gpio_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for GPIO results in case error.
+ * \param self Reference to CGpio instance
+ * \param msg_ptr Pointer to received message
+ */
+typedef void (*Gpio_ErrResultCb_t)(void *self, void *result_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by GPIO during initialization. */
+typedef struct Gpio_InitData_
+{
+ /*!< \brief Reference to INIC instance */
+ CInic *inic_ptr;
+ /*!< \brief Reference to NSM instance */
+ CNodeScriptManagement *nsm_ptr;
+ /*!< \brief GPIO Trigger event status function pointer */
+ Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr;
+
+} Gpio_InitData_t;
+
+/*! \brief Stores data required by GPIO during initialization. */
+typedef struct Gpio_UserData_
+{
+ /*!< \brief PinState Result callback */
+ Ucs_Gpio_PinStateResCb_t pinstate_res_cb;
+ /*!< \brief PinMode Result callback */
+ Ucs_Gpio_ConfigPinModeResCb_t pinmode_res_cb;
+ /*!< \brief PortCreate Result callback */
+ Ucs_Gpio_CreatePortResCb_t portcreate_res_cb;
+ /*!< \brief GPIO Trigger event status function pointer */
+ Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr;
+
+} Gpio_UserData_t;
+
+/*! \brief Script structure of the GPIO module */
+typedef struct Gpio_Script_
+{
+ uint8_t cfg_data[40];
+ /*! \brief script used for transmitting commands */
+ Ucs_Ns_Script_t script;
+ /*! \brief config messages used for transmitting commands */
+ Ucs_Ns_ConfigMsg_t cfg_msg;
+} Gpio_Script_t;
+
+/*! \brief Class structure of the GPIO module */
+typedef struct CGpio_
+{
+ /*! \brief Reference to an INIC instance */
+ CInic *inic_ptr;
+ /*!< \brief Reference to NSM instance */
+ CNodeScriptManagement *nsm_ptr;
+ /*! \brief Current user data */
+ Gpio_UserData_t curr_user_data;
+ /*! \brief Indicates the address of the target device */
+ uint16_t device_address;
+ /*! \brief Observer used for GPIO TriggerEvents */
+ CObserver triggerevent_observer;
+ /*!< \brief Current script to be looked for */
+ Gpio_Script_t curr_script;
+ /*!< \brief Current reference to the result callback function */
+ Gpio_ErrResultCb_t curr_res_cb;
+
+} CGpio;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CGpio */
+/*------------------------------------------------------------------------------------------------*/
+extern void Gpio_Ctor(CGpio * self, Gpio_InitData_t * init_ptr);
+extern Ucs_Return_t Gpio_CreatePort(CGpio * self, uint8_t index, uint16_t debounce_time, Ucs_Gpio_CreatePortResCb_t res_fptr);
+extern Ucs_Return_t Gpio_SetPinModeConfig(CGpio * self, uint16_t gpio_port_handle, uint8_t pin, Ucs_Gpio_PinMode_t mode, Ucs_Gpio_ConfigPinModeResCb_t res_fptr);
+extern Ucs_Return_t Gpio_GetPinModeConfig(CGpio * self, uint16_t gpio_port_handle, Ucs_Gpio_ConfigPinModeResCb_t res_fptr);
+extern Ucs_Return_t Gpio_SetPinStateConfig(CGpio * self, uint16_t gpio_port_handle, uint16_t mask, uint16_t data, Ucs_Gpio_PinStateResCb_t res_fptr);
+extern Ucs_Return_t Gpio_GetPinStateConfig(CGpio * self, uint16_t gpio_port_handle, Ucs_Gpio_PinStateResCb_t res_fptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_GPIO_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_gpio_pb.h b/ucs2-lib/inc/ucs_gpio_pb.h
new file mode 100644
index 0000000..c098243
--- /dev/null
+++ b/ucs2-lib/inc/ucs_gpio_pb.h
@@ -0,0 +1,143 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Gpio module.
+ * \addtogroup G_UCS_GPIO_TYPES
+ * @{
+ */
+
+#ifndef UCS_GPIO_PB_H
+#define UCS_GPIO_PB_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of the GPIO Module. */
+typedef enum Ucs_Gpio_ResultCode_
+{
+ UCS_GPIO_RES_SUCCESS = 0x00U, /*!< \brief GPIO command succeeded */
+ UCS_GPIO_RES_ERR_CMD = 0x01U, /*!< \brief GPIO command failed due to an INIC function-specific error or a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_Gpio_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_GPIO_RES_ERR_SYNC = 0x02U /*!< \brief Remote synchronization of target device failed.
+ * \details The \em inic_result section in Ucs_Gpio_ResultDetails_t will provide you with more detailed information concerning this error code.
+ */
+} Ucs_Gpio_ResultCode_t;
+
+/*! \brief This enumerator specifies the kind of result - Target or Transmission. */
+typedef enum Ucs_Gpio_ResultType_
+{
+ UCS_GPIO_RESULT_TYPE_TGT = 0x00U, /*!< \brief Specifies the target results, typically INIC function-specific error from target device. */
+ UCS_GPIO_RESULT_TYPE_TX = 0x01U /*!< \brief Specifies the transmission error information that occurred on the MOST network. */
+
+} Ucs_Gpio_ResultType_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Detailed information used for GPIO results. */
+typedef struct Ucs_Gpio_ResultDetails_
+{
+ /*! \brief Specifies the type of the current asynchronous result.
+ * \details The following briefly describes the different types of results available:
+ * - \b UCS_GPIO_RESULT_TYPE_TGT: target results, typically INIC function-specific error found on target device. \n Refer to \em inic_result to get the detailed information.
+ * - \b UCS_GPIO_RESULT_TYPE_TX: transmission results, typically transmission error on the MOST network. \n Refer to \em tx_result to get the transmission information.
+ */
+ Ucs_Gpio_ResultType_t result_type;
+ /*! \brief Holds the status of the transmission. */
+ Ucs_MsgTxStatus_t tx_result;
+ /*! \brief Holds the results of the target device. */
+ Ucs_StdResult_t inic_result;
+
+} Ucs_Gpio_ResultDetails_t;
+
+/*! \brief Result structure of the GPIO Module. */
+typedef struct Ucs_Gpio_Result_
+{
+ /*! \brief Result code. */
+ Ucs_Gpio_ResultCode_t code;
+ /*! \brief Detailed information on the returned result. */
+ Ucs_Gpio_ResultDetails_t details;
+
+} Ucs_Gpio_Result_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature of result callback used by Ucs_Gpio_CreatePort()
+ * \param node_address The node address of the device from where the results come
+ * \param gpio_port_handle The port resource handle.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Gpio_CreatePortResCb_t)(uint16_t node_address, uint16_t gpio_port_handle, Ucs_Gpio_Result_t result, void *user_ptr);
+
+/*! \brief Function signature of result callback used by Ucs_Gpio_SetPinMode() and Ucs_Gpio_GetPinMode().
+ * \param node_address The node address of the device from where the results come
+ * \param gpio_port_handle The port resource handle.
+ * \param pin The pin that has been configured.
+ * \param mode The mode of the GPIO pin.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Gpio_ConfigPinModeResCb_t)(uint16_t node_address, uint16_t gpio_port_handle, Ucs_Gpio_PinConfiguration_t pin_cfg_list[], uint8_t list_sz, Ucs_Gpio_Result_t result, void *user_ptr);
+
+/*! \brief Function signature of result callback used by Ucs_Gpio_WritePort() and Ucs_Gpio_ReadPort().
+ * \param node_address The node address of the device from where the results come
+ * \param gpio_port_handle The port resource handle.
+ * \param current_state The current state of the GPIO pin
+ * \param sticky_state The sticky state of all GPIO pins configured as sticky inputs.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Gpio_PinStateResCb_t)(uint16_t node_address, uint16_t gpio_port_handle, uint16_t current_state, uint16_t sticky_state, Ucs_Gpio_Result_t result, void *user_ptr);
+
+/*! \brief Function signature of result callback used by Gpio_TriggerEvents()
+ * \param node_address The node address of the device from where the results come
+ * \param gpio_port_handle The port resource handle.
+ * \param rising_edges The GPIO pins on which a rising-edge trigger condition was detected
+ * \param falling_edges The GPIO pins on which a falling-edge trigger condition was detected
+ * \param levels The GPIO pins on which a logic level condition was detected
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Gpio_TriggerEventResultCb_t)(uint16_t node_address, uint16_t gpio_port_handle, uint16_t rising_edges, uint16_t falling_edges, uint16_t levels, void *user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_GPIO_PB_H */
+
+/*!
+ * @}
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_i2c.h b/ucs2-lib/inc/ucs_i2c.h
new file mode 100644
index 0000000..5146e78
--- /dev/null
+++ b/ucs2-lib/inc/ucs_i2c.h
@@ -0,0 +1,147 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the I2C module.
+ *
+ * \defgroup G_UCS_I2C_TYPES I2C Referred Types
+ * \brief Referred types used by the Extended Resource Manager.
+ * \ingroup G_UCS_I2C
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_I2C
+ * @{
+ */
+
+
+#ifndef UCS_I2C_H
+#define UCS_I2C_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_nsm.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_i2c_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for I2C results in case error.
+ * \param self Reference to CI2c instance
+ * \param msg_ptr Pointer to received message
+ */
+typedef void (*I2c_ErrResultCb_t)(void *self, void *result_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by I2C during initialization. */
+typedef struct I2c_InitData_
+{
+ /*!< \brief Reference to INIC instance */
+ CInic *inic_ptr;
+ /*!< \brief Reference to NSM instance */
+ CNodeScriptManagement *nsm_ptr;
+ /*!< \brief Status function pointer for the I2C Interrupt event */
+ Ucs_I2c_IntEventReportCb_t i2c_interrupt_report_fptr;
+
+} I2c_InitData_t;
+
+/*! \brief Stores data required by I2C during initialization. */
+typedef struct I2c_UserData_
+{
+ /*!< \brief PinState Result callback */
+ Ucs_I2c_ReadPortResCb_t portread_res_cb;
+ /*!< \brief PortCreate Result callback */
+ Ucs_I2c_WritePortResCb_t portwrite_res_cb;
+ /*!< \brief PortCreate Result callback */
+ Ucs_I2c_CreatePortResCb_t portcreate_res_cb;
+ /*!< \brief Status function pointer for the I2c interrupt */
+ Ucs_I2c_IntEventReportCb_t i2c_interrupt_report_fptr;
+ /*!< \brief I2C interrupt pin mask on GPIO Port */
+ uint8_t int_pin_mask;
+
+} I2c_UserData_t;
+
+/*! \brief Script structure of the I2C module */
+typedef struct I2c_Script_
+{
+ uint8_t cfg_data[40];
+ /*! \brief script used for transmitting commands */
+ Ucs_Ns_Script_t script;
+ /*! \brief config messages used for transmitting commands */
+ Ucs_Ns_ConfigMsg_t cfg_msg;
+} I2c_Script_t;
+
+/*! \brief Class structure of the I2C module */
+typedef struct CI2c_
+{
+ /*! \brief Reference to an INIC instance */
+ CInic *inic_ptr;
+ /*! \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*!< \brief Reference to NSM instance */
+ CNodeScriptManagement *nsm_ptr;
+ /*!< \brief Current user data */
+ I2c_UserData_t curr_user_data;
+ /*!< \brief Indicates the address of target device */
+ uint16_t device_address;
+ /*! \brief Observer used for I2C to check the GPIO TriggerEvents */
+ CObserver triggerevent_observer;
+ /*!< \brief Current script to be looked for */
+ I2c_Script_t curr_script;
+ /*!< \brief Current reference to the result callback function */
+ I2c_ErrResultCb_t curr_res_cb;
+
+} CI2c;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CI2c */
+/*------------------------------------------------------------------------------------------------*/
+extern void I2c_Ctor(CI2c * self, I2c_InitData_t * init_ptr);
+extern Ucs_Return_t I2c_CreatePort(CI2c * self, uint8_t index, Ucs_I2c_Speed_t speed, uint8_t i2c_int_mask, Ucs_I2c_CreatePortResCb_t res_fptr);
+extern Ucs_Return_t I2c_WritePort(CI2c * self, uint16_t port_handle, Ucs_I2c_TrMode_t mode, uint8_t block_count, uint8_t slave_address, uint16_t timeout,
+ uint8_t data_len, uint8_t data_ptr[], Ucs_I2c_WritePortResCb_t res_fptr);
+extern Ucs_Return_t I2c_ReadPort(CI2c * self, uint16_t port_handle, uint8_t slave_address, uint8_t data_len, uint16_t timeout, Ucs_I2c_ReadPortResCb_t res_fptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_I2C_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_i2c_pb.h b/ucs2-lib/inc/ucs_i2c_pb.h
new file mode 100644
index 0000000..2ad1eba
--- /dev/null
+++ b/ucs2-lib/inc/ucs_i2c_pb.h
@@ -0,0 +1,142 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the I2c module.
+ * \addtogroup G_UCS_I2C_TYPES
+ * @{
+ */
+
+#ifndef UCS_I2C_PB_H
+#define UCS_I2C_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of the I2C Module. */
+typedef enum Ucs_I2c_ResultCode_
+{
+ UCS_I2C_RES_SUCCESS = 0x00U, /*!< \brief I2C command succeeded */
+ UCS_I2C_RES_ERR_CMD = 0x01U, /*!< \brief I2C command failed due to an INIC function-specific error or a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_I2c_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_I2C_RES_ERR_SYNC = 0x02U /*!< \brief Remote synchronization of target device failed.
+ * \details The \em inic_result section in Ucs_I2c_ResultDetails_t will provide you with more detailed information concerning the error code.
+ */
+} Ucs_I2c_ResultCode_t;
+
+/*! \brief This enumerator specifies the kind of result - Target or Transmission. */
+typedef enum Ucs_I2c_ResultType_
+{
+ UCS_I2C_RESULT_TYPE_TGT = 0x00U, /*!< \brief Specifies the target results, typically INIC function-specific error from target device. */
+ UCS_I2C_RESULT_TYPE_TX = 0x01U /*!< \brief Specifies the transmission error information that occurred on the MOST network. */
+
+} Ucs_I2c_ResultType_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Detailed information used for I2C results. */
+typedef struct Ucs_I2c_ResultDetails_
+{
+ /*! \brief Specifies the type of the current asynchronous result.
+ * \details The following briefly describes the different types of results available:
+ * - \b UCS_I2C_RESULT_TYPE_TGT: target results, typically INIC function-specific error found on target device. \n Refer to \em inic_result to get the detailed information.
+ * - \b UCS_I2C_RESULT_TYPE_TX: transmission results, typically transmission error on the MOST network. \n Refer to \em tx_result to get the transmission information.
+ */
+ Ucs_I2c_ResultType_t result_type;
+ /*! \brief Holds the status of the transmission. */
+ Ucs_MsgTxStatus_t tx_result;
+ /*! \brief Holds the results of the target device. */
+ Ucs_StdResult_t inic_result;
+
+} Ucs_I2c_ResultDetails_t;
+
+/*! \brief Result structure of the I2C Module. */
+typedef struct Ucs_I2c_Result_
+{
+ /*! \brief Result code. */
+ Ucs_I2c_ResultCode_t code;
+ /*! \brief Detailed information on the returned result. */
+ Ucs_I2c_ResultDetails_t details;
+
+} Ucs_I2c_Result_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback function type to retrieve the result of the I2c_CreatePort function
+ * \param node_address The node address of the device from where the results come
+ * \param i2c_port_handle The port resource handle.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_I2c_CreatePortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, Ucs_I2c_Result_t result, void *user_ptr);
+
+/*! \brief Callback function type to retrieve the result of the Gpio_ConfigPinMode function
+ * \param node_address The node address of the device from where the results come
+ * \param i2c_port_handle The port resource handle.
+ * \param i2c_slave_address The 7-bit I2C Port slave address of the peripheral to be read.
+ * \param data_len The number of bytes wrote to the I2C address.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_I2c_WritePortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, uint8_t i2c_slave_address, uint8_t data_len, Ucs_I2c_Result_t result, void *user_ptr);
+
+/*! \brief Callback function type to retrieve the result of the Gpio_ConfigPinMode function
+ * \param node_address The node address of the device from where the results come
+ * \param i2c_port_handle The port resource handle.
+ * \param i2c_slave_address The 7-bit I2C Port slave address of the peripheral from which the data have been read.
+ * \param data_len The number of bytes read from the address.
+ * \param data_ptr The reference to the data list.
+ * \param result The operation result
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_I2c_ReadPortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, uint8_t i2c_slave_address, uint8_t data_len, uint8_t data_ptr[], Ucs_I2c_Result_t result, void *user_ptr);
+
+/*! \brief Callback function type to report the I2C interrupt event
+ * \param node_address The node address of the device from where the interrupt comes
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_I2c_IntEventReportCb_t)(uint16_t node_address, void *user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_I2C_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_inic.h b/ucs2-lib/inc/ucs_inic.h
new file mode 100644
index 0000000..159dbf4
--- /dev/null
+++ b/ucs2-lib/inc/ucs_inic.h
@@ -0,0 +1,858 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CInic.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \defgroup G_UCS_DIAG_TYPES Diagnosis Referred Types
+ * \brief Referred types used by Diagnosis functions.
+ * \ingroup G_INIC
+ *
+ * \addtogroup G_INIC
+ * @{
+ */
+
+#ifndef UCS_INIC_H
+#define UCS_INIC_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_inic_pb.h"
+#include "ucs_ret_pb.h"
+#include "ucs_dec.h"
+#include "ucs_transceiver.h"
+#include "ucs_misc.h"
+#include "ucs_obs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions and Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+#define FB_INIC 0x00U
+#define FB_EXC 0x0AU
+
+/*! \brief Defines the max number of invalid resources to be destroyed by the INIC in one command. */
+#define MAX_INVALID_HANDLES_LIST 0x0AU
+
+/*! \brief Data Type which describes the operation mode of the INIC. */
+typedef enum Inic_AttachState_
+{
+ INIC_ATS_PROTECTED = 0x00U, /*!< \brief Interface is detached */
+ INIC_ATS_ATTACHED = 0x01U, /*!< \brief Interface is attached */
+ INIC_ATS_REMOTE = 0x02U /*!< \brief Interface is remote controlled
+ * (only possible for configuration interface) */
+} Inic_AttachState_t;
+
+/*! \brief Control commands used for the INIC resource monitor. */
+typedef enum Ucs_Resource_MonitorCtrl_
+{
+ UCS_INIC_RES_MON_CTRL_RESET = 0x00U /*!< \brief Requests the INIC resource monitor to go back to
+ * the OK state and release the MUTE pin of the INIC.
+ */
+} Ucs_Resource_MonitorCtrl_t;
+
+/*! \brief Control commands used for the INIC notification
+ */
+typedef enum Ucs_Inic_NotificationCtrl_
+{
+ UCS_INIC_NTF_SET_ALL = 0x00U, /*!< \brief Requests the INIC to enter the DeviceID in all properties
+ * that support notification.
+ */
+ UCS_INIC_NTF_SET_FUNC = 0x01U, /*!< \brief Requests the INIC enter the DeviceID for the functions
+ * listed.
+ */
+ UCS_INIC_NTF_CLEAR_ALL = 0x02U, /*!< \brief Requests the INIC to delete DeviceID from all functions of
+ * the notification matrix.
+ */
+ UCS_INIC_NTF_CLEAR_FUNC = 0x03U /*!< \brief Requests the INIC to delete DeviceID from the function listed.
+ *
+ */
+} Ucs_Inic_NotificationCtrl_t;
+
+/*! \brief State of the INIC resource monitor
+ */
+typedef enum Ucs_Resource_MonitorState_
+{
+ UCS_INIC_RES_MON_STATE_OK = 0x00U, /*!< \brief Default state. There are no action required
+ * from the EHC.
+ */
+ UCS_INIC_RES_MON_STATE_ACT_REQ = 0x01U /*!< \brief There are actions required from the EHC. */
+
+} Ucs_Resource_MonitorState_t;
+
+/*! \brief Data Type which describes the status/result of the Built-in Self-Test (BIST). */
+typedef enum Inic_Bist_
+{
+ /*! \brief Processing */
+ INIC_BIST_PROCESSING = 0x00U,
+ /*! \brief Error detected */
+ INIC_BIST_ERROR = 0x01U,
+ /*! \brief No errors detected */
+ INIC_BIST_OK = 0x02U
+
+} Inic_Bist_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* INIC FunctionIDs */
+/*------------------------------------------------------------------------------------------------*/
+#define INIC_FID_NOTIFICATION 0x001U /*!< \brief INIC FktID for Notification */
+#define INIC_FID_DEVICE_STATUS 0x220U /*!< \brief INIC FktID for DeviceStatus */
+#define INIC_FID_DEVICE_VERSION 0x221U /*!< \brief INIC FktID for DeviceVersion */
+#define INIC_FID_DEVICE_POWER_OFF 0x222U /*!< \brief INIC FktID for DevicePowerOff */
+#define INIC_FID_DEVICE_ATTACH 0x223U /*!< \brief INIC FktID for DeviceAttach */
+#define INIC_FID_DEVICE_SYNC 0x224U /*!< \brief INIC FktID for DeviceSync */
+#define INIC_FID_MOST_NW_STATUS 0x520U /*!< \brief INIC FktID for MOSTNetworkStatus */
+#define INIC_FID_MOST_NW_CFG 0x521U /*!< \brief INIC FktID for MOSTNetworkConfiguration */
+#define INIC_FID_MOST_NW_FRAME_COUNTER 0x523U /*!< \brief INIC FktID for MOSTNetworkFrameCounter */
+#define INIC_FID_MOST_NW_STARTUP 0x524U /*!< \brief INIC FktID for MOSTNetworkStartup */
+#define INIC_FID_MOST_NW_SHUTDOWN 0x525U /*!< \brief INIC FktID for MOSTNetworkShutdown */
+#define INIC_FID_MOST_NW_TRIGGER_RBD 0x526U /*!< \brief INIC FktID for MOSTNetworkTriggerRBD */
+#define INIC_FID_MOST_NW_RBD_RESULT 0x527U /*!< \brief INIC FktID for MOSTNetworkRBDResult */
+#define INIC_FID_MOST_NW_ATTACH 0x528U /*!< \brief INIC FktID for MOSTNetworkAttach */
+#define INIC_FID_MOST_NW_DETACH 0x529U /*!< \brief INIC FktID for MOSTNetworkDetach */
+#define INIC_FID_MOST_NW_FORCE_NO_AVAIL 0x52BU /*!< \brief INIC FktID for MOSTNetworkForceNotAvailable */
+#define INIC_FID_MOST_NW_SYS_DIAGNOSIS 0x52CU /*!< \brief INIC FktID for MOSTNetworkSystemDiagnosis */
+#define INIC_FID_MOST_NW_SYS_DIAG_END 0x52DU /*!< \brief INIC FktID for MOSTNetworkSystemDiagnosisEnd */
+#define INIC_FID_BACK_CHANNEL_DIAGNOSIS 0x52EU /*!< \brief INIC FktID for BackChannelDiagnosis */
+#define INIC_FID_BACK_CHANNEL_DIAG_END 0x52FU /*!< \brief INIC FktID for BackChannelDiagnosisEnd */
+#define INIC_FID_MOST_PORT_STATUS 0x602U /*!< \brief INIC FktID for MOSTPortStatus */
+#define INIC_FID_MOST_SOCKET_CREATE 0x611U /*!< \brief INIC FktID for MOSTSocketCreate */
+#define INIC_FID_MOST_SOCKET_STATUS 0x612U /*!< \brief INIC FktID for MOSTSocketStatus */
+#define INIC_FID_MLB_PORT_CREATE 0x621U /*!< \brief INIC FktID for MediaLBPortCreate */
+/*#define INIC_FID_MLB_PORT_ALLOCATE_ONLY 0x623U */ /*!< \brief INIC FktID for MediaLBPortAllocateOnly */
+/*#define INIC_FID_MLB_PORT_DEALLOC_ONLY 0x624U */ /*!< \brief INIC FktID for MediaLBDeallocateOnly */
+#define INIC_FID_MLB_SOCKET_CREATE 0x631U /*!< \brief INIC FktID for MediaLBSocketCreate */
+#define INIC_FID_SPI_PORT_CREATE 0x641U /*!< \brief INIC FktID for SPIPortCreate */
+#define INIC_FID_SPI_SOCKET_CREATE 0x651U /*!< \brief INIC FktID for SPISocketCreate */
+#define INIC_FID_USB_PORT_CREATE 0x661U /*!< \brief INIC FktID for USBPortCreate */
+#define INIC_FID_USB_SOCKET_CREATE 0x671U /*!< \brief INIC FktID for USBSocketCreate */
+#define INIC_FID_STREAM_PORT_CONFIG 0x680U /*!< \brief INIC FktID for StreamPortConfiguration */
+#define INIC_FID_STREAM_PORT_CREATE 0x681U /*!< \brief INIC FktID for StreamPortCreate */
+#define INIC_FID_STREAM_PORT_LOOPBACK 0x683U /*!< \brief INIC FktID for StreamPortLoopback */
+#define INIC_FID_STREAM_SOCKET_CREATE 0x691U /*!< \brief INIC FktID for StreamSocketCreate */
+#define INIC_FID_RMCK_PORT_CREATE 0x6A1U /*!< \brief INIC FktID for RMCKPortCreate */
+#define INIC_FID_I2C_PORT_CREATE 0x6C1U /*!< \brief INIC FktID for I2CPortCreate */
+#define INIC_FID_I2C_PORT_READ 0x6C3U /*!< \brief INIC FktID for I2CPortRead */
+#define INIC_FID_I2C_PORT_WRITE 0x6C4U /*!< \brief INIC FktID for I2CPortWrite */
+#define INIC_FID_PCI_PORT_CREATE 0x6E1U /*!< \brief INIC FktID for PCIPortCreate */
+#define INIC_FID_PCI_SOCKET_CREATE 0x6F1U /*!< \brief INIC FktID for PCISocketCreate */
+#define INIC_FID_GPIO_PORT_CREATE 0x701U /*!< \brief INIC FktID for GPIOPortCreate */
+#define INIC_FID_MOST_PORT_ENABLE 0x702U /*!< \brief INIC FktID for MOSTPortEnable */
+#define INIC_FID_GPIO_PORT_PIN_MODE 0x703U /*!< \brief INIC FktID for GPIOPortPinMode */
+#define INIC_FID_GPIO_PORT_PIN_STATE 0x704U /*!< \brief INIC FktID for GPIOPortPinState */
+#define INIC_FID_GPIO_PORT_TRIGGER_EVENT 0x705U /*!< \brief INIC FktID for GPIOPortTriggerEvent */
+#define INIC_FID_RESOURCE_DESTROY 0x800U /*!< \brief INIC FktID for ResourceDestroy */
+#define INIC_FID_RESOURCE_INVALID_LIST 0x801U /*!< \brief INIC FktID for ResourceInvalidList */
+#define INIC_FID_RESOURCE_MONITOR 0x802U /*!< \brief INIC FktID for ResourceMonitor */
+/*#define INIC_FID_PACKET_ATTACH_SOCKETS 0x843U*/ /*!< \brief INIC FktID for PacketAttachSockets */
+/*#define INIC_FID_PACKET_DETACH_SOCKETS 0x844U*/ /*!< \brief INIC FktID for PacketDetachSockets */
+#define INIC_FID_QOS_CREATE 0x851U /*!< \brief INIC FktID for QoSPacketCreate */
+#define INIC_FID_AVP_CREATE 0x861U /*!< \brief INIC FktID for AVPCreate */
+#define INIC_FID_SYNC_CREATE 0x871U /*!< \brief INIC FktID for SyncCreate */
+#define INIC_FID_SYNC_MUTE 0x873U /*!< \brief INIC FktID for SyncMute */
+#define INIC_FID_SYNC_DEMUTE 0x874U /*!< \brief INIC FktID for SyncDemute */
+#define INIC_FID_DFIPHASE_CREATE 0x881U /*!< \brief INIC FktID for DFIPhaseCreate */
+#define INIC_FID_IPC_CREATE 0x891U /*!< \brief INIC FktID for IPCPacketCreate */
+#define INIC_FID_COMBINER_CREATE 0x901U /*!< \brief INIC FktID for CombinerCreate */
+#define INIC_FID_SPLITTER_CREATE 0x911U /*!< \brief INIC FktID for SplitterCreate */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Indexes of SingleSubjects */
+/*------------------------------------------------------------------------------------------------*/
+#define INIC_SSUB_CREATE_CLASS 0U
+#define INIC_SSUB_DEVICE_VERSION 1U
+#define INIC_SSUB_DEVICE_ATTACH 2U
+#define INIC_SSUB_NW_STARTUP 3U
+#define INIC_SSUB_NW_SHUTDOWN 4U
+#define INIC_SSUB_NW_TRIGGER_RBD 5U
+#define INIC_SSUB_NW_ATTACH 6U
+#define INIC_SSUB_NW_DETACH 7U
+#define INIC_SSUB_NW_CHANGE_NODE_ADDR 8U
+#define INIC_SSUB_SYNC_MUTE 9U
+#define INIC_SSUB_SYNC_DEMUTE 10U
+#define INIC_SSUB_NW_RBD_RESULT 11U
+#define INIC_SSUB_NW_FRAME_COUNTER 12U
+#define INIC_SSUB_RESOURCE_DESTROY 13U
+#define INIC_SSUB_RESOURCE_INVAL_LIST 14U
+#define INIC_SSUB_ATTACH_SOCKETS 15U
+#define INIC_SSUB_DETACH_SOCKETS 16U
+#define INIC_SSUB_STREAM_PORT_CONFIG 17U
+#define INIC_SSUB_MOST_PORT_ENABLE 18U
+#define INIC_SSUB_MOST_PORT_EN_FULL_STR 19U
+#define INIC_SSUB_DEVICE_SYNC 20U
+#define INIC_SSUB_NOTIFICATION 21U
+#define INIC_SSUB_NW_CONFIG 22U
+#define INIC_SSUB_GPIO_PIN_MODE 23U
+#define INIC_SSUB_GPIO_PIN_STATE 24U
+#define INIC_SSUB_I2C_PORT_WR 25U
+#define INIC_SSUB_NW_SYS_DIAGNOSIS 26U
+#define INIC_SSUB_NW_SYS_DIAGEND 27U
+#define INIC_SSUB_NW_FORCE_NA 28U
+#define INIC_SSUB_BC_DIAGNOSIS 29U
+#define INIC_SSUB_BC_DIAG_END 30U
+
+#define INIC_NUM_SSUB 31U /* Total number of SingleSubjects */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Indexes of Subjects */
+/*------------------------------------------------------------------------------------------------*/
+#define INIC_SUB_TX_MSG_OBJ_AVAIL 0U
+#define INIC_SUB_NW_STATUS 1U
+#define INIC_SUB_NW_CONFIG 2U
+#define INIC_SUB_MOST_PORT_STATUS 3U
+#define INIC_SUB_RES_MONITOR 4U
+#define INIC_SUB_GPIO_TRIGGER_EVENT 5U
+#define INIC_SUB_DEVICE_STATUS 6U
+
+#define INIC_NUM_SUB 7U /* Total number of Subjects */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the INIC module. */
+typedef struct Inic_InitData_
+{
+ CTransceiver *xcvr_ptr; /*!< \brief Reference to a Transceiver instance */
+ CBase *base_ptr; /*!< \brief Reference to UCS base instance */
+ uint16_t tgt_addr; /*!< \brief Address of the target device */
+
+} Inic_InitData_t;
+
+/*! \brief Structure used for returning method results/errors
+ *
+ * Either the data_info or the error part of the structure contain the information.
+ * In case an error happened, data_info will be NULL except for error transmission
+ * where the type of transmission error (BF, CRC, ID, WT, etc.) is registered.
+ * If no error happened, error.code is 0 and error.info is NULL.
+*/
+typedef struct Inic_StdResult_
+{
+ Ucs_StdResult_t result; /*!< \brief Result code and info byte stream */
+ void *data_info; /*!< \brief Reference to result values */
+
+} Inic_StdResult_t;
+
+/*! \brief Structure used for ResourceHandleList */
+typedef struct Inic_ResHandleList_
+{
+ uint16_t *res_handles; /*!< \brief pointer to array containing resource handles */
+ uint8_t num_handles; /*!< \brief number of resource handles */
+
+} Inic_ResHandleList_t;
+
+/*! \brief Structure used for FktIDList */
+typedef struct Inic_FktIdList_
+{
+ uint16_t *fktids_ptr; /*!< \brief pointer to array containing resource handles */
+ uint8_t num_fktids; /*!< \brief number of FktIDs in the list */
+
+} Inic_FktIdList_t;
+
+/*! \brief Structure DeviceStatus */
+typedef struct Inic_DeviceStatus_
+{
+ /*! \brief State of the application interface (ICM/RCM channel synced & DeviceAttach) */
+ Inic_AttachState_t config_iface_state;
+ /*! \brief State of the configuration interface (MCM channel synced) */
+ Inic_AttachState_t app_iface_state;
+ /*! \brief State of power management */
+ Ucs_Inic_PowerState_t power_state;
+ /*! \brief Shows the last reset reason of the INIC. */
+ Ucs_Inic_LastResetReason_t last_reset_reason;
+ /*! \brief Status/Result of the Built-in Self-Test (BIST) */
+ Inic_Bist_t bist;
+
+} Inic_DeviceStatus_t;
+
+/*! \brief Structure MOSTNetworkStatus */
+typedef struct Inic_NetworkStatus_
+{
+ /*! \brief Indicates if the MOST network is available and ready for control/packet
+ * data transmission
+ */
+ Ucs_Network_Availability_t availability;
+ /*! \brief Indicates the sub state to parameter Availability */
+ Ucs_Network_AvailInfo_t avail_info;
+ /*! \brief Indicates the transition cause of the MOST network going from Available to
+ * NotAvailable or vice versa
+ */
+ Ucs_Network_AvailTransCause_t avail_trans_cause;
+ /*! \brief Contains events relating to the functionality for the MOST Network Interface */
+ uint16_t events;
+ /*! \brief Current size of packet bandwidth */
+ uint16_t packet_bw;
+ /*! \brief Node address of the device */
+ uint16_t node_address;
+ /*! \brief Node position of the device */
+ uint8_t node_position;
+ /*! \brief Node position of last device in the ring */
+ uint8_t max_position;
+
+} Inic_NetworkStatus_t;
+
+/*! \brief Structure MOSTNetworkConfiguration */
+typedef struct Inic_NetworkConfig_
+{
+ uint16_t node_address; /*!< \brief NodeAddress */
+ uint16_t group_address; /*!< \brief GroupAddress */
+ uint8_t llrbc; /*!< \brief Control low-level retry block count */
+
+} Inic_NetworkConfig_t;
+
+/*! \brief This structure provides information on the Physical layer test result */
+typedef struct Inic_PhyTestResult_
+{
+ uint16_t most_port_handle; /*!< \brief MOST Port Handle */
+ bool lock_status; /*!< \brief Lock status */
+ uint16_t err_count; /*!< \brief Number of Coding Errors */
+
+} Inic_PhyTestResult_t;
+
+/*! \brief This structure provides information on the Ring Break Diagnosis */
+typedef struct Inic_RbdResult_
+{
+ Ucs_Diag_RbdResult_t result; /*!< \brief RBD result */
+ uint8_t position; /*!< \brief RBD position */
+ uint8_t status; /*!< \brief RBD Status */
+ uint16_t diag_id; /*!< \brief RBDDiagID */
+} Inic_RbdResult_t;
+
+/*! \brief This structure provides Mode information of a GPIO pin */
+typedef struct Inic_GpioPortPinModeStatus_
+{
+ uint16_t gpio_handle; /*!< \brief Port resource handle. */
+ Ucs_Gpio_PinConfiguration_t *cfg_list; /*!< \brief GPIO pin that is to be configured */
+ uint8_t len; /*!< \brief The size of the list */
+
+} Inic_GpioPortPinModeStatus_t;
+
+/*! \brief This structure provides State information of a GPIO pin */
+typedef struct Inic_GpioPortPinStateStatus_
+{
+ uint16_t gpio_handle; /*!< \brief Port resource handle. */
+ uint16_t current_state; /*!< \brief the current state of the GPIO pin */
+ uint16_t sticky_state; /*!< \brief sticky state of all GPIO pins configured as sticky inputs */
+
+} Inic_GpioPortPinStateStatus_t;
+
+/*! \brief This structure provides the status of the GPIO TriggerEvent Reports */
+typedef struct Inic_GpioReportTimeStatus_
+{
+ bool first_report; /*!< \brief \c True if the GPIO trigger events are reported for the first time */
+
+} Inic_GpioReportTimeStatus_t;
+
+/*! \brief This structure provides TriggerEvents information on GPIO port */
+typedef struct Inic_GpioTriggerEventStatus_
+{
+ uint16_t gpio_handle; /*!< \brief Port resource handle. */
+ uint16_t rising_edges; /*!< \brief GPIO pins on which a rising-edge trigger condition was detected by rising edge or dual edge detection logic */
+ uint16_t falling_edges; /*!< \brief GPIO pins on which a falling-edge trigger condition was detected by falling edge or dual edge detection logic */
+ uint16_t levels; /*!< \brief GPIO pins on which a logic level condition was detected by level detection logic. */
+ bool is_first_report; /*!< \brief State of the report. */
+
+} Inic_GpioTriggerEventStatus_t;
+
+/*! \brief This structure provides result information of the I2cPortRead */
+typedef struct Inic_I2cReadResStatus_
+{
+ uint16_t port_handle; /*!< \brief Port resource handle. */
+ uint8_t slave_address; /*!< \brief The 7-bit I2C slave address of the peripheral read */
+ uint8_t data_len; /*!< \brief Size of the data_ptr */
+ uint8_t * data_ptr; /*!< \brief Reference to the data. */
+
+} Inic_I2cReadResStatus_t;
+
+/*! \brief This structure provides status information on the I2cPortWrite */
+typedef struct Inic_I2cWriteResStatus_
+{
+ uint16_t port_handle; /*!< \brief Port resource handle. */
+ uint8_t slave_address; /*!< \brief The 7-bit I2C slave address of the target peripheral */
+ uint8_t data_len; /*!< \brief Number of bytes wrote */
+
+} Inic_I2cWriteResStatus_t;
+
+/*! \brief This structure provides information on the notification results */
+typedef struct Inic_NotificationResult_
+{
+ uint16_t func_id; /*!< \brief function id */
+ uint16_t device_id; /*!< \brief address of the sending device */
+
+} Inic_NotificationResult_t;
+
+/*! \brief This structure contains the results of the frame counter */
+typedef struct Inic_FrameCounterStatus_
+{
+ uint32_t reference; /*!< \brief reference value */
+ uint32_t frame_counter; /*!< \brief MOST Network frame counter */
+ uint8_t lock; /*!< \brief Indicates if the TimingSlave device is locked
+ to the MOST network. For a TimingMaster
+ device this value is always True. */
+
+}Inic_FrameCounterStatus_t;
+
+/*! \brief Structure holds parameters for API locking */
+typedef struct Inic_ApiLock_
+{
+ /*! \brief API locking instance for INIC functions */
+ CApiLocking api;
+ /*! \brief Observer used for locking timeouts for INIC functions */
+ CSingleObserver observer;
+ /*! \brief API locking instance for resource methods */
+ CApiLocking res_api;
+ /*! \brief Observer used for locking timeouts for resource methods */
+ CSingleObserver res_observer;
+ /*! \brief Used to realize a longer API timeout */
+ uint8_t rbd_trigger_timeout_counter;
+
+} Inic_ApiLock_t;
+
+/*! \brief Structure of MOSTPortStatus data */
+typedef struct Inic_MostPortStatus_
+{
+ Ucs_Most_PortAvail_t availability;
+ Ucs_Most_PortAvailInfo_t avail_info;
+ uint16_t most_port_handle;
+ uint16_t freestreaming_bw;
+ bool fullstreaming_enabled;
+
+} Inic_MostPortStatus_t;
+
+/*! \brief Structure of class CInic. */
+typedef struct CInic_
+{
+ Inic_DeviceStatus_t device_status; /*!< \brief Structure DeviceStatus */
+ Inic_GpioReportTimeStatus_t gpio_rt_status; /*!< \brief Status of the GPIO TriggerEvent Report */
+ Ucs_Inic_Version_t device_version; /*!< \brief Structure DeviceVersion*/
+ Inic_NetworkStatus_t network_status; /*!< \brief Structure MOSTNetworkStatus */
+ Inic_NetworkConfig_t network_config; /*!< \brief Structure MOSTNetworkConfiguration */
+ Inic_MostPortStatus_t most_port_status; /*!< \brief Structure MOSTPortStatus */
+ CSubject subs[INIC_NUM_SUB]; /*!< \brief contains all subjects */
+ CSingleSubject ssubs[INIC_NUM_SSUB]; /*!< \brief contains all single-subjects */
+ Inic_ApiLock_t lock; /*!< \brief Parameters for API locking */
+ bool startup_locked; /*!< \brief Locking of NetworkStartup without timeout */
+ Dec_FktOpIcm_t const *fkt_op_list_ptr; /*!< \brief pointer to the FktID/OPType list */
+ CBase *base_ptr; /*!< \brief Reference to UCS base instance */
+ CTransceiver *xcvr_ptr; /*!< \brief Reference to a Transceiver instance */
+ CMaskedObserver internal_error_obs; /*!< \brief Error observer to handle internal
+ errors and events */
+ uint16_t target_address; /*!< \brief Address of the target device */
+
+} CInic;
+
+/*! \brief Structure of MOSTSocketCreate result */
+typedef struct Inic_MostSocketCreate_Result_
+{
+ uint16_t most_socket_handle; /*!< \brief Socket resource handle of the created socket */
+ uint16_t conn_label; /*!< \brief MOST network connection label */
+
+} Inic_MostSocketCreate_Result_t;
+
+/*! \brief Structure of StreamPortConfiguration status */
+typedef struct Inic_StreamPortConfigStatus_
+{
+ uint8_t index; /*!< \brief Streaming Port instance */
+ Ucs_Stream_PortOpMode_t op_mode; /*!< \brief Streaming Port Operation mode */
+ Ucs_Stream_PortOption_t port_option; /*!< \brief Streaming Port Options */
+ Ucs_Stream_PortClockMode_t clock_mode; /*!< \brief Stream Port Clock Mode */
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay; /*!< \brief Stream Port Clock Data Delay */
+
+} Inic_StreamPortConfigStatus_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Inic_Ctor(CInic *self, Inic_InitData_t *init_ptr);
+extern void Inic_OnIcmRx(void *self, Msg_MostTel_t *tel_ptr);
+extern void Inic_OnRcmRxFilter(void *self, Msg_MostTel_t *tel_ptr);
+extern void Inic_InitResourceManagement(CInic *self);
+extern void Inic_AddObsrvResMonitor(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsrvResMonitor(CInic *self, CObserver *obs_ptr);
+extern void Inic_AddObsrvMostPortStatus(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsrvMostPortStatus(CInic *self, CObserver *obs_ptr);
+extern void Inic_AddObsrvGpioTriggerEvent(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsrvGpioTriggerEvent(CInic *self, CObserver *obs_ptr);
+
+/* internal API functions */
+extern Ucs_Return_t Inic_DeviceVersion_Get(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_DeviceAttach(CInic *self,
+ CSingleObserver *obs_ptr);
+Ucs_Return_t Inic_DeviceSync (CInic *self,
+ CSingleObserver *obs_ptr);
+Ucs_Return_t Inic_DeviceUnsync (CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwAttach(CInic *self,
+ uint16_t pmp_channel_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_SyncMute(CInic *self,
+ uint16_t sync_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_SyncDemute(CInic *self,
+ uint16_t sync_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_DfiPhaseCreate(CInic *self,
+ uint16_t resource_handle_in,
+ uint16_t resource_handle_out,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_CombinerCreate(CInic *self,
+ uint16_t port_socket_handle,
+ uint16_t most_port_handle,
+ uint16_t bytes_per_frame,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_SplitterCreate(CInic *self,
+ uint16_t socket_handle_in,
+ uint16_t most_port_handle,
+ uint16_t bytes_per_frame,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwRbdResult_Get(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwPhyTestResult_Get(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwStartup(CInic *self,
+ uint16_t auto_forced_na,
+ uint16_t packet_bandwidth,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwShutdown(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwTriggerRbd(CInic *self,
+ Ucs_Diag_RbdType_t type,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwForceNotAvailable(CInic *self,
+ bool force,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwConfig_SetGet(CInic *self,
+ uint16_t mask,
+ Inic_NetworkConfig_t config, CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwConfig_Get(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwFrameCounter_Get(CInic *self, uint32_t reference,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_ResourceDestroy(CInic *self,
+ Inic_ResHandleList_t res_handle_list,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_ResourceInvalidList_Get(CInic *self,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_ResourceMonitor_Set(CInic *self,
+ Ucs_Resource_MonitorCtrl_t control);
+extern Ucs_Return_t Inic_Notification_Set(CInic *self,
+ Ucs_Inic_NotificationCtrl_t control,
+ uint16_t device_id,
+ Inic_FktIdList_t fktid_list);
+extern Ucs_Return_t Inic_Notification_Get(CInic *self,
+ uint16_t fktid,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_SyncCreate(CInic *self,
+ uint16_t resource_handle_in,
+ uint16_t resource_handle_out,
+ bool default_mute,
+ Ucs_Sync_MuteMode_t mute_mode,
+ uint16_t offset,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_QoSCreate(CInic *self,
+ uint16_t socket_in_handle,
+ uint16_t socket_out_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_IpcCreate(CInic *self,
+ uint16_t socket_in_handle,
+ uint16_t socket_out_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_AvpCreate(CInic *self,
+ uint16_t socket_in_handle,
+ uint16_t socket_out_handle,
+ Ucs_Avp_IsocPacketSize_t isoc_packet_size,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_MostSocketCreate(CInic *self,
+ uint16_t most_port_handle,
+ Ucs_SocketDirection_t direction,
+ Ucs_Most_SocketDataType_t data_type,
+ uint16_t bandwidth,
+ uint16_t connection_label,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_MlbPortCreate(CInic *self,
+ uint8_t index,
+ Ucs_Mlb_ClockConfig_t clock_config,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_MlbSocketCreate(CInic *self,
+ uint16_t mlb_port_handle,
+ Ucs_SocketDirection_t direction,
+ Ucs_Mlb_SocketDataType_t data_type,
+ uint16_t bandwidth,
+ uint16_t channel_address,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_UsbPortCreate(CInic *self,
+ uint8_t index,
+ Ucs_Usb_PhysicalLayer_t physical_layer,
+ uint16_t devices_interfaces,
+ uint8_t streaming_if_ep_out_count,
+ uint8_t streaming_if_ep_in_count,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_UsbSocketCreate(CInic *self,
+ uint16_t usb_port_handle,
+ Ucs_SocketDirection_t direction,
+ Ucs_Usb_SocketDataType_t data_type,
+ uint8_t end_point_addr,
+ uint16_t frames_per_transfer,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_StreamPortConfig_SetGet(CInic *self,
+ uint8_t index,
+ Ucs_Stream_PortOpMode_t op_mode,
+ Ucs_Stream_PortOption_t port_option,
+ Ucs_Stream_PortClockMode_t clock_mode,
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_StreamPortConfig_Get(CInic *self,
+ uint8_t index,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_StreamPortCreate(CInic *self,
+ uint8_t index,
+ Ucs_Stream_PortClockConfig_t clock_config,
+ Ucs_Stream_PortDataAlign_t data_alignment,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_StreamSocketCreate(CInic *self,
+ uint16_t stream_port_handle,
+ Ucs_SocketDirection_t direction,
+ Ucs_Stream_SocketDataType_t data_type,
+ uint16_t bandwidth,
+ Ucs_Stream_PortPinId_t stream_pin_id,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_RmckPortCreate(CInic *self,
+ uint8_t index,
+ Ucs_Rmck_PortClockSource_t clock_source,
+ uint16_t divisor,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_I2cPortCreate(CInic *self,
+ uint8_t index,
+ uint8_t address,
+ uint8_t mode,
+ Ucs_I2c_Speed_t speed,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_I2cPortRead(CInic *self,
+ uint16_t port_handle,
+ uint8_t slave_address,
+ uint8_t data_len,
+ uint16_t timeout,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_I2cPortWrite(CInic *self,
+ uint16_t port_handle,
+ Ucs_I2c_TrMode_t mode,
+ uint8_t block_count,
+ uint8_t slave_address,
+ uint16_t timeout,
+ uint8_t data_len,
+ uint8_t data_list[],
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_PciPortCreate(CInic *self,
+ uint8_t index,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_PciSocketCreate(CInic *self,
+ uint16_t pci_port_handle,
+ Ucs_SocketDirection_t direction,
+ Ucs_Pci_SocketDataType_t data_type,
+ uint8_t dma_channel,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_GpioPortCreate(CInic *self,
+ uint8_t gpio_port_index,
+ uint16_t debounce_time,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_MostPortEnable(CInic *self,
+ uint16_t most_port_handle,
+ bool enabled,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_GpioPortPinMode_Get(CInic *self, uint16_t gpio_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_GpioPortPinMode_SetGet(CInic *self,
+ uint16_t gpio_handle,
+ uint8_t pin,
+ Ucs_Gpio_PinMode_t mode,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_GpioPortPinState_Get(CInic *self, uint16_t gpio_handle,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_GpioPortPinState_SetGet(CInic *self,
+ uint16_t gpio_handle,
+ uint16_t mask,
+ uint16_t data,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_MostPortEnFullStr(CInic *self,
+ uint16_t most_port_handle,
+ bool enabled,
+ CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_BCDiagnosis(CInic *self, CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_BCDiagEnd(CInic *self, CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwSysDiagnosis(CInic *self, CSingleObserver *obs_ptr);
+extern Ucs_Return_t Inic_NwSysDiagEnd(CInic *self, CSingleObserver *obs_ptr);
+
+extern void Inic_AddObsrvOnTxMsgObjAvail(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsrvOnTxMsgObjAvail(CInic *self, CObserver *obs_ptr);
+extern void Inic_AddObsrvNwStatus(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsrvNwStatus(CInic *self, CObserver *obs_ptr);
+extern void Inic_AddObsvrNwConfig(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsvrNwConfig(CInic *self, CObserver *obs_ptr);
+extern void Inic_AddObsvrDeviceStatus(CInic *self, CObserver *obs_ptr);
+extern void Inic_DelObsvrDeviceStatus(CInic *self, CObserver *obs_ptr);
+
+/* handler functions */
+extern void Inic_DummyHandler(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_Notification_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_Notification_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceStatus_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceVersion_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceVersion_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwStatus_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwConfig_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwConfig_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwFrameCounter_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwFrameCounter_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwStartup_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwStartup_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwShutdown_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwShutdown_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwTriggerRbd_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwTriggerRbd_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwForceNotAvailable_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwForceNotAvailable_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceAttach_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceAttach_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceSync_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DeviceSync_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwAttach_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwAttach_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwSysDiagnosis_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwSysDiagnosis_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwSysDiagEnd_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwSysDiagEnd_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_BCDiagnosis_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_BCDiagnosis_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_BCDiagEnd_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_BCDiagEnd_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwChangeNodeAddress_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwChangeNodeAddress_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncMute_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncMute_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncDemute_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncDemute_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DfiPhaseCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DfiPhaseCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwRbdResult_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_NwRbdResult_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceDestroy_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceDestroy_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceInvalidList_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceInvalidList_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceMonitor_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_ResourceMonitor_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_AttachSockets_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_AttachSockets_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DetachSockets_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_DetachSockets_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SyncCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_QoSCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_QoSCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_IpcCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_IpcCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_AvpCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_AvpCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortStatus_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortStatus_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MlbPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MlbPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MlbSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MlbSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_UsbPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_UsbPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_UsbSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_UsbSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamPortConfig_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamPortConfig_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_StreamSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_RmckPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_RmckPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortRead_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortRead_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortWrite_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_I2cPortWrite_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_PciPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_PciPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_PciSocketCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_PciSocketCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortEnable_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortEnable_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortPinMode_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortPinMode_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortPinState_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortPinState_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortTrigger_Status(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_GpioPortTrigger_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortEnFullStr_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_MostPortEnFullStr_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_CombinerCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_CombinerCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SplitterCreate_Error(void *self, Msg_MostTel_t *msg_ptr);
+extern void Inic_SplitterCreate_Result(void *self, Msg_MostTel_t *msg_ptr);
+
+/* Helper functions */
+extern Ucs_StdResult_t Inic_TranslateError(CInic *self, uint8_t error_data[], uint8_t error_size);
+
+/* Synchronous Getters */
+extern uint16_t Inic_GetGroupAddress(CInic *self);
+extern uint16_t Inic_GetPacketDataBandwidth(CInic *self);
+extern uint16_t Inic_GetNodeAddress(CInic *self);
+extern uint8_t Inic_GetNodePosition(CInic *self);
+extern uint8_t Inic_GetNumberOfNodes(CInic *self);
+extern uint8_t Inic_GetInicLlrbc(CInic *self);
+extern Ucs_Inic_Version_t Inic_GetDeviceVersion(CInic *self);
+extern Ucs_Inic_LastResetReason_t Inic_GetLastResetReason(CInic *self);
+extern Ucs_Inic_PowerState_t Inic_GetDevicePowerState(CInic *self);
+extern Ucs_Network_Availability_t Inic_GetAvailability(CInic *self);
+extern uint16_t Inic_GetTargetAddress (CInic *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_INIC_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_inic_pb.h b/ucs2-lib/inc/ucs_inic_pb.h
new file mode 100644
index 0000000..cb8add9
--- /dev/null
+++ b/ucs2-lib/inc/ucs_inic_pb.h
@@ -0,0 +1,932 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of class CInic.
+ */
+
+#ifndef UCS_INIC_PB_H
+#define UCS_INIC_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_ret_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Bitmask used for network status event "Network Change Event".
+ * \ingroup G_UCS_NET_TYPES
+ */
+#define UCS_NETWORK_EVENT_NCE 0x0001U
+
+/*! \brief Signature version limit of EXC commands. Denotes the maximum signature version
+ * number the INIC can handle.
+ * \ingroup G_UCS_NET_TYPES
+ */
+#define UCS_EXC_SIGNATURE_VERSION_LIMIT 1U
+
+
+/*! \brief No evaluable segment information available for BackChannel Diagnosis.
+ * \ingroup G_UCS_BC_DIAG_TYPES
+ */
+#define UCS_BCD_DUMMY_SEGMENT 0xFFU
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Data Type which describes the last reset reason of the device.
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef enum Ucs_Inic_LastResetReason_
+{
+ /*! \brief Reset due to Power on reset or reset pin (!RST) is held low. */
+ UCS_INIC_RST_STARTUP = 0x00U,
+ /*! \brief Reset due to hardware watchdog that had snapped */
+ UCS_INIC_RST_HW_WATCHDOG = 0x01U,
+ /*! \brief Reset due to stack overflow */
+ UCS_INIC_RST_STACK_OVERFLOW = 0x02U
+
+} Ucs_Inic_LastResetReason_t;
+
+/*! \brief The current power state of the INICs power management interface (PS0/PS1).
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef enum Ucs_Inic_PowerState_
+{
+ /*! \brief Power state "UNormal" */
+ UCS_INIC_PWS_U_NORMAL = 0x00U,
+ /*! \brief Power state "ULow" */
+ UCS_INIC_PWS_U_LOW = 0x01U,
+ /*! \brief Power State "STP" */
+ UCS_INIC_PWS_STP = 0x02U,
+ /*! \brief Power State "UCritical" */
+ UCS_INIC_PWS_U_CRITICAL = 0x03U,
+ /*! \brief No power state. Power management monitoring is disabled in INIC configuration string. */
+ UCS_INIC_PWS_NO_MONITORING = 0xFFU
+
+} Ucs_Inic_PowerState_t;
+
+
+/*! \brief Defines the flags set in \c change_mask used by NetworkStatus.Status
+ * \ingroup G_UCS_NET_TYPES
+ */
+
+typedef enum Ucs_Network_StatusMask_
+{
+ UCS_NW_M_EVENTS = 0x01U, /*!< \brief Flag for notification of event changes */
+ UCS_NW_M_AVAIL = 0x02U, /*!< \brief Flag for notification of availability changes */
+ UCS_NW_M_AVAIL_INFO = 0x04U, /*!< \brief Flag for notification of availability info changes */
+ UCS_NW_M_AVAIL_TR_CAUSE = 0x08U, /*!< \brief Flag for notification of availability transition cause changes */
+ UCS_NW_M_NODE_ADDR = 0x10U, /*!< \brief Flag for notification of node address changes */
+ UCS_NW_M_NODE_POS = 0x20U, /*!< \brief Flag for notification of node position changes */
+ UCS_NW_M_MAX_POS = 0x40U, /*!< \brief Flag for notification of MPR changes */
+ UCS_NW_M_PACKET_BW = 0x80U /*!< \brief Flag for notification of packet bandwidth changes */
+
+} Ucs_Network_StatusMask_t;
+
+
+/*! \brief MOST Network Availability
+ * \ingroup G_UCS_NET_TYPES
+ */
+typedef enum Ucs_Network_Availability_
+{
+ UCS_NW_NOT_AVAILABLE = 0x00U, /*!< \brief MOST network is not available */
+ UCS_NW_AVAILABLE = 0x01U /*!< \brief MOST network is available */
+
+} Ucs_Network_Availability_t;
+
+/*! \brief MOST Network Availability Information.
+ * \details AvailabilityInfo is a sub state of Availability (\ref Ucs_Network_Availability_t)
+ * Possible pairs of Availability and Availability Information
+ * Availability | Availability Information
+ * ------------------------| ------------------------------------
+ * UCS_NW_NOT_AVAILABLE | UCS_NW_AVAIL_INFO_REGULAR
+ * UCS_NW_NOT_AVAILABLE | UCS_NW_AVAIL_INFO_DIAGNOSIS
+ * UCS_NW_NOT_AVAILABLE | UCS_NW_AVAIL_INFO_FORCED_NA
+ * UCS_NW_AVAILABLE | UCS_NW_AVAIL_INFO_UNSTABLE
+ * UCS_NW_AVAILABLE | UCS_NW_AVAIL_INFO_STABLE
+ * \ingroup G_UCS_NET_TYPES
+ */
+typedef enum Ucs_Network_AvailInfo_
+{
+ /*! \brief The network is not available because it is in NetInterface Off or Init state.
+ * It is pending to get available again.
+ */
+ UCS_NW_AVAIL_INFO_REGULAR = 0x00U,
+ /*! \brief The network is not available because it performs a ring break diagnosis or
+ * physical layer test.
+ */
+ UCS_NW_AVAIL_INFO_DIAGNOSIS = 0x02U,
+ /*! \brief The INIC forces the network to stay in "not available" state. The
+ * application may enter or leave this state by calling
+ * Ucs_Network_ForceNotAvailable(). Also see Ucs_Network_Startup().
+ */
+ UCS_NW_AVAIL_INFO_FORCED_NA = 0x06U,
+ /*! \brief Network is available. Unlocks have been detected. */
+ UCS_NW_AVAIL_INFO_UNSTABLE = 0x10U,
+ /*! \brief Network is available. Network is in Stable Lock. */
+ UCS_NW_AVAIL_INFO_STABLE = 0x11U
+
+} Ucs_Network_AvailInfo_t;
+
+/*! \brief MOST Network Availability Transition Cause
+ * \ingroup G_UCS_NET_TYPES
+ */
+typedef enum Ucs_Network_AvailTransCause_
+{
+ /*! \brief Start-up is initiated by chip e.g., INIC.MOSTNetworkStartup() */
+ UCS_NW_AV_TR_CA_CMD = 0x00U,
+ /*! \brief Chip is woken up by network activity. */
+ UCS_NW_AV_TR_CA_RX_ACTIVITY = 0x01U,
+ /*! \brief Network is typically shutdown by an INIC.MOSTNetworkShutdown() command initiated
+ * locally or by a node positioned upstream (in the latter case, the shutdown flag
+ * indicates a Normal Shutdown).
+ */
+ UCS_NW_AV_TR_CA_NORMAL = 0x10U,
+ /*! \brief Network is shutdown due to an error. In this case the shutdown reason was a sudden
+ * signal off. No shutdown flag is present.
+ */
+ UCS_NW_AV_TR_CA_ERR_SSO = 0x11U,
+ /*! \brief Network is shutdown due to an error. In this case the shutdown reason was a critical
+ * unlock. No shutdown flag is present.
+ */
+ UCS_NW_AV_TR_CA_ERR_CRIT_UNLOCK = 0x12U,
+ /*! \brief Network is shutdown due to a chip or system error. Possible reasons are:
+ * - INIC enters ForcedNA state
+ * - The AutoShutdownDownDelay time expires after the EHC has detached.
+ */
+ UCS_NW_AV_TR_CA_ERR_SYSTEM = 0x13U,
+ /*! \brief No transition */
+ UCS_NW_AV_TR_CA_NO_TRANSITION = 0xFFU
+
+} Ucs_Network_AvailTransCause_t;
+
+/*! \brief Result values for the Ring Break Diagnosis
+ * \ingroup G_UCS_DIAG_TYPES
+ */
+typedef enum Ucs_Diag_RbdResult_
+{
+ UCS_DIAG_RBD_NO_ERROR = 0x00U, /*!< \brief No error */
+ UCS_DIAG_RBD_POS_DETECTED = 0x01U, /*!< \brief Position detected */
+ UCS_DIAG_RBD_DIAG_FAILED = 0x02U, /*!< \brief Diagnosis failed */
+ UCS_DIAG_RBD_POS_0_WEAK_SIG = 0x03U /*!< \brief PosDetected = 0 and un-lockable signal on
+ * Rx was detected
+ */
+} Ucs_Diag_RbdResult_t;
+
+/*! \brief Data packet size of the isochronous channel
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Avp_IsocPacketSize_
+{
+ UCS_ISOC_PCKT_SIZE_188 = 188U, /*!< \brief Standard MPEG2 Transport Stream packet size, no
+ * encryption
+ */
+ UCS_ISOC_PCKT_SIZE_196 = 196U, /*!< \brief DTCP Supplement B, DTCP over MOST */
+ UCS_ISOC_PCKT_SIZE_206 = 206U /*!< \brief DTCP Supplement E, DTCP over IP */
+
+} Ucs_Avp_IsocPacketSize_t;
+
+/*! \brief Mute Mode
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Sync_MuteMode_
+{
+ UCS_SYNC_MUTE_MODE_NO_MUTING = 0x00U, /*!< \brief No mute monitoring */
+ UCS_SYNC_MUTE_MODE_MUTE_SIGNAL = 0x01U /*!< \brief Mute signal. The MUTE pin will be asserted if any registered connection may stream
+ * corrupted data.
+ */
+
+} Ucs_Sync_MuteMode_t;
+
+/*! \brief Direction of the data stream from the perspective of the INIC
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_SocketDirection_
+{
+ UCS_SOCKET_DIR_INPUT = 0U, /*!< \brief Socket transfers data into INIC */
+ UCS_SOCKET_DIR_OUTPUT = 1U /*!< \brief Socket transfers data out of INIC */
+
+} Ucs_SocketDirection_t;
+
+/*! \brief Data type of MOST Sockets
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Most_SocketDataType_
+{
+ UCS_MOST_SCKT_SYNC_DATA = 0U, /*!< \brief Specifies the synchronous streaming data type */
+ UCS_MOST_SCKT_AV_PACKETIZED = 3U, /*!< \brief Specifies the A/V Packetized Isochronous
+ streaming data type*/
+ UCS_MOST_SCKT_QOS_IP = 4U, /*!< \brief Specifies the Quality of Service IP
+ streaming data type*/
+ UCS_MOST_SCKT_DISC_FRAME_PHASE = 5U /*!< \brief Specifies the DiscreteFrame Isochronous
+ streaming phase data type */
+} Ucs_Most_SocketDataType_t;
+
+/*! \brief Data type of MediaLB Sockets
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Mlb_SocketDataType_
+{
+ UCS_MLB_SCKT_SYNC_DATA = 0U, /*!< \brief Specifies the synchronous streaming data type */
+ UCS_MLB_SCKT_CONTROL_DATA = 2U, /*!< \brief Specifies the control data type */
+ UCS_MLB_SCKT_AV_PACKETIZED = 3U, /*!< \brief Specifies the A/V Packetized Isochronous
+ streaming data type */
+ UCS_MLB_SCKT_QOS_IP = 4U, /*!< \brief Specifies the Quality of Service IP
+ streaming data type*/
+ UCS_MLB_SCKT_DISC_FRAME_PHASE = 5U, /*!< \brief Specifies the DiscreteFrame Isochronous
+ streaming phase data type */
+ UCS_MLB_SCKT_IPC_PACKET = 7U /*!< \brief Specifies the IPC packet data type */
+
+} Ucs_Mlb_SocketDataType_t;
+
+/*! \brief Data type of USB Sockets
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Usb_SocketDataType_
+{
+ UCS_USB_SCKT_SYNC_DATA = 0U, /*!< \brief Specifies the synchronous streaming data type */
+ UCS_USB_SCKT_CONTROL_DATA = 2U, /*!< \brief Specifies the control data type */
+ UCS_USB_SCKT_AV_PACKETIZED = 3U, /*!< \brief Specifies the A/V Packetized Isochronous
+ streaming data type */
+ UCS_USB_SCKT_IPC_PACKET = 7U /*!< \brief Specifies the IPC packet data type */
+
+} Ucs_Usb_SocketDataType_t;
+
+/*! \brief Physical interface of the USB Port
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Usb_PhysicalLayer_
+{
+ UCS_USB_PHY_LAYER_STANDARD = 0U, /*!< \brief Standard - USB uses the standard physical
+ * interface with analog transceivers for board
+ * communication
+ */
+ UCS_USB_PHY_LAYER_HSCI = 1U /*!< \brief HSIC - USB uses the High-Speed Inter-Chip
+ * interface without analog transceivers for board
+ * communication.
+ */
+} Ucs_Usb_PhysicalLayer_t;
+
+/*! \brief MediaLB clock speed configuration
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Mlb_ClockConfig_
+{
+ UCS_MLB_CLK_CFG_256_FS = 0U, /*!< \brief 256 Fs */
+ UCS_MLB_CLK_CFG_512_FS = 1U, /*!< \brief 512 Fs */
+ UCS_MLB_CLK_CFG_1024_FS = 2U, /*!< \brief 1024 Fs */
+ UCS_MLB_CLK_CFG_2048_FS = 3U, /*!< \brief 2048 Fs */
+ UCS_MLB_CLK_CFG_3072_FS = 4U, /*!< \brief 3072 Fs */
+ UCS_MLB_CLK_CFG_4096_FS = 5U, /*!< \brief 4096 Fs */
+ UCS_MLB_CLK_CFG_6144_FS = 6U, /*!< \brief 6144 Fs */
+ UCS_MLB_CLK_CFG_8192_FS = 7U, /*!< \brief 8192 Fs */
+ UCS_MLB_CLK_CFG_WILDCARD = 0xFFU /*!< \brief Uses the corresponding parameter in the INIC
+ Configuration String */
+} Ucs_Mlb_ClockConfig_t;
+
+/*! \brief Source of the RMCK clock
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Rmck_PortClockSource_
+{
+ UCS_RMCK_PORT_CLK_SRC_NW_SYSTEM = 0x01U /*!< \brief RMCK is locked to the system clock */
+
+} Ucs_Rmck_PortClockSource_t;
+
+/*! \brief Data type of PCIe Sockets
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Pci_SocketDataType_
+{
+ UCS_PCI_SCKT_AV_PACKETIZED = 3U /*!< \brief Specifies the A/V Packetized Isochronous
+ streaming data type */
+
+} Ucs_Pci_SocketDataType_t;
+
+/*! \brief Operation mode of the Streaming Port
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortOpMode_
+{
+ UCS_STREAM_PORT_OP_MODE_GENERIC = 0x00U /*!< \brief If Index = PortB, data pins are linked
+ to PortA clock configuration. */
+
+} Ucs_Stream_PortOpMode_t;
+
+/*! \brief Direction of the physical pins of the indexed Streaming Port
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortOption_
+{
+ UCS_STREAM_PORT_OPT_IN_OUT = 0x00U, /*!< \brief Two serial interface pins are available;
+ one for direction IN and one for direction
+ OUT. */
+ UCS_STREAM_PORT_OPT_DUAL_IN = 0x01U, /*!< \brief Tow serial interface pins are available
+ for direction IN. */
+ UCS_STREAM_PORT_OPT_DUAL_OUT = 0x02U /*!< \brief Tow serial interface pins are available
+ for direction OUT. */
+
+} Ucs_Stream_PortOption_t;
+
+/*! \brief Indicates if FSY/SCK signals are configured as outputs or inputs.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortClockMode_
+{
+ /*! \brief INIC drives the FSY/SCK signals as outputs, frequency locked to the network clock. */
+ UCS_STREAM_PORT_CLK_MODE_OUTPUT = 0x00U,
+ /*! \brief FSY/SCK signals are configured as inputs and are driven from outside the INIC. Use
+ * RMCK, frequency locked to the network clock, as reference for clock generation.
+ */
+ UCS_STREAM_PORT_CLK_MODE_INPUT = 0x01U,
+ /*! \brief Wildcard */
+ UCS_STREAM_PORT_CLK_MODE_WILD = 0xFFU
+
+} Ucs_Stream_PortClockMode_t;
+
+/*! \brief This setting is only applicable to data pins used for Generic Streaming including any
+ linked pins to Streaming Port B. All data pins share the same FSY / SCK signals, hence
+ this setting applies to all data pins.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortClockDataDelay_
+{
+ /*! \brief Data is not delayed by a single SCK clock delay. */
+ UCS_STREAM_PORT_CLK_DLY_NONE = 0x00U,
+ /*! \brief There is a single SCK clock delay between the start of frame (falling edge of FSY)
+ * and the start of the frame data on the data pins.
+ */
+ UCS_STREAM_PORT_CLK_DLY_DELAYED = 0x01U,
+ /*! \brief Wildcard */
+ UCS_STREAM_PORT_CLK_DLY_WILD = 0xFFU
+
+} Ucs_Stream_PortClockDataDelay_t;
+
+/*! \brief Clock speed configuration of the SCK signal.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortClockConfig_
+{
+ /*! \brief 8 x Fs. All data pins must be configured for sequential routing. */
+ UCS_STREAM_PORT_CLK_CFG_8FS = 0x00U,
+ /*! \brief 16 x Fs. All data pins must be configured for sequential routing. */
+ UCS_STREAM_PORT_CLK_CFG_16FS = 0x01U,
+ /*! \brief 32 x Fs. All data pins must be configured for sequential routing. */
+ UCS_STREAM_PORT_CLK_CFG_32FS = 0x02U,
+ /*! \brief 64 x Fs */
+ UCS_STREAM_PORT_CLK_CFG_64FS = 0x03U,
+ /*! \brief 128 x Fs */
+ UCS_STREAM_PORT_CLK_CFG_128FS = 0x04U,
+ /*! \brief 256 x Fs */
+ UCS_STREAM_PORT_CLK_CFG_256FS = 0x05U,
+ /*! \brief 512 x Fs */
+ UCS_STREAM_PORT_CLK_CFG_512FS = 0x06U,
+ /*! \brief Wildcard */
+ UCS_STREAM_PORT_CLK_CFG_WILD = 0xFFU
+
+} Ucs_Stream_PortClockConfig_t;
+
+/*! \brief Data types of Streaming Sockets
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_SocketDataType_
+{
+ /*! \brief Specifies the synchronous streaming data type. */
+ UCS_STREAM_PORT_SCKT_SYNC_DATA = 0x00U
+
+} Ucs_Stream_SocketDataType_t;
+
+/*! \brief ID of the serial interface pin of the addressed Streaming Port instance to which the
+ socket should be attached to.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortPinId_
+{
+ UCS_STREAM_PORT_PIN_ID_SRXA0 = 0x00U, /*!< \brief PortA, pin 5. */
+ UCS_STREAM_PORT_PIN_ID_SRXA1 = 0x01U, /*!< \brief PortA, pin 6. */
+ UCS_STREAM_PORT_PIN_ID_SRXB0 = 0x10U, /*!< \brief PortB, pin 7. */
+ UCS_STREAM_PORT_PIN_ID_SRXB1 = 0x11U /*!< \brief PortB, pin 8. */
+
+} Ucs_Stream_PortPinId_t;
+
+/*! \brief Defines the alignment of the data bytes within the streaming port frame.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Stream_PortDataAlign_
+{
+ UCS_STREAM_PORT_ALGN_LEFT16BIT = 0x00U, /*!< \brief Left-justified, 16 bit, legacy */
+ UCS_STREAM_PORT_ALGN_LEFT24BIT = 0x01U, /*!< \brief Left-justified, 24 bit, legacy */
+ UCS_STREAM_PORT_ALGN_RIGHT16BIT = 0x02U, /*!< \brief Right-justified, 16 bit, legacy */
+ UCS_STREAM_PORT_ALGN_RIGHT24BIT = 0x03U, /*!< \brief Right-justified, 16 bit, legacy */
+ UCS_STREAM_PORT_ALGN_SEQ = 0x04U /*!< \brief Sequential */
+
+} Ucs_Stream_PortDataAlign_t;
+
+/*! \brief Indicates if the MOST Network Port is available and ready for streaming data connections.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Most_PortAvail_
+{
+ /*! \brief MOST Network Port is available and it is possible to have streaming data
+ * connections.
+ */
+ UCS_MOST_PORT_AVAIL = 0x01U,
+ /*! \brief MOST Network Port is not available for streaming data. FreeStreamingBW gets 0.
+ * All created sockets on this port get invalid.
+ */
+ UCS_MOST_PORT_NOT_AVAIL = 0x00U
+
+} Ucs_Most_PortAvail_t;
+
+/*! \brief Indicates the sub state to parameter Available.
+ * \ingroup G_UCS_XRM_ENUM
+ */
+typedef enum Ucs_Most_PortAvailInfo_
+{
+ /*! \brief MOST Network Port is not available for streaming data. This is for instance the
+ * case if the MOST network is shut down or Ring Break Diagnosis is running.
+ */
+ UCS_MOST_PRT_AVL_INF_REGULAR = 0x00U,
+ /*! \brief Unlocks have been detected at the port and streaming is temporarily not
+ * available.
+ */
+ UCS_MOST_PRT_AVL_INF_UNSTABLE = 0x10U,
+ /*! \brief Port is in Stable Lock. */
+ UCS_MOST_PRT_AVL_INF_STABLE = 0x11U
+
+} Ucs_Most_PortAvailInfo_t;
+
+/*! \brief Indicates the type of the Physical Layer Test.
+ * \ingroup G_UCS_DIAG_TYPES
+ */
+typedef enum Ucs_Diag_PhyTest_Type_
+{
+ UCS_DIAG_PHYTEST_MASTER = 1U, /*!< \brief Force Retimed Bypass TimingMaster mode */
+ UCS_DIAG_PHYTEST_SLAVE = 2U /*!< \brief Force Retimed Bypass TimingSlave mode */
+
+} Ucs_Diag_PhyTest_Type_t;
+
+
+/*! \brief Specifies whether the the INIC behaves as a TimingMaster or TimingSlave device
+ * during the Ring Break Diagnosis (RBD).
+ * \ingroup G_UCS_DIAG_TYPES
+ */
+typedef enum Ucs_Diag_RbdType_
+{
+ UCS_DIAG_RBDTYPE_SLAVE = 0U, /*!< \brief The INIC starts the RBD as a TimingSlave */
+ UCS_DIAG_RBDTYPE_MASTER = 1U /*!< \brief The INIC starts the RBD as a TimingMaster */
+
+} Ucs_Diag_RbdType_t;
+
+/*! \brief The speed grade of the I2C Port.
+ * \ingroup G_UCS_I2C_TYPES
+ */
+typedef enum Ucs_I2c_Speed_
+{
+ UCS_I2C_SLOW_MODE = 0x00U, /*!< \brief Speed grade of the port is 100 kHz. */
+ UCS_I2C_FAST_MODE = 0x01U /*!< \brief Speed grade of the port is 400 kHz. */
+
+} Ucs_I2c_Speed_t;
+
+/*! \brief The write transfer mode.
+ * \ingroup G_UCS_I2C_TYPES
+ */
+typedef enum Ucs_I2c_TrMode_
+{
+ UCS_I2C_DEFAULT_MODE = 0x00U, /*!< \brief Default mode of the I2C write transfer */
+ UCS_I2C_REPEATED_MODE = 0x01U, /*!< \brief Repeated Mode of the I2C write transfer */
+ UCS_I2C_BURST_MODE = 0x02U /*!< \brief Burst mode of the I2C write transfer */
+
+} Ucs_I2c_TrMode_t;
+
+/*! \brief The mode of the GPIO pin.
+ * \ingroup G_UCS_GPIO_TYPES
+ */
+typedef enum Ucs_Gpio_PinMode_
+{
+ UCS_GPIO_UNAVAILABLE = 0x00U, /*!< \brief Unavailable Mode */
+ UCS_GPIO_UNUSED = 0x01U, /*!< \brief Unused Mode */
+ UCS_GPIO_INPUT = 0x10U, /*!< \brief Input Mode */
+ UCS_GPIO_IN_STICKY_HL = 0x11U, /*!< \brief InputStickyHighLevel Mode */
+ UCS_GPIO_IN_STICKY_LL = 0x12U, /*!< \brief InputStickyLowLevel Mode */
+ UCS_GPIO_IN_TRIGGER_RE = 0x13U, /*!< \brief InputTriggerRisingEdge Mode */
+ UCS_GPIO_IN_TRIGGER_FE = 0x14U, /*!< \brief InputTriggerFallingEdge Mode */
+ UCS_GPIO_IN_TRIGGER_HL = 0x16U, /*!< \brief InputTriggerHighLevel Mode */
+ UCS_GPIO_IN_TRIGGER_LL = 0x17U, /*!< \brief InputTriggerLowLevel Mode */
+ UCS_GPIO_IN_DEBOUNCED = 0x30U, /*!< \brief InputDebounced Mode */
+ UCS_GPIO_IN_DB_TRIGGER_RE = 0x33U, /*!< \brief InputDebouncedTriggerRisingEdge Mode */
+ UCS_GPIO_IN_DB_TRIGGER_FE = 0x34U, /*!< \brief InputDebouncedTriggerFallingEdge Mode */
+ UCS_GPIO_IN_DB_TRIGGER_HL = 0x36U, /*!< \brief InputDebouncedTriggerHighLevel Mode */
+ UCS_GPIO_IN_DB_TRIGGER_LL = 0x37U, /*!< \brief InputDebouncedTriggerLowLevel Mode */
+ UCS_GPIO_OUT_DEFAULT_LOW = 0x40U, /*!< \brief OutputDefaultLow Mode */
+ UCS_GPIO_OUT_DEFAULT_HIGH = 0x41U, /*!< \brief OutputDefaultHigh Mode */
+ UCS_GPIO_OUT_OPEN_DRAIN = 0x50U, /*!< \brief OutputOpenDrain Mode */
+ UCS_GPIO_OUT_OD_TRIGGER_RE = 0x53U, /*!< \brief OutputOpenDrainTriggerRisingEdge Mode */
+ UCS_GPIO_OUT_OD_TRIGGER_FE = 0x54U, /*!< \brief OutputOpenDrainTriggerFallingEdge Mode */
+ UCS_GPIO_OUT_OD_TRIGGER_HL = 0x56U, /*!< \brief OutputOpenDrainTriggerHighLevel Mode */
+ UCS_GPIO_OUT_OD_TRIGGER_LL = 0x57U /*!< \brief OutputOpenDrainTriggerLowLevel Mode */
+
+} Ucs_Gpio_PinMode_t;
+
+/*! \brief Type of System Diagnosis Report.
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef enum Ucs_Sd_ResCode_
+{
+ UCS_SD_TARGET_FOUND = 0x01U, /*!< \brief Segment description */
+ UCS_SD_FINISHED = 0x02U, /*!< \brief System Diagnosis finished */
+ UCS_SD_CABLE_LINK_RES = 0x03U, /*!< \brief Cable Link Diagnosis was executed. */
+ UCS_SD_ABORTED = 0x04U, /*!< \brief System Diagnosis stopped by application command */
+ UCS_SD_ERROR = 0x05U /*!< \brief System Diagnosis detected unexpected error */
+
+} Ucs_Sd_ResCode_t;
+
+/*! \brief Type of System Diagnosis Error Codes.
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef enum Ucs_Sd_ErrCode_
+{
+ /*! \brief An internal error occurred during System Diagnosis. */
+ UCS_SD_ERR_UNSPECIFIED = 0x01U,
+ /*! \brief INIC answered with "NoSuccess" to a Welcome.StartResult command. */
+ UCS_SD_ERR_WELCOME_NO_SUCCESS = 0x02U,
+ /*! \brief Stopping the System Diagnosis mode on INIC failed. The INIC may remain in System
+ Diagnosis mode. */
+ UCS_SD_ERR_STOP_SYSDIAG_FAILED = 0x03U,
+ /*! \brief System Diagnosis stopped due to a severe error. The INIC may remain in System
+ Diagnosis mode. */
+ UCS_SD_ERR_TERMINATED = 0x04U
+
+} Ucs_Sd_ErrCode_t;
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This structure contains information on the hardware and firmware modules of the INIC.
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef struct Ucs_Inic_Version_
+{
+ uint32_t product_identifier; /*!< \brief Unique identifier that represents the product name.\mns_name_inic{ProductIdentifier} */
+ uint32_t build_version; /*!< \brief Firmware build version number.\mns_name_inic{BuildVersion} */
+ uint8_t major_version; /*!< \brief Firmware major version number.\mns_name_inic{MajorVersion} */
+ uint8_t minor_version; /*!< \brief Firmware build version number.\mns_name_inic{MinorVersion} */
+ uint8_t release_version; /*!< \brief Firmware release version number.\mns_name_inic{ReleaseVersion} */
+ uint8_t hw_revision; /*!< \brief Chip revision number.\mns_name_inic{HardwareRevision} */
+ uint16_t diagnosis_id; /*!< \brief Diagnosis identifier of the INIC.\mns_name_inic{DiagnosisID} */
+ uint8_t cs_major_version; /*!< \brief Configuration String major version number.\mns_name_inic{ExtMajorVersion} */
+ uint8_t cs_minor_version; /*!< \brief Configuration String minor version number.\mns_name_inic{ExtMinorVersion} */
+ uint8_t cs_release_version; /*!< \brief Configuration String release version number.\mns_name_inic{ExtReleaseVersion} */
+
+} Ucs_Inic_Version_t;
+
+/*! \brief This structure contains information on the GPIO pin configuration.
+ * \ingroup G_UCS_INIC_TYPES
+ */
+typedef struct Ucs_Gpio_PinConfiguration_
+{
+ uint8_t pin; /*!< \brief The GPIO pin that is to be configured */
+ Ucs_Gpio_PinMode_t mode; /*!< \brief The mode of the GPIO pin */
+
+} Ucs_Gpio_PinConfiguration_t;
+
+
+
+
+
+
+/*! \brief This structure holds the signature of the Hello, Welcome and Signature messages.
+ * It supports the signature v1 only.
+ * \ingroup G_INIC_TYPES
+ */
+typedef struct Ucs_Signature_t_
+{
+ uint16_t node_address; /*!< \brief NodeAddress */
+ uint16_t group_address; /*!< \brief GroupAddress */
+ uint16_t mac_47_32; /*!< \brief MACAddress_47_32 */
+ uint16_t mac_31_16; /*!< \brief MACAddress_31_16 */
+ uint16_t mac_15_0; /*!< \brief MACAddress_15_0 */
+ uint16_t node_pos_addr; /*!< \brief NodePositionAddress */
+ uint16_t diagnosis_id; /*!< \brief DiagnosisID */
+ uint8_t num_ports; /*!< \brief NumberOfPorts */
+ uint8_t chip_id; /*!< \brief ChipID */
+ uint8_t fw_major; /*!< \brief FWVersion_Major */
+ uint8_t fw_minor; /*!< \brief FWVersion_Minor */
+ uint8_t fw_release; /*!< \brief FWVersion_Release */
+ uint32_t fw_build; /*!< \brief FWVersion_Build */
+ uint8_t cs_major; /*!< \brief CSVersion_Major */
+ uint8_t cs_minor; /*!< \brief CSVersion_Minor */
+ uint8_t cs_release; /*!< \brief CSVersion_Release */
+/* uint8_t uid_persistency;*/ /*!< \brief UIDPersistency */
+/* uint32_t uid;*/ /*!< \brief UID */
+
+} Ucs_Signature_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* System Diagnosis */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This structure holds the segment information of the system diagnosis
+ * \ingroup G_INIC_TYPES
+ */
+typedef struct Ucs_Sd_Segment_t_
+{
+ uint8_t branch; /*!< \brief Number of the currently tested branch. Numbering starts
+ with 0 and corresponds to the port number if the Timing
+ Master is a multi port INIC */
+ uint8_t num; /*!< \brief Segment number inside the tested branch. Numbering starts with 1 */
+ Ucs_Signature_t source; /*!< \brief Signature of the first node of the segment
+ \mns_param_inic{Signature,Hello,MNSH2-Hello200} */
+ Ucs_Signature_t target; /*!< \brief Signature of the second node of the segment
+ \mns_param_exc{Signature,Hello,MNSH2-Hello200} */
+} Ucs_Sd_Segment_t;
+
+
+/*! \brief This structure holds the results of the system diagnosis
+ * \ingroup G_INIC_TYPES
+ */
+typedef struct Ucs_Sd_Report_t_
+{
+ Ucs_Sd_ResCode_t code; /*!< \brief Result code */
+ Ucs_Sd_Segment_t segment; /*!< \brief Information about tested segment */
+ uint8_t cable_link_info; /*!< \brief Result of a cable link diagnosis.
+ \mns_param_exc{Result,CableLinkDiagnosis,MNSH2-CableLinkDiagnosis211} */
+ Ucs_Sd_ErrCode_t err_info; /*!< \brief Error codes, values are defined in Ucs_Sd_ErrCode_t */
+
+} Ucs_Sd_Report_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Node Discovery */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*! \brief Result values of the Node Discovery service.
+ * \ingroup G_UCS_NODE_DISCOVERY_TYPES
+ */
+typedef enum Ucs_Nd_ResCode_t_
+{
+ UCS_ND_RES_WELCOME_SUCCESS = 0x01U, /*!< \brief Node was successfully added to the network. */
+ UCS_ND_RES_UNKNOWN = 0x02U, /*!< \brief Node signature is unknown to the application, node will be ignored. */
+ UCS_ND_RES_MULTI = 0x03U, /*!< \brief A node with the same signature is already part of the system. The new node will be ignored. */
+ UCS_ND_RES_STOPPED = 0x04U, /*!< \brief The Node Discovery service was stopped by API function Ucs_Nd_Stop(). Ucs_Nd_Start() has to be called to start again. */
+ UCS_ND_RES_NETOFF = 0x05U, /*!< \brief The Node Discovery service detected a NetOff event and pauses . It resumes automatically as soon as NetOn occurs. */
+ UCS_ND_RES_ERROR = 0x06U /*!< \brief An unexpected error occurred. Node Discovery service was stopped. Ucs_Nd_Start() has to be called to start again. */
+
+} Ucs_Nd_ResCode_t;
+
+/*! \brief Result values of the application's evaluation function (type \ref Ucs_Nd_EvalCb_t).
+ * \ingroup G_UCS_NODE_DISCOVERY_TYPES
+ */
+typedef enum Ucs_Nd_CheckResult_t_
+{
+ UCS_ND_CHK_WELCOME = 0x01U, /*!< \brief Node is ok, try to add it to the network. */
+ UCS_ND_CHK_UNIQUE = 0x02U, /*!< \brief Test if this node is unique. */
+ UCS_ND_CHK_UNKNOWN = 0x03U /*!< \brief The node is unknown, no further action. */
+
+} Ucs_Nd_CheckResult_t;
+
+
+/*! \brief Function signature of node evaluation callback used by Node Discovery service.
+ *
+ * The Node Discovery service announces the signature of each node it has found to the
+ * application via the evaluation function. In this function the application
+ * decides how the Node Discovery service shall proceed with the node.
+ * The application maintains two lists:
+ *
+ * <dl>
+ * <dt> *set_list* </dt>
+ * <dd> Contains the signatures of the nodes the system shall contain
+ *
+ * <dt> *device_list* </dt>
+ * <dd> Contains the signatures of the nodes detected in the system
+ * </dl>
+ *
+ * The evaluation has to follow these rules:
+ * - If the node is not part of the *set_list*, it is regarded as unknown (\ref UCS_ND_CHK_UNKNOWN)
+ * and will be ignored.
+ * - If the node is part of the *set_list* and is not yet in the *device_list*, the Node Discovery
+ * Service shall try to add the node to network (\ref UCS_ND_CHK_WELCOME).
+ * - If the node is already part of the *device_list*, there are two possibilities: the node in the
+ * *device_list* experienced a reset or there are two nodes with the same signature. Evaluation
+ * result is \ref UCS_ND_CHK_UNIQUE. The Node Discovery service will perform further tests.
+ *
+ * \param signature Signature of the respective node
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \returns UCS_ND_CHK_WELCOME Node is ok, try to add it to the network.
+ * \returns UCS_ND_CHK_UNIQUE Test if this node is unique.
+ * \returns UCS_ND_CHK_UNKNOWN Node is unknown, no further action.
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+typedef Ucs_Nd_CheckResult_t (*Ucs_Nd_EvalCb_t)(Ucs_Signature_t *signature, void *user_ptr);
+
+/*! \brief Function signature of result callback used by Node Discovery service.
+ *
+ * The Node Discovery service reports the result of each node and some system events by
+ * this callback function.
+ *
+ * \note The parameter <b>signature</b> will be NULL, if parameter <b>code</b> is
+ * \ref UCS_ND_RES_STOPPED, \ref UCS_ND_RES_NETOFF or \ref UCS_ND_RES_ERROR.
+ *
+ * \param code Result code
+ * \param signature Signature of the respective node
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+typedef void (*Ucs_Nd_ReportCb_t)(Ucs_Nd_ResCode_t code,
+ Ucs_Signature_t *signature,
+ void *user_ptr);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Programming service */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Defines the set of MemIDs and the memory access types.
+ * \ingroup G_UCS_PROG_MODE_TYPES
+ */
+typedef enum Ucs_Prg_SessionType_
+{
+ UCS_PRG_ST_CS = 0x01U, /*!< \brief Writes to configuration string */
+ UCS_PRG_ST_IS = 0x02U, /*!< \brief Writes to identification string */
+ UCS_PRG_ST_CS_IS = 0x04U, /*!< \brief Writes to configuration and identification string */
+ UCS_PRG_ST_ERASE_EM = 0x08U, /*!< \brief Erases the error memory */
+ UCS_PRG_ST_CFG_READ = 0x10U /*!< \brief Reads data from all configuration memories */
+} Ucs_Prg_SessionType_t;
+
+
+/*! \brief Represents the memory resource to be written.
+ * \ingroup G_UCS_PROG_MODE_TYPES
+ */
+typedef enum Ucs_Prg_MemId_
+{
+ UCS_PRG_MID_CS = 0x00U, /*!< \brief Writes the configuration string */
+ UCS_PRG_MID_IS = 0x01U, /*!< \brief Writes the identification string */
+ UCS_PRG_MID_CSTEST = 0x0CU, /*!< \brief Writes the test configuration string */
+ UCS_PRG_MID_ISTEST = 0x0DU /*!< \brief Writes the test identification string */
+} Ucs_Prg_MemId_t;
+
+/*! \brief Represents a programming task.
+ * \ingroup G_UCS_PROG_MODE_TYPES
+ */
+typedef struct Ucs_Prg_Command_
+{
+ Ucs_Prg_MemId_t mem_id; /*!< \brief Represents the memory resource to be written. */
+ uint32_t address; /*!< \brief Defines the memory location at which the writing
+ operation starts. */
+ uint8_t unit_length; /*!< \brief Sets the number of memory units to be written.
+ Memory units can be unsigned bytes, unsigned words
+ or unsigned masked data depending on the memory type. */
+ uint8_t data_length; /*!< \brief Lenght of data */
+ uint8_t *data; /*!< \brief Contains the actual data written to the memory
+ resource and formatted as memory units. */
+} Ucs_Prg_Command_t;
+
+/*! \brief Result values of the Programming service.
+ * \ingroup G_UCS_PROG_MODE_TYPES
+ */
+typedef enum Ucs_Prg_ResCode_t_
+{
+ UCS_PRG_RES_SUCCESS = 0x01U, /*!< \brief Node was successfully programmed. */
+ UCS_PRG_RES_TIMEOUT = 0x02U, /*!< \brief Node did not answer timely. */
+ UCS_PRG_RES_NET_OFF = 0x03U, /*!< \brief A NetOff event occurred during programming. */
+ UCS_PRG_RES_FKT_SYNCH = 0x04U, /*!< \brief The call of the internal API function returned an error,
+ so the command was not sent to the node.*/
+ UCS_PRG_RES_FKT_ASYNCH = 0x05U, /*!< \brief Node returned an error message as result. */
+ UCS_PRG_RES_ERROR = 0x06U /*!< \brief An unexcpected error occurred. Programming service was stopped. */
+
+} Ucs_Prg_ResCode_t;
+
+/*! \brief Denotes the function where an error occurred.
+ * \ingroup G_UCS_PROG_MODE_TYPES
+ */
+typedef enum Ucs_Prg_Func_t_
+{
+ UCS_PRG_FKT_DUMMY = 0x00U, /*!< \brief Dummy value, used in case of UCS_PRG_RES_SUCCESS */
+ UCS_PRG_FKT_WELCOME = 0x01U, /*!< \brief Error occurred in the context of function Welcome */
+ UCS_PRG_FKT_WELCOME_NOSUCCESS = 0x02U, /*!< \brief Welcome result was No Success */
+ UCS_PRG_FKT_MEM_OPEN = 0x03U, /*!< \brief Error occurred in the context of function MemorySessionOpen */
+ UCS_PRG_FKT_MEM_WRITE = 0x04U, /*!< \brief Error occurred in the context of function MemoryWrite */
+ UCS_PRG_FKT_MEM_CLOSE = 0x05U, /*!< \brief Error occurred in the context of function MemorySessionClose */
+ UCS_PRG_FKT_INIT = 0x06U /*!< \brief Error occurred in the context of function Init */
+} Ucs_Prg_Func_t;
+
+/*! \brief Function signature of result callback used by Programming service.
+ *
+ * The Programming service reports the result of programming a certain device by
+ * this callback function.
+ *
+ *
+ * \param code Result values of the Programming service
+ * \param function Signature of the node to be programmed.
+ * \param ret_len Length of the error parameter field parm. It is 0 if no error occurred.
+ * \param parm Pointer to the parameters of a potential error message.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_PROG_MODE
+ */
+typedef void (*Ucs_Prg_ReportCb_t)(Ucs_Prg_ResCode_t code,
+ Ucs_Prg_Func_t function,
+ uint8_t ret_len,
+ uint8_t parm[],
+ void *user_ptr);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* BackChannel Diagnosis */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Result values of the BackChannel Diagnosis.
+ * \ingroup G_UCS_BC_DIAG_TYPES
+ */
+typedef enum Ucs_Bcd_ResCode_t_
+{
+ UCS_BCD_RES_SUCCESS = 0x01U, /*!< \brief current segment is not broken */
+ UCS_BCD_RES_NO_RING_BREAK = 0x02U, /*!< \brief TM answered: no ring break. */
+ UCS_BCD_RES_RING_BREAK = 0x03U, /*!< \brief Ring break detected in current segment. */
+ UCS_BCD_RES_TIMEOUT1 = 0x04U, /*!< \brief No communication on back channel. */
+ UCS_BCD_RES_TIMEOUT2 = 0x05U, /*!< \brief No result from INIC received. */
+ UCS_BCD_RES_ERROR = 0x06U, /*!< \brief An unexpected error occurred. BackChannel Diagnosis was stopped. */
+ UCS_BCD_RES_END = 0x07U /*!< \brief BackChannel Diagnosis ended regularly. */
+} Ucs_Bcd_ResCode_t;
+
+
+/*! \brief Function signature of result callback used by BackChannel Diagnosis.
+ *
+ * The BackChannel Diagnosis reports the result of certain segment by
+ * this callback function.
+ *
+ * \param code Result code
+ * \param segment Number of the segment which was inspected. Numbering starts with 0 denoting the segment following the TimingMaster. The number is increased for each following segment.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_BC_DIAG
+ */
+typedef void (*Ucs_Bcd_ReportCb_t)(Ucs_Bcd_ResCode_t code,
+ uint8_t segment,
+ void *user_ptr);
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Network functions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature of result callback used by Ucs_Network_GetFrameCounter().
+ * \mns_res_inic{MOSTNetworkFrameCounter,MNSH3-MOSTNetworkFrameCounter523}
+ * \mns_ic_manual{ See also <i>User Manual</i>, section \ref P_UM_SYNC_AND_ASYNC_RESULTS. }
+ * \param frame_counter The MOST network frame count.\mns_name_inic{FrameCounter}
+ * \param reference Reference value that was passed to Mns_Network_GetFrameCounter().\mns_name_inic{Reference}
+ * \param lock Indicates if the TimingSlave device is locked to the MOST network. For a
+ TimingMaster device this value is always True.
+ * \param result Returned result of the operation
+ * \param user_pter User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ * \ingroup G_UCS_NET
+ */
+typedef void (*Ucs_Network_FrameCounterCb_t)(uint32_t reference,
+ uint32_t frame_counter,
+ bool frame_lock,
+ Ucs_StdResult_t result,
+ void * user_pointer);
+
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_INIC_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_jobs.h b/ucs2-lib/inc/ucs_jobs.h
new file mode 100644
index 0000000..7642279
--- /dev/null
+++ b/ucs2-lib/inc/ucs_jobs.h
@@ -0,0 +1,173 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Job classes
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_JOBS
+ * @{
+ */
+
+#ifndef UCS_JOBS_H
+#define UCS_JOBS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants */
+/*------------------------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+struct CJob_;
+typedef struct CJob_ CJob;
+
+/*! \brief Starts up the MOST Network
+ * \param self The instance
+ */
+typedef void (*Job_StartCb_t)(void *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJob Class */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Job state */
+typedef enum Job_State_
+{
+ JOB_S_STOPPED = 0U,
+ JOB_S_STARTED = 1U,
+ JOB_S_FINISHED = 2U
+
+} Job_State_t;
+
+/*! \brief Job result */
+typedef enum Job_Result_
+{
+ JOB_R_NA = 0U,
+ JOB_R_SUCCESS = 1U,
+ JOB_R_FAILED = 2U
+
+} Job_Result_t;
+
+/*! \brief Job class
+ * \details Definition of job class
+ */
+struct CJob_
+{
+ void *inst_ptr;
+ Job_StartCb_t start_fptr;
+ Job_State_t state;
+ Job_Result_t result;
+ CSingleSubject subject;
+};
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJob Methods */
+/*------------------------------------------------------------------------------------------------*/
+void Job_Ctor(CJob *self, Job_StartCb_t start_fptr, void *inst_ptr);
+void Job_Start(CJob *self, CSingleObserver *result_obs_ptr);
+void Job_Stop(CJob *self);
+void Job_SetResult(CJob *self, Job_Result_t result);
+Job_State_t Job_GetState(CJob *self);
+Job_Result_t Job_GetResult(CJob *self);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJobQ Class */
+/*------------------------------------------------------------------------------------------------*/
+struct CJobService_;
+typedef struct CJobService_ CJobService;
+
+/*! \brief JobQ class
+ * \details Definition of job queue class
+ */
+typedef struct CJobQ_
+{
+ Srv_Event_t event_id;
+ Job_State_t state;
+ Job_Result_t result;
+ CJob** job_list;
+ CJobService* job_service_ptr;
+
+ uint8_t index; /*! \brief The index of current job */
+ CSingleObserver result_obs; /*! \brief Required to get the job result */
+ CSingleSubject q_subject; /*! \brief Notifies the JobQ result */
+ CDlNode node; /*! \brief Required node to add JobQ to JobService class*/
+
+} CJobQ;
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJobQ Methods */
+/*------------------------------------------------------------------------------------------------*/
+void Jbq_Ctor(CJobQ *self, CJobService *job_service_ptr, Srv_Event_t event_id, CJob *job_list[]);
+void Jbq_Start(CJobQ *self, CSingleObserver *result_obs_ptr);
+void Jbq_Stop(CJobQ *self);
+void Jbq_Service(CJobQ *self);
+Srv_Event_t Jbq_GetEventId(CJobQ *self);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJobService Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Job Service class
+ * \details Definition of job service class
+ */
+struct CJobService_
+{
+ CBase *base_ptr;
+ CDlList list;
+ CService service;
+};
+
+/*------------------------------------------------------------------------------------------------*/
+/* CJobService Methods */
+/*------------------------------------------------------------------------------------------------*/
+void Jbs_Ctor(CJobService *self, CBase *base_ptr);
+void Jbs_RegisterJobQ(CJobService *self, CDlNode *job_q_node);
+void Jbs_TriggerEvent(CJobService *self, Srv_Event_t id);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_JOBS_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_lld_pb.h b/ucs2-lib/inc/ucs_lld_pb.h
new file mode 100644
index 0000000..268e564
--- /dev/null
+++ b/ucs2-lib/inc/ucs_lld_pb.h
@@ -0,0 +1,222 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of the low-level driver interface
+ *
+ * \addtogroup G_UCS_LLD
+ * @{
+ * \details UNICENS provides a certain set of functions which are only dedicated to the low-level driver.
+ * The low-level driver \em API is a set of functions which shall be used by the low-level driver.
+ * The low-level driver \em callbacks is a set of function that shall be implemented by the low-level driver.
+ * The low-level driver \em callbacks shall be assigned to the UNICENS initialization structure.
+ * During initialization UNICENS invokes the callback \ref Ucs_Lld_Callbacks_t "start_fptr" and
+ * passes the low-level driver \em API as pointer to \ref Ucs_Lld_Api_t.
+ * <!--
+ * \mns_ic_started{ See also Getting Started with \ref P_UM_STARTED_LLD. }
+ * \mns_ic_examples{ See also <i>Examples</i>, section \ref P_UM_EXAMPLE_LLD_01, \ref P_UM_EXAMPLE_LLD_02 and \ref P_UM_EXAMPLE_LLD_03. }
+ * -->
+ * @}
+ */
+
+#ifndef UCS_LLD_PB_H
+#define UCS_LLD_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+#include "ucs_memory_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*!
+ * \addtogroup G_UCS_LLD_TYPES
+ * @{
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Tx message object providing the raw port message byte stream */
+typedef struct Ucs_Lld_TxMsg_
+{
+ struct Ucs_Lld_TxMsg_ *custom_next_msg_ptr;/*!< \brief Shall be used by the LLD implementation to queue messages for
+ * asynchronous transmission
+ * \details UNICENS will set this value to \c NULL since only
+ * single messages are forwarded to the LLD. Within the transmit function
+ * it is recommended that the LLD queues the message for asynchronous
+ * transmission. Despite a driver's transmit function might signal busy for
+ * a short term the UNICENS library might forward multiple messages for
+ * transmission. If a driver works asynchronously (interrupt driven) it
+ * can easily use this pointer build a queue of waiting messages.
+ * Nonetheless, it is important that \ref Ucs_Lld_Api_t::tx_release_fptr
+ * "tx_release_fptr" is invoked for every message separately. The Interface
+ * between the UNICENS library and the LLD does only support single messages.
+ */
+ Ucs_Mem_Buffer_t *memory_ptr; /*!< \brief Points to the data buffer */
+
+} Ucs_Lld_TxMsg_t;
+
+/*! \brief Rx message object pointing to the raw port message byte stream. */
+typedef struct Ucs_Lld_RxMsg_
+{
+ uint8_t* data_ptr; /*!< \brief Points to a UNICENS allocated memory chunk. */
+ uint16_t data_size; /*!< \brief Size of the memory chunk in bytes. Valid values: 6..72. */
+
+} Ucs_Lld_RxMsg_t;
+
+/*!
+ * @}
+ * \addtogroup G_UCS_LLD_API
+ * @{
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Low-level driver API */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Allocates an Rx message object
+ * \param inst_ptr Reference to an internal UNICENS handler
+ * \param buffer_size The size in bytes of the received Rx message.
+ * Valid values: 6..72.
+ * \return The Rx message object or \c NULL if no message object is available. In the latter
+ * case the low-level driver can wait until Ucs_Lld_RxMsgAvailableCb_t() is invoked.
+ * The low-level driver is allowed to pre-allocate Rx messages with the maximum size
+ * of 72 bytes. After writing received data into Ucs_Lld_RxMsg_t::data_ptr the
+ * low-level driver must set Ucs_Lld_RxMsg_t::data_size to the actual message size.
+ * \warning
+ * The function will also return \c NULL if the requested \c buffer_size exceeds the valid range.
+ * In such a case the UNICENS cannot guarantee that Ucs_Lld_RxMsgAvailableCb_t() is
+ * called as expected. Received messages exceeding the valid range must be discarded by the LLD.
+ */
+typedef Ucs_Lld_RxMsg_t* (*Ucs_Lld_RxAllocateCb_t)(void *inst_ptr, uint16_t buffer_size);
+
+/*! \brief Frees an unused Rx message object
+ * \param inst_ptr Reference to internal UNICENS handler
+ * \param msg_ptr Reference to the unused Rx message object
+ */
+typedef void (*Ucs_Lld_RxFreeUnusedCb_t)(void *inst_ptr, Ucs_Lld_RxMsg_t *msg_ptr);
+
+/*! \brief Pass an Rx message to UNICENS
+ * \param inst_ptr Reference to internal UNICENS handler
+ * \param msg_ptr Reference to the Rx message object containing the received
+ * message.
+ */
+typedef void (*Ucs_Lld_RxReceiveCb_t)(void *inst_ptr, Ucs_Lld_RxMsg_t *msg_ptr);
+
+/*! \brief Notifies that the LLD no longer needs to access the Tx message object
+ * \param inst_ptr Reference to internal UNICENS handler
+ * \param msg_ptr Reference to the Tx message object which is no longer accessed
+ * by the low-level driver
+ */
+typedef void (*Ucs_Lld_TxReleaseCb_t)(void *inst_ptr, Ucs_Lld_TxMsg_t *msg_ptr);
+
+/*! \brief Initialization required for one communication channel (control or packet)
+ */
+typedef struct Ucs_Lld_Api_
+{
+ Ucs_Lld_RxAllocateCb_t rx_allocate_fptr; /*!< \brief Allocates an Rx message object */
+ Ucs_Lld_RxFreeUnusedCb_t rx_free_unused_fptr; /*!< \brief Frees an unused Rx message object */
+ Ucs_Lld_RxReceiveCb_t rx_receive_fptr; /*!< \brief Pass an Rx message to the UNICENS library */
+ Ucs_Lld_TxReleaseCb_t tx_release_fptr; /*!< \brief Notifies that the LLD no longer needs to access the Tx message object */
+
+} Ucs_Lld_Api_t;
+
+/*!
+ * @}
+ * \addtogroup G_UCS_LLD
+ * @{
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* LLD interface functions */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Notifies the LLD to start transmitting and receiving messages
+ * \param api_ptr Reference to UNICENS LLD interface
+ * \param inst_ptr Reference to internal UNICENS handler
+ * \param lld_user_ptr User defined pointer which is provided in \ref Ucs_Lld_Callbacks_t structure.
+ */
+typedef void (*Ucs_Lld_StartCb_t)(Ucs_Lld_Api_t* api_ptr, void *inst_ptr, void *lld_user_ptr);
+
+/*! \brief Notifies the LLD to stop/abort transmitting and receiving messages
+ * \details As soon as this function is called the low-level driver is not allowed
+ * to call any UNICENS API function.
+ * \param lld_user_ptr User defined pointer which is provided in \ref Ucs_Lld_Callbacks_t structure.
+ */
+typedef void (*Ucs_Lld_StopCb_t)(void *lld_user_ptr);
+
+/*! \brief Notifies the LLD to reset the INIC
+ * \details If this function is called the low-level driver is responsible to
+ * perform an INIC hardware reset.
+ * \param lld_user_ptr User defined pointer which is provided in \ref Ucs_Lld_Callbacks_t structure.
+ */
+typedef void (*Ucs_Lld_ResetInicCb_t)(void *lld_user_ptr);
+
+/*! \brief Callback function which is invoked as soon as port message objects are available again.
+ * \details By implementing this callback function the low-level driver can avoid polling for
+ * Rx message objects. The low-level driver should wait for the function call as soon
+ * as Ucs_Lld_RxAllocateCb_t() returns NULL. Only then it shall call those functions again.
+ * \param lld_user_ptr User defined pointer which is provided in \ref Ucs_Lld_Callbacks_t structure.
+ */
+typedef void (*Ucs_Lld_RxMsgAvailableCb_t)(void *lld_user_ptr);
+
+/*! \brief Callback function which is invoked to transmit a single message to the INIC
+ * \param msg_ptr Reference to a single Tx message.
+ * \param lld_user_ptr User defined pointer which is provided in \ref Ucs_Lld_Callbacks_t structure.
+ */
+typedef void (*Ucs_Lld_TxTransmitCb_t)(Ucs_Lld_TxMsg_t *msg_ptr, void *lld_user_ptr);
+
+/*!
+ * @}
+ * \addtogroup G_UCS_LLD_TYPES
+ * @{
+ */
+
+/*! \brief Set of functions implemented by the low-level driver
+ */
+typedef struct Ucs_Lld_Callbacks_
+{
+ void *lld_user_ptr; /*!< \brief Optional pointer that is passed when invoking a callback function which is assigned in Ucs_Lld_Callbacks_t. */
+ Ucs_Lld_StartCb_t start_fptr; /*!< \brief Callback function to initialize the low-level driver and
+ * start the transmission and reception of messages */
+ Ucs_Lld_StopCb_t stop_fptr; /*!< \brief Callback function to stop/abort the transmission and reception of messages */
+ Ucs_Lld_RxMsgAvailableCb_t rx_available_fptr; /*!< \brief Callback function which is invoked as soon as Rx message objects are available again */
+ Ucs_Lld_TxTransmitCb_t tx_transmit_fptr; /*!< \brief Callback function to transmit one or multiple messages to the INIC */
+
+} Ucs_Lld_Callbacks_t;
+
+/*! @} */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_LLD_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_lldpool.h b/ucs2-lib/inc/ucs_lldpool.h
new file mode 100644
index 0000000..77d8bd4
--- /dev/null
+++ b/ucs2-lib/inc/ucs_lldpool.h
@@ -0,0 +1,110 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of LLD Message Pool
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMF
+ * @{
+ */
+
+#ifndef UCS_LLDPOOL_H
+#define UCS_LLDPOOL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_base.h"
+#include "ucs_lld_pb.h"
+#include "ucs_message.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Number of LLD Tx handles dedicated to each FIFO */
+#define LLDP_NUM_HANDLES 5U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Internal LLD Tx message */
+typedef struct Lld_IntTxMsg_
+{
+ Ucs_Lld_TxMsg_t lld_msg; /*!< \brief Contains the public LLD Tx message
+ * \details This attribute needs to be the first one in this structure
+ */
+ CDlNode node; /*!< \brief Node required for queuing */
+ CMessage *msg_ptr; /*!< \brief Reference to the associated common message object, or
+ * \c NULL if the object is a command */
+ void *owner_ptr; /*!< \brief Points to the FIFO which owns the message object
+ * or NULL if the object is a command */
+
+} Lld_IntTxMsg_t;
+
+/*! \brief Internal LLD Rx message */
+typedef struct Lld_IntRxMsg_
+{
+ Ucs_Lld_RxMsg_t lld_msg; /*!< \brief Contains the public LLD Rx message
+ * \details This attribute needs to be the first one in this structure
+ */
+ CMessage *msg_ptr; /*!< \brief Reference to the associated common message object*/
+
+} Lld_IntRxMsg_t;
+
+/*! \brief The class CLldPool*/
+typedef struct CLldPool_
+{
+ CDlList list; /*!< \brief Points to the first available message in Tx pool */
+ Lld_IntTxMsg_t messages[LLDP_NUM_HANDLES];/*!< \brief Available messages in Tx pool */
+
+} CLldPool;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Function prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Lldp_Ctor(CLldPool *self, void *owner_ptr, void *ucs_user_ptr);
+extern void Lldp_ReturnTxToPool(CLldPool *self, Lld_IntTxMsg_t *msg_ptr);
+extern Lld_IntTxMsg_t* Lldp_GetTxFromPool(CLldPool *self);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_LLDPOOL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_memory.h b/ucs2-lib/inc/ucs_memory.h
new file mode 100644
index 0000000..927ed78
--- /dev/null
+++ b/ucs2-lib/inc/ucs_memory.h
@@ -0,0 +1,110 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of internal memory buffer
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_MEMORY
+ * @{
+ */
+
+#ifndef UCS_MEMORY_H
+#define UCS_MEMORY_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_memory_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* IAllocator Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback function which frees memory
+ * \param allocator Reference to the Mem_Allocator_t object
+ * \param mem_ptr Reference to memory chunk
+ * \param mem_info_ptr Customer specific information needed to free
+ * the related memory chunk
+ */
+typedef void (*Mem_Free_t)(void *allocator, void* mem_ptr, void* mem_info_ptr);
+
+/*! \brief Callback function which allocated memory
+ * \param allocator Reference to the Mem_Allocator_t object
+ * \param size Size of the demanded memory chunk
+ * \param mem_info_ptr Customer specific information needed to free
+ * the related memory chunk
+ * \return Reference to a memory chunk with a minimum size of \c size.
+ * Otherwise NULL.
+ */
+typedef void* (*Mem_Allocate_t)(void *allocator, uint16_t size, void** mem_info_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Interface IAllocator */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Interface which is needed to be implemented by a memory allocator */
+typedef struct IAllocator_
+{
+ void* base; /*!< Reference to the base class */
+ Mem_Allocate_t allocate_fptr; /*!< Callback function required to allocate memory */
+ Mem_Free_t free_fptr; /*!< Callback function required to free memory */
+
+} IAllocator;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Memory buffer */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Memory chunk comprising non public fields */
+typedef struct Mem_IntBuffer_
+{
+ Ucs_Mem_Buffer_t public_buffer; /*!< \brief Public attributes of memory buffer
+ * \details This has to be the first member in this
+ * struct
+ */
+ IAllocator *allocator_ptr; /*!< \brief Reference to the allocator which is
+ * required to free the memory chunk
+ */
+ void *mem_info_ptr; /*!< \brief Customer specific information needed to
+ * free the related memory chunk
+ */
+} Mem_IntBuffer_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_MEMORY_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_memory_pb.h b/ucs2-lib/inc/ucs_memory_pb.h
new file mode 100644
index 0000000..2495a78
--- /dev/null
+++ b/ucs2-lib/inc/ucs_memory_pb.h
@@ -0,0 +1,70 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of memory buffer and memory allocator
+ */
+/*!
+ * \addtogroup G_UCS_LLD_TYPES
+ * @{
+ */
+
+#ifndef UCS_MEMORY_PB_H
+#define UCS_MEMORY_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Memory buffer */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Memory chunk representing a message or part of a message. */
+typedef struct Ucs_Mem_Buffer_
+{
+ struct Ucs_Mem_Buffer_ *next_buffer_ptr; /*!< \brief Points to an additional memory buffer
+ * that belongs to the same message.
+ */
+ uint8_t *data_ptr; /*!< \brief Points to the data buffer */
+ uint16_t data_size; /*!< \brief Size of the data buffer */
+ uint16_t total_size; /*!< \brief Reserved for future use. Size of this and all concatenated data buffers */
+
+} Ucs_Mem_Buffer_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_MEMORY_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_message.h b/ucs2-lib/inc/ucs_message.h
new file mode 100644
index 0000000..6e4ea58
--- /dev/null
+++ b/ucs2-lib/inc/ucs_message.h
@@ -0,0 +1,182 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of class message
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_MESSAGE
+ * @{
+ */
+
+#ifndef UCS_MESSAGE_H
+#define UCS_MESSAGE_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_memory.h"
+#include "ucs_dl.h"
+#include "ucs_message_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Common macros */
+/*------------------------------------------------------------------------------------------------*/
+#define MSG_ADDR_INVALID 0U /*!< \brief The (source) address the INIC uses to declare an invalid source address.
+ * \details Invalid source addresses can be:
+ * - invalid messages from MOST: source_address = [0x0000..0x000F]
+ * - invalid messages from EHC: source_address != [0x0002, 0x0003]
+ * .
+ */
+#define MSG_ADDR_INIC 1U /*!< \brief The address of the local INIC */
+#define MSG_ADDR_EHC_CFG 2U /*!< \brief The address of the EHC configuration interface (ICM and RCM FIFO) */
+#define MSG_ADDR_EHC_APP 3U /*!< \brief The address of the EHC application interface (MCM FIFO) */
+
+#define MSG_LLRBC_DEFAULT 10U /*!< \brief The default LowLevelRetry BlockCount */
+#define MSG_LLRBC_MAX 100U/*!< \brief The maximum LowLevelRetry BlockCount */
+
+#define MSG_DEF_FBLOCK_ID 0xCCU /*! \brief Predefined FBlockID required to surround "new 16bit message id". */
+#define MSG_DEF_FUNC_ID_LSN 0xCU /*! \brief Predefined function id (least sign. nibble) required to surround "new 16bit message id". */
+#define MSG_DEF_OP_TYPE (UCS_OP_STATUS) /*! \brief Predefined OpType required to surround "new 16bit message id". */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/* necessary forward declaration */
+struct CMessage_;
+/*! \brief Common message class which provides MOST style message addressing */
+typedef struct CMessage_ CMessage;
+
+/*! \brief Assignable function which is invoked as soon as transmission
+ * of the message object is finished.
+ * \param self The instance
+ * \param msg_ptr Reference to the message object
+ * \param status Transmission status
+ */
+typedef void (*Msg_TxStatusCb_t)(void *self, Msg_MostTel_t *tel_ptr, Ucs_MsgTxStatus_t status);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Size in bytes of reserved message header */
+#define MSG_SIZE_RSVD_HEADER 24U
+/*! \brief Size in bytes of message payload */
+#define MSG_MAX_SIZE_PAYLOAD 45U
+/*! \brief Size in bytes of pre-allocated message buffer
+ * \details Size = 24(header) + 45(payload) + 3(stuffing) = 72 */
+#define MSG_SIZE_RSVD_BUFFER 72U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class CMessage */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class CMessage
+ * \details Common internal message class which embeds the public message attributes
+ */
+struct CMessage_
+{
+ Msg_MostTel_t pb_msg; /*!< \brief Public part which defines the MOST telegram
+ * structure. This attribute must be the first
+ * element inside the message structure.
+ */
+ uint8_t rsvd_buffer[MSG_SIZE_RSVD_BUFFER]; /*!< \brief Reserved memory space */
+ Mem_IntBuffer_t rsvd_memory; /*!< \brief Reserved memory which is needed at least for the
+ * Port message header (24 bytes) */
+ Mem_IntBuffer_t ext_memory; /*!< \brief Possible user memory */
+
+ uint8_t *start_ptr; /*!< \brief Points to the start of the message buffer */
+ uint8_t header_curr_idx; /*!< \brief Index of the end of the current header */
+ uint8_t header_curr_sz; /*!< \brief Current size of header in bytes */
+ uint8_t header_rsvd_sz; /*!< \brief Reserved size of header in bytes */
+
+ void *pool_ptr; /*!< \brief Point to the pool the message is allocated from and released to */
+ void *lld_handle_ptr; /*!< \brief Possible reference to another message object */
+ CDlNode node; /*!< \brief Node for usage in a doubly linked list */
+
+ Msg_TxStatusCb_t tx_status_fptr; /*!< \brief Pointer to Tx status callback */
+ void *tx_status_inst; /*!< \brief Reference to instance which needs Tx status notification */
+
+ bool tx_active; /*!< \brief Is \c true if the object is occupied by the LLD, otherwise \c false */
+ bool tx_bypass; /*!< \brief Is \c true if a message was queued as bypass message */
+
+};
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Msg_Ctor(CMessage *self);
+extern void Msg_Cleanup(CMessage *self);
+
+extern void Msg_ReserveHeader(CMessage *self, uint8_t header_sz);
+extern void Msg_PullHeader(CMessage *self, uint8_t header_sz);
+extern void Msg_PushHeader(CMessage *self, uint8_t header_sz);
+
+extern void Msg_NotifyTxStatus(CMessage *self, Ucs_MsgTxStatus_t status);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Properties */
+/*------------------------------------------------------------------------------------------------*/
+extern Msg_MostTel_t* Msg_GetMostTel(CMessage *self);
+
+extern uint8_t* Msg_GetHeader(CMessage *self);
+extern uint8_t Msg_GetHeaderSize(CMessage *self);
+extern Ucs_Mem_Buffer_t* Msg_GetMemTx(CMessage *self);
+
+extern void Msg_SetLldHandle(CMessage *self, void *handle);
+extern void *Msg_GetLldHandle(CMessage *self);
+extern void Msg_SetPoolReference(CMessage *self, void *pool_ptr);
+extern void *Msg_GetPoolReference(CMessage *self);
+
+extern CDlNode *Msg_GetNode(CMessage *self);
+
+extern void Msg_SetTxStatusHandler(CMessage *self, Msg_TxStatusCb_t callback_fptr, void *inst_ptr);
+extern void Msg_SetExtPayload(CMessage *self, uint8_t *payload_ptr, uint8_t payload_sz, void* mem_info_ptr);
+extern void Msg_SetTxActive(CMessage *self, bool active);
+extern bool Msg_IsTxActive(CMessage *self);
+extern void Msg_SetTxBypass(CMessage *self, bool bypass);
+extern bool Msg_IsTxBypass(CMessage *self);
+
+extern bool Msg_VerifyContent(CMessage *self);
+
+extern uint16_t Msg_GetAltMsgId(CMessage *self);
+extern void Msg_SetAltMsgId(CMessage *self, uint16_t alt_id);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_MESSAGE_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_message_pb.h b/ucs2-lib/inc/ucs_message_pb.h
new file mode 100644
index 0000000..53ec7fe
--- /dev/null
+++ b/ucs2-lib/inc/ucs_message_pb.h
@@ -0,0 +1,181 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of public message types
+ */
+
+#ifndef UCS_MESSAGE_PB_H
+#define UCS_MESSAGE_PB_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*!
+ * \addtogroup G_UCS_TRACE_TYPES
+ * @{
+ */
+/*------------------------------------------------------------------------------------------------*/
+/* Defines */
+/*------------------------------------------------------------------------------------------------*/
+#define UCS_ADDR_INTERNAL 0x0000U /* < \brief Internal transmission destination address
+ * \details Can be used for internal message transmission
+ * to avoid possible race conditions during
+ * recalculation of the own node address.
+ */
+#define UCS_ADDR_LOCAL_INIC 0x0001U /* < \brief Destination address of the local INIC */
+#define UCS_ADDR_BROADCAST_BLOCKING 0x03C8U /*!< \brief Blocking broadcast destination address */
+#define UCS_ADDR_BROADCAST_UNBLOCKING 0x03FFU /*!< \brief Unblocking broadcast destination address */
+#define UCS_ADDR_DEBUG 0x0FF0U /* < \brief Optional debug destination address */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Message transmission status for internal/debug use
+ */
+typedef enum Ucs_MsgTxStatus_
+{
+ UCS_MSG_STAT_OK = 0x00U, /*!< \brief Transmission succeeded */
+ UCS_MSG_STAT_ERROR_CFG_NO_RCVR = 0x01U, /*!< \brief No internal receiver exists */
+ UCS_MSG_STAT_ERROR_BF = 0x08U, /*!< \brief Buffer full */
+ UCS_MSG_STAT_ERROR_CRC = 0x09U, /*!< \brief CRC */
+ UCS_MSG_STAT_ERROR_ID = 0x0AU, /*!< \brief Corrupted identifiers */
+ UCS_MSG_STAT_ERROR_ACK = 0x0BU, /*!< \brief Corrupted PACK or CACK */
+ UCS_MSG_STAT_ERROR_TIMEOUT = 0x0CU, /*!< \brief TX timeout */
+ UCS_MSG_STAT_ERROR_FATAL_WT = 0x10U, /*!< \brief Wrong target */
+ UCS_MSG_STAT_ERROR_FATAL_OA = 0x11U, /*!< \brief Own node address */
+ UCS_MSG_STAT_ERROR_NA_TRANS = 0x18U, /*!< \brief Control channel was switched off and
+ * a pending transmission was canceled */
+ UCS_MSG_STAT_ERROR_NA_OFF = 0x19U, /*!< \brief Control channel not available */
+ UCS_MSG_STAT_ERROR_UNKNOWN = 0xFEU, /*!< \brief Unknown error status */
+ UCS_MSG_STAT_ERROR_SYNC = 0xFFU /*!< \brief Internal error which is notified if
+ * communication link with INIC is lost
+ */
+} Ucs_MsgTxStatus_t;
+
+/*! \brief Operation Types
+ */
+typedef enum Ucs_OpType_
+{
+ UCS_OP_SET = 0x0, /*!< \brief Operation Set (Property) */
+ UCS_OP_GET = 0x1, /*!< \brief Operation Get (Property) */
+ UCS_OP_SETGET = 0x2, /*!< \brief Operation SetGet (Property) */
+ UCS_OP_INC = 0x3, /*!< \brief Operation Increment (Property) */
+ UCS_OP_DEC = 0x4, /*!< \brief Operation Decrement (Property) */
+ UCS_OP_STATUS = 0xC, /*!< \brief Operation Status (Property) */
+
+ UCS_OP_START = 0x0, /*!< \brief Operation Start (Method) */
+ UCS_OP_ABORT = 0x1, /*!< \brief Operation Abort (Method) */
+ UCS_OP_STARTRESULT = 0x2, /*!< \brief Operation StartResult (Method) */
+ UCS_OP_PROCESSING = 0xB, /*!< \brief Operation Processing (Method) */
+ UCS_OP_RESULT = 0xC, /*!< \brief Operation Result (Method) */
+
+ UCS_OP_STARTACK = 0x8, /*!< \brief Operation StartAck (Method) */
+ UCS_OP_ABORTACK = 0x7, /*!< \brief Operation AbortAck (Method) */
+ UCS_OP_STARTRESULTACK = 0x6, /*!< \brief Operation StartResultAck (Method) */
+ UCS_OP_PROCESSINGACK = 0xA, /*!< \brief Operation ProcessingAck (Method) */
+ UCS_OP_RESULTACK = 0xD, /*!< \brief Operation ResultAck (Method) */
+
+ UCS_OP_GETINTERFACE = 0x5, /*!< \brief Operation GetInterface (Property/Method) */
+ UCS_OP_INTERFACE = 0xE, /*!< \brief Operation Interface (Property/Method) */
+ UCS_OP_ERROR = 0xF, /*!< \brief Operation Error (Property/Method) */
+ UCS_OP_ERRORACK = 0x9 /*!< \brief Operation ErrorAck (Property/Method) */
+
+} Ucs_OpType_t;
+
+/*! \brief MOST message id "FBlockID.InstID.FktID.OPType" */
+typedef struct Msg_MsgId_
+{
+ uint8_t fblock_id; /*!< \brief FBlockID */
+ uint8_t instance_id; /*!< \brief InstID */
+ uint16_t function_id; /*!< \brief FktID */
+ Ucs_OpType_t op_type; /*!< \brief Operation type */
+
+} Msg_MsgId_t;
+
+/*! \brief Retry options */
+typedef struct Msg_TxOptions_
+{
+ uint8_t llrbc; /*!< \brief Low-level retry block count performed by the INIC.
+ * \details The LLRBC are applicable for MCMs. ICMs don't care.
+ * Values exceeding the maximum value are be corrected
+ * by the INIC silently to the maximum value.
+ * Valid range: 0..100
+ */
+ uint8_t cancel_id; /*!< \brief Either "0" or label for a group of dependent telegrams.
+ * \details The value determines the required action if the transmission
+ * has failed.
+ * Valid range:
+ * - 0: Only the failed telegram will is removed from the FIFO.
+ * - 1..255: All telegrams with the same cancel_id as a failed telegram
+ * will be removed from the FIFO queue.
+ */
+
+} Msg_TxOptions_t;
+
+/*! \brief Most telegram data */
+typedef struct Msg_TelData_
+{
+ uint8_t tel_id; /*!< \brief Telegram id which indicates the telegram as part of
+ * segmented message or as single transfer. */
+ uint8_t tel_len; /*!< \brief The telegram length.
+ * I.e. the number of telegram bytes starting at address
+ * which is referred in \c tel_data_ptr. The INIC will add
+ * \em one in case of \"tel_id = 1..3\".
+ */
+ uint8_t tel_cnt; /*!< \brief The message count indexing the telegram within a segmented
+ * message.
+ * The respective tel_cnt is moved by the INIC to \"DATA[0]\"
+ * in case of \"tel_id = 1..3\". Otherwise it is ignored.
+ */
+ uint8_t *tel_data_ptr; /*!< \brief Points to telegram data. */
+
+} Msg_TelData_t;
+
+/*! \brief Common MOST message */
+typedef struct Msg_MostTel_
+{
+ uint16_t destination_addr; /*!< \brief MOST destination address */
+ uint16_t source_addr; /*!< \brief MOST source address */
+
+ Msg_MsgId_t id; /*!< \brief MOST message id "FBlockID.InstID.FktID.OPType" */
+ Msg_TxOptions_t opts; /*!< \brief Message transmission options */
+ Msg_TelData_t tel; /*!< \brief MOST telegram data */
+ void *info_ptr; /*!< \brief Possible reference to additional data */
+
+} Msg_MostTel_t;
+
+/*! @} */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_MESSAGE_PB_H */
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_mgr.h b/ucs2-lib/inc/ucs_mgr.h
new file mode 100644
index 0000000..719b622
--- /dev/null
+++ b/ucs2-lib/inc/ucs_mgr.h
@@ -0,0 +1,121 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the CManager class
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_MGR
+ * @{
+ */
+
+#ifndef UCS_MGR_H
+#define UCS_MGR_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_fsm.h"
+#include "ucs_inic.h"
+#include "ucs_net.h"
+#include "ucs_base.h"
+#include "ucs_jobs.h"
+#include "ucs_nodedis.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief The default value of the desired packet bandwidth for startup command */
+#define MGR_PACKET_BW_DEFAULT 52U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Manager Class
+ * \details Implements the UNICENS Manager State Machine
+ */
+typedef struct CManager_
+{
+ bool listening; /*!< \brief Listening is active */
+ CFsm fsm; /*!< \brief State machine object */
+ CJobService job_service;
+ CSingleObserver job_q_obs;
+ CJobQ *current_q_ptr;
+
+ CJobQ job_q_startup;
+ CJobQ job_q_force_startup;
+ /* CJobQ job_q_shutdown; */
+ CJob job_startup;
+ CJob job_leave_forced_na;
+ /* CJob job_shutdown; */
+
+ CJob *list_startup[2];
+ CJob *list_force_startup[3];
+ /* CJob *list_shutdown[2]; */
+
+ CMaskedObserver event_observer; /*!< \brief Observes init complete event */
+ CMaskedObserver nwstatus_mobs; /*!< \brief Observe network status */
+
+ uint16_t packet_bw; /*!< \brief The desired packet bandwidth */
+ CBase *base_ptr; /*!< \brief Reference to base services */
+ CInic *inic_ptr; /*!< \brief Reference to class CInic */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to network management */
+ CNodeDiscovery *nd_ptr; /*!< \brief Reference to node discovery */
+
+ CSingleObserver startup_obs; /*!< \brief Startup result callback */
+ /* CSingleObserver shutdown_obs; */ /*!< \brief Shutdown result callback */
+ CSingleObserver force_na_obs; /*!< \brief ForceNA result callback */
+ bool initial; /*!< \brief Is \c true for the initial network status "available" */
+
+} CManager;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Mgr_Ctor(CManager *self, CBase *base_ptr, CInic *inic_ptr, CNetworkManagement *net_ptr, CNodeDiscovery *nd_ptr, uint16_t packet_bw);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_MGR_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_misc.h b/ucs2-lib/inc/ucs_misc.h
new file mode 100644
index 0000000..fb383cb
--- /dev/null
+++ b/ucs2-lib/inc/ucs_misc.h
@@ -0,0 +1,153 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the library module which contains miscellaneous helper functions.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_MISC
+ * @{
+ */
+
+#ifndef UCS_MISC_H
+#define UCS_MISC_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Standard library functions */
+/*------------------------------------------------------------------------------------------------*/
+/* parasoft suppress item MISRA2004-19_7 reason "function-like macros allowed for stdlib and helper functions" */
+
+/*! \def MISC_MEM_SET
+ * \brief Macro to encapsulate memset function
+ * \details By defining the macro UCS_MEM_SET the application is able to specify its own memset
+ * function. If the macro is not defined UNICENS internal memset function
+ * Misc_MemSet() is used.
+ * \param dest Pointer to the block of memory to fill
+ * \param value Value to be set
+ * \param size Number of bytes to be set to the value.
+ */
+#ifdef UCS_MEM_SET
+#define MISC_MEM_SET(dest, value, size) (UCS_MEM_SET((dest), (value), (size)))
+#else
+#define MISC_MEM_SET(dest, value, size) (Misc_MemSet((dest), (value), (size)))
+#endif
+
+/*! \def MISC_MEM_CPY
+ * \brief Macro to encapsulate memcpy function
+ * \details By defining the macro UCS_MEM_CPY the application is able to specify its own memcpy
+ * function. If the macro is not defined UNICENS internal memcpy function
+ * Misc_MemCpy() is used.
+ * \param dest Pointer to the destination array where the content is to be copied
+ * \param src Pointer to the source of data to be copied
+ * \param size Number of bytes to copy
+ */
+#ifdef UCS_MEM_CPY
+#define MISC_MEM_CPY(dest, src, size) (UCS_MEM_CPY((dest), (src), (size)))
+#else
+#define MISC_MEM_CPY(dest, src, size) (Misc_MemCpy((dest), (src), (size)))
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Helper Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Macro to avoid compiler warning "Unused Parameter" */
+#define MISC_UNUSED(p) ((p) = (p))
+
+/*! \brief High Byte of 16-bit value */
+#define MISC_HB(value) ((uint8_t)((uint16_t)(value) >> 8))
+
+/*! \brief Low Byte of 16-bit value */
+#define MISC_LB(value) ((uint8_t)((uint16_t)(value) & (uint16_t)0xFF))
+
+/*! \brief Big-Endian to target 16 bit */
+#define MISC_DECODE_WORD(w_ptr, msb_ptr) (*(w_ptr) = \
+ (uint16_t)((uint16_t)((uint16_t)(msb_ptr)[0] << 8) | (uint16_t)(msb_ptr)[1]))
+
+/*! \brief Big-Endian to target 32 bit */
+#define MISC_DECODE_DWORD(dw_ptr, msb_ptr) (*(dw_ptr) = \
+ (uint32_t)((uint32_t)((uint32_t)(msb_ptr)[0] << 24) | \
+ (uint32_t)((uint32_t)(msb_ptr)[1] << 16) | \
+ (uint32_t)((uint32_t)(msb_ptr)[2] << 8) | (uint32_t)(msb_ptr)[3]))
+
+/*! \brief Checks if a value is inside a certain range */
+#define MISC_IS_VALUE_IN_RANGE(val, min, max) ((((val) >= (min)) && ((val) <= (max))) ? true : false)
+
+/*! \brief Checks if the given size is a multiple of 4. If not, the given size is corrected
+ * by that macro.
+ */
+#define MISC_QUADLET_ALGINED_SIZE(size) (((((size)+4U)-1U)/4U)*4U)
+
+/* parasoft unsuppress item MISRA2004-19_7 reason "function-like macros allowed for stdlib and helper functions" */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Misc_MemSet(void *dst_ptr, int32_t value, uint32_t size);
+extern void Misc_MemCpy(void *dst_ptr, void *src_ptr, uint32_t size);
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*!
+ * \def UCS_MEM_SET
+ * \brief Customer assignment of memset function
+ * \details By defining the macro UCS_MEM_SET the application is able to specify its own memset
+ * function to be used by UNICENS. If the macro is not set will use byte wise write operations.
+ * \ingroup G_UCS_MISC_CFG
+ */
+#ifndef UCS_MEM_SET
+#define UCS_MEM_SET
+#endif
+
+/*!
+ * \def UCS_MEM_CPY
+ * \brief Customer assignment of memcpy function
+ * \details By defining the macro UCS_MEM_CPY the application is able to specify its own memcpy
+ * function to be used by UNICENS. If the macro is not set UNICENS will use byte wise copy operations.
+ * \ingroup G_UCS_MISC_CFG
+ */
+#ifndef UCS_MEM_CPY
+#define UCS_MEM_CPY
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_MISC_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_net.h b/ucs2-lib/inc/ucs_net.h
new file mode 100644
index 0000000..4e53c0b
--- /dev/null
+++ b/ucs2-lib/inc/ucs_net.h
@@ -0,0 +1,179 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Network Management.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_NET
+ * @{
+ */
+
+#ifndef UCS_NET_H
+#define UCS_NET_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_inic.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_fsm.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of function Net_IsOwnAddress() */
+typedef enum Net_IsOwnAddrResult_
+{
+ NET_IS_OWN_ADDR_NODE, /*!< \brief Is own node position address or own logical node address */
+ NET_IS_OWN_ADDR_GROUP, /*!< \brief Is own group address */
+ NET_IS_OWN_ADDR_NONE /*!< \brief Is foreign address */
+
+} Net_IsOwnAddrResult_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the attach service. */
+typedef struct Net_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CInic *inic_ptr; /*!< \brief Reference to INIC instance */
+
+} Net_InitData_t;
+
+/*! \brief Parameter structure for MOST Network Status */
+typedef struct Net_NetworkStatusParam_
+{
+ /*! \brief Indicates if parameters have been changed since last update */
+ uint16_t change_mask;
+ /*! \brief Indicates if the MOST network is available and ready for control/packet
+ data transmission */
+ Ucs_Network_Availability_t availability;
+ /*! \brief Indicates the sub state to parameter Availability */
+ Ucs_Network_AvailInfo_t avail_info;
+ /*! \brief Indicates the transition cause of the MOST network going from Available to
+ NotAvailable or vice versa */
+ Ucs_Network_AvailTransCause_t avail_trans_cause;
+ /*! \brief Contains events relating to the functionality for the MOST Network Interface */
+ uint16_t events;
+ /*! \brief Current size of packet bandwidth */
+ uint16_t packet_bw;
+ /*! \brief Current node address of the device */
+ uint16_t node_address;
+ /*! \brief Node position of the device */
+ uint8_t node_position;
+ /*! \brief Node position of last device in the ring */
+ uint8_t max_position;
+
+} Net_NetworkStatusParam_t;
+
+/*! \brief Structure holds the parameters of property INIC.MOSTNetworkStatus */
+typedef struct Net_NetworkStatus_
+{
+ /*! \brief Parameters of MOST Network Status */
+ Net_NetworkStatusParam_t param;
+ /*! \brief Observe MOST Network status in INIC module */
+ CObserver observer;
+ /*! \brief Subject to notify MOST Network Status the first time a observer has been added */
+ CSubject pre_subject;
+ /*! \brief Subject to notify MOST Network Status */
+ CSubject subject;
+
+} Net_NetworkStatus_t;
+
+/*! \brief Parameter structure for MOST Network Configuration */
+typedef struct Net_NetworkConfigParam_
+{
+ /*! \brief Indicates if parameters have been changed since last update */
+ uint16_t change_mask;
+ /*! \brief Current node address of the device */
+ uint16_t node_address;
+ /*! \brief Current group address of the device */
+ uint16_t group_address;
+ /*! \brief Low-level retry block count */
+ uint8_t llrbc;
+
+} Net_NetworkConfigParam_t;
+
+/*! \brief Structure holds the parameters of property INIC.MOSTNetworkConfiguration */
+typedef struct Net_NetworkConfiguration_
+{
+ /*! \brief Parameters of MOST Network Configuration */
+ Net_NetworkConfigParam_t param;
+ /*! \brief Observe MOST Network Configuration in INIC module */
+ CObserver observer;
+ /*! \brief Subject to notify MOST Network Configuration the first time a observer has been added */
+ CSubject pre_subject;
+ /*! \brief Subject to notify MOST Network Configuration */
+ CSubject subject;
+
+} Net_NetworkConfiguration_t;
+
+/*! \brief Class structure of the Network Management. */
+typedef struct CNetworkManagement_
+{
+ /*! \brief Parameters of property INIC.MOSTNetworkStatus */
+ Net_NetworkStatus_t network_status;
+ /*! \brief Parameters of property INIC.MOSTNetworkConfig. */
+ Net_NetworkConfiguration_t network_configuration;
+ /*! \brief Reference to INIC instance */
+ CInic *inic_ptr;
+ /*! \brief Reference to base instance */
+ CBase *base_ptr;
+ /*! \brief Service instance for the scheduler */
+ CService net_srv;
+
+} CNetworkManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CNetworkManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Net_Ctor(CNetworkManagement *self, Net_InitData_t *init_ptr);
+extern void Net_AddObserverNetworkStatus(CNetworkManagement *self, CMaskedObserver *obs_ptr);
+extern void Net_DelObserverNetworkStatus(CNetworkManagement *self, CMaskedObserver *obs_ptr);
+extern void Net_AddObserverNetworkConfig(CNetworkManagement *self, CMaskedObserver *obs_ptr);
+extern void Net_DelObserverNetworkConfig(CNetworkManagement *self, CMaskedObserver *obs_ptr);
+extern Net_IsOwnAddrResult_t Net_IsOwnAddress(CNetworkManagement *self, uint16_t address);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_NET_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_nodedis.h b/ucs2-lib/inc/ucs_nodedis.h
new file mode 100644
index 0000000..bd4b676
--- /dev/null
+++ b/ucs2-lib/inc/ucs_nodedis.h
@@ -0,0 +1,197 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CNodeDiscovery.
+ *
+ * \cond UCS_INTERNAL_DOC
+ */
+#ifndef UCS_NODEDIS_H
+#define UCS_NODEDIS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_exc.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#define ND_NUM_NODES 40U /*!< \brief max number of nodes */
+
+
+
+/*! \brief Function signature of node evaluation callback used by Node Discovery service.
+ *
+ * The Node Discovery service announces the signature of each node it has found to the
+ * application via the evaluation function. In this function the application
+ * decides how the Node Discovery service shall proceed with the node.
+ * The application maintains two lists:
+ *
+ * <dl>
+ * <dt> *set_list* </dt>
+ * <dd> Contains the signatures of the nodes the system shall contain
+ *
+ * <dt> *device_list* </dt>
+ * <dd> Contains the signatures of the nodes detected in the system
+ * </dl>
+ *
+ * The evaluation has to follow these rules:
+ * - If the node is not part of the *set_list*, it is regarded as unknown (\ref UCS_ND_CHK_UNKNOWN)
+ * and will be ignored.
+ * - If the node is part of the *set_list* and is not yet in the *device_list*, the Node Discovery
+ * Service shall try to add the node to network (\ref UCS_ND_CHK_WELCOME).
+ * - If the node is already part of the *device_list*, there are two possibilities: the node in the
+ * *device_list* experienced a reset or there are two nodes with the same signature. Evaluation
+ * result is \ref UCS_ND_CHK_UNIQUE. The Node Discovery service will perform further tests.
+ *
+ * \param self The instance
+ * \param signature Signature of the respective node
+ * \returns UCS_ND_CHK_WELCOME Node is ok, try to add it to the network.
+ * \returns UCS_ND_CHK_UNIQUE Test if this node is unique.
+ * \returns UCS_ND_CHK_UNKNOWN Node is unknown, no further action.
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+typedef Ucs_Nd_CheckResult_t (*Nd_EvalCb_t)(void *self, Ucs_Signature_t *signature);
+
+/*! \brief Function signature of result callback used by Node Discovery service.
+ *
+ * The Node Discovery service reports the result of each node and some system events by
+ * this callback function.
+ *
+ * \note The parameter <b>signature</b> will be NULL, if parameter <b>code</b> is
+ * \ref UCS_ND_RES_STOPPED, \ref UCS_ND_RES_NETOFF or \ref UCS_ND_RES_ERROR.
+ *
+ * \param self The instance
+ * \param code Result code
+ * \param signature Signature of the respective node
+ * \ingroup G_UCS_NODE_DISCOVERY
+ */
+typedef void (*Nd_ReportCb_t)(void *self, Ucs_Nd_ResCode_t code, Ucs_Signature_t *signature);
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure decribing a node. */
+typedef struct Nd_Node_
+{
+ /*bool available; */ /*!< \brief node available? *//*! i todo RWI: */
+ /*uint16_t node_address; */ /*!< \brief node address used for welcome command */
+ /*uint8_t result; */ /*!< \brief result parameter of Welcome.Result message */
+ /*uint8_t version; */ /*!< \brief version parameter of Hello and Welcome messages */
+ Ucs_Signature_t signature; /*!< \brief signature of the node */
+ CDlNode node; /*!< \brief enables listing */
+
+} Nd_Node;
+
+
+/*! \brief Initialization structure of the Node Discovery service. */
+typedef struct Nd_InitData_
+{
+ void *inst_ptr; /*!< \brief The instance used when invoking the callback functions */
+ Nd_ReportCb_t report_fptr; /*!< \brief Report callback function */
+ Nd_EvalCb_t eval_fptr; /*!< \brief Evaluation callback function */
+
+} Nd_InitData_t;
+
+
+
+
+/*! \brief Structure of class CNodeDiscovery. */
+typedef struct CNodeDiscovery_
+{
+ CInic *inic; /*!< \brief Reference to CInic object */
+ CExc *exc; /*!< \brief Reference to CExc object */
+ CBase *base; /*!< \brief Reference to CBase object */
+
+ bool running; /*!< \brief Indicates th Node Discovery is running. */
+ CSingleObserver nd_hello; /*!< \brief Observes the Hello result */
+ CSingleObserver nd_welcome; /*!< \brief Observes the Welcome result */
+ CSingleObserver nd_signature; /*!< \brief Observes the Signature result */
+ CSingleObserver nd_init; /*!< \brief Observes the DeviceInit result */
+
+ CMaskedObserver nd_terminate; /*!< \brief Observes events leading to termination */
+
+ CObserver nd_nwstatus; /*!< \brief Observes the MOST Network status */
+
+ CFsm fsm; /*!< \brief Node Discovery state machine */
+ CService service; /*!< \brief Service instance for the scheduler */
+
+ CTimer timer; /*!< \brief timer for monitoring messages */
+
+
+ CDlList new_list; /*!< \brief list of detected nodes */
+ CDlList unused_list; /*!< \brief list of unused node elements */
+ Nd_Node nodes[ND_NUM_NODES]; /*!< \brief device nodes */
+ Ucs_Signature_t current_sig; /*!< \brief node which is checked currently */
+
+ Exc_WelcomeResult_t welcome_result; /*!< \brief buffer for welcome result */
+ Exc_SignatureStatus_t signature_status; /*!< \brief buffer for signature status */
+
+ bool stop_request; /*!< \brief indicates a request to stop node discovery */
+ bool hello_mpr_request; /*!< \brief indicates an Hello.Get request due to an MPR event*/
+ bool hello_neton_request; /*!< \brief indicates an Hello.Get request due to an NetOn event*/
+ bool neton; /*!< \brief indicates Network availability */
+
+ void *cb_inst_ptr; /*!< \brief Instance required for callback functions */
+ Nd_ReportCb_t report_fptr; /*!< \brief Report callback function */
+ Nd_EvalCb_t eval_fptr; /*!< \brief Node evaluation callback function */
+
+}CNodeDiscovery;
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+void Nd_Ctor(CNodeDiscovery *self,
+ CInic *inic,
+ CBase *base,
+ CExc *exc,
+ Nd_InitData_t *init_ptr);
+
+
+extern Ucs_Return_t Nd_Start(CNodeDiscovery *self);
+extern Ucs_Return_t Nd_Stop(CNodeDiscovery *self);
+extern void Nd_InitAll(CNodeDiscovery *self);
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_NODEDIS_H */
+/*!
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_nodeobserver.h b/ucs2-lib/inc/ucs_nodeobserver.h
new file mode 100644
index 0000000..30ec5cd
--- /dev/null
+++ b/ucs2-lib/inc/ucs_nodeobserver.h
@@ -0,0 +1,101 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the CNodeObserver class
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_NODEOBSERVER
+ * @{
+ */
+
+#ifndef UCS_NODEOBSERVER_H
+#define UCS_NODEOBSERVER_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_nodedis.h"
+#include "ucs_rtm.h"
+#include "ucs_nodeobserver_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants */
+/*------------------------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief CNodeObserver Class
+ * \details Implements the NodeObserver
+ */
+typedef struct CNodeObserver_
+{
+ CBase *base_ptr; /*!< \brief Reference to base services */
+ CNodeDiscovery *nd_ptr; /*!< \brief Reference to node discovery */
+ CRouteManagement *rtm_ptr; /*!< \brief Reference to route management */
+ Ucs_Mgr_InitData_t init_data; /*!< \brief Initialization data describing nodes and routes*/
+ CMaskedObserver event_observer; /*!< \brief Observes init complete event */
+
+ Ucs_Signature_t eval_signature;
+ Ucs_Nd_CheckResult_t eval_action;
+ Ucs_Rm_Node_t *eval_node_ptr;
+ CTimer wakeup_timer; /*!< \brief Timer wakes up processing, sets current
+ * node available and restarts NodeDiscovery
+ */
+
+} CNodeObserver;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Nobs_Ctor(CNodeObserver *self, CBase *base_ptr, CNodeDiscovery *nd_ptr, CRouteManagement *rtm_ptr, Ucs_Mgr_InitData_t *init_ptr);
+extern Ucs_Nd_CheckResult_t Nobs_OnNdEvaluate(void *self, Ucs_Signature_t *signature_ptr);
+extern void Nobs_OnNdReport(void *self, Ucs_Nd_ResCode_t code, Ucs_Signature_t *signature_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_NODEOBSERVER_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_nodeobserver_pb.h b/ucs2-lib/inc/ucs_nodeobserver_pb.h
new file mode 100644
index 0000000..a76e1ee
--- /dev/null
+++ b/ucs2-lib/inc/ucs_nodeobserver_pb.h
@@ -0,0 +1,105 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the CNodeObserver class
+ */
+/*!
+ * \addtogroup G_UCS_MGR
+ * @{
+ */
+
+#ifndef UCS_NODEOBSERVER_PB_H
+#define UCS_NODEOBSERVER_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_rm_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*! \brief Manager report codes */
+typedef enum Ucs_MgrReport_
+{
+ UCS_MGR_REP_IGNORED_UNKNOWN = 0, /*!< \brief A discovered node is ignored due to a wrong signature,
+ * a missing entry in the \ref Ucs_Mgr_InitData_t "nodes_list_ptr",
+ * or since the desired node address is not within the following range:
+ * 0x200..0x2FF, 0x500..0xEFF.
+ */
+ UCS_MGR_REP_IGNORED_DUPLICATE = 1, /*!< \brief A discovered node is ignored due since it is a duplicate
+ * of an alredy welcomed node.
+ */
+ UCS_MGR_REP_AVAILABLE = 2, /*!< \brief A discovered node was successfully "welcomed"
+ * in the network.
+ */
+ UCS_MGR_REP_NOT_AVAILABLE = 3 /*!< \brief A previously welcomed node became invalid and is
+ * no longer accessible in the network.
+ */
+} Ucs_MgrReport_t;
+
+/*! \brief Optional callback function that reports events on ignored, welcomed and lost nodes.
+ * \param code Report code
+ * \param node_address The desired node_address of the node which is defined in it's signature.
+ * \param node_ptr Reference to the node object which is part of the \ref Ucs_Mgr_InitData_t "nodes_list_ptr".
+ * The reference is \c NULL if \c code is \c UCS_MGR_REP_IGNORED_UNKNOWN or
+ * \c UCS_MGR_REP_IGNORED_DUPLICATE.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr".
+ */
+typedef void (*Ucs_MgrReportCb_t)(Ucs_MgrReport_t code, uint16_t node_address, Ucs_Rm_Node_t *node_ptr, void *user_ptr);
+
+/*! \brief The initialization data of the Manager */
+typedef struct Ucs_Mgr_InitData_
+{
+ bool enabled; /*!< \brief If set to \c false the application must
+ * handle network startup, node discovery and
+ * rooting by hand.
+ */
+ uint16_t packet_bw; /*!< \brief The desired packet bandwidth.\mns_name_inic{PacketBW} */
+
+ Ucs_Rm_Route_t *routes_list_ptr; /*!< \brief Reference to a list of routes */
+ uint16_t routes_list_size; /*!< \brief Number of routes in the list */
+
+ Ucs_Rm_Node_t *nodes_list_ptr; /*!< \brief Reference to the list of nodes */
+ uint16_t nodes_list_size; /*!< \brief Number of nodes in the list */
+
+ Ucs_MgrReportCb_t report_fptr; /*!< \brief Optional callback function notifying node events */
+
+} Ucs_Mgr_InitData_t;
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* ifndef UCS_NODEOBSERVER_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_nsm.h b/ucs2-lib/inc/ucs_nsm.h
new file mode 100644
index 0000000..7c2be23
--- /dev/null
+++ b/ucs2-lib/inc/ucs_nsm.h
@@ -0,0 +1,200 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Node Scripting Management.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_NSM
+ * @{
+ */
+#ifndef UCS_NSM_H
+#define UCS_NSM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_ret_pb.h"
+#include "ucs_rsm.h"
+#include "ucs_nsm_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This enumerator specifies the kind of result - Target or Transmission. */
+typedef enum Ns_ResultType_
+{
+ /*!< \brief Specifies the result of the scripting from target device (typically INIC function-specific error) */
+ NS_RESULT_TYPE_TGT_SCRIPT = 0x00U,
+ /*!< \brief Specifies the result of the remote synchronization from target device (typically INIC function-specific error) */
+ NS_RESULT_TYPE_TGT_SYNC = 0x01U,
+ /*!< \brief Specifies the transmission error information that occurred on the MOST network. */
+ NS_RESULT_TYPE_TX = 0x02U
+
+} Ns_ResultType_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Detailed information used for I2C results. */
+typedef struct Nsm_ResultDetails_
+{
+ /*! \brief Specifies the type of the current asynchronous result.
+ * \details The following briefly describes the different types of results available:
+ * - \b NS_RESULT_TYPE_TGT: target results, typically INIC function-specific error found on target device. \n Refer to \em inic_result to get the detailed information.
+ * - \b NS_RESULT_TYPE_TX: transmission results, typically transmission error on the MOST network. \n Refer to \em tx_result to get the transmission information.
+ */
+ Ns_ResultType_t result_type;
+ /*! \brief Holds the status of the transmission. */
+ Ucs_MsgTxStatus_t tx_result;
+ /*! \brief Holds the results of the target device. */
+ Ucs_StdResult_t inic_result;
+
+} Nsm_ResultDetails_t;
+
+/*! \brief Stores the NodeScript result for internal use. */
+typedef struct Nsm_Result_
+{
+ /*! \brief Result code. */
+ Ucs_Ns_ResultCode_t code;
+ /*! \brief Detailed information on the returned result. */
+ Nsm_ResultDetails_t details;
+
+} Nsm_Result_t;
+
+/*! \brief Stores data required by NSM during initialization. */
+typedef struct Nsm_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CTransceiver * rcm_ptr; /*!< \brief Reference to RCM transceiver instance */
+ CRemoteSyncManagement * rsm_ptr; /*!< \brief Reference to RSM instance */
+
+} Nsm_InitData_t;
+
+/*! \brief Structure holds parameters for API locking */
+typedef struct Script_ApiLock_
+{
+ /*! \brief Flag to lock the API */
+ bool api;
+ /*! \brief API locking instance for Scripting function */
+ CApiLocking rcm_api;
+ /*! \brief Observer used for locking timeouts for Scripting function */
+ CSingleObserver observer;
+
+} Script_ApiLock_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for the results of the Scripting Manager.
+ * \param user_ptr Reference to the called user instance.
+ * \param result Result of the scripting operation.
+ */
+typedef void (*Nsm_ResultCb_t)(void * user_ptr, Nsm_Result_t result);
+
+/*! \brief Function signature used for the results of the Scripting Manager.
+ * \param tel_ptr Reference to the message object.
+ * \param user_ptr Reference to the user argument.
+ * \return Returns \c true to discard the message and free it to the pool (no-pass). Otherwise, returns
+ * \c false (pass).
+ */
+typedef bool (*Nsm_RxFilterCb_t)(Msg_MostTel_t *tel_ptr, void *user_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class structure of the Node Scripting Management. */
+typedef struct CNodeScriptManagement_
+{
+ /*!< \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*!< \brief Reference to RCM instance */
+ CTransceiver * rcm_ptr;
+ /*!< \brief Reference to RSM instance */
+ CRemoteSyncManagement * rsm_ptr;
+ /*!< \brief Reference to the timer management */
+ CTimerManagement * tm_ptr;
+ /*!< \brief Timer for pausing script */
+ CTimer script_pause;
+ /*!< \brief Service instance for the scheduler */
+ CService nsm_srv;
+ /*!< \brief Observer used to monitor UCS initialization result */
+ CMaskedObserver ucsinit_observer;
+ /*!< \brief Observer used to monitor UCS termination event */
+ CMaskedObserver ucstermination_observer;
+ /*!< \brief Flag to lock the API */
+ Script_ApiLock_t lock;
+ /*!< \brief Current reference to the script table */
+ Ucs_Ns_Script_t * curr_sript_ptr;
+ /*!< \brief Current result for internal use */
+ Nsm_Result_t curr_internal_result;
+ /*!< \brief Current script size */
+ uint8_t curr_sript_size;
+ /*!< \brief Current script pause */
+ uint16_t curr_pause;
+ /*!< \brief Flag to determine whether the private api is used or not */
+ bool is_private_api_used;
+ /*!< \brief Reference to the user instance */
+ void * curr_user_ptr;
+ /*!< \brief RX filter callback function */
+ Nsm_RxFilterCb_t curr_rxfilter_fptr;
+ /*!< \brief Private result callback function pointer for current script */
+ Nsm_ResultCb_t curr_pv_result_fptr;
+ /*!< \brief Current reference to the Node used in public API */
+ Ucs_Rm_Node_t * curr_node_ptr;
+ /*!< \brief Public result callback function pointer for current script */
+ Ucs_Ns_ResultCb_t curr_pb_result_fptr;
+ /*!< \brief Target address of the device to be looked for */
+ uint16_t target_address;
+
+} CNodeScriptManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CRemoteSyncManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Nsm_Ctor(CNodeScriptManagement * self, Nsm_InitData_t * init_ptr);
+extern Ucs_Return_t Nsm_Run_Pb(CNodeScriptManagement * self, Ucs_Rm_Node_t * node_ptr, Ucs_Ns_ResultCb_t pb_result_fptr);
+extern Ucs_Return_t Nsm_Run_Pv(CNodeScriptManagement * self, Ucs_Ns_Script_t * script, uint8_t size, void * user_ptr, Nsm_RxFilterCb_t rx_filter_fptr, Nsm_ResultCb_t result_fptr);
+extern bool Nsm_OnRcmRxFilter(void *self, Msg_MostTel_t *tel_ptr);
+extern bool Nsm_IsLocked(CNodeScriptManagement * self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_NSM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_nsm_pb.h b/ucs2-lib/inc/ucs_nsm_pb.h
new file mode 100644
index 0000000..9062360
--- /dev/null
+++ b/ucs2-lib/inc/ucs_nsm_pb.h
@@ -0,0 +1,136 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Node Script Management.
+ */
+
+#ifndef UCS_NSM_PB_H
+#define UCS_NSM_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_rm_pv.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of the Node Script Management.
+ * \ingroup G_UCS_SCRIPTING
+ */
+typedef enum Ucs_Ns_ResultCode_
+{
+ UCS_NS_RES_SUCCESS = 0x00U, /*!< \brief Transmission of script(s) was successful. */
+ UCS_NS_RES_ERROR = 0x01U /*!< \brief Transmission of script(s) failed. */
+
+} Ucs_Ns_ResultCode_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure of a ConfigMsg used in Node-Script.
+ * \ingroup G_UCS_SCRIPTING
+ */
+typedef struct Ucs_Ns_ConfigMsg_
+{
+ /*! \brief FBlockId of the config msg. */
+ uint8_t FBlockId;
+ /*! \brief InstId of the config msg. */
+ uint8_t InstId;
+ /*! \brief FunktId of the config msg. */
+ uint16_t FunktId;
+ /*! \brief OpCode of the config msg. */
+ uint8_t OpCode;
+ /*! \brief Data length. */
+ uint8_t DataLen;
+ /*! \brief Reference to the Data */
+ uint8_t * DataPtr;
+
+} Ucs_Ns_ConfigMsg_t;
+
+/*! \brief Structure of a node-script used to configure a remote node.
+ * \attention The Node Scripting module is designed and intended for the use of \b I2C and \b GPIO commands only. That is, using the Scripting for any other FBlock INIC commands
+ * (for example MOST, MediaLB, USB, Streaming, Connections, etc.) is expressly \b prohibited.
+ * \ingroup G_UCS_SCRIPTING
+ */
+typedef struct Ucs_Ns_Script_
+{
+ /*! \brief Specifies the pause which shall be set before sending
+ * the configuration message.
+ */
+ uint16_t pause;
+ /*! \brief Command to be transmitted. */
+ Ucs_Ns_ConfigMsg_t * send_cmd;
+ /*! \brief Expected result. */
+ Ucs_Ns_ConfigMsg_t * exp_result;
+
+} Ucs_Ns_Script_t;
+
+/*! \brief Configuration structure of a Node.
+ *
+ * \attention Use the \ref UCS_ADDR_LOCAL_DEV macro to address your local device when specifying routes to/from It.
+ * \n The following address ranges are supported:
+ * - [0x10 ... 0x2FF]
+ * - [0x500 ... 0xFEF]
+ * - UCS_ADDR_LOCAL_DEV
+ * \ingroup G_UCS_ROUTING_TYPES
+ */
+typedef struct Ucs_Rm_Node_
+{
+ /*! \brief node signature. */
+ Ucs_Signature_t * signature_ptr;
+ /*! \brief Reference to a list of configuration scripts. */
+ Ucs_Ns_Script_t * script_list_ptr;
+ /*! \brief size of the scripts table. */
+ uint8_t script_list_size;
+ /*! \brief Internal information of this node object. */
+ Ucs_Rm_NodeInt_t internal_infos;
+
+} Ucs_Rm_Node_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for the results of the Scripting Manager.
+ * \param node_ptr Reference to the node instance
+ * \param result Result of the scripting operation.
+ * \param ucs_user_ptr User reference for API callback functions.
+ * \ingroup G_UCS_SCRIPTING
+ */
+typedef void (*Ucs_Ns_ResultCb_t)(Ucs_Rm_Node_t * node_ptr, Ucs_Ns_ResultCode_t result, void *ucs_user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_NSM_PB_H */
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_obs.h b/ucs2-lib/inc/ucs_obs.h
new file mode 100644
index 0000000..7ef2d83
--- /dev/null
+++ b/ucs2-lib/inc/ucs_obs.h
@@ -0,0 +1,195 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the observer library module. The module consists of the two
+ * classes CSubject and CObserver.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_OBS
+ * @{
+ */
+
+#ifndef UCS_OBS_H
+#define UCS_OBS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+#include "ucs_dl.h"
+#include "ucs_ret_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for callback functions which notifies the observers.
+ * \param self Instance pointer
+ * \param data_ptr Reference to optional data
+ */
+typedef void (*Obs_UpdateCb_t)(void *self, void *data_ptr);
+
+/*! \brief Function signature used for callback functions which notifies the single-observers.
+ * \param self Instance pointer
+ * \param data_ptr Reference to optional data
+ */
+typedef void (*Sobs_UpdateCb_t)(void *self, void *data_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Standard return values of the subject class. */
+typedef enum Sub_Ret_
+{
+ SUB_OK, /*!< \brief No error */
+ SUB_DELAYED, /*!< \brief Operation is queued since notification is still active */
+ SUB_ALREADY_ADDED, /*!< \brief Observer already added */
+ SUB_UNKNOWN_OBSERVER, /*!< \brief Unknown observer */
+ SUB_INVALID_OPERATION /*!< \brief Invalid operation */
+
+} Sub_Ret_t;
+
+/*! \brief Standard return values of the single-subject class. */
+typedef enum Ssub_Ret_
+{
+ SSUB_OK, /*!< \brief No error */
+ SSUB_ALREADY_ADDED, /*!< \brief Observer already added */
+ SSUB_UNKNOWN_OBSERVER /*!< \brief Unknown observer */
+
+} Ssub_Ret_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class structure of observers which are notified by subjects. */
+typedef struct CObserver_
+{
+ CDlNode node; /*!< \brief Node element to be able to add observer to list */
+ void *inst_ptr; /*!< \brief Reference to instance used by update_fptr() */
+ Obs_UpdateCb_t update_fptr; /*!< \brief Callback function to update the observer */
+ bool valid; /*!< \brief Used for queued remove operation */
+
+} CObserver;
+
+/*! \brief Class structure of subjects. */
+typedef struct CSubject_
+{
+ CDlList list; /*!< \brief Doubly linked list to manage observers */
+ CDlList add_list; /*!< \brief List to manage delayed add operations */
+ uint8_t num_observers; /*!< \brief Number of added observers */
+ bool notify; /*!< \brief Signals that the notification is in progress */
+ bool changed; /*!< \brief Signals that an add- or a remove-operation
+ has been queued */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CSubject;
+
+/*! \brief Class structure of a single-observer which is notified by a single-subject. */
+typedef struct CSingleObserver_
+{
+ void *inst_ptr; /*!< \brief Reference to instance used by update_fptr() */
+ Obs_UpdateCb_t update_fptr; /*!< \brief Callback function to update the observer */
+
+} CSingleObserver;
+
+/*! \brief Class structure of a single-subject. */
+typedef struct CSingleSubject_
+{
+ CSingleObserver *observer_ptr; /*!< \brief Reference to the assigned single-observer */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+ uint32_t user_mask; /*!< \brief Current user mask to the single observer */
+
+} CSingleSubject;
+
+/*! \brief Class structure of masked observers which are notified by subjects. */
+typedef struct CMaskedObserver_
+{
+ CObserver parent; /*!< \brief Parent class instance */
+ uint32_t notification_mask; /*!< \brief Notification bitmask */
+
+} CMaskedObserver;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CSubject */
+/*------------------------------------------------------------------------------------------------*/
+extern void Sub_Ctor(CSubject *self, void *ucs_user_ptr);
+extern Sub_Ret_t Sub_AddObserver(CSubject *self, CObserver *obs_ptr);
+extern Sub_Ret_t Sub_RemoveObserver(CSubject *self, CObserver *obs_ptr);
+extern void Sub_Notify(CSubject *self, void *data_ptr);
+extern uint8_t Sub_GetNumObservers(CSubject *self);
+extern Sub_Ret_t Sub_SwitchObservers(CSubject *sub_target, CSubject *sub_source);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CObserver */
+/*------------------------------------------------------------------------------------------------*/
+extern void Obs_Ctor(CObserver *self, void *inst_ptr, Obs_UpdateCb_t update_fptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CSingleSubject */
+/*------------------------------------------------------------------------------------------------*/
+extern void Ssub_Ctor(CSingleSubject *self, void *ucs_user_ptr);
+extern Ssub_Ret_t Ssub_AddObserver(CSingleSubject *self, CSingleObserver *obs_ptr);
+extern void Ssub_RemoveObserver(CSingleSubject *self);
+extern void Ssub_Notify(CSingleSubject *self, void *data_ptr, bool auto_remove);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CSingleObserver */
+/*------------------------------------------------------------------------------------------------*/
+extern void Sobs_Ctor(CSingleObserver *self, void *inst_ptr, Sobs_UpdateCb_t update_fptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CMaskedObserver */
+/*------------------------------------------------------------------------------------------------*/
+extern void Mobs_Ctor(CMaskedObserver *self,
+ void *inst_ptr,
+ uint32_t notification_mask,
+ Obs_UpdateCb_t update_fptr);
+extern void Mobs_SetNotificationMask(CMaskedObserver *self, uint32_t mask);
+extern uint32_t Mobs_GetNotificationMask(CMaskedObserver *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Additional prototypes of class CSubject used in combination with CMaskedObserver */
+/*------------------------------------------------------------------------------------------------*/
+extern Sub_Ret_t Msub_AddObserver(CSubject *self, CMaskedObserver *obs_ptr);
+extern Sub_Ret_t Msub_RemoveObserver(CSubject *self, CMaskedObserver *obs_ptr);
+extern void Msub_Notify(CSubject *self, void *data_ptr, uint32_t notification_mask);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_OBS_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmchannel.h b/ucs2-lib/inc/ucs_pmchannel.h
new file mode 100644
index 0000000..300c00a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmchannel.h
@@ -0,0 +1,175 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Port Message Channel
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMC
+ * @{
+ */
+
+#ifndef UCS_PMCHANNEL_H
+#define UCS_PMCHANNEL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_lld_pb.h"
+#include "ucs_lldpool.h"
+#include "ucs_pool.h"
+#include "ucs_base.h"
+#include "ucs_message.h"
+#include "ucs_pmp.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+#define PMCH_POOL_SIZE_RX_MIN 10U /*!< \brief Minimal size of Rx pool which is shared by all FIFOs */
+#define PMCH_POOL_SIZE_RX_OPT 35U /*!< \brief Optimal size of Rx pool which is shared by all FIFOs */
+
+#define PMCH_MCM_CREDITS_OPT 21U /*!< \brief Optimal number of credits configured for MCM FIFO */
+#define PMCH_MCM_THRESHOLD_OPT 8U /*!< \brief Optimal threshold configured for MCM FIFO */
+
+#define PMCH_FIFO_CREDITS_OPT 5U /*!< \brief Optimal number of credits configured for conventional FIFOs */
+#define PMCH_FIFO_THRESHOLD_OPT 4U /*!< \brief Optimal threshold configured for conventional FIFO */
+
+#define PMCH_FIFO_CREDITS_MIN 3U /*!< \brief Minimal number of credits configured for conventional FIFOs */
+#define PMCH_FIFO_THRESHOLD_MIN 2U /*!< \brief Minimal threshold configured for conventional FIFO */
+
+/* required rules */
+#if defined(MNSL_FOOTPRINT_TINY) && defined(MNSL_CHANNEL_POOL_SIZE_RX)
+# error Forbidden combination of macros MNSL_FOOTPRINT_TINY and MNSL_CHANNEL_POOL_SIZE_RX
+#endif
+
+#ifdef MNSL_CHANNEL_POOL_SIZE_RX
+# if (MNSL_CHANNEL_POOL_SIZE_RX < PMCH_POOL_SIZE_RX_MIN)
+# error MNSL_CHANNEL_POOL_SIZE_RX must be at least 10
+# endif
+#endif
+
+/*! \def MNSL_CHANNEL_POOL_SIZE_RX
+ * \brief MNSL configuration that defines the number of pre-allocated Rx messages which are shared by all FIFOs.
+ * Valid values: 35...65535. Default value: 35.
+ *
+ * \def PMCH_POOL_SIZE_RX
+ * \brief Defines the number of pre-allocated Rx messages which are shared by all FIFOs.
+ */
+#ifdef MNSL_FOOTPRINT_TINY
+# define PMCH_POOL_SIZE_RX (PMCH_POOL_SIZE_RX_MIN)
+# define PMCH_MCM_CREDITS (PMCH_FIFO_CREDITS_MIN)
+# define PMCH_FIFO_CREDITS (PMCH_FIFO_CREDITS_MIN)
+# define PMCH_MCM_THRESHOLD (PMCH_FIFO_THRESHOLD_MIN)
+# define PMCH_FIFO_THRESHOLD (PMCH_FIFO_THRESHOLD_MIN)
+# define MNSL_CHANNEL_POOL_SIZE_RX (PMCH_POOL_SIZE_RX_MIN)
+#elif defined MNSL_CHANNEL_POOL_SIZE_RX
+# define PMCH_POOL_SIZE_RX ((uint16_t)MNSL_CHANNEL_POOL_SIZE_RX)
+# define PMCH_MCM_CREDITS (PMCH_FIFO_CREDITS_MIN)
+# define PMCH_FIFO_CREDITS (PMCH_FIFO_CREDITS_MIN)
+# define PMCH_MCM_THRESHOLD (PMCH_FIFO_THRESHOLD_MIN)
+# define PMCH_FIFO_THRESHOLD (PMCH_FIFO_THRESHOLD_MIN)
+#else
+# define PMCH_POOL_SIZE_RX (PMCH_POOL_SIZE_RX_OPT)
+# define PMCH_MCM_CREDITS (PMCH_MCM_CREDITS_OPT)
+# define PMCH_FIFO_CREDITS (PMCH_FIFO_CREDITS_OPT)
+# define PMCH_MCM_THRESHOLD (PMCH_MCM_THRESHOLD_OPT)
+# define PMCH_FIFO_THRESHOLD (PMCH_FIFO_THRESHOLD_OPT)
+# define MNSL_CHANNEL_POOL_SIZE_RX (PMCH_POOL_SIZE_RX_OPT)
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+typedef void (*Pmch_OnRxMsg_t)(void *fifo_ptr, CMessage *msg_ptr);
+typedef void (*Pmch_OnTxRelease_t)(void *fifo_ptr, Ucs_Lld_TxMsg_t *handle_ptr);
+
+/*! \brief Initialization structure of the Base Module. */
+typedef struct Pmch_InitData_
+{
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+ Ucs_Lld_Callbacks_t lld_iface; /*!< \brief LLD callback functions */
+ Pmch_OnTxRelease_t tx_release_fptr; /*!< \brief Callback which releases a FIFO dedicated LLD buffer */
+
+} Pmch_InitData_t;
+
+/*! \brief Combination of callback and instance for a receiving FIFO */
+typedef struct Pmch_Receiver_
+{
+ Pmch_OnRxMsg_t rx_fptr; /*!< \brief Reference to an Rx callback function */
+ void *inst_ptr; /*!< \brief Reference to the instance which shall be
+ * passed to the callback function */
+} Pmch_Receiver_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class attributes */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure of a PMS object */
+typedef struct CPmChannel_
+{
+ Pmch_InitData_t init_data; /*!< \brief Copy of initialization data */
+
+ Lld_IntRxMsg_t lld_rx_msgs[PMCH_POOL_SIZE_RX]; /*!< \brief Pre-allocated LLD Rx message objects */
+ CMessage rx_msgs[PMCH_POOL_SIZE_RX]; /*!< \brief Pre-allocated Rx message objects */
+ CPool rx_msgs_pool; /*!< \brief Pre-allocated Rx message pool */
+ bool rx_trigger_available; /*!< \brief Triggers LLD callback function if a buffer
+ * is available again.
+ */
+ bool lld_active; /*!< \brief Determines whether the LLD is running */
+ Ucs_Lld_Api_t ucs_iface; /*!< \brief PMS function pointers */
+
+ Pmch_Receiver_t receivers[PMP_MAX_NUM_FIFOS]; /*!< \brief Registered FIFOs for Rx */
+
+} CPmChannel;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class methods */
+/*------------------------------------------------------------------------------------------------*/
+/* component creation */
+extern void Pmch_Ctor(CPmChannel *self, const Pmch_InitData_t *init_ptr);
+extern void Pmch_Initialize(CPmChannel *self);
+extern void Pmch_Uninitialize(CPmChannel *self);
+extern void Pmch_RegisterReceiver(CPmChannel *self, Pmp_FifoId_t fifo_id, Pmch_OnRxMsg_t rx_fptr, void *inst_ptr);
+extern void Pmch_Transmit(CPmChannel *self, Ucs_Lld_TxMsg_t *msg_ptr);
+extern void Pmch_ReturnRxToPool(void *self, CMessage *msg_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PMCHANNEL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmcmd.h b/ucs2-lib/inc/ucs_pmcmd.h
new file mode 100644
index 0000000..3fdc5d1
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmcmd.h
@@ -0,0 +1,90 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of class CPmCommand
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PM_CMD
+ * @{
+ */
+
+#ifndef UCS_PMCMD_H
+#define UCS_PMCMD_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_types_cfg.h"
+#include "ucs_memory.h"
+#include "ucs_lldpool.h"
+#include "ucs_pmp.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class CPmCommand */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class CPmCommand */
+typedef struct CPmCommand_
+{
+ Lld_IntTxMsg_t tx_obj; /*!< \brief Required LLD Tx structure, must be first attribute */
+ uint8_t data[10]; /*!< \brief Reserved memory space */
+ Ucs_Mem_Buffer_t memory; /*!< \brief Public memory structure */
+ bool reserved; /*!< \brief \c true if the command is in use, otherwise \c false. */
+ bool trigger; /*!< \brief \c true if the command is triggered, otherwise \c false. */
+
+} CPmCommand;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Pmcmd_Ctor(CPmCommand *self, Pmp_FifoId_t fifo, Pmp_MsgType_t type);
+extern Ucs_Lld_TxMsg_t* Pmcmd_GetLldTxObject(CPmCommand *self);
+extern bool Pmcmd_Reserve(CPmCommand *self);
+extern void Pmcmd_Release(CPmCommand *self);
+extern void Pmcmd_SetContent(CPmCommand *self, uint8_t sid, uint8_t ext_type,
+ uint8_t ext_code, uint8_t add_data_ptr[], uint8_t add_data_sz);
+extern void Pmcmd_UpdateContent(CPmCommand *self, uint8_t sid, uint8_t ext_type, uint8_t ext_code);
+extern void Pmcmd_SetTrigger(CPmCommand *self, bool trigger);
+extern bool Pmcmd_IsTriggered(CPmCommand *self);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_PMCMD_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmevent.h b/ucs2-lib/inc/ucs_pmevent.h
new file mode 100644
index 0000000..d12d8e0
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmevent.h
@@ -0,0 +1,85 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Port Message Event Handler
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMEH
+ * @{
+ */
+
+#ifndef UCS_PMEV_H
+#define UCS_PMEV_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_pmfifos.h"
+#include "ucs_base.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class attributes */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Structure of a Port Message Event Handler */
+typedef struct CPmEventHandler_
+{
+ CBase *base_ptr; /*!< \brief Reference to base object */
+ CPmFifos *fifos_ptr; /*!< \brief Reference to FIFOs handler */
+ CObserver observer; /*!< \brief Observer of PMS events */
+ CMaskedObserver sys_observer; /*!< \brief Observer of system events */
+
+} CPmEventHandler;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Pmev_Ctor(CPmEventHandler *self, CBase *base_ptr, CPmFifos *fifos_ptr);
+extern void Pmev_Start(CPmEventHandler *self);
+extern void Pmev_Stop(CPmEventHandler *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PMEV_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmfifo.h b/ucs2-lib/inc/ucs_pmfifo.h
new file mode 100644
index 0000000..0f7f68a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmfifo.h
@@ -0,0 +1,230 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Port Message FIFO
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMF
+ * @{
+ */
+
+#ifndef UCS_PMFIFO_H
+#define UCS_PMFIFO_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_base.h"
+#include "ucs_lld_pb.h"
+#include "ucs_message.h"
+#include "ucs_encoder.h"
+#include "ucs_pmp.h"
+#include "ucs_lldpool.h"
+#include "ucs_pmchannel.h"
+#include "ucs_pmcmd.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Number of LLD Tx handles dedicated to each FIFO */
+#define FIFO_TX_HANDLES 5U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback function which is invoked when receiving an Rx message
+ * \param self The Instance (of the host)
+ * \param msg_ptr The Rx message
+ */
+typedef void (*Fifo_OnRxMsg_t)(void *self, CMessage *msg_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of class Port Message FIFO */
+typedef struct Fifo_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base module */
+ CPmChannel *channel_ptr; /*!< \brief Points to channel object which is needed to communicate with
+ * the driver */
+ IEncoder *tx_encoder_ptr; /*!< \brief Encoder for Tx messages */
+ IEncoder *rx_encoder_ptr; /*!< \brief Encoder for Rx messages */
+ Fifo_OnRxMsg_t rx_cb_fptr; /*!< \brief Callback function invoked for Rx */
+ void *rx_cb_inst; /*!< \brief Instance which is referred when invoking rx_cb_fptr */
+
+} Fifo_InitData_t;
+
+/*! \brief Initialization structure of class Port Message FIFO */
+typedef struct Fifo_Config_
+{
+ Pmp_FifoId_t fifo_id; /*!< \brief Identifier of message FIFO.
+ * \details It is required that the fifo_id has the same value as
+ * specified in PMP.
+ */
+ uint8_t rx_credits; /*!< \brief Number of Rx credits, i.e. reserved Rx messages */
+ uint8_t rx_threshold; /*!< \brief Number of Rx credits which are acknowledged in a single status.
+ * \details The value needs to be smaller or equal than \c rx_credits.
+ * Valid values are:
+ * - 0,1: Single message acknowledge
+ * - 2..rx_credits: Implicit acknowledge is triggered after
+ * the specified number of messages.
+ */
+ uint8_t tx_wd_timeout; /*!< \brief Idle timeout in x100ms. Formerly known as watchdog timeout */
+ uint16_t tx_wd_timer_value; /*!< \brief Timer value used to trigger the watchdog in ms */
+ uint8_t rx_ack_timeout; /*!< \brief Rx status timeout in x100ms. */
+ uint8_t rx_busy_allowed; /*!< \brief Number of allowed RxStatus busy responds. 0..14, or 0xF (infinite) */
+
+} Fifo_Config_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief The synchronization status */
+typedef enum Fifo_SyncState_
+{
+ FIFO_S_UNSYNCED_INIT,
+ FIFO_S_SYNCING,
+ FIFO_S_UNSYNCED_BUSY,
+ FIFO_S_UNSYNCED_READY,
+ FIFO_S_SYNCED,
+ FIFO_S_UNSYNCING
+
+} Fifo_SyncState_t;
+
+/*! \brief The class CPmFifo*/
+typedef struct CPmFifo_
+{
+ Fifo_InitData_t init; /*!< \brief Initialization data */
+ Fifo_Config_t config; /*!< \brief Configuration data */
+
+ CService service; /*!< \brief Service object */
+ Fifo_SyncState_t sync_state; /*!< \brief Synchronization state of the FIFO */
+ CSubject sync_state_subject; /*!< \brief Notification of changed synchronization state */
+ uint8_t sync_params[4]; /*!< \brief Synchronization parameters */
+ uint8_t sync_cnt; /*!< \brief Counts the number of synchronization attempts */
+
+ struct CPmFifo_wd_
+ {
+ CTimer timer; /*!< \brief The timer object */
+ CPmCommand wd_cmd; /*!< \brief The watchdog command message */
+ uint16_t timer_value; /*!< \brief The internal timer value used by PMC to trigger the watchdog */
+ bool request_started; /*!< \brief Is used to check if the INIC responds with a status before the
+ * next Cmd.REQUEST_STATUS is triggered.
+ */
+ } wd;
+
+ struct CPmFifo_rx_
+ {
+ CDlList queue; /*!< \brief Message queue containing all incoming messages */
+
+ IEncoder *encoder_ptr; /*!< \brief Encoder for Rx messages */
+ Fifo_OnRxMsg_t on_complete_fptr; /*!< \brief Callback function invoked for Rx */
+ void *on_complete_inst; /*!< \brief Instance which is referred when invoking rx_cb_fptr */
+
+ uint8_t ack_threshold; /*!< \brief Number of unacknowledged Rx credits */
+ uint8_t ack_last_ok_sid; /*!< \brief Latest SID which was acknowledged with "success" */
+ uint8_t expected_sid; /*!< \brief The next expected Rx message SeqId */
+ uint8_t busy_num; /*!< \brief The number of currently processing data messages */
+
+ bool wait_processing; /*!< \brief If set: Wait until transmission of e.g. NACK has finished
+ * before continuing with further Rx message processing.
+ * The flag is used if a status must be sent explicitly.
+ */
+ CPmCommand status; /*!< \brief Rx status channel control */
+
+ } rx;
+
+ struct CPmFifo_tx_
+ {
+ CDlList waiting_queue; /*!< \brief Queue containing all outgoing messages */
+ CDlList pending_q; /*!< \brief Queue containing all messages waiting for Tx status */
+ IEncoder *encoder_ptr; /*!< \brief Encoder for Tx messages */
+ uint8_t credits; /*!< \brief Remaining Tx credits */
+
+ CLldPool lld_pool; /*!< \brief Pool of LLD Tx messages, used for data messages */
+
+ CPmh pm_header; /*!< \brief Temporary header which is used to build the FIFO data messages*/
+ CPmCommand cancel_cmd; /*!< \brief Tx cancel command message */
+ CPmCommand sync_cmd; /*!< \brief Sync command message */
+
+ uint8_t sid_next_to_use; /*!< \brief SID that shall be used for the next transmission */
+ uint8_t sid_last_completed; /*!< \brief Latest SID that was acknowledged by the INIC */
+ uint8_t current_sid; /*!< \brief Tracks the latest valid FIFO status SID received from the INIC */
+ Pmp_StatusType_t current_type; /*!< \brief Tracks the latest valid FIFO status type received from the INIC */
+ uint8_t current_code; /*!< \brief Tracks the latest valid FIFO status code received from the INIC */
+
+ bool status_waiting_release; /*!< \brief Is \c true if status notification wasn't completed due to messages
+ * which are not yet released by the LLD.
+ */
+ bool cancel_all_running; /*!< \brief Is \c true during pending command CANCEL_ALL. This command is required
+ * if the front-most message is segmented which requires to discard all
+ * belonging segments (same \c cancel_id) after the CANCEL_ALL was completed.
+ */
+ uint8_t failure_status; /*!< \brief Stores the Tx status until the message is canceled */
+ uint8_t failure_sid; /*!< \brief Stores the SID of the last cancelled data message */
+ } tx;
+
+} CPmFifo;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Function Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Fifo_Ctor(CPmFifo *self, const Fifo_InitData_t *init_ptr, const Fifo_Config_t *config_ptr);
+extern void Fifo_Stop(CPmFifo *self, Fifo_SyncState_t new_state, bool allow_notification);
+extern void Fifo_Cleanup(CPmFifo *self);
+
+extern void Fifo_Synchronize(CPmFifo *self);
+extern void Fifo_Unsynchronize(CPmFifo *self);
+extern Fifo_SyncState_t Fifo_GetState(CPmFifo *self);
+extern void Fifo_AddStateObserver(CPmFifo *self, CObserver *obs_ptr);
+extern void Fifo_RemoveStateObserver(CPmFifo *self, CObserver *obs_ptr);
+
+/* Rx interface */
+extern void Fifo_RxReleaseMsg(CPmFifo *self, CMessage *msg_ptr);
+
+/* Tx interface */
+extern void Fifo_Tx(CPmFifo *self, CMessage *msg_ptr, bool bypass);
+extern void Fifo_TxOnRelease(void *self, Ucs_Lld_TxMsg_t *handle_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PMFIFO_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmfifos.h b/ucs2-lib/inc/ucs_pmfifos.h
new file mode 100644
index 0000000..fb815dc
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmfifos.h
@@ -0,0 +1,128 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CPmFifos
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMFIFOS
+ * @{
+ */
+
+#ifndef UCS_PMFIFOS_H
+#define UCS_PMFIFOS_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_base.h"
+#include "ucs_pmfifo.h"
+#include "ucs_pmchannel.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+#define FIFOS_SYNC_TIMEOUT 50U /*!< \brief Synchronization timeout in milliseconds */
+#define FIFOS_SYNC_RETRIES 40U /*!< \brief Maximum number of synchronization retries after timeout */
+#define FIFOS_UNSYNC_TIMEOUT 200U /*!< \brief Un-synchronization timeout in milliseconds */
+#define FIFOS_UNSYNC_RETRIES 0U /*!< \brief Un-synchronization retries */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief The synchronization status of all FIFOs */
+typedef enum Fifos_SyncState_
+{
+ FIFOS_S_UNSYNCED, /*!< \brief Not all FIFOs are synchronized */
+ FIFOS_S_SYNCING, /*!< \brief FIFOs synchronization has started */
+ FIFOS_S_SYNCED, /*!< \brief All FIFOs are synchronized */
+ FIFOS_S_UNSYNCING /*!< \brief FIFOs un-synchronization has started */
+
+} Fifos_SyncState_t;
+
+/*! \brief PMS Events */
+typedef enum Fifos_Event_
+{
+ FIFOS_EV_SYNC_LOST = 0, /*!< \brief Synchronization of at least one FIFO is lost */
+ FIFOS_EV_SYNC_ESTABLISHED = 1, /*!< \brief Synchronization of all FIFOs is established */
+ FIFOS_EV_SYNC_FAILED = 2, /*!< \brief The initial synchronization of FIFOs failed */
+ FIFOS_EV_UNSYNC_COMPLETE = 3, /*!< \brief Un-synchronization of all FIFOs has succeeded */
+ FIFOS_EV_UNSYNC_FAILED = 4 /*!< \brief Un-synchronization of all FIFOs has failed */
+
+} Fifos_Event_t;
+
+/*! \brief The class CPmFifos*/
+typedef struct CPmFifos_
+{
+ CBase *base_ptr; /*!< \brief Reference to base object */
+ uint8_t ucs_inst_id; /*!< \brief UNICENS instance ID */
+ CPmChannel *channel_ptr; /*!< \brief UNICENS instance ID */
+
+ CPmFifo *fifos[PMP_MAX_NUM_FIFOS]; /*!< \brief Reference to assigned FIFOs */
+
+ CObserver obs_icm; /*!< \brief Observes ICM synchronization state */
+ CObserver obs_rcm; /*!< \brief Observes ICM synchronization state */
+ CObserver obs_mcm; /*!< \brief Observes MCM synchronization state */
+ Fifos_SyncState_t state; /*!< \brief The Overall synchronization state */
+ uint8_t sync_cnt; /*!< \brief The current count of synchronization command */
+
+ uint8_t cmd_retries; /*!< \brief The number of sync/un-sync retries */
+ uint16_t cmd_timeout; /*!< \brief The the timeout to retry sync/un-sync */
+ bool unsync_initial; /*!< \brief Specifies if un-sync complete shall un-initialize the channel */
+
+ CSubject event_subject; /*!< \brief Subject to report synchronization result */
+ CTimer init_timer; /*!< \brief Timer elapses on synchronization timeout */
+
+} CPmFifos;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Function prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Fifos_Ctor(CPmFifos *self, CBase *base_ptr, CPmChannel *channel_ptr, CPmFifo *icm_fifo_ptr, CPmFifo *mcm_fifo_ptr, CPmFifo *rcm_fifo_ptr);
+extern void Fifos_AddEventObserver(CPmFifos *self, CObserver *obs_ptr);
+extern void Fifos_RemoveEventObserver(CPmFifos *self, CObserver *obs_ptr);
+extern void Fifos_Synchronize(CPmFifos *self, bool reset_cnt, bool force_sync);
+extern void Fifos_Unsynchronize(CPmFifos *self, bool reset_cnt, bool initial);
+extern void Fifos_ForceTermination(CPmFifos *self);
+extern void Fifos_ConfigureSyncParams(CPmFifos *self, uint8_t retries, uint16_t timeout);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PMFIFOS_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pmp.h b/ucs2-lib/inc/ucs_pmp.h
new file mode 100644
index 0000000..75f70b4
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pmp.h
@@ -0,0 +1,209 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of Port Message Protocol
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_PMH
+ * @{
+ */
+
+#ifndef UCS_PMP_H
+#define UCS_PMP_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+#define PMP_PM_MAX_SIZE_HEADER 8U /*!< \brief Maximum size of a port message header */
+#define PMP_PM_MIN_SIZE_HEADER 6U /*!< \brief Minimum size of a port message header */
+#define PMP_MAX_NUM_FIFOS 7U /*!< \brief Maximum number if FIFOs an an array
+ * \details Means "3" if FIFO "0" and "2" is used
+ */
+#define PMP_CREDITS_MASK 0x3FU /*!< \brief Valid bits for credits: 5..0 */
+#define PMP_CREDITS_MIN 1U /*!< \brief Minimum value for credits: 1 */
+#define PMP_CREDITS_MAX 63U /*!< \brief Maximum value for credits: 63 */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Specifies the FIFO */
+typedef enum Pmp_FifoId_
+{
+ PMP_FIFO_ID_MCM = 0U, /*!< \brief FIFO dedicated to MOST Control Messages (MCM) */
+ /* PMP_FIFO_ID_MDP = 1U, < (reserved identifier) */
+ PMP_FIFO_ID_ICM = 2U, /*!< \brief FIFO dedicated to INIC Control Messages (ICM) */
+ PMP_FIFO_ID_ALL = 3U, /*!< \brief All FIFOs (ICM, MCM) */
+ /* PMP_FIFO_ID_MEP = 4U < (reserved identifier) */
+ /* PMP_FIFO_ID_IOCM = 5U < (reserved identifier) */
+ PMP_FIFO_ID_RCM = 6U /*!< \brief FIFO dedicated to Remote Control Messages (RCM) */
+ /* PMP_FIFO_ID_RSVD = 7U < (reserved identifier) */
+
+} Pmp_FifoId_t;
+
+/*! \brief Specifies the messages type */
+typedef enum Pmp_MsgType_
+{
+ PMP_MSG_TYPE_CMD = 0U, /*!< \brief FIFO command message */
+ PMP_MSG_TYPE_STATUS = 1U, /*!< \brief FIFO status message */
+ PMP_MSG_TYPE_DATA = 2U /*!< \brief FIFO data message */
+
+} Pmp_MsgType_t;
+
+/*! \brief Specifies the direction of the Port Message */
+typedef enum Pmp_Direction_
+{
+ PMP_DIR_TX = 0, /*!< \brief Direction Tx (EHC -> INIC) */
+ PMP_DIR_RX = 1 /*!< \brief Direction Rx (INIC -> EHC) */
+
+} Pmp_Direction_t;
+
+/*! \brief Specifies FIFO status types */
+typedef enum Pmp_StatusType_
+{
+ PMP_STATUS_TYPE_FAILURE = 0U, /*!< \brief PMP status type "failure" */
+ PMP_STATUS_TYPE_FLOW = 1U, /*!< \brief PMP status type "flow" */
+ PMP_STATUS_TYPE_SYNCED = 4U, /*!< \brief PMP status type "synced" */
+ PMP_STATUS_TYPE_UNSYNCED_BSY = 5U, /*!< \brief PMP status type "unsynced_busy" */
+ PMP_STATUS_TYPE_UNSYNCED_RDY = 6U /*!< \brief PMP status type "unsynced_ready" */
+
+} Pmp_StatusType_t;
+
+/*! \brief Specifies FIFO status codes */
+typedef enum Pmp_StatusCode_
+{
+ PMP_STATUS_CODE_BUSY = 0U, /*!< \brief PMP status code "busy" */
+ PMP_STATUS_CODE_SUCCESS = 1U, /*!< \brief PMP status code "success" */
+ PMP_STATUS_CODE_CANCELED = 3U, /*!< \brief PMP status code "canceled" */
+ PMP_STATUS_CODE_NACK = 8U /*!< \brief PMP status code "not_acknowledge" */
+
+} Pmp_StatusCode_t;
+
+/*! \brief Specifies FIFO status codes */
+typedef enum Pmp_UnsyncReason_
+{
+ PMP_UNSYNC_R_STARTUP = 1U, /*!< \brief PMP status code, UnsyncReason "INIC Startup" */
+ PMP_UNSYNC_R_REINIT = 2U, /*!< \brief PMP status code, UnsyncReason "Re-init of another FIFO" */
+ PMP_UNSYNC_R_COMMAND = 3U, /*!< \brief PMP status code, UnsyncReason "By sync or un-sync command" */
+ PMP_UNSYNC_R_ACK_TIMEOUT = 4U, /*!< \brief PMP status code, UnsyncReason "Missing EHC Rx acknowledge" */
+ PMP_UNSYNC_R_WD_TIMEOUT = 5U, /*!< \brief PMP status code, UnsyncReason "Missing EHC status request" */
+ PMP_UNSYNC_R_TX_TIMEOUT = 6U /*!< \brief PMP status code, UnsyncReason "Missing EHC read, or blocked communication" */
+
+} Pmp_UnsyncReason_t;
+
+/*! \brief Specifies FIFO command types */
+typedef enum Pmp_CommandType_
+{
+ PMP_CMD_TYPE_REQ_STATUS = 0U, /*!< \brief PMP command type "request_status" */
+ PMP_CMD_TYPE_MSG_ACTION = 1U, /*!< \brief PMP command type "message_action" */
+ /* PMP_CMD_TYPE_TRIGGER_NAOMDP = 2U, < (reserved identifier) */
+ PMP_CMD_TYPE_SYNCHRONIZATION = 4U /*!< \brief PMP command type "synchronization" */
+
+} Pmp_CommandType_t;
+
+/*! \brief Specifies FIFO command codes */
+typedef enum Pmp_CommandCode_
+{
+ PMP_CMD_CODE_REQ_STATUS = 0U, /*!< \brief PMP command code "request_status" */
+ /* PMP_CMD_CODE_TRIGGER_NAOMDP = 0U, < (reserved identifier)*/
+ PMP_CMD_CODE_ACTION_RETRY = 1U, /*!< \brief PMP command type "request_status" */
+ PMP_CMD_CODE_ACTION_CANCEL = 2U, /*!< \brief PMP command type "request_status" */
+ PMP_CMD_CODE_ACTION_CANCEL_ALL = 3U, /*!< \brief PMP command type "request_status" */
+ PMP_CMD_CODE_UNSYNC = 10U, /*!< \brief PMP command type "request_status" */
+ PMP_CMD_CODE_SYNC = 21U /*!< \brief PMP command type "request_status" */
+
+} Pmp_CommandCode_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Header buffer operations */
+/*------------------------------------------------------------------------------------------------*/
+extern void Pmp_SetPml(uint8_t header[], uint8_t length);
+extern void Pmp_SetPmhl(uint8_t header[], uint8_t length);
+extern void Pmp_SetFph(uint8_t header[], Pmp_FifoId_t id, Pmp_MsgType_t type);
+extern void Pmp_SetExtType(uint8_t header[], uint8_t type, uint8_t code);
+extern void Pmp_SetSid(uint8_t header[], uint8_t sid);
+
+extern uint8_t Pmp_GetPml(uint8_t header[]);
+extern uint8_t Pmp_GetPmhl(uint8_t header[]);
+extern Pmp_FifoId_t Pmp_GetFifoId(uint8_t header[]);
+extern Pmp_MsgType_t Pmp_GetMsgType(uint8_t header[]);
+extern uint8_t Pmp_GetSid(uint8_t header[]);
+extern uint8_t Pmp_GetDataSize(uint8_t header[]);
+extern uint8_t Pmp_GetData(uint8_t header[], uint8_t index);
+extern bool Pmp_VerifyHeader(uint8_t header[], uint8_t buf_len);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class CPmh */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Defines the content of a Port Message Header
+ * \details The current structure does not support "direction" and "retransmitted" flag.
+ */
+typedef struct CPmh_
+{
+ uint8_t pml; /*!< \brief Port Message length */
+ uint8_t pmhl; /*!< \brief Port Message Header length */
+ Pmp_MsgType_t msg_type; /*!< \brief Port Message type */
+ Pmp_FifoId_t fifo_id; /*!< \brief FIFO identifier */
+ uint8_t sid; /*!< \brief The SequenceId */
+ uint8_t ext_type; /*!< \brief status or content type */
+
+} CPmh;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Function Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void Pmh_Ctor(CPmh *self);
+extern void Pmh_BuildHeader(CPmh *self, uint8_t data[]);
+extern void Pmh_DecodeHeader(CPmh *self, uint8_t data[]);
+extern void Pmh_SetFph(CPmh *self, Pmp_FifoId_t fifo_id, Pmp_MsgType_t msg_type);
+extern Pmp_StatusType_t Pmh_GetExtStatusType(CPmh *self);
+extern Pmp_StatusCode_t Pmh_GetExtStatusCode(CPmh *self);
+extern Pmp_CommandCode_t Pmh_GetExtCommandCode(CPmh *self);
+extern Pmp_CommandType_t Pmh_GetExtCommandType(CPmh *self);
+extern void Pmh_SetExtType(CPmh *self, uint8_t type, uint8_t code);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PMP_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_pool.h b/ucs2-lib/inc/ucs_pool.h
new file mode 100644
index 0000000..ac9166a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_pool.h
@@ -0,0 +1,80 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of message pool class
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_POOL
+ * @{
+ */
+#ifndef UCS_POOL_H
+#define UCS_POOL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message.h"
+#include "ucs_dl.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*------------------------------------------------------------------------------------------------*/
+/* Class CPool */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class CMessage
+ * \details Common internal message class which embeds a list of MOST telegrams
+ */
+typedef struct CPool_
+{
+ uint16_t initial_size; /*! \brief The size of a provided message array */
+ CMessage *messages; /*! \brief Reference to a message array provided by another module */
+ CDlList message_list; /*! \brief Doubly linked list required providing available messages */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CPool;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Pool_Ctor(CPool *self, CMessage messages[], uint16_t size, void *ucs_user_ptr);
+extern CMessage* Pool_GetMsg(CPool *self);
+extern void Pool_ReturnMsg(CMessage *msg_ptr);
+extern uint16_t Pool_GetCurrentSize(CPool *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_POOL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_prog.h b/ucs2-lib/inc/ucs_prog.h
new file mode 100644
index 0000000..ec181c4
--- /dev/null
+++ b/ucs2-lib/inc/ucs_prog.h
@@ -0,0 +1,114 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+#ifndef UCS_PROG_H
+#define UCS_PROG_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_exc.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+
+#define PRG_MAX_LEN_ERROR 3U
+
+typedef struct Prg_Error_t_
+{
+ Ucs_Prg_ResCode_t code;
+ Ucs_Prg_Func_t function;
+ uint8_t ret_len;
+ uint8_t parm[PRG_MAX_LEN_ERROR];
+} Prg_Error_t;
+
+
+
+
+/*! \brief Structure of class CProgramming. */
+typedef struct CProgramming_
+{
+ CInic *inic; /*!< \brief Reference to CInic object */
+ CExc *exc; /*!< \brief Reference to CExc object */
+ CBase *base; /*!< \brief Reference to CBase object */
+
+ CSingleObserver prg_welcome; /*!< \brief Observes the Welcome result */
+ CSingleObserver prg_memopen; /*!< \brief Observes the MemSessionOpen result */
+ CSingleObserver prg_memwrite; /*!< \brief Observes the MemoryWrite result */
+ CSingleObserver prg_memclose; /*!< \brief Observes the MemSessionClose result */
+
+ CMaskedObserver prg_terminate; /*!< \brief Observes events leading to termination */
+ CObserver prg_nwstatus; /*!< \brief Observes the MOST Network status */
+
+ CFsm fsm; /*!< \brief Node Discovery state machine */
+ CService service; /*!< \brief Service instance for the scheduler */
+ CTimer timer; /*!< \brief timer for monitoring messages */
+ bool neton; /*!< \brief indicates Network availability */
+
+ uint16_t node_id; /*!< \brief Position address of the node to be programmed. */
+ uint16_t target_address; /*!< \brief Actual target address */
+ Ucs_Signature_t signature; /*!< \brief Signature of the node to be programmed. */
+ Ucs_Prg_SessionType_t session_type; /*!< \brief Defines the memory access type. */
+ Ucs_Prg_Command_t* command_list; /*!< \brief Refers to array of programming tasks. */
+ uint8_t command_index; /*!< \brief index for command_list */
+ uint16_t admin_node_address; /*!< \brief Admin Node Address */
+ Ucs_Prg_ReportCb_t report_fptr; /*!< \brief Report callback function */
+ uint16_t session_handle; /*!< \brief Unique number used to authorize memory access. */
+ Ucs_Prg_Func_t current_function; /*!< \brief last used function. */
+ Prg_Error_t error; /*!< \brief stores the current error information */
+}CProgramming;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+void Prg_Ctor(CProgramming *self,
+ CInic *inic,
+ CBase *base,
+ CExc *exc);
+
+extern void Prg_Start(CProgramming *self,
+ uint16_t node_id,
+ Ucs_Signature_t *signature,
+ Ucs_Prg_SessionType_t session_type,
+ Ucs_Prg_Command_t* command_list,
+ Ucs_Prg_ReportCb_t report_fptr);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_PROG_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_ret_pb.h b/ucs2-lib/inc/ucs_ret_pb.h
new file mode 100644
index 0000000..779d80a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_ret_pb.h
@@ -0,0 +1,141 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief This header file contains standard return values used by UNICENS functions
+ * and methods.
+ * \addtogroup G_UCS_INIT_AND_SRV_TYPES
+ * @{
+ */
+
+#ifndef UCS_RET_H
+#define UCS_RET_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Standard return codes used for synchronous response */
+typedef enum Ucs_Return_
+{
+ UCS_RET_SUCCESS = 0x00, /*!< \brief Operation successfully completed */
+ UCS_RET_ERR_PARAM = 0x01, /*!< \brief At least one parameter exceeds its
+ admissible range */
+ UCS_RET_ERR_BUFFER_OVERFLOW = 0x02, /*!< \brief Buffer overflow or service busy */
+ UCS_RET_ERR_NOT_AVAILABLE = 0x03, /*!< \brief Functionality not available */
+ UCS_RET_ERR_NOT_SUPPORTED = 0x04, /*!< \brief This function is not supported by this
+ derivative of INIC / physical layer / MOST
+ speed */
+ UCS_RET_ERR_INVALID_SHADOW = 0x05, /*!< \brief The requested information is not yet
+ available */
+ UCS_RET_ERR_ALREADY_SET = 0x06, /*!< \brief The value to be set is already set. The
+ application can therefore be aware that no
+ message will be send to INIC and no
+ callback will be called */
+ UCS_RET_ERR_API_LOCKED = 0x07, /*!< \brief INIC performs already requested function. */
+ UCS_RET_ERR_NOT_INITIALIZED = 0x08 /*!< \brief UNICENS is not initialized */
+
+} Ucs_Return_t;
+
+/*! \brief Result codes used for asynchronous response */
+typedef enum Ucs_Result_
+{
+ UCS_RES_SUCCESS = 0x00, /*!< \brief Operation successfully completed */
+ UCS_RES_ERR_MOST_STANDARD = 0x01, /*!< \brief MOST standard error occurred */
+ UCS_RES_ERR_BUSY = 0x02, /*!< \brief Function currently busy */
+ UCS_RES_ERR_PROCESSING = 0x03, /*!< \brief Processing error occurred */
+ UCS_RES_ERR_CONFIGURATION = 0x04, /*!< \brief Configuration error occurred */
+ UCS_RES_ERR_SYSTEM = 0x05, /*!< \brief System error occurred */
+ UCS_RES_ERR_TIMEOUT = 0x06, /*!< \brief Timeout occurred */
+ UCS_RES_ERR_TRANSMISSION = 0x07 /*!< \brief Transmission error occurred */
+
+} Ucs_Result_t;
+
+/*! \brief Result values of initialization result callback function */
+typedef enum Ucs_InitResult_
+{
+ UCS_INIT_RES_SUCCESS = 0x00U, /*!< \brief Initialization succeeded */
+ UCS_INIT_RES_ERR_BUF_OVERFLOW = 0x01U, /*!< \brief No message buffer available */
+ UCS_INIT_RES_ERR_INIC_SYNC = 0x02U, /*!< \brief INIC synchronization failed */
+ UCS_INIT_RES_ERR_INIC_VERSION = 0x03U, /*!< \brief INIC device version check failed */
+ UCS_INIT_RES_ERR_INIC_SYSTEM = 0x04U, /*!< \brief Device attach failed due to an INIC
+ * system error
+ */
+ UCS_INIT_RES_ERR_DEV_ATT_CFG = 0x05U, /*!< \brief INIC device attach failed due to an
+ * configuration error
+ */
+ UCS_INIT_RES_ERR_DEV_ATT_PROC = 0x06U, /*!< \brief Device attach failed due to a
+ * processing error
+ */
+ UCS_INIT_RES_ERR_NET_CFG = 0x07U, /*!< \brief Network Configuration request failed */
+ UCS_INIT_RES_ERR_INTERNAL = 0x0AU, /*!< \brief Internal error occurred */
+ UCS_INIT_RES_ERR_TIMEOUT = 0x0BU /*!< \brief Initialization timeout occurred */
+
+} Ucs_InitResult_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Standard result structure which provides fields for detailed status and
+ * error information
+ */
+typedef struct Ucs_StdResult_
+{
+ Ucs_Result_t code; /*!< \brief Result/Error code */
+ uint8_t *info_ptr; /*!< \brief INIC error data */
+ uint8_t info_size; /*!< \brief Size of the INIC error data in bytes */
+
+} Ucs_StdResult_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for UNICENS standard result callbacks
+ * \param result Result of the callback
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_StdResultCb_t)(Ucs_StdResult_t result, void *user_ptr);
+
+/*! \brief Function signature used for UNICENS standard result callbacks
+ * \param result Result of the callback
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_InitResultCb_t)(Ucs_InitResult_t result, void *user_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RET_H */
+
+/*!
+ * @}
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rm_pb.h b/ucs2-lib/inc/ucs_rm_pb.h
new file mode 100644
index 0000000..80d7d70
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rm_pb.h
@@ -0,0 +1,112 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Routing Management.
+ * \addtogroup G_UCS_ROUTING_TYPES
+ * @{
+ */
+
+#ifndef UCS_RM_PB_H
+#define UCS_RM_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rm_pv.h"
+#include "ucs_nsm_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This enumerator specifies the type of an EndPoint object. */
+typedef enum Ucs_Rm_EndPointType_
+{
+ UCS_RM_EP_SOURCE = 0x00U, /*!< \brief Specifies the source endpoint. */
+ UCS_RM_EP_SINK = 0x01U /*!< \brief Specifies the sink endpoint. */
+
+} Ucs_Rm_EndPointType_t;
+
+/*! \brief This enumerator specifies the possible route information returned via User callback function of \ref Ucs_Rm_Start(). */
+typedef enum Ucs_Rm_RouteInfos_
+{
+ UCS_RM_ROUTE_INFOS_BUILT = 0x00U, /*!< \brief Specifies that the route has been built. */
+ UCS_RM_ROUTE_INFOS_DESTROYED = 0x01U, /*!< \brief Specifies that the route has been destroyed. */
+ UCS_RM_ROUTE_INFOS_SUSPENDED = 0x02U, /*!< \brief Specifies that the route has been suspended. */
+ UCS_RM_ROUTE_INFOS_PROCESS_STOP = 0x03U /*!< \brief Specifies that the route cannot be processed anymore because of UNICENS Termination. */
+
+} Ucs_Rm_RouteInfos_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Configuration structure of a Connection EndPoint. */
+typedef struct Ucs_Rm_EndPoint_
+{
+ /*! \brief Type of the endpoint object. */
+ Ucs_Rm_EndPointType_t endpoint_type;
+ /*! \brief Reference to a job list. */
+ Ucs_Xrm_ResObject_t ** jobs_list_ptr;
+ /*! \brief Reference to a node object. */
+ Ucs_Rm_Node_t * node_obj_ptr;
+ /*! \brief Internal information of this endpoint object. */
+ Ucs_Rm_EndPointInt_t internal_infos;
+
+} Ucs_Rm_EndPoint_t;
+
+/*! \brief Configuration structure of a Route. */
+typedef struct Ucs_Rm_Route_
+{
+ /*! \brief Reference to a Source Endpoint object. */
+ Ucs_Rm_EndPoint_t * source_endpoint_ptr;
+ /*! \brief Reference to a Sink Endpoint object. */
+ Ucs_Rm_EndPoint_t * sink_endpoint_ptr;
+ /*! \brief Route activity. Specifies whether the route is active yet or not. */
+ uint8_t active;
+ /*! \brief User-defined route identifier. */
+ uint16_t route_id;
+ /*! \brief Internal information of the route object. */
+ Ucs_Rm_RouteInt_t internal_infos;
+
+} Ucs_Rm_Route_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RM_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rm_pv.h b/ucs2-lib/inc/ucs_rm_pv.h
new file mode 100644
index 0000000..09fc85e
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rm_pv.h
@@ -0,0 +1,69 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Private header file of the Routing Management.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_RTM
+ * @{
+ */
+
+#ifndef UCS_RM_PV_H
+#define UCS_RM_PV_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rtm_pv.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Internal configuration structure of a Connection Node. */
+typedef struct Ucs_Rm_NodeInt_
+{
+ uint8_t available; /*!< \brief Availability flag */
+ uint8_t mgr_joined; /*!< \brief Indicates whether the node was made available by manager */
+
+} Ucs_Rm_NodeInt_t;
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RM_PV_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rsm.h b/ucs2-lib/inc/ucs_rsm.h
new file mode 100644
index 0000000..261542a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rsm.h
@@ -0,0 +1,161 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*!
+ * \file
+ * \brief Internal header file of the Remote Sync Manager.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_RSM
+ * @{
+ */
+
+
+#ifndef UCS_RSM_H
+#define UCS_RSM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_net.h"
+#include "ucs_base.h"
+#include "ucs_inic.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_rsm_pv.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief RSM internal state transitions */
+typedef enum Rsm_StateTransition_
+{
+ RSM_ST_IDLE, /*!< \brief Transition to "Idle" state */
+ RSM_ST_SYNC_REQ, /*!< \brief Transition to "Sync Request" state */
+ RSM_ST_NTF_REQ, /*!< \brief Transition to "Notification Request" state */
+ RSM_ST_NTF_CLEAR, /*!< \brief Transition to "Notification Clear" state */
+ RSM_ST_NTF_ALL, /*!< \brief Transition to "All Notification" state */
+ RSM_ST_NTF_GPIO, /*!< \brief Transition to "Gpio Notification" state */
+ RSM_ST_SYNC_SUCC, /*!< \brief Transition to "Sync Success" state */
+ RSM_ST_SYNC_ERR /*!< \brief Transition to "Sync Error" state */
+
+} Rsm_StateTransition_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by RSM during initialization. */
+typedef struct Rsm_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CInic *inic_ptr; /*!< \brief Reference to INIC instance */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
+
+} Rsm_InitData_t;
+
+/*! \brief Stores information required for a RSM device. */
+typedef struct Rsm_DeviceInfos_
+{
+ /*! \brief State of the device */
+ Rsm_DevSyncState_t sync_state;
+ /*! \brief next state transition */
+ Rsm_StateTransition_t next_st;
+ /*! \brief stores the current result */
+ Rsm_Result_t curr_result;
+ /*! \brief stores the current user data that'll be passes to curr_res_cb_fptr */
+ void * curr_user_data;
+ /*! \brief current result callback function ptr */
+ Rsm_ResultCb_t curr_res_cb_fptr;
+
+} Rsm_DeviceInfos_t;
+
+/*! \brief Stores parameter used for signaling RSM event. */
+typedef struct Rsm_EventParam_
+{
+ /*! \brief own current device address */
+ uint16_t own_device_address;
+ /*! \brief max node position */
+ uint8_t max_node_pos;
+ /*! \brief Result observer used for sockets, ports and connections */
+ CSingleObserver stdresult_observer;
+ /*! \brief Observer used to monitor ICM or MCM Tx Message objects availability */
+ CObserver txavailability_observer;
+ /*! \brief Observer used to monitor MNS initialization result */
+ CMaskedObserver ucsinit_observer;
+ /*! \brief Observe MOST Network status in Net module */
+ CMaskedObserver nwstatus_observer;
+ /*! \brief Own subject to notify the SyncLost event */
+ CSubject subject;
+
+} Rsm_EventParam_t;
+
+/*! \brief Class structure of the Remote Sync Management. */
+typedef struct CRemoteSyncManagement_
+{
+ /*! \brief Reference to an INIC instance */
+ CInic *inic_ptr;
+ /*! \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*! \brief Reference to a network instance */
+ CNetworkManagement *net_ptr;
+ /*! \brief RSM DeviceInfos list */
+ Rsm_DeviceInfos_t dev_infos;
+ /*! \brief stores the last synclost cause */
+ Rsm_SyncLostCause_t last_synclost_cause;
+ /*! \brief Parameter object for the RSM Event */
+ Rsm_EventParam_t event_param;
+ /*! \brief Service instance for the scheduler */
+ CService rsm_srv;
+
+} CRemoteSyncManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CRemoteSyncManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Rsm_Ctor(CRemoteSyncManagement * self, Rsm_InitData_t * init_ptr);
+extern void Rsm_AddObserver(CRemoteSyncManagement * self, CObserver * obs);
+extern void Rsm_DelObserver(CRemoteSyncManagement * self, CObserver * obs_ptr);
+extern Ucs_Return_t Rsm_SyncDev(CRemoteSyncManagement * self, void* user_data, Rsm_ResultCb_t sync_complete_fptr);
+extern Rsm_DevSyncState_t Rsm_GetDevState(CRemoteSyncManagement * self);
+extern void Rsm_ReportSyncLost (CRemoteSyncManagement * self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RSM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rsm_pv.h b/ucs2-lib/inc/ucs_rsm_pv.h
new file mode 100644
index 0000000..5d70aa5
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rsm_pv.h
@@ -0,0 +1,145 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Extended Resource Manager.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_RSM
+ * @{
+ */
+
+#ifndef UCS_RSM_PB_H
+#define UCS_RSM_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief SyncLost Causes
+ * \ingroup G_UCS_RSM_TYPES
+ */
+typedef enum Rsm_SyncLostCause_
+{
+ RSM_SLC_NWSHUTDOWN, /*!< \brief "Network Shutdown" causes the SyncLost */
+ RSM_SLC_CFGNOTOK, /*!< \brief "Config Not Ok" causes the SyncLost */
+ RSM_SLC_SYSMODIF /*!< \brief "System Changes like own node address or MPR changes" cause the SyncLost */
+
+} Rsm_SyncLostCause_t;
+
+/*! \brief RSM Sync states
+ * \ingroup G_UCS_RSM_TYPES
+ */
+typedef enum Rsm_DevSyncState_
+{
+ RSM_DEV_UNSYNCED, /*!< \brief RSM device is "Unsynced", i.e. not in remote control mode */
+ RSM_DEV_SYNCING, /*!< \brief RSM device is "Synching" */
+ RSM_DEV_SYNCED /*!< \brief RSM device is "Synced", i.e. in remote control mode */
+
+} Rsm_DevSyncState_t;
+
+/*! \brief Result codes of the Extended Resource Manager.
+ * \ingroup G_UCS_RSM_TYPES
+ */
+typedef enum Rsm_ResultCode_
+{
+ RSM_RES_SUCCESS, /*!< \brief Device Sync succeeded */
+ RSM_RES_ERR_SYNC /*!< \brief Device Sync failed because of not Remote Control Mode */
+
+} Rsm_ResultCode_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Detailed information used for Extended Resource Manager results. */
+typedef struct Rsm_ResultDetails_
+{
+ /*! \brief Holds the status of the transmission. */
+ Ucs_MsgTxStatus_t tx_result;
+ /*! \brief Holds the results of the target device. */
+ Ucs_StdResult_t inic_result;
+
+} Rsm_ResultDetails_t;
+
+/*! \brief Result structure of the Extended Resource Manager. */
+typedef struct Rsm_Result_
+{
+ /*! \brief Result code. */
+ Rsm_ResultCode_t code;
+ /*! \brief Detailed information on the returned result. */
+ Rsm_ResultDetails_t details;
+
+} Rsm_Result_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback function type to retrieve a RSM result
+ * \param self The instance (optional)
+ * \param result The result message object
+ * \ingroup G_UCS_RSM_TYPES
+ */
+typedef void (*Rsm_ResultCb_t)(void * self, Rsm_Result_t result);
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*!
+ * \def UCS_NUM_REMOTE_DEVICES
+ * \brief Customer assignment for number of remote devices required by Resources Management modules.
+ * \details If the macro is not defined, the UNICENS library will use a default value of 0. The user
+ * can overwrite this default value by defining the macro. Valid values are in the range
+ * from 0 to 63.
+ * \ingroup G_UCS_XRM_CFG
+ */
+#ifndef UCS_NUM_REMOTE_DEVICES
+# define UCS_NUM_REMOTE_DEVICES 0U
+#endif
+
+/*! \def UCS_ADDR_LOCAL_DEV
+ * \brief Defines the address of the local device.
+ * \details This macro is used to define the address of the local device. It should be used by
+ * the application to trigger jobs on the local device.
+ * \ingroup G_UCS_IRM
+ */
+#define UCS_ADDR_LOCAL_DEV 0x0001U
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RSM_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rtm.h b/ucs2-lib/inc/ucs_rtm.h
new file mode 100644
index 0000000..2fbccfd
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rtm.h
@@ -0,0 +1,127 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Route Manager.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_RTM
+ * @{
+ */
+
+#ifndef UCS_RTM_H
+#define UCS_RTM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_base.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_epm.h"
+#include "ucs_net.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by RTM during initialization. */
+typedef struct Rtm_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CEndpointManagement *epm_ptr; /*!< \brief Reference to the endpoint management instance */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
+ Ucs_Rm_ReportCb_t report_fptr; /*!< \brief Reference to the report callback function */
+
+} Rtm_InitData_t;
+
+/*! \brief Class structure of the Route Management. */
+typedef struct CRouteManagement_
+{
+ /*! \brief Reference to a base instance */
+ CBase *base_ptr;
+ /*! \brief Reference to a network instance */
+ CEndpointManagement * epm_ptr;
+ /*!< \brief Reference to the timer management */
+ CTimerManagement * tm_ptr;
+ /*!< \brief Reference to Network instance */
+ CNetworkManagement *net_ptr;
+ /*!< \brief Timer for checking routes process */
+ CTimer route_check;
+ /*!< \brief Reference to the routes list */
+ Ucs_Rm_Route_t * routes_list_ptr;
+ /*! \brief Points to the current routes to be handled */
+ Ucs_Rm_Route_t * curr_route_ptr;
+ /*! \brief Current route index */
+ uint16_t curr_route_index;
+ /*! \brief Size of the current routes list */
+ uint16_t routes_list_size;
+ /*! \brief Service instance for the scheduler */
+ CService rtm_srv;
+ /*! \brief Report callback of the routes list */
+ Ucs_Rm_ReportCb_t report_fptr;
+ /*! \brief Observe MOST Network status in Net module */
+ CMaskedObserver nwstatus_observer;
+ /*! \brief Observer used to monitor UCS initialization result */
+ CMaskedObserver ucsinit_observer;
+ /*! \brief Observer used to monitor UCS termination event */
+ CMaskedObserver ucstermination_observer;
+ /*! \brief Specifies used to monitor UCS termination event */
+ bool ucs_is_stopping;
+ /*! \brief specifies whether the network status is available or not */
+ bool nw_available;
+ /*! \brief Flag to lock the API */
+ bool lock_api;
+
+} CRouteManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CRouteManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Rtm_Ctor(CRouteManagement * self, Rtm_InitData_t * init_ptr);
+extern Ucs_Return_t Rtm_StartProcess(CRouteManagement * self, Ucs_Rm_Route_t routes_list[], uint16_t size);
+extern Ucs_Return_t Rtm_DeactivateRoute(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
+extern Ucs_Return_t Rtm_ActivateRoute(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
+extern Ucs_Return_t Rtm_SetNodeAvailable(CRouteManagement * self, Ucs_Rm_Node_t *node_ptr, bool available);
+extern bool Rtm_GetNodeAvailable(CRouteManagement * self, Ucs_Rm_Node_t *node_ptr);
+extern Ucs_Return_t Rtm_GetAttachedRoutes(CRouteManagement * self, Ucs_Rm_EndPoint_t * ep_inst, Ucs_Rm_Route_t * ext_routes_list[], uint16_t size_list);
+extern uint16_t Rtm_GetConnectionLabel(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RTM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rtm_pv.h b/ucs2-lib/inc/ucs_rtm_pv.h
new file mode 100644
index 0000000..82b6210
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rtm_pv.h
@@ -0,0 +1,116 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Extended Resource Manager.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_RTM
+ * @{
+ */
+
+#ifndef UCS_RTM_PV_H
+#define UCS_RTM_PV_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_epm_pv.h"
+#include "ucs_obs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief This enumerator specifies the kind of result - Internal, Target or Transmission. */
+typedef enum Ucs_Rm_RouteState_
+{
+ UCS_RM_ROUTE_IDLE = 0x00U, /*!< \brief Specifies that the Route is in idle state, i.e. not handled yet. */
+ UCS_RM_ROUTE_CONSTRUCTION = 0x01U, /*!< \brief Specifies that the Route is under Construction. */
+ UCS_RM_ROUTE_BUILT = 0x02U, /*!< \brief Specifies that the Route is built. */
+ UCS_RM_ROUTE_DETERIORATED = 0x03U, /*!< \brief Specifies that the Route is Deteriorated. */
+ UCS_RM_ROUTE_DESTRUCTION = 0x04U, /*!< \brief Specifies that the Route is under Destruction. */
+ UCS_RM_ROUTE_SUSPENDED = 0x05U /*!< \brief Specifies that the Route is Suspended. */
+
+} Ucs_Rm_RouteState_t;
+
+/*! \brief This enumerator specifies the kind of result - Internal, Target or Transmission. */
+typedef enum Ucs_Rm_RouteResult_
+{
+ UCS_RM_ROUTE_NOERROR = 0x00U, /*!< \brief Specifies that the result is error free. */
+ UCS_RM_ROUTE_UNCRITICAL = 0x01U, /*!< \brief Specifies that the result is uncritical. A retry is necessary. */
+ UCS_RM_ROUTE_CRITICAL = 0x02U /*!< \brief Specifies that the result is critical. No retry necessary. */
+
+} Ucs_Rm_RouteResult_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/* Rtm_Inst_t requires incomplete forward declaration, to hide internal data type.
+ * The Rtm_Inst_t object is allocated internally, the core library must access only the pointer to Rtm_Inst_t. */
+struct Rtm_Inst_;
+
+/*!\brief RouteManagement instance */
+typedef struct Rtm_Inst_ Rtm_Inst_t;
+
+/*! \brief Internal configuration structure of a Route. */
+typedef struct Ucs_Rm_RouteInt_
+{
+ /*! \brief Specifies the RTM instance that manages this route. */
+ Rtm_Inst_t * rtm_inst;
+ /*! \brief Specifies the route state. */
+ Ucs_Rm_RouteState_t route_state;
+ /*! \brief Specifies the last route result. */
+ Ucs_Rm_RouteResult_t last_route_result;
+ /*! \brief Specifies the observer object for source endpoint. */
+ CObserver source_ep_observer;
+ /*! \brief Specifies whether the sink observer object is initialized or not. */
+ uint8_t sink_obsvr_initialized;
+ /*! \brief Specifies whether the source observer object is initialized or not. */
+ uint8_t src_obsvr_initialized;
+ /*! \brief Specifies whether or not the UCS termination has been notified for this route. */
+ uint8_t notify_termination;
+ /*! \brief Specifies the observer object for sink endpoint. */
+ CObserver sink_ep_observer;
+
+} Ucs_Rm_RouteInt_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_RTM_PV_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_rules.h b/ucs2-lib/inc/ucs_rules.h
new file mode 100644
index 0000000..9a6a5ff
--- /dev/null
+++ b/ucs2-lib/inc/ucs_rules.h
@@ -0,0 +1,59 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief UNICENSV2 API include file
+ */
+
+#ifndef UCS_SHARED_CONFIG_H
+#define UCS_SHARED_CONFIG_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_cfg.h"
+
+/*------------------------------------------------------------------------------------------------*/
+/* Shared Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \def UCS_FOOTPRINT_TINY
+ * \brief Define this macro to reduce the RAM and ROM size of the UNICENS software by
+ * disabling certain features.
+ * \ingroup G_UCS_INIT_AND_SRV
+ * \details If this macro is defined the following changes apply:
+ * - Reduction of low-level buffers
+ * - AMS does not support segmentation (payload > 45 bytes)
+ * .
+ */
+#ifndef UCS_FOOTPRINT_TINY
+# define UCS_FOOTPRINT_TINY
+#else
+# define AMS_FOOTPRINT_TINY
+# define MNSL_FOOTPRINT_TINY
+# define SMM_FOOTPRINT_TINY
+#endif
+
+#endif /* UCS_SHARED_CONFIG_H */
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_scheduler.h b/ucs2-lib/inc/ucs_scheduler.h
new file mode 100644
index 0000000..6eed99d
--- /dev/null
+++ b/ucs2-lib/inc/ucs_scheduler.h
@@ -0,0 +1,146 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the scheduler module. The module consists of the two classes
+ * CScheduler and CService.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_SCHEDULER
+ * @{
+ */
+
+#ifndef UCS_SCHEDULER_H
+#define UCS_SCHEDULER_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_dl.h"
+#include "ucs_obs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for UCS request callback function */
+typedef void (*Scd_UcsServiceRequest_t)(void);
+/*! \brief Function signature used for service callback functions
+ * \param self Instance pointer
+ */
+typedef void (*Srv_Cb_t)(void *self);
+/*! \brief Data type of event masks */
+typedef uint32_t Srv_Event_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+extern const Srv_Event_t SRV_EMPTY_EVENT_MASK; /*!< \brief Empty event mask */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Standard return values of scheduler module. */
+typedef enum Scd_Ret_
+{
+ SCD_OK, /*!< \brief No error */
+ SCD_UNKNOWN_SRV, /*!< \brief Service is unknown */
+ SCD_SRV_ALREADY_LISTED /*!< \brief Service is already part of the schedulers list */
+
+} Scd_Ret_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the scheduler module. */
+typedef struct Scd_InitData_
+{
+ /*! \brief Observer to request a UCS service call */
+ CSingleObserver *service_request_obs_ptr;
+ /*! \brief UNICENS instance ID */
+ /*uint8_t ucs_inst_id;*/
+
+} Scd_InitData_t;
+
+/*! \brief Class structure of the scheduler. */
+typedef struct CScheduler_
+{
+ /*! \brief Subject to request a UCS service call */
+ CSingleSubject service_request_subject;
+ /*! \brief Service list of the scheduler */
+ CDlList srv_list;
+ /*! \brief Indicates if the scheduler services is running */
+ bool scd_srv_is_running;
+ /*! \brief UNICENS instance ID */
+ void * ucs_user_ptr;
+
+} CScheduler;
+
+/*! \brief Class structure of services used by the scheduler. */
+typedef struct CService_
+{
+ CDlNode list_node; /*!< \brief Administration area for the linked list */
+ CScheduler *scd_ptr; /*!< \brief Back link to scheduler */
+ void *instance_ptr; /*!< \brief Reference of instance passed to service_fptr() */
+ Srv_Cb_t service_fptr; /*!< \brief Reference of the service callback function */
+ Srv_Event_t event_mask; /*!< \brief Event mask of the service */
+ uint8_t priority; /*!< \brief Priority of the service */
+
+} CService;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CScheduler */
+/*------------------------------------------------------------------------------------------------*/
+extern void Scd_Ctor(CScheduler *self, Scd_InitData_t *init_ptr, void *ucs_user_ptr);
+extern void Scd_Service(CScheduler *self);
+extern Scd_Ret_t Scd_AddService(CScheduler *self, CService *srv_ptr);
+extern Scd_Ret_t Scd_RemoveService(CScheduler *self, CService *srv_ptr);
+extern bool Scd_AreEventsPending(CScheduler *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CService */
+/*------------------------------------------------------------------------------------------------*/
+extern void Srv_Ctor(CService *self, uint8_t priority, void *instance_ptr, Srv_Cb_t service_fptr);
+extern void Srv_SetEvent(CService *self, Srv_Event_t event_mask);
+extern void Srv_GetEvent(CService *self, Srv_Event_t *event_mask_ptr);
+extern void Srv_ClearEvent(CService *self, Srv_Event_t event_mask);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_SCHEDULER_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_segmentation.h b/ucs2-lib/inc/ucs_segmentation.h
new file mode 100644
index 0000000..849517f
--- /dev/null
+++ b/ucs2-lib/inc/ucs_segmentation.h
@@ -0,0 +1,144 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of AMS Segmentation Class
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_AMSSEGM
+ * @{
+ */
+
+#ifndef UCS_SEGMENTATION_H
+#define UCS_SEGMENTATION_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message.h"
+#include "ucs_amsmessage.h"
+#include "ucs_amspool.h"
+#include "ucs_base.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Defines the maximum payload size of a single transfer in bytes */
+#define SEGM_MAX_SIZE_TEL 45U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Collection of possible segmentation errors */
+typedef enum Segm_Error_
+{
+ SEGM_ERR_1 = 1, /*!< \brief The first segment is missing. */
+
+ SEGM_ERR_2 = 2, /*!< \brief The device is not able to receive a message of this size.
+ * MNS specific: The allocation of user provided payload failed.
+ */
+ SEGM_ERR_3 = 3, /*!< \brief Unexpected segment number. */
+
+ SEGM_ERR_4 = 4, /*!< \brief Too many unfinished segmentation messages were pending. */
+
+ SEGM_ERR_5 = 5, /*!< \brief A timeout occurred while waiting for the next segment. */
+
+ SEGM_ERR_6 = 6, /*!< \brief The Device is not capable to handle segmented messages.
+ * MNS specific: The application did not assign the payload allocation
+ * function in Ucs_Ams_InitData_t prior calling Ucs_Init().
+ */
+ SEGM_ERR_7 = 7 /*!< \brief Segmented message has not been finished before the arrival of
+ * another message with the identical FBlockID, InstID, FktID, and
+ * OPType sent by the same node.
+ */
+} Segm_Error_t;
+
+/*! \brief Segmentation result */
+typedef enum Segm_Result_
+{
+ SEGM_RES_OK, /*!< \brief Telegram was processed */
+ SEGM_RES_RETRY /*!< \brief Telegram shall be processed again as soon as messages are freed to the Rx pool */
+
+} Segm_Result_t;
+
+/*! \brief Callback function to notify that a segmentation error has occurred
+ * \param self The instance
+ * \param tel_ptr The affected telegram
+ * \param error The segmentation error code (1..7)
+ */
+typedef void (*Segm_OnError_t)(void *self, Msg_MostTel_t *tel_ptr, Segm_Error_t error);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief AMS Segmentation Class
+ * \details Performs Tx and Rx Segmentation
+ */
+typedef struct CSegmentation_
+{
+ CBase *base_ptr; /*!< \brief Reference to base services */
+ CAmsMsgPool *pool_ptr; /*!< \brief Reference to object/payload pool */
+
+ Segm_OnError_t error_fptr; /*!< \brief Callback function to notify segmentation errors */
+ void *error_inst; /*!< \brief Instance which is notified on segmentation errors */
+
+ CDlList processing_list; /*!< \brief Segmented and un-finished Rx messages */
+ CTimer gc_timer; /*!< \brief Timer to trigger the garbage collector */
+ uint16_t rx_default_payload_sz; /*!< \brief Payload size that shall be allocated if size-prefixes
+ * segmentation message is missing */
+
+} CSegmentation;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Initialization Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Segm_Ctor(CSegmentation *self, CBase *base_ptr, CAmsMsgPool *pool_ptr, uint16_t rx_def_payload_sz);
+extern void Segm_AssignRxErrorHandler(CSegmentation *self, Segm_OnError_t error_fptr, void *error_inst);
+extern void Segm_Cleanup(CSegmentation *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Public method prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern bool Segm_TxBuildSegment(CSegmentation *self, Ucs_AmsTx_Msg_t *msg_ptr, Msg_MostTel_t *tel_ptr);
+extern Ucs_AmsRx_Msg_t* Segm_RxExecuteSegmentation(CSegmentation *self, Msg_MostTel_t *tel_ptr, Segm_Result_t *result_ptr);
+extern void Segm_RxGcScanProcessingHandles(void *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UCS_SEGMENTATION_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_smm.h b/ucs2-lib/inc/ucs_smm.h
new file mode 100644
index 0000000..e129ff3
--- /dev/null
+++ b/ucs2-lib/inc/ucs_smm.h
@@ -0,0 +1,149 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Header file of the class CStaticMemoryManager.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_SMM_CLASS
+ * @{
+ */
+
+#ifndef UCS_SMM_H
+#define UCS_SMM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_smm_pb.h"
+#include "ucs_ret_pb.h"
+#include "ucs_dl.h"
+#include "ucs_amsmessage.h"
+#include "ucs_amsallocator.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+#define SMM_NUM_TX_MSGS ((uint16_t)UCS_AMS_NUM_TX_MSGS)
+#define SMM_NUM_RX_MSGS ((uint16_t)UCS_AMS_NUM_RX_MSGS)
+#define SMM_SIZE_TX_MSG ((uint16_t)UCS_AMS_SIZE_TX_MSG)
+#define SMM_SIZE_RX_MSG ((uint16_t)UCS_AMS_SIZE_RX_MSG)
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Tx object allocation info */
+typedef struct Smm_TxObject_
+{
+ Amsg_IntMsgTx_t object; /*!< \brief Tx object memory */
+ CDlNode node; /*!< \brief Node that enables listing */
+
+} Smm_TxObject_t;
+
+/*! \brief Rx object allocation info */
+typedef struct Smm_RxObject_
+{
+ Amsg_IntMsgRx_t object; /*!< \brief Rx object memory */
+ CDlNode node; /*!< \brief Node that enables listing */
+
+} Smm_RxObject_t;
+
+/*! \brief Tx payload allocation info */
+typedef struct Smm_TxPayload_
+{
+ uint8_t data[SMM_SIZE_TX_MSG]; /*!< \brief Tx payload memory */
+ CDlNode node; /*!< \brief Node that enables listing */
+
+} Smm_TxPayload_t;
+
+/*! \brief Rx payload allocation info */
+typedef struct Smm_RxPayload_
+{
+ uint8_t data[SMM_SIZE_RX_MSG]; /*!< \brief Rx payload memory */
+ CDlNode node; /*!< \brief Node that enables listing */
+
+} Smm_RxPayload_t;
+
+/*! \brief Static memory allocation of objects and payload */
+typedef struct Smm_Resources_
+{
+ Smm_TxObject_t tx_objects[SMM_NUM_TX_MSGS]; /*!< \brief Statically allocated Tx objects */
+ Smm_RxObject_t rx_objects[SMM_NUM_RX_MSGS]; /*!< \brief Statically allocated Rx objects */
+
+ Smm_TxPayload_t tx_payload[SMM_NUM_TX_MSGS]; /*!< \brief Statically allocated Tx payload */
+ Smm_RxPayload_t rx_payload[SMM_NUM_RX_MSGS]; /*!< \brief Statically allocated Rx payload */
+
+} Smm_Resources_t;
+
+/*! \brief Descriptor which simplifies access to different memory types */
+typedef struct Smm_Descriptor_
+{
+ CDlList list; /*!< \brief The list of available memory chunks */
+ uint16_t max_mem_size; /*!< \brief The maximum size of one memory chunk */
+
+} Smm_Descriptor_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure of the class CStaticMemoryManager. */
+typedef struct CStaticMemoryManager_
+{
+ Smm_Resources_t resources; /*!< \brief Static allocation of memory */
+
+ Smm_Descriptor_t null_descr; /*!< \brief Descriptor for unknown memory type. Performance measure. */
+ Smm_Descriptor_t tx_object_descr; /*!< \brief Descriptor of Tx object type */
+ Smm_Descriptor_t tx_payload_descr; /*!< \brief Descriptor of Tx payload type */
+ Smm_Descriptor_t rx_object_descr; /*!< \brief Descriptor of Rx object type */
+ Smm_Descriptor_t rx_payload_descr; /*!< \brief Descriptor of Rx payload type */
+
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CStaticMemoryManager;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CStaticMemoryManager */
+/*------------------------------------------------------------------------------------------------*/
+extern void Smm_Ctor(CStaticMemoryManager *self, void *ucs_user_ptr);
+extern Ucs_Return_t Smm_LoadPlugin(CStaticMemoryManager *self, Ams_MemAllocator_t *allocator_ptr, uint16_t rx_def_payload_size);
+extern Ucs_Return_t Smm_GetFreeBufferCnt(CStaticMemoryManager *self, uint16_t *rx_cnt_ptr, uint16_t *tx_cnt_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_SMM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_smm_pb.h b/ucs2-lib/inc/ucs_smm_pb.h
new file mode 100644
index 0000000..ff5042e
--- /dev/null
+++ b/ucs2-lib/inc/ucs_smm_pb.h
@@ -0,0 +1,114 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Header file of the static memory manager plug-in.
+ * \addtogroup G_UCS_AMS
+ * @{
+ */
+
+#ifndef UCS_SMM_API_H
+#define UCS_SMM_API_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Default configuration */
+/*------------------------------------------------------------------------------------------------*/
+/*! \def UCS_AMS_NUM_RX_MSGS
+ * \brief Defines the number of reserved Rx message objects.
+ * Valid values: 5..255. Default value: 20.
+ */
+#ifndef UCS_AMS_NUM_RX_MSGS
+# define UCS_AMS_NUM_RX_MSGS 20
+#else
+# if (UCS_AMS_NUM_RX_MSGS < 5) || (UCS_AMS_NUM_RX_MSGS > 255)
+# error "UCS_AMS_NUM_RX_MSGS is not properly defined. Choose a value between: 10 and 255."
+# endif
+#endif
+
+/*! \def UCS_AMS_SIZE_RX_MSG
+ * \brief Defines the payload size in bytes which is available for every Rx message object.
+ * Valid values: 45..65535. Default value: 45.
+ */
+#ifndef UCS_AMS_SIZE_RX_MSG
+# define UCS_AMS_SIZE_RX_MSG 45
+#else
+# if (UCS_AMS_SIZE_RX_MSG >= 45) && (UCS_AMS_SIZE_RX_MSG <= 65535)
+# if defined(SMM_FOOTPRINT_TINY) && (UCS_AMS_SIZE_RX_MSG != 45)
+# error Do not define UCS_AMS_SIZE_RX_MSG together with SMM_FOOTPRINT_TINY.
+# endif
+# else
+# error UCS_AMS_SIZE_RX_MSG is not properly defined. Choose a value between: 45 and 65535.
+# endif
+#endif
+
+/*! \def UCS_AMS_NUM_TX_MSGS
+ * \brief Defines the number of reserved Tx message objects.
+ * Valid values: 5..255. Default value: 20.
+ */
+#ifndef UCS_AMS_NUM_TX_MSGS
+# define UCS_AMS_NUM_TX_MSGS 20
+#else
+# if (UCS_AMS_NUM_TX_MSGS < 5) || (UCS_AMS_NUM_TX_MSGS > 255)
+# error "UCS_AMS_NUM_TX_MSGS is not properly defined. Choose a value between: 10 and 255."
+# endif
+#endif
+
+/*! \def UCS_AMS_SIZE_TX_MSG
+ * \brief Defines the payload size in bytes which is available for every Tx message object.
+ * Valid values: 45..65535. Default value: 45.
+ */
+#ifndef UCS_AMS_SIZE_TX_MSG
+# define UCS_AMS_SIZE_TX_MSG 45
+#else
+# if (UCS_AMS_SIZE_TX_MSG >= 45) && (UCS_AMS_SIZE_TX_MSG <= 65535)
+# if defined(SMM_FOOTPRINT_TINY) && (UCS_AMS_SIZE_TX_MSG != 45)
+# error "Do not define UCS_AMS_SIZE_TX_MSG together with SMM_FOOTPRINT_TINY."
+# endif
+# else
+# error "UCS_AMS_SIZE_TX_MSG is not properly defined. Choose a value between: 45 and 65535."
+# endif
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_SMM_API_H */
+
+/*!
+ * @}
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_sys_diag.h b/ucs2-lib/inc/ucs_sys_diag.h
new file mode 100644
index 0000000..83f034a
--- /dev/null
+++ b/ucs2-lib/inc/ucs_sys_diag.h
@@ -0,0 +1,143 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of class CSysDiag.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_SYS_DIAG
+ * @{
+ */
+
+#ifndef UCS_SYS_DIAG_H
+#define UCS_SYS_DIAG_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_obs.h"
+#include "ucs_fsm.h"
+#include "ucs_inic.h"
+#include "ucs_exc.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of a tested segment. */
+typedef enum Sd_ResultCode_
+{
+ SD_INIT = 0x01U, /*!< \brief initialized */
+ SD_SEGMENT = 0x02U, /*!< \brief segment explored */
+ SD_CABLE_LINK = 0x03U /*!< \brief cable link diagnosis executed */
+
+} Sd_ResultCode_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \brief Structure decribing a node of the segment to be tested. */
+typedef struct Sd_Node_
+{
+ bool available; /*!< \brief node available? *//*! i todo RWI: */
+ uint16_t node_address; /*!< \brief node address used for welcome command */
+ uint8_t result; /*!< \brief result parameter of Welcome.Result message */
+ uint8_t version; /*!< \brief version parameter of Hello and Welcome messages */
+ Ucs_Signature_t signature; /*!< \brief signature of the node */
+
+} Sd_Node;
+
+
+
+/*! \brief Structure of class CSysDiag. */
+typedef struct CSysDiag_
+{
+ CInic *inic; /*!< \brief Reference to CInic object */
+ CExc *exc; /*!< \brief Reference to CExc object */
+ CBase *base; /*!< \brief Reference to CBase object */
+
+ bool startup_locked; /*!< \brief Locking of NetworkStartup without timeout */
+ CSingleSubject sysdiag; /*!< \brief Subject for the System Diagnosis reports */
+
+ CSingleObserver sys_diag_start; /*!< \brief Observes the Inic_NwSysDiagnosis() command */
+ CSingleObserver sys_diag_stop; /*!< \brief Observes the Inic_NwSysDiagEnd() command */
+ CSingleObserver sys_hello; /*!< \brief Observes the Hello result */
+ CSingleObserver sys_welcome; /*!< \brief Observes the Welcome result */
+ CSingleObserver sys_enable_port; /*!< \brief Observes enabling a port */
+ CSingleObserver sys_disable_port; /*!< \brief Observes disabling a port */
+ CSingleObserver sys_cable_link_diagnosis; /*!< \brief Observes the CableLinkDiagnosis result */
+ CMaskedObserver sys_terminate; /*!< \brief Observes events leading to termination */
+
+ CFsm fsm; /*!< \brief System Diagnosis state machine */
+ CService sd_srv; /*!< \brief Service instance for the scheduler */
+
+ uint8_t segment_nr; /*!< \brief segment number which is currently checked*/
+ uint8_t num_ports; /*!< \brief number of ports of master node */
+ uint8_t curr_branch; /*!< \brief branch which is currently examined */
+ uint16_t admin_node_address; /*!< \brief node address used during system diagnosis */
+ Sd_ResultCode_t last_result; /*!< \brief result of last segment
+ */
+ Sd_Node master; /*!< \brief Timing Master node */
+ Sd_Node source; /*!< \brief Source node of segment to be tested */
+ Sd_Node target; /*!< \brief Target node of segment to be tested */
+ uint16_t hello_retry; /*!< \brief retry counter for hello message */
+ CTimer timer; /*!< \brief timer for monitoring messages */
+
+ Ucs_Sd_Report_t report; /*!< \brief reports segment results */
+
+} CSysDiag;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes */
+/*------------------------------------------------------------------------------------------------*/
+extern void SysDiag_Ctor(CSysDiag *self, CInic *inic, CBase *base, CExc *exc);
+extern Ucs_Return_t SysDiag_Run(CSysDiag *self, CSingleObserver *obs_ptr);
+extern Ucs_Return_t SysDiag_Abort(CSysDiag *self);
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_SYS_DIAG_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_telqueue.h b/ucs2-lib/inc/ucs_telqueue.h
new file mode 100644
index 0000000..555ee8b
--- /dev/null
+++ b/ucs2-lib/inc/ucs_telqueue.h
@@ -0,0 +1,91 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of class CTelQueue
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_MSG_QUEUE
+ * @{
+ */
+
+#ifndef UCS_MSGQUEUE_H
+#define UCS_MSGQUEUE_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message.h"
+#include "ucs_dl.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class CTelQueue */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class CTelQueue
+ * \details Internal class to queue MOST telegrams
+ */
+typedef struct CTelQueue_
+{
+ CDlList list; /*! \brief Doubly linked list */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+
+} CTelQueue;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+extern void Telq_Ctor(CTelQueue *self, void *ucs_user_ptr);
+extern Msg_MostTel_t* Telq_Dequeue(CTelQueue *self);
+extern Msg_MostTel_t* Telq_Peek(CTelQueue *self);
+extern void Telq_Enqueue(CTelQueue *self, Msg_MostTel_t *tel_ptr);
+extern uint8_t Telq_GetSize(CTelQueue *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_MSGQUEUE_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_timer.h b/ucs2-lib/inc/ucs_timer.h
new file mode 100644
index 0000000..5321988
--- /dev/null
+++ b/ucs2-lib/inc/ucs_timer.h
@@ -0,0 +1,144 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the timer management module.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_TIMER
+ * @{
+ */
+
+#ifndef UCS_TIMER_H
+#define UCS_TIMER_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_dl.h"
+#include "ucs_scheduler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for timer handler
+ * \param args Void pointer to optional data
+ */
+typedef void (*Tm_Handler_t)(void *args);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Initialization structure of the timer management module. */
+typedef struct Tm_InitData_
+{
+ /*! \brief Observer used to request current tick count value */
+ CSingleObserver *get_tick_count_obs_ptr;
+ /*! \brief Observer used to start application timer for delayed TM service calls */
+ CSingleObserver *set_application_timer_obs_ptr;
+ /*! \brief UNICENS instance ID */
+ /*uint8_t ucs_inst_id;*/
+
+} Tm_InitData_t;
+
+/*! \brief Class structure of the a timer object. */
+typedef struct CTimer_
+{
+ /*! \brief Node of the doubly linked (timer-) list */
+ CDlNode node;
+ /*! \brief Handler function which is invoked when the timer expires */
+ Tm_Handler_t handler_fptr;
+ /*! \brief Reference to optional parameter */
+ void *args_ptr;
+ /*! \brief The Timeout value before the timer expires for the first time, in milliseconds */
+ uint16_t elapse;
+ /*! \brief The period of the timer, in milliseconds */
+ uint16_t period;
+ /*! \brief Delta time related to next timer in list */
+ uint16_t delta;
+ /*! \brief Flag which signals that the timer is in use */
+ bool in_use;
+ /*! \brief Flag to check if timer object has changed within timer handler callback function */
+ bool changed;
+
+} CTimer;
+
+/*! \brief Class structure of the timer management */
+typedef struct CTimerManagement_
+{
+ /*! \brief Doubly linked list to manage the active timers */
+ CDlList timer_list;
+ /*! \brief Subject to request current tick count */
+ CSingleSubject get_tick_count_subject;
+ /*! \brief Subject to start the application timer which triggers a UCS service call */
+ CSingleSubject set_application_timer_subject;
+ /*! \brief Service instance to add the timer management to the scheduler */
+ CService tm_srv;
+ /*! \brief Last tick count value (saved at TM service) */
+ uint16_t last_tick_count;
+ /*! \brief Signals that the application timer callbacks are used */
+ bool delayed_tm_service_enabled;
+ /*! \brief Indicates that the application timer must be started */
+ bool set_service_timer;
+ /*! \brief UNICENS instance ID */
+ void * ucs_user_ptr;
+
+} CTimerManagement;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CTimerManagement */
+/*------------------------------------------------------------------------------------------------*/
+extern void Tm_Ctor(CTimerManagement *self, CScheduler *scd, const Tm_InitData_t *init_ptr, void * ucs_user_ptr);
+extern void Tm_SetTimer(CTimerManagement *self, CTimer *timer_ptr, Tm_Handler_t handler_fptr,
+ void *args_ptr, uint16_t elapse, uint16_t period);
+extern void Tm_ClearTimer(CTimerManagement *self, CTimer *timer_ptr);
+extern void Tm_CheckForNextService(CTimerManagement *self);
+extern void Tm_TriggerService(CTimerManagement *self);
+extern void Tm_StopService(CTimerManagement *self);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CTimer */
+/*------------------------------------------------------------------------------------------------*/
+extern void T_Ctor(CTimer *self);
+extern bool T_IsTimerInUse(CTimer *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_TIMER_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_trace.h b/ucs2-lib/inc/ucs_trace.h
new file mode 100644
index 0000000..3137932
--- /dev/null
+++ b/ucs2-lib/inc/ucs_trace.h
@@ -0,0 +1,237 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the trace interface
+ */
+
+#ifndef UCS_TRACE_H
+#define UCS_TRACE_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_trace_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Unit and entry ids */
+/*------------------------------------------------------------------------------------------------*/
+#define TR_UCS_ASSERT "ASSERT failed in line %d"
+#define TR_UCS_INIC_RESULT_ID_1 "INIC error data:"
+#define TR_UCS_INIC_RESULT_ID_2 "--> Data[%u]: 0x%02X"
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal macros */
+/*------------------------------------------------------------------------------------------------*/
+
+/*! \def UCS_TR_INFO
+ * \brief Trace macro to capture trace info events
+ * \details This macro is used to enable the capturing of trace info events. The macro must be
+ * mapped onto a user-defined function. To disable the trace info events, the macro must
+ * not be defined. The mapped user-defined function must adhere to the following function
+ * signature.
+ *
+ * void (*Ucs_TraceCb_t)(void * ucs_user_ptr, const char module_str[], const char entry_str[], uint16_t vargs_cnt, ...);
+ * - <b>ucs_user_ptr</b><br>Reference to the User argument
+ * - <b>module_str</b><br>The name of the software module that has posted the trace
+ * - <b>entry_str</b><br>The trace entry as formatted string
+ * - <b>vargs_cnt</b><br>Number of trace arguments which will be passed within the variable
+ * argument list
+ * - <b>[...]</b><br>Variable argument list to pass trace arguments
+ *
+ * \warning Do not assign UCS_TR_INFO in a production system. This has major effects on the CPU load and runtime.
+ * UCS_TR_INFO is intended for debugging software during development phase. Microchip Support might
+ * request you to assign of this macro to spy on internal events. Disable this macro definition after
+ * your support case is closed.
+ *
+ * <b>Example:</b>
+ * \code
+ * extern void App_UcsTraceInfo(void * ucs_user_ptr,
+ * const char module_str[],
+ * const char entry_str[],
+ * uint16_t vargs_cnt,
+ * ...);
+ *
+ * #define UCS_TR_INFO App_UcsTraceInfo
+ * \endcode
+ *
+ * \ingroup G_UCS_TRACE
+ */
+
+/*! \def UCS_TR_ERROR
+ * \brief Trace macro to capture trace error events
+ * \details This macro is used to enable the capturing of trace error events. The macro must be
+ * mapped onto a user-defined function. To disable the trace error events, the macro must
+ * not be defined. The mapped user-defined function must adhere to the following function
+ * signature.
+ *
+ * void (*Ucs_TraceCb_t)(void * ucs_user_ptr, const char module_str[], const char entry_str[], uint16_t vargs_cnt, ...);
+ * - <b>ucs_user_ptr</b><br>Reference to the User argument
+ * - <b>module_str</b><br>The name of the software module that has posted the trace
+ * - <b>entry_str</b><br>The trace entry as formatted string
+ * - <b>vargs_cnt</b><br>Number of trace arguments which will be passed within the variable
+ * argument list
+ * - <b>[...]</b><br>Variable argument list to pass trace arguments
+ *
+ * \note The captured error events can be used for logging and as a first step for debugging
+ * unexpected behavior. However, the application must not derive any action when an error
+ * is indicated by the trace interface. An application must handle rely on result callback
+ * functions and handle "general.error_fptr()".
+ *
+ * <b>Example:</b>
+ * \code
+ * extern void App_UcsTraceError(void * ucs_user_ptr,
+ * const char module_str[],
+ * const char entry_str[],
+ * uint16_t vargs_cnt,
+ * ...);
+ *
+ * #define UCS_TR_ERROR App_UcsTraceError
+ * \endcode
+ *
+ * \ingroup G_UCS_TRACE
+ */
+
+
+/*! \addtogroup G_UCS_TRACE
+ * \details The UCS Trace Interface is intended for debugging and logging purpose.
+ * There are 2 different trace options:
+ * - The definition of trace macros to print out internal states, messages
+ * and errors. This option provides two trace classes: \c info and \c error. Each trace
+ * class can be activated by defining the respective macro UCS_TR_INFO
+ * UCS_TR_ERROR in the configuration header file \c ucs_cfg.h.
+ * While the \c info class is intended only for debugging purpose during
+ * development, the \c error class can also be active for logging purpose
+ * in a production system.
+ * - Implementation of the callback function Ucs_DebugErrorMsgCb_t which is assigned
+ * during initialization. The callback function is fired on every received Error
+ * message from a local or remote INIC.
+ */
+
+/*!
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_TRACE
+ * @{
+ */
+
+/*! \def TR_INFO
+ * \brief Trace macro to capture trace info events
+ * \details The macro is referenced to a public trace macro which must be defined in ucs_cfg.h. The
+ * public macros refers to a trace function which must be implemented by the application.
+ * The given arguments can be stored or immediately converted into a trace output by
+ * invoking the function Ucs_Tr_DecodeTrace().
+ * \param args Container of arguments. The following arguments are of the container.
+ * - ucs_user_ptr Reference to the User argument
+ * - unit Id of the UNICENS unit that has posted the trace
+ * - entry Id of the trace entry
+ * - vargs_cnt Number of trace arguments which will be passed within the variable
+ * argument list
+ * - [...] Variable argument list to pass trace arguments
+ */
+
+/*! \def TR_ERROR
+ * \brief Trace macro to capture trace error events
+ * \details The macro is referenced to a public trace macro which must be defined in ucs_cfg.h. The
+ * public macros refers to a trace function which must be implemented by the application.
+ * The given arguments can be stored or immediately converted into a trace output by
+ * invoking the function Ucs_Tr_DecodeTrace().
+ * \param args Container of arguments. The following arguments are of the container.
+ * - ucs_user_ptr Reference to the User argument
+ * - unit Id of the UNICENS unit that has posted the trace
+ * - entry Id of the trace entry
+ * - vargs_cnt Number of trace arguments which will be passed within the variable
+ * argument list
+ * - [...] Variable argument list to pass trace arguments
+ */
+
+/*! \def TR_FAILED_ASSERT
+ * \brief Failed Assert statement which will add error entry into the trace output.
+ * \param ucs_user_ptr Reference to the User argument
+ * \param unit Identifier for the respective software unit.
+ */
+
+/*! \def TR_ASSERT
+ * \brief Assert statement which evaluates an expression to true. If the expression
+ * evaluates to false a failed assert will be printed into the trace output.
+ * \param ucs_user_ptr Reference to the User argument
+ * \param unit Identifier for the respective software unit.
+ * \param expr Expression which shall evaluate to \c true (expectation applies)
+ */
+
+/*! \def TR_ERROR_INIC_RESULT
+ * \brief Trace macro to capture INIC error data
+ * \param ucs_user_ptr Reference to the User argument
+ * \param unit Identifier for the respective software unit.
+ * \param info_ptr Byte stream which contains the raw INIC error data
+ * \param info_size Size of the INIC error data in bytes
+ */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/* parasoft suppress MISRA2004-19_7 MISRA2004-19_4 reason "function-like macros are allowed for tracing" */
+#ifdef UCS_TR_ERROR
+# define TR_ERROR(args) UCS_TR_ERROR args;
+# define TR_FAILED_ASSERT(ucs_user_ptr, unit) TR_ERROR(((ucs_user_ptr), (unit), TR_UCS_ASSERT, 1U, __LINE__))
+# define TR_ASSERT(ucs_user_ptr, unit, expr) if (!(expr)) {TR_FAILED_ASSERT((ucs_user_ptr), (unit));}
+# define TR_ERROR_INIC_RESULT(ucs_user_ptr, unit, info_ptr, info_size) \
+ { \
+ uint8_t i; \
+ TR_ERROR(((ucs_user_ptr), (unit), TR_UCS_INIC_RESULT_ID_1, 0U)); \
+ for(i=0U; i<info_size; i++) \
+ { \
+ TR_ERROR(((ucs_user_ptr), (unit), TR_UCS_INIC_RESULT_ID_2, 2U, i, info_ptr[i])) \
+ } \
+ }
+#else
+# define UCS_TR_ERROR
+# define TR_ERROR(args)
+# define TR_FAILED_ASSERT(ucs_user_ptr, unit)
+# define TR_ASSERT(ucs_user_ptr, unit, expr)
+# define TR_ERROR_INIC_RESULT(ucs_user_ptr, unit, info_ptr, info_size)
+#endif
+
+#ifdef UCS_TR_INFO
+# define TR_INFO(args) UCS_TR_INFO args;
+#else
+# define UCS_TR_INFO
+# define TR_INFO(args)
+#endif
+/* parasoft unsuppress item MISRA2004-19_7 item MISRA2004-19_4 reason "function-like macros are allowed for tracing" */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_TRACE_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_trace_pb.h b/ucs2-lib/inc/ucs_trace_pb.h
new file mode 100644
index 0000000..6a972aa
--- /dev/null
+++ b/ucs2-lib/inc/ucs_trace_pb.h
@@ -0,0 +1,52 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the trace interface
+ */
+
+#ifndef UCS_TRACE_PB_H
+#define UCS_TRACE_PB_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Defines the needed buffer size to decode a trace entry.
+ * \ingroup G_UCS_TRACE
+ */
+#define UCS_TR_SIZE_BUFFER 256
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_TRACE_PB_H */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_transceiver.h b/ucs2-lib/inc/ucs_transceiver.h
new file mode 100644
index 0000000..ca5cf68
--- /dev/null
+++ b/ucs2-lib/inc/ucs_transceiver.h
@@ -0,0 +1,133 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Declaration of class CTransceiver
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_TRCV
+ * @{
+ */
+
+#ifndef UCS_TRANSCEIVER_H
+#define UCS_TRANSCEIVER_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_message.h"
+#include "ucs_pool.h"
+#include "ucs_pmfifo.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Types */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Assignable callback function which is invoked for message reception
+ * \param self The instance
+ * \param tel_ptr Reference to the message object
+ */
+typedef void (*Trcv_RxCompleteCb_t)(void *self, Msg_MostTel_t *tel_ptr);
+
+/*! \brief Assignable callback function which is invoked to filter Rx messages
+ * \details Filtering is a synchronous operation. Hence, it is not possible to keep a message
+ * object for delayed processing. The invoked function has to decide whether a
+ * message shall be discarded and freed to the Rx pool. Therefore, it has to return
+ * \c true. By returning \ false, the message will be received in the usual way.
+ * \param self The instance
+ * \param tel_ptr Reference to the message object
+ * \return Returns \c true to discard the message and free it to the pool (no-pass). Otherwise, returns
+ * \c false (pass).
+ */
+typedef bool (*Trcv_RxFilterCb_t)(void *self, Msg_MostTel_t *tel_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Macros */
+/*------------------------------------------------------------------------------------------------*/
+#define TRCV_SIZE_TX_POOL 10U /*!< \brief Number of messages in the message pool */
+
+/*------------------------------------------------------------------------------------------------*/
+/* Class CTransceiver */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Class CTransceiver
+ * \details Provides MOST message objects and communication methods to further classes
+ */
+typedef struct CTransceiver_
+{
+ CMessage tx_msgs[TRCV_SIZE_TX_POOL];/*!< \brief Messages in message pool */
+ CPool tx_msg_pool; /*!< \brief The message pool */
+ uint16_t tx_def_src; /*!< \brief Default source address for Tx message object */
+ void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
+ uint8_t own_id; /*!< \brief ID of the transceiver required for tracing */
+ CPmFifo *fifo_ptr; /*!< \brief Reference to dedicated port message FIFO */
+
+ Trcv_RxCompleteCb_t rx_complete_fptr; /*!< \brief Callback function which is invoked on
+ * message reception
+ */
+ void *rx_complete_inst; /*!< \brief Instance which is notified on
+ * message reception
+ */
+ Trcv_RxFilterCb_t rx_filter_fptr; /*!< \brief Callback function which is invoked
+ * to filter Rx messages
+ */
+ void *rx_filter_inst; /*!< \brief Instance which is notified to
+ * filter Rx messages
+ */
+} CTransceiver;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Methods */
+/*------------------------------------------------------------------------------------------------*/
+/* Constructor */
+extern void Trcv_Ctor(CTransceiver *self, CPmFifo *fifo_ptr, uint16_t def_src_addr, void *ucs_user_ptr, uint8_t trace_id);
+/* Tx */
+extern Msg_MostTel_t* Trcv_TxAllocateMsg(CTransceiver *self, uint8_t size);
+extern void Trcv_TxSendMsg(CTransceiver *self, Msg_MostTel_t *tel_ptr);
+extern void Trcv_TxSendMsgExt(CTransceiver *self, Msg_MostTel_t *tel_ptr, Msg_TxStatusCb_t callback_fptr, void *inst_ptr);
+extern void Trcv_TxSendMsgBypass(CTransceiver *self, Msg_MostTel_t *tel_ptr, Msg_TxStatusCb_t callback_fptr, void *inst_ptr);
+extern void Trcv_TxReleaseMsg(Msg_MostTel_t *tel_ptr);
+extern void Trcv_TxReuseMsg(Msg_MostTel_t *tel_ptr);
+/* Rx */
+extern void Trcv_RxAssignReceiver(CTransceiver *self, Trcv_RxCompleteCb_t callback_fptr, void *inst_ptr);
+extern void Trcv_RxAssignFilter(CTransceiver *self, Trcv_RxFilterCb_t callback_fptr, void *inst_ptr);
+extern void Trcv_RxReleaseMsg(CTransceiver *self, Msg_MostTel_t *tel_ptr);
+extern void Trcv_RxOnMsgComplete(void *self, CMessage *tel_ptr);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_TRANSCEIVER_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_xrm.h b/ucs2-lib/inc/ucs_xrm.h
new file mode 100644
index 0000000..6746c18
--- /dev/null
+++ b/ucs2-lib/inc/ucs_xrm.h
@@ -0,0 +1,219 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Include file of the Extended Resource Manager.
+ *
+ * \defgroup G_UCS_XRM_STREAM Additional Streaming Port Functions
+ * \brief Additional Streaming Port functions of the Extended Resource Manager.
+ * \ingroup G_UCS_IRM
+ *
+ */
+
+#ifndef UCS_XRM_H
+#define UCS_XRM_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_net.h"
+#include "ucs_rsm.h"
+#include "ucs_inic.h"
+#include "ucs_ret_pb.h"
+#include "ucs_obs.h"
+#include "ucs_xrmpool.h"
+#include "ucs_class_pb.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*!
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_XRM_INT
+ * @{
+ */
+
+/*! \def XRM_NUM_RES_HDL_PER_ICM
+ * \brief Maximum number of resource handles per ICM. Depends on the maximum payload of ICMs.
+ */
+#define XRM_NUM_RES_HDL_PER_ICM 22U
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Stores data required by XRM during initialization. */
+typedef struct Xrm_InitData_
+{
+ CBase *base_ptr; /*!< \brief Reference to base instance */
+ CInic *inic_ptr; /*!< \brief Reference to INIC instance */
+ CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
+ CRemoteSyncManagement *rsm_ptr; /*!< \brief Reference to a RSM instance */
+ CXrmPool *xrmp_ptr; /*!< \brief Reference to a xrm pool instance */
+ Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr; /*!< \brief Callback function pointer to monitor XRM resources from application */
+ Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr; /*!< \brief Callback function pointer to signal unmute of devices */
+
+} Xrm_InitData_t;
+
+/*! \brief Structure that defines a XRM StreamPort configuration */
+typedef struct Xrm_StreamPort_Config_
+{
+ uint8_t index; /*!< \brief Streaming Port instance */
+ Ucs_Stream_PortOpMode_t op_mode; /*!< \brief Streaming Port Operation mode */
+ Ucs_Stream_PortOption_t port_option; /*!< \brief Streaming Port Options */
+ Ucs_Stream_PortClockMode_t clock_mode; /*!< \brief Stream Port Clock Mode */
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay; /*!< \brief Stream Port Clock Data Delay */
+ Ucs_Xrm_Stream_PortCfgResCb_t result_fptr; /*!< \brief Result callback */
+
+} Xrm_StreamPort_Config_t;
+
+/*! \brief Result observers used by FBlock INIC Resource Management functions */
+typedef struct Xrm_Observers_
+{
+ /*! \brief Observer used to monitor internal errors (e.g., INIC BIST Error) */
+ CMaskedObserver internal_error_obs;
+ /*! \brief Observer used to monitor network status infos */
+ CMaskedObserver nw_status_obs;
+ /*! \brief Observer used to monitor ICM tx message object availability */
+ CObserver tx_msg_obj_obs;
+ /*! \brief Observer used for the INIC resource monitor */
+ CObserver resource_monitor_obs;
+ /*! \brief Result observer used for destruction of INIC resources */
+ CSingleObserver resource_destroy_obs;
+ /*! \brief Result observer used for requests of invalid resource handles */
+ CSingleObserver resource_invalid_list_obs;
+ /*! \brief Result observer used for sockets, ports and connections */
+ CSingleObserver std_result_obs;
+ /*! \brief Application callback to signal unmute of devices */
+ Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr;
+ /*! \brief Callback function pointer used for streaming port configurations */
+ Ucs_Xrm_Stream_PortCfgResCb_t stream_port_config_fptr;
+ /*! \brief Observer to proxy callback stream_port_config_fptr() */
+ CSingleObserver stream_port_config_obs;
+ /*! \brief Callback function pointer used by operation that enables a MOST Port */
+ Ucs_StdResultCb_t most_port_enable_fptr;
+ /*! \brief Observer to proxy callback most_port_enable_port_fptr() */
+ CSingleObserver most_port_enable_obs;
+ /*! \brief Callback function pointer by operation that enables full streaming for a MOST Port*/
+ Ucs_StdResultCb_t most_port_en_full_str_fptr;
+ /*! \brief Observer to proxy callback most_port_en_full_str_fptr() */
+ CSingleObserver most_port_en_full_str_obs;
+ /*! \brief Observer to the SyncLost event in RSM */
+ CObserver rsm_sync_lost_obs;
+
+} Xrm_Observers_t;
+
+/*! \brief Structure of the Extended Resource Manager class. */
+typedef struct CExtendedResourceManager_
+{
+ /*!< \brief Jobs list queue */
+ CDlList job_list;
+ /*! \brief List to temporarily store invalid resource handles */
+ uint16_t inv_resource_handle_list[XRM_NUM_RES_HDL_PER_ICM];
+ /*! \brief Reference to an INIC instance */
+ CInic *inic_ptr;
+ /*! \brief Reference to a network instance */
+ CNetworkManagement *net_ptr;
+ /*! \brief Reference to a rsm instance */
+ CRemoteSyncManagement *rsm_ptr;
+ /*!< \brief Reference to base instance */
+ CBase *base_ptr;
+ /*!< \brief Reference to the xrm pool instance */
+ CXrmPool *xrmp_ptr;
+ /*! \brief Reference to the currently processed job */
+ Xrm_Job_t *current_job_ptr;
+ /*! \brief Reference to the currently processed resource object */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t **current_obj_pptr;
+ /*! \brief Number of invalid handles in list inv_resource_handle_list[] */
+ uint8_t inv_resource_handle_list_size;
+ /*! \brief Current number of destroyed handles in list inv_resource_handle_list[] */
+ uint8_t curr_dest_resource_handle_size;
+ /*! \brief Start index for the current invalid handles index in list inv_resource_handle_list[] */
+ uint8_t inv_resource_handle_index;
+ /*! \brief Service instance to add the Extended Resource Manager to the MNS scheduler */
+ CService xrm_srv;
+ /*! \brief Report result of the Extended Resource Manager. Used to reported status and error
+ * information to the application.
+ */
+ Ucs_Xrm_Result_t report_result;
+ /*! \brief Required result observers */
+ Xrm_Observers_t obs;
+ /*! \brief Mask that stores queued event */
+ Srv_Event_t queued_event_mask;
+ /*! \brief stores the currently stream port configuration (in process) */
+ Xrm_StreamPort_Config_t current_streamport_config;
+ /*!< \brief Callback function pointer to monitor XRM resources */
+ Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr;
+ /*! \brief Flag to lock the API */
+ bool lock_api;
+ /*!< \brief Signal whether this instance is in Remote Control Mode */
+ bool IsInRemoteControlMode;
+
+} CExtendedResourceManager;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CExtendedResourceManager */
+/*------------------------------------------------------------------------------------------------*/
+extern void Xrm_Ctor(CExtendedResourceManager *self, Xrm_InitData_t * data_ptr);
+extern Ucs_Return_t Xrm_Process(CExtendedResourceManager *self,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[],
+ uint16_t most_network_connection_label,
+ void * user_arg,
+ Ucs_Xrm_ReportCb_t report_fptr);
+extern Ucs_Return_t Xrm_Destroy(CExtendedResourceManager *self,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
+extern Ucs_Return_t Xrm_Stream_SetPortConfig(CExtendedResourceManager *self,
+ uint8_t index,
+ Ucs_Stream_PortOpMode_t op_mode,
+ Ucs_Stream_PortOption_t port_option,
+ Ucs_Stream_PortClockMode_t clock_mode,
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
+extern Ucs_Return_t Xrm_Stream_GetPortConfig(CExtendedResourceManager *self,
+ uint8_t index,
+ Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
+extern Ucs_Return_t Xrm_Most_EnablePort(CExtendedResourceManager *self,
+ uint16_t most_port_handle,
+ bool enabled,
+ Ucs_StdResultCb_t result_fptr);
+extern Ucs_Return_t Xrm_Most_PortEnFullStr(CExtendedResourceManager *self,
+ uint16_t most_port_handle,
+ bool enabled,
+ Ucs_StdResultCb_t result_fptr);
+extern void Xrm_SetResourceDebugCbFn(CExtendedResourceManager *self, Ucs_Xrm_ResourceDebugCb_t dbg_cb_fn);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_XRM_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_xrm_pb.h b/ucs2-lib/inc/ucs_xrm_pb.h
new file mode 100644
index 0000000..99c618f
--- /dev/null
+++ b/ucs2-lib/inc/ucs_xrm_pb.h
@@ -0,0 +1,578 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Public header file of the Extended Resource Manager.
+ */
+
+#ifndef UCS_XRM_PB_H
+#define UCS_XRM_PB_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_xrm_cfg.h"
+#include "ucs_ret_pb.h"
+#include "ucs_inic_pb.h"
+#include "ucs_rsm_pv.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \def UCS_XRM_CONST
+ * \brief Defines a ROM data qualifier for XRM data objects.
+ * \details This macro is used to define a XRM ROM data qualifier. It is used for XRM
+ * configuration structures and XRM resource object lists. The definition of this
+ * macro must be part of the XRM configuration file ucs_xrm_cfg.h.
+ */
+#ifdef UCS_XRM_CONST
+# error UCS_XRM_CONST macro is not supported on UNICENS anymore. Please remove It from your config file.
+#endif
+
+#define UCS_XRM_CONST
+
+/*! \def UCS_XRM_NUM_JOBS
+ * \brief Defines the size of the internal job list.
+ * \details The number of XRM jobs to execute. The value is used to specify the size of the
+ * internal job list. The definition of this macro must be part of the XRM
+ * configuration file ucs_xrm_cfg.h.
+ * Valid range: 1..254. Default value: 1.
+ * \ingroup G_UCS_XRM_CFG
+ */
+#ifndef UCS_XRM_NUM_JOBS
+# define UCS_XRM_NUM_JOBS
+# define XRM_NUM_JOBS 1U
+#else
+# define XRM_NUM_JOBS ((uint8_t)UCS_XRM_NUM_JOBS)
+#endif
+
+/*! \def UCS_XRM_NUM_RESOURCES
+ * \brief Defines the number of provided resources.
+ * \details The number of required resources depends on the defined XRM jobs. The
+ * definition of the public macro UCS_XRM_NUM_RESOURCES must be part of the
+ * XRM configuration file ucs_xrm_cfg.h.
+ * Valid range: 1..254. Default value: 8.
+ * \ingroup G_UCS_XRM_CFG
+ */
+#ifndef UCS_XRM_NUM_RESOURCES
+# define UCS_XRM_NUM_RESOURCES
+# define XRM_NUM_RESOURCE_HANDLES 8U
+#else
+# define XRM_NUM_RESOURCE_HANDLES ((uint8_t)UCS_XRM_NUM_RESOURCES)
+#endif
+
+/*!
+ * \addtogroup G_UCS_XRM_TYPES
+ * @{
+ */
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerators */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of the Extended Resource Manager. */
+typedef enum Ucs_Xrm_ResultCode_
+{
+ UCS_XRM_RES_SUCCESS_BUILD = 0x00U, /*!< \brief Build of connection succeeded. */
+ UCS_XRM_RES_SUCCESS_DESTROY = 0x01U, /*!< \brief Destruction of connection succeeded. */
+ UCS_XRM_RES_RC_AUTO_DESTROYED = 0x02U, /*!< \brief Invalid resources have been successfully destroyed. */
+ UCS_XRM_RES_ERR_CONFIG = 0x03U, /*!< \brief Invalid user settings in the XRM configuration file.
+ * \details The number of jobs or resources exceeds the maximum allowed in your XRM configuration file. */
+ UCS_XRM_RES_ERR_BUILD = 0x04U, /*!< \brief Build of connection failed due to a function-specific error found on target device or a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_Xrm_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_XRM_RES_ERR_DESTROY = 0x05U, /*!< \brief Destruction of connection failed due to a function-specific error found on target device or a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_Xrm_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_XRM_RES_ERR_INV_LIST = 0x06U, /*!< \brief Request of invalid resources failed due to a function-specific error found on target device or a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_Xrm_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_XRM_RES_ERR_SYNC = 0x07U, /*!< \brief The remote synchronization of target device failed due to a function-specific error a transmission error on the MOST network.
+ * \details The \em result_type section in Ucs_Xrm_ResultDetails_t will provide you with more detailed information concerning the error type.
+ */
+ UCS_XRM_RES_UNKNOWN = 0xFFU /*!< \brief Result is unknown. */
+} Ucs_Xrm_ResultCode_t;
+
+/*! \brief INIC resource types used by the Extended Resource Manager. */
+typedef enum Ucs_Xrm_ResourceType_
+{
+ UCS_XRM_RC_TYPE_DC_PORT = 0x00U, /*!< \brief Default created port */
+ UCS_XRM_RC_TYPE_MOST_SOCKET = 0x01U, /*!< \brief MOST socket */
+ UCS_XRM_RC_TYPE_MLB_PORT = 0x02U, /*!< \brief MediaLB port */
+ UCS_XRM_RC_TYPE_MLB_SOCKET = 0x03U, /*!< \brief MediaLB socket */
+ UCS_XRM_RC_TYPE_USB_PORT = 0x04U, /*!< \brief USB port */
+ UCS_XRM_RC_TYPE_USB_SOCKET = 0x05U, /*!< \brief USB socket */
+ UCS_XRM_RC_TYPE_RMCK_PORT = 0x06U, /*!< \brief RMCK port */
+ UCS_XRM_RC_TYPE_STRM_PORT = 0x07U, /*!< \brief Streaming port */
+ UCS_XRM_RC_TYPE_STRM_SOCKET = 0x08U, /*!< \brief Streaming socket */
+ UCS_XRM_RC_TYPE_SYNC_CON = 0x09U, /*!< \brief Synchronous data connection */
+ UCS_XRM_RC_TYPE_DFIPHASE_CON = 0x0AU, /*!< \brief DiscreteFrame Isochronous streaming
+ * phase connection
+ */
+ UCS_XRM_RC_TYPE_COMBINER = 0x0BU, /*!< \brief Combiner */
+ UCS_XRM_RC_TYPE_SPLITTER = 0x0CU, /*!< \brief Splitter */
+ UCS_XRM_RC_TYPE_AVP_CON = 0x0DU, /*!< \brief A/V packetized isochronous streaming
+ * data connection
+ */
+ UCS_XRM_RC_TYPE_QOS_CON = 0x0EU /*!< \brief Quality of Service IP streaming data
+ * connection
+ */
+
+} Ucs_Xrm_ResourceType_t;
+
+/*! \brief Port types use for default created ports. */
+typedef enum Ucs_Xrm_PortType_
+{
+ UCS_XRM_PORT_TYPE_MLB = 0x0AU, /*!< \brief MediaLB Port */
+ UCS_XRM_PORT_TYPE_USB = 0x12U, /*!< \brief USB Port */
+ UCS_XRM_PORT_TYPE_STRM = 0x16U /*!< \brief Streaming Port */
+
+} Ucs_Xrm_PortType_t;
+
+/*! \brief This enumerator specifies the kind of result - Internal, Target or Transmission. */
+typedef enum Ucs_Xrm_ResultType_
+{
+ UCS_XRM_RESULT_TYPE_INT = 0x00U, /*!< \brief Specifies the internal results, typically standard return codes of MNS used for synchronous response. */
+ UCS_XRM_RESULT_TYPE_TGT = 0x01U, /*!< \brief Specifies the target results, typically INIC function-specific error from target device. */
+ UCS_XRM_RESULT_TYPE_TX = 0x02U /*!< \brief Specifies the transmission error information on the MOST network. */
+
+} Ucs_Xrm_ResultType_t;
+
+/*! \brief This enumerator specifies the type of resources information */
+typedef enum Ucs_Xrm_ResourceInfos_
+{
+ UCS_XRM_INFOS_BUILT = 0x00U, /*!< \brief Signals that the resource is built */
+ UCS_XRM_INFOS_DESTROYED = 0x01U, /*!< \brief Signals that the resource is destroyed */
+ UCS_XRM_INFOS_ERR_BUILT = 0x02U, /*!< \brief Signals that XRM fails to build the resource */
+ UCS_XRM_INFOS_ERR_DESTROYED = 0x03U /*!< \brief Signals that XRM fails to destroy the resource */
+
+} Ucs_Xrm_ResourceInfos_t;
+
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief INIC Resource Object used for Extended Resource Manager jobs.
+ * \attention This resource object must be \b terminated with a \b NULL \b pointer to mark the end of the list.
+ */
+typedef void Ucs_Xrm_ResObject_t;
+
+/*! \brief Function signature of result callback used by Ucs_Xrm_Stream_SetPortConfig() and
+ * Ucs_Xrm_Stream_GetPortConfig().
+ * \mns_res_inic{StreamPortConfiguration,MNSH3-StreamPortConfiguration680}
+ * \param node_address The node address from which the results come
+ * \param index Streaming Port instance. \mns_name_inic{Index}
+ * \param op_mode Operation mode of the Streaming Port. \mns_name_inic{OperationMode}
+ * \param port_option Direction of the physical pins of the indexed Streaming Port. \mns_name_inic{PortOption}
+ * \param clock_mode Configuration of the FSY/SCK signals. \mns_name_inic{ClockMode}
+ * \param clock_data_delay Configuration of the FSY/SCK signals for Generic Streaming. \mns_name_inic{ClockDataDelay}
+ * \param result Returned result of the operation
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Xrm_Stream_PortCfgResCb_t)(uint16_t node_address,
+ uint8_t index,
+ Ucs_Stream_PortOpMode_t op_mode,
+ Ucs_Stream_PortOption_t port_option,
+ Ucs_Stream_PortClockMode_t clock_mode,
+ Ucs_Stream_PortClockDataDelay_t clock_data_delay,
+ Ucs_StdResult_t result,
+ void *user_ptr);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Detailed information used for Extended Resource Manager results. */
+typedef struct Ucs_Xrm_ResultDetails_
+{
+ /*! \brief Specifies the INIC resource type for which the result has been returned. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Specifies the table index of the resource object for which the result has been returned. */
+ uint8_t resource_index;
+ /*! \brief Specifies the type of the current asynchronous result.
+ * \details The following briefly describes the different types of results available:
+ * - \b UCS_XRM_RESULT_TYPE_INT: internal results, typically standard return codes of MNS used for synchronous response. \n Refer to \em int_result to get the results.
+ * - \b UCS_XRM_RESULT_TYPE_TGT: target results, typically INIC function-specific error from target device. \n Refer to \em inic_result to get the results.
+ * - \b UCS_XRM_RESULT_TYPE_TX: transmission results, typically transmission error on the MOST network. \n Refer to \em tx_result to get the results.
+ */
+ Ucs_Xrm_ResultType_t result_type;
+ /*! \brief Holds the internal MNS results. */
+ Ucs_Return_t int_result;
+ /*! \brief Holds the INIC results. */
+ Ucs_StdResult_t inic_result;
+ /*! \brief Holds the transmission error information. */
+ Ucs_MsgTxStatus_t tx_result;
+
+} Ucs_Xrm_ResultDetails_t;
+
+/*! \brief Result structure of the Extended Resource Manager. */
+typedef struct Ucs_Xrm_Result_
+{
+ /*! \brief Result code. */
+ Ucs_Xrm_ResultCode_t code;
+ /*! \brief Detailed information on the returned result. */
+ Ucs_Xrm_ResultDetails_t details;
+
+} Ucs_Xrm_Result_t;
+
+/*! \brief Resources Identity from user point of view. */
+typedef struct Ucs_Xrm_ResIdentity_
+{
+ /*! \brief Result code. */
+ Ucs_Xrm_ResObject_t * resource_store;
+ /*! \brief Result code. */
+ uint8_t resource_id;
+
+} Ucs_Xrm_ResIdentity_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures used for INIC resource objects */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Configuration structure of a default created port. This structure is used for ports that
+ * are configured via the INIC's Configuration String and are automatically created at
+ * startup.
+ */
+typedef struct Ucs_Xrm_DefaultCreatedPort_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Type of the hardware port */
+ Ucs_Xrm_PortType_t port_type;
+ /*! \brief Port instance identifier */
+ uint8_t index;
+
+} Ucs_Xrm_DefaultCreatedPort_t;
+
+/*! \brief Configuration structure of a MOST socket. */
+typedef struct Ucs_Xrm_MostSocket_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Port resource handle. \mns_param_inic{MOSTPortHandle,MOSTSocketCreate,MNSH3-MOSTSocketCreate611}
+ */
+ uint16_t most_port_handle;
+ /*! \brief Direction of data stream. \mns_param_inic{Direction,MOSTSocketCreate,MNSH3-MOSTSocketCreate611}
+ */
+ Ucs_SocketDirection_t direction;
+ /*! \brief Data type. \mns_param_inic{DataType,MOSTSocketCreate,MNSH3-MOSTSocketCreate611}
+ */
+ Ucs_Most_SocketDataType_t data_type;
+ /*! \brief Required socket bandwidth. \mns_param_inic{Bandwidth,MOSTSocketCreate,MNSH3-MOSTSocketCreate611}
+ */
+ uint16_t bandwidth;
+
+} Ucs_Xrm_MostSocket_t;
+
+/*! \brief Configuration structure of a MediaLB port. */
+typedef struct Ucs_Xrm_MlbPort_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief MLB port instance. \mns_param_inic{Index,MediaLBPortCreate,MNSH3-MediaLBPortCreate621}
+ */
+ uint8_t index;
+ /*! \brief Clock speed configuration. \mns_param_inic{ClockConfig,MediaLBPortCreate,MNSH3-MediaLBPortCreate621}
+ */
+ Ucs_Mlb_ClockConfig_t clock_config;
+
+} Ucs_Xrm_MlbPort_t;
+
+/*! \brief Configuration structure of a MediaLB socket. */
+typedef struct Ucs_Xrm_MlbSocket_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object the socket is attached to. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *mlb_port_obj_ptr;
+ /*! \brief Direction of data stream. \mns_param_inic{Direction,MediaLBSocketCreate,MNSH3-MediaLBSocketCreate631}
+ */
+ Ucs_SocketDirection_t direction;
+ /*! \brief Data type. \mns_param_inic{DataType,MediaLBSocketCreate,MNSH3-MediaLBSocketCreate631}
+ */
+ Ucs_Mlb_SocketDataType_t data_type;
+ /*! \brief Required socket bandwidth. \mns_param_inic{Bandwidth,MediaLBSocketCreate,MNSH3-MediaLBSocketCreate631}
+ */
+ uint16_t bandwidth;
+ /*! \brief MLB channel address. \mns_param_inic{ChannelAddress,MediaLBSocketCreate,MNSH3-MediaLBSocketCreate631}
+ */
+ uint16_t channel_address;
+
+} Ucs_Xrm_MlbSocket_t;
+
+/*! \brief Configuration structure of a USB port. */
+typedef struct Ucs_Xrm_UsbPort_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief USB port instance. \mns_param_inic{Index,USBPortCreate,MNSH3-USBPortCreate661}
+ */
+ uint8_t index;
+ /*! \brief interface of the USB Port’s physical layer. \mns_param_inic{PhysicalLayer,USBPortCreate,MNSH3-USBPortCreate661}
+ */
+ Ucs_Usb_PhysicalLayer_t physical_layer;
+ /*! \brief USB devices interfaces mask. \mns_param_inic{DeviceInterfaces,USBPortCreate,MNSH3-USBPortCreate661}
+ */
+ uint16_t devices_interfaces;
+ /*! \brief OUT Endpoints inside the streaming interface. \mns_param_inic{StreamingIfEpOutCount,USBPortCreate,MNSH3-USBPortCreate661}
+ */
+ uint8_t streaming_if_ep_out_count;
+ /*! \brief IN Endpoints inside the streaming interface. \mns_param_inic{StreamingIfEpInCount,USBPortCreate,MNSH3-USBPortCreate661}
+ */
+ uint8_t streaming_if_ep_in_count;
+
+} Ucs_Xrm_UsbPort_t;
+
+/*! \brief Configuration structure of a USB socket. */
+typedef struct Ucs_Xrm_UsbSocket_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object the socket is attached to. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *usb_port_obj_ptr;
+ /*! \brief Direction of the data stream. \mns_param_inic{Direction,USBSocketCreate,MNSH3-USBSocketCreate671}
+ */
+ Ucs_SocketDirection_t direction;
+ /*! \brief Data type. \mns_param_inic{DataType,USBSocketCreate,MNSH3-USBSocketCreate671}
+ */
+ Ucs_Usb_SocketDataType_t data_type;
+ /*! \brief Address of a USB Endpoint. \mns_param_inic{EndpointAddress,USBSocketCreate,MNSH3-USBSocketCreate671}
+ */
+ uint8_t end_point_addr;
+ /*! \brief Number of MOST network frames/packets per one USB transaction. \mns_param_inic{FramesPerTransfer,USBSocketCreate,MNSH3-USBSocketCreate671}
+ */
+ uint16_t frames_per_transfer;
+
+} Ucs_Xrm_UsbSocket_t;
+
+/*! \brief Configuration structure of a RMCK port. */
+typedef struct Ucs_Xrm_RmckPort_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief RMCK Port instance. \mns_param_inic{Index,RMCKPortCreate,MNSH3-RMCKPortCreate6A1}
+ */
+ uint8_t index;
+ /*! \brief Source of the RMCK clock. \mns_param_inic{ClockSource,RMCKPortCreate,MNSH3-RMCKPortCreate6A1}
+ */
+ Ucs_Rmck_PortClockSource_t clock_source;
+ /*! \brief Divisor of the clock source. \mns_param_inic{Divisor,RMCKPortCreate,MNSH3-RMCKPortCreate6A1}
+ */
+ uint16_t divisor;
+
+} Ucs_Xrm_RmckPort_t;
+
+/*! \brief Configuration structure of a streaming port. */
+typedef struct Ucs_Xrm_StrmPort_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Streaming Port instance. \mns_param_inic{Index,StreamPortCreate,MNSH3-StreamPortCreate681}
+ */
+ uint8_t index;
+ /*! \brief Clock speed configuration. \mns_param_inic{ClockConfig,StreamPortCreate,MNSH3-StreamPortCreate681}
+ */
+ Ucs_Stream_PortClockConfig_t clock_config;
+ /*! \brief Alignment of the data bytes. \mns_param_inic{DataAlignment,StreamPortCreate,MNSH3-StreamPortCreate681}
+ */
+ Ucs_Stream_PortDataAlign_t data_alignment;
+
+} Ucs_Xrm_StrmPort_t;
+
+/*! \brief Configuration structure of a streaming data socket. */
+typedef struct Ucs_Xrm_StrmSocket_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object the socket is attached to. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *stream_port_obj_ptr;
+ /*! \brief Direction of the data stream. \mns_param_inic{Direction,StreamSocketCreate,MNSH3-StreamSocketCreate691}
+ */
+ Ucs_SocketDirection_t direction;
+ /*! \brief Data type. \mns_param_inic{DataType,StreamSocketCreate,MNSH3-StreamSocketCreate691}
+ */
+ Ucs_Stream_SocketDataType_t data_type;
+ /*! \brief Required socket bandwidth in bytes. \mns_param_inic{Bandwidth,StreamSocketCreate,MNSH3-StreamSocketCreate691}
+ */
+ uint16_t bandwidth;
+ /*! \brief ID of the serial interface pin. \mns_param_inic{StreamPinID,StreamSocketCreate,MNSH3-StreamSocketCreate691}
+ */
+ Ucs_Stream_PortPinId_t stream_pin_id;
+
+} Ucs_Xrm_StrmSocket_t;
+
+/*! \brief Configuration structure of a synchronous data connection. */
+typedef struct Ucs_Xrm_SyncCon_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * starting point of the link. Must be a socket of type \c Input.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_in_obj_ptr;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * ending point of the link. Must be a socket of type \c Output.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_out_obj_ptr;
+ /*! \brief Mode of operation of mute. \mns_param_inic{MuteMode,SyncCreate,MNSH3-SyncCreate871}
+ */
+ Ucs_Sync_MuteMode_t mute_mode;
+ /*! \brief Offset from where the socket data should be routed from a splitter. \mns_param_inic{Offset,SyncCreate,MNSH3-SyncCreate871}
+ */
+ uint16_t offset;
+
+} Ucs_Xrm_SyncCon_t;
+
+/*! \brief Configuration structure of a DiscreteFrame Isochronous streaming phase connection. */
+typedef struct Ucs_Xrm_DfiPhaseCon_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * starting point of the link. Must be a socket of type \c Input.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_in_obj_ptr;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * ending point of the link. Must be a socket of type \c Output.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_out_obj_ptr;
+
+} Ucs_Xrm_DfiPhaseCon_t;
+
+/*! \brief Configuration structure of a combiner resource. */
+typedef struct Ucs_Xrm_Combiner_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the synchronous socket. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *port_socket_obj_ptr;
+ /*! \brief Port resource handle. \mns_param_inic{MOSTPortHandle,CombinerCreate,MNSH3-CombinerCreate901}
+ */
+ uint16_t most_port_handle;
+ /*! \brief Total number of data bytes to be transferred each MOST network frame. \mns_param_inic{BytesPerFrame,CombinerCreate,MNSH3-CombinerCreate901}
+ */
+ uint16_t bytes_per_frame;
+
+} Ucs_Xrm_Combiner_t;
+
+/*! \brief Configuration structure of a splitter resource. */
+typedef struct Ucs_Xrm_Splitter_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the synchronous socket. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_in_obj_ptr;
+ /*! \brief Port resource handle. \mns_param_inic{MOSTPortHandle,SplitterCreate,MNSH3-SplitterCreate911}
+ */
+ uint16_t most_port_handle;
+ /*! \brief Total number of data bytes to be transferred each MOST network frame. \mns_param_inic{BytesPerFrame,SplitterCreate,MNSH3-SplitterCreate911}
+ */
+ uint16_t bytes_per_frame;
+
+} Ucs_Xrm_Splitter_t;
+
+/*! \brief Configuration structure for a A/V Packetized isochronous streaming data connection. */
+typedef struct Ucs_Xrm_AvpCon_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * starting point of the link. Must be a socket of type \c Input.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_in_obj_ptr;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * ending point of the link. Must be a socket of type \c Output.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_out_obj_ptr;
+ /*! \brief Size of data packets. \mns_param_inic{IsocPacketSize,AVPacketizedCreate,MNSH3-AVPacketizedCreate861}
+ */
+ Ucs_Avp_IsocPacketSize_t isoc_packet_size;
+
+} Ucs_Xrm_AvpCon_t;
+
+/*! \brief Configuration structure for a Quality of Service IP streaming data connection. */
+typedef struct Ucs_Xrm_QoSCon_
+{
+ /*! \brief Type of the INIC resource object. */
+ Ucs_Xrm_ResourceType_t resource_type;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * starting point of the link. Must be a socket of type \c Input.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_in_obj_ptr;
+ /*! \brief Reference to the INIC resource object that specifies the socket that is the
+ * ending point of the link. Must be a socket of type \c Output.
+ */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *socket_out_obj_ptr;
+
+} Ucs_Xrm_QoSCon_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Function signature used for the MOST Port status.
+ *
+ * This callback function is called to report streaming-related information for a MOST Port.
+ * \param most_port_handle Port resource handle.
+ * \param availability State of the MOST port related to streaming connections.
+ * \param avail_info Sub state to parameter \c availability.
+ * \param free_streaming_bw Free streaming bandwidth for the dedicated MOST Port.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr".
+ * \ingroup G_UCS_IRM
+ */
+typedef void (*Ucs_Xrm_Most_PortStatusCb_t)(uint16_t most_port_handle,
+ Ucs_Most_PortAvail_t availability,
+ Ucs_Most_PortAvailInfo_t avail_info,
+ uint16_t free_streaming_bw,
+ void* user_ptr);
+
+/*! \brief Function signature used for monitoring the XRM resources.
+ * \param resource_type The XRM resource type to be looked for
+ * \param resource_ptr Reference to the resource to be looked for
+ * \param resource_infos Resource information
+ * \param endpoint_inst_ptr Reference to the endpoint object that encapsulates the given resource.
+ * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
+ */
+typedef void (*Ucs_Xrm_ResourceDebugCb_t)(Ucs_Xrm_ResourceType_t resource_type, Ucs_Xrm_ResObject_t *resource_ptr, Ucs_Xrm_ResourceInfos_t resource_infos, void *endpoint_inst_ptr, void *user_ptr);
+
+/*! \brief Function signature used for the check unmute callback.
+ *
+ * Whenever this callback function is called and the EHC has sink connections muted by the mute pin, the application has to ensure that this mute pin is not asserted before attempting unmute.
+ * \param node_address The node address of the device to be looked for.
+ * \ingroup G_UCS_IRM
+ */
+typedef void (*Ucs_Xrm_CheckUnmuteCb_t)(uint16_t node_address, void *user_ptr);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_XRM_PB_H */
+
+/*! @} */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_xrm_pv.h b/ucs2-lib/inc/ucs_xrm_pv.h
new file mode 100644
index 0000000..b3bae38
--- /dev/null
+++ b/ucs2-lib/inc/ucs_xrm_pv.h
@@ -0,0 +1,210 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Private header file of the Extended Resource Manager.
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_XRM_INT
+ * @{
+ */
+
+#ifndef UCS_XRM_PV_H
+#define UCS_XRM_PV_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_rules.h"
+#include "ucs_xrm_cfg.h"
+#include "ucs_xrm.h"
+
+/*------------------------------------------------------------------------------------------------*/
+/* Enumerations */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Result codes of function Xrm_PrepareJobDestruction(). */
+typedef enum Xrm_PreJobDestrResult_
+{
+ XRM_PRE_JOB_DEST_TASKS_EXIST = 0x00U, /*!< \brief There are resources to destroy */
+ XRM_PRE_JOB_DEST_NO_TASKS_EXIST = 0x01U, /*!< \brief All resources already destroyed */
+ XRM_PRE_JOB_DEST_DONE = 0x02U, /*!< \brief Only shared resources affected. Invoke
+ * result callback immediately.
+ */
+ XRM_PRE_JOB_DEST_BUSY = 0x03U /*!< \brief Preparation of JobDestruction is
+ * currently not possible. Other resources
+ * are currently being destroyed.
+ */
+} Xrm_PreJobDestrResult_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure used to count the number of entries of a given resource handle. */
+typedef struct Xrm_CntEntriesResHandle_
+{
+ /*! \brief Reference to the XRM instance to be looked for. */
+ CExtendedResourceManager *xrm_inst;
+ /*! \brief Reference the resource object to be looked for. */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr;
+ /*! \brief Storage for the count result. */
+ uint8_t * cnt_res;
+
+} Xrm_CntEntriesResHandle_t;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal constants (extern declarations only) */
+/*------------------------------------------------------------------------------------------------*/
+extern const uint8_t XRM_SRV_PRIO;
+extern const Srv_Event_t XRM_EVENT_PROCESS;
+extern const Srv_Event_t XRM_EVENT_ERROR;
+extern const Srv_Event_t XRM_EVENT_REQ_INV_RES_LST;
+extern const Srv_Event_t XRM_EVENT_DESTROY_INV_RES;
+extern const Srv_Event_t XRM_EVENT_NOTIFY_AUTO_DEST_RES;
+extern const Srv_Event_t XRM_EVENT_NOTIFY_AUTO_DEST_RESR;
+extern const Srv_Event_t XRM_EVENT_SYNC_NEXT_DEV;
+extern const Srv_Event_t XRM_EVENT_NOTIFY_DESTROYED_JOB;
+extern const Srv_Event_t XRM_EVENT_RESUME_JOB_DESTRUCT;
+extern const Srv_Event_t XRM_EVENT_RESET_RES_MONITOR;
+extern const Srv_Event_t XRM_EVENT_STREAMPORT_CONFIG_SET;
+extern const Srv_Event_t XRM_EVENT_STREAMPORT_CONFIG_GET;
+extern const uint16_t XRM_INVALID_RESOURCE_HANDLE;
+extern const uint16_t XRM_INVALID_CONNECTION_LABEL;
+extern const uint16_t XRM_DEFAULT_SENDER_HANDLE;
+extern const uint16_t XRM_INVALID_NODE_ADDRESS;
+extern const uint16_t XRM_MASK_NETWORK_AVAILABILITY;
+extern const uint16_t XRM_MASK_NETWORK_NODE_ADDRESS;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Internal Prototypes class CExtendedResourceManager */
+/*------------------------------------------------------------------------------------------------*/
+/* Basic functions */
+extern void Xrm_Service(void *self);
+extern bool Xrm_IsApiFree(CExtendedResourceManager *self);
+extern bool Xrm_IsInMyJobList(CExtendedResourceManager *self, UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
+extern void Xrm_ApiLocking(CExtendedResourceManager *self, bool status);
+extern void Xrm_WaitForTxMsgObj(CExtendedResourceManager *self, Srv_Event_t event_mask);
+extern void Xrm_UninitializeService(void *self, void *error_code_ptr);
+extern void Xrm_MnsNwStatusInfosCb(void *self, void *result_ptr);
+extern void Xrm_MsgObjAvailCb(void *self, void *result_ptr);
+extern void Xrm_RmtDevSyncLostCb(void *self, void *result_ptr);
+extern Xrm_PreJobDestrResult_t Xrm_PrepareJobDestruction(CExtendedResourceManager *self);
+extern Xrm_PreJobDestrResult_t Xrm_UnsafePrepareJobDestruction(CExtendedResourceManager *self);
+extern void Xrm_ResumeJobDestruction(CExtendedResourceManager *self);
+extern uint8_t Xrm_CountResourceObjects(CExtendedResourceManager *self, Xrm_Job_t *job_ptr);
+extern Xrm_Job_t * Xrm_GetJob(CExtendedResourceManager *self,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
+extern void * Xrm_GetNextDevInUnnotifiedState(CExtendedResourceManager *self);
+extern uint8_t Xrm_GetResourceObjectIndex(CExtendedResourceManager *self,
+ Xrm_Job_t *job_ptr,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t **obj_pptr);
+extern bool Xrm_SearchNextResourceObject(CExtendedResourceManager *self);
+extern bool Xrm_IsCurrDeviceAlreadyAttached(CExtendedResourceManager *self);
+extern void Xrm_ProcessJob(CExtendedResourceManager *self);
+extern bool Xrm_IsPartOfJobList (void * job_ptr, void * resrc_obj_ptr);
+extern bool Xrm_IsDefaultCreatedPort(CExtendedResourceManager *self,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr);
+extern bool Xrm_StoreResourceHandle(CExtendedResourceManager *self,
+ uint16_t resource_handle,
+ Xrm_Job_t *job_ptr,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr);
+extern bool Xrm_SetJobAsInvalid(void * job_ptr, void * xrm_inst);
+extern bool Xrm_MarkThisResrcAsInvalid (void *resrc_ptr, void * xrm_inst, void *ud_ptr2, void *ud_ptr3);
+extern bool Xrm_FreeResrcHandleAndNtf(void *resrc_ptr, void *resrc_handle, void *job_ptr, void * user_arg);
+extern bool Xrm_SetCurrJobPtr(void *resrc_ptr, void *resrc_handle, void *job_ptr, void * user_arg);
+extern bool Xrm_ReleaseResrcHandle(void *resrc_ptr, void *job_ptr, void *resrc_obj_pptr, void * user_arg);
+extern bool Xrm_CntResHandleEntries(void * job_ptr, void * param_ptr);
+extern bool Xrm_IncrResHandleEntryCnt (void *resrc_ptr, void *job_ptr, void *param_ptr, void * user_arg);
+extern bool Xrm_SetNtfForThisJob(void * job_ptr, void * ud_ptr);
+extern bool Xrm_IsInMyJobsList (void * self, void * job_ptr);
+extern uint16_t Xrm_GetResourceHandle(CExtendedResourceManager *self,
+ Xrm_Job_t *job_ptr,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr,
+ Xrmp_CheckJobListFunc_t func_ptr);
+extern uint8_t Xrm_CountResourceHandleEntries(CExtendedResourceManager *self,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr);
+extern void Xrm_ReleaseResourceHandle(CExtendedResourceManager *self,
+ Xrm_Job_t *job_ptr,
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr);
+extern uint8_t Xrm_ReleaseResourceHandles(CExtendedResourceManager *self,
+ Xrm_Job_t *job_ptr,
+ uint16_t resource_handle_list[],
+ uint8_t resource_handle_list_size,
+ uint16_t failed_resource_handle);
+extern void Xrm_ReleaseResrcHandles(CExtendedResourceManager *self);
+extern void Xrm_HandleError(CExtendedResourceManager *self);
+extern void Xrm_ReportAutoDestructionResult(CExtendedResourceManager *self);
+extern void Xrm_MarkResrcAndJobsAsInvalid (CExtendedResourceManager *self);
+extern void Xrm_MarkRemoteDevicesAsUnsync(CExtendedResourceManager *self);
+extern void Xrm_ReportJobDestructionResult(CExtendedResourceManager *self);
+extern void Xrm_FinishJob(CExtendedResourceManager *self);
+extern void Xrm_NotifyInvalidJobs(CExtendedResourceManager *self);
+
+/* INIC Resource Management API */
+extern void Xrm_CreateMostSocket(CExtendedResourceManager *self);
+extern void Xrm_CreateMlbPort(CExtendedResourceManager *self);
+extern void Xrm_CreateMlbSocket(CExtendedResourceManager *self);
+extern void Xrm_CreateUsbPort(CExtendedResourceManager *self);
+extern void Xrm_CreateUsbSocket(CExtendedResourceManager *self);
+extern void Xrm_CreateRmckPort(CExtendedResourceManager *self);
+extern void Xrm_CreateStreamPort(CExtendedResourceManager *self);
+extern void Xrm_CreateStreamSocket(CExtendedResourceManager *self);
+extern void Xrm_CreateSyncCon(CExtendedResourceManager *self);
+extern void Xrm_CreateDfiPhaseCon(CExtendedResourceManager *self);
+extern void Xrm_CreateCombiner(CExtendedResourceManager *self);
+extern void Xrm_CreateSplitter(CExtendedResourceManager *self);
+extern void Xrm_CreateAvpCon(CExtendedResourceManager *self);
+extern void Xrm_CreateQoSCon(CExtendedResourceManager *self);
+extern void Xrm_ResourceMonitorCb(void *self, void *result_ptr);
+extern void Xrm_RequestResourceList(CExtendedResourceManager *self);
+extern void Xrm_RequestResourceListResultCb(void *self, void *result_ptr);
+extern void Xrm_DestroyResources(CExtendedResourceManager *self, Sobs_UpdateCb_t result_fptr);
+extern void Xrm_ResetResourceMonitor(CExtendedResourceManager *self);
+extern void Xrm_DestroyResourcesResultCb(void *self, void *result_ptr);
+extern void Xrm_DestroyJobResourcesResultCb(void *self, void *result_ptr);
+extern void Xrm_StdResultCb(void *self, void *result_ptr);
+extern void Xrm_Stream_PortConfigResult(void *self, void *result_ptr);
+extern void Xrm_Most_PortEnableResult(void *self, void *result_ptr);
+extern void Xrm_Most_PortEnFullStrResult(void *self, void *result_ptr);
+extern Ucs_Return_t Xrm_RemoteDeviceAttach (CExtendedResourceManager *self, Srv_Event_t next_set_event);
+extern void Xrm_RmtDevAttachResultCb(void *self, Rsm_Result_t result);
+extern Ucs_Return_t Xrm_SetStreamPortConfiguration (CExtendedResourceManager *self);
+extern Ucs_Return_t Xrm_GetStreamPortConfiguration (CExtendedResourceManager *self);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_XRM_PV_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+
diff --git a/ucs2-lib/inc/ucs_xrmpool.h b/ucs2-lib/inc/ucs_xrmpool.h
new file mode 100644
index 0000000..2cea2f6
--- /dev/null
+++ b/ucs2-lib/inc/ucs_xrmpool.h
@@ -0,0 +1,154 @@
+/*------------------------------------------------------------------------------------------------*/
+/* UNICENS V2.1.0-3491 */
+/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
+/* */
+/* This program is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/* You may also obtain this software under a propriety license from Microchip. */
+/* Please contact Microchip for further information. */
+/*------------------------------------------------------------------------------------------------*/
+
+/*!
+ * \file
+ * \brief Internal header file of the Connection Storage Pool.
+ *
+ * \cond UCS_INTERNAL_DOC
+ * \addtogroup G_UCS_XRM_INT
+ * @{
+ */
+
+
+#ifndef UCS_XRMPOOL_H
+#define UCS_XRMPOOL_H
+
+/*------------------------------------------------------------------------------------------------*/
+/* Includes */
+/*------------------------------------------------------------------------------------------------*/
+#include "ucs_xrm_pb.h"
+#include "ucs_dl.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*------------------------------------------------------------------------------------------------*/
+/* Type definitions */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Callback signature used by foreach-function for the resources list
+ * \param rc_ptr Reference to a resource object in the list
+ * \param ud_ptr1 Reference to the user data 1
+ * \param ud_ptr2 Reference to the user data 2
+ * \param ud_ptr3 Reference to the user data 3
+ * \return true: Stop the for-each-loop
+ * \return false: Continue the for-each-loop
+ */
+typedef bool (*Xrmp_ForeachFunc_t)(void *rc_ptr, void *ud_ptr1, void *ud_ptr2, void *ud_ptr3);
+
+/*! \brief Callback signature used by _GetResourceHandle-function to check whether found resources belongs to provided jobs list
+ * \param xrm_inst Reference to the XRM instance to be looked for
+ * \param job_ptr Reference to the job list to be checked
+ * \return true: Stop the for-each-loop since given job matches, otherwise
+ * \return false: Continue the for-each-loop in order to catch new jobs.
+ */
+typedef bool (*Xrmp_CheckJobListFunc_t)(void * xrm_inst, void * job_ptr);
+
+/*! \brief Function signature used for the results and reports of the Extended Resource Manager.
+ * \param node_address The node address from which the results come
+ * \param connection_label Returned MOST network connection label
+ * \param result Result of the job
+ * \param user_arg Reference to the user argument
+ * \ingroup G_UCS_IRM
+ */
+typedef void (*Ucs_Xrm_ReportCb_t)(uint16_t node_address, uint16_t connection_label, Ucs_Xrm_Result_t result, void * user_arg);
+
+/*------------------------------------------------------------------------------------------------*/
+/* Structures */
+/*------------------------------------------------------------------------------------------------*/
+/*! \brief Structure that defines a job of the Extended Resource Manager. */
+typedef struct Xrm_Job_
+{
+ /*! \brief Reference to resource object list */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t **resource_object_list_ptr;
+ /*! \brief Report callback of the job */
+ Ucs_Xrm_ReportCb_t report_fptr;
+ /*! \brief User defined MOST connection label */
+ uint16_t most_network_connection_label;
+ /*! \brief MOST connection label, returned during MOST socket creation */
+ uint16_t connection_label;
+ /*!< \brief Node required for jobs pool */
+ CDlNode node;
+ /*! \brief address of the device in which the job is built */
+ bool sync_lost;
+ /*! \brief State of the job (valid/invalid) */
+ bool valid;
+ /*! \brief Notification flag */
+ bool notify;
+ /*!< \brief user argument */
+ void * user_arg;
+
+} Xrm_Job_t;
+
+/*! \brief Structure that defines an item of the resource handle list. */
+typedef struct Xrm_ResourceHandleListItem_
+{
+ /*! \brief Reference to the job */
+ Xrm_Job_t *job_ptr;
+ /*! \brief Reference to the resource object */
+ UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_ptr;
+ /*! \brief INIC Resource handle */
+ uint16_t resource_handle;
+
+} Xrm_ResourceHandleListItem_t;
+
+/*! \brief Class structure of the Storage Pool of XRM Jobs and Resources. */
+typedef struct CXrmPool_
+{
+ /*! \brief Job list */
+ Xrm_Job_t job_list[XRM_NUM_JOBS];
+ /*! \brief List of resource handles */
+ Xrm_ResourceHandleListItem_t resource_handle_list[XRM_NUM_RESOURCE_HANDLES];
+ /*!< \brief Reference to the resource identification table */
+ Ucs_Xrm_ResIdentity_t * res_id_ptr;
+ /*! \brief Size of the resources Id table.
+ */
+ uint16_t res_id_size;
+
+} CXrmPool;
+
+/*------------------------------------------------------------------------------------------------*/
+/* Prototypes of class CXrmPool */
+/*------------------------------------------------------------------------------------------------*/
+extern void Xrmp_Ctor(CXrmPool * self);
+extern bool Xrmp_StoreResourceHandle(CXrmPool * self_ptr, uint16_t resource_handle, Xrm_Job_t * job_ptr, UCS_XRM_CONST Ucs_Xrm_ResObject_t * resource_object_ptr);
+extern uint16_t Xrmp_GetResourceHandle(CXrmPool * self, Xrm_Job_t * job_ptr, UCS_XRM_CONST Ucs_Xrm_ResObject_t * resource_object_ptr, Xrmp_CheckJobListFunc_t func_ptr, void * usr_ptr);
+extern uint8_t Xrmp_GetResourceHandleIdx(CXrmPool *self, Xrm_Job_t *job_ptr, UCS_XRM_CONST Ucs_Xrm_ResObject_t **obj_pptr);
+extern Xrm_Job_t * Xrmp_GetJob(CXrmPool * self, UCS_XRM_CONST Ucs_Xrm_ResObject_t * resource_object_list[]);
+extern void Xrmp_Foreach(CXrmPool *self, Xrmp_ForeachFunc_t func_ptr, void *user_data_ptr1, void *user_data_ptr2, void *user_data_ptr3);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef UCS_XRMPOOL_H */
+
+/*!
+ * @}
+ * \endcond
+ */
+
+/*------------------------------------------------------------------------------------------------*/
+/* End of file */
+/*------------------------------------------------------------------------------------------------*/
+