1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
25 * \brief Internal header file of the Remote Sync Manager.
27 * \cond UCS_INTERNAL_DOC
36 /*------------------------------------------------------------------------------------------------*/
38 /*------------------------------------------------------------------------------------------------*/
42 #include "ucs_ret_pb.h"
44 #include "ucs_rsm_pv.h"
52 /*------------------------------------------------------------------------------------------------*/
54 /*------------------------------------------------------------------------------------------------*/
55 /*! \brief RSM internal state transitions */
56 typedef enum Rsm_StateTransition_
58 RSM_ST_IDLE, /*!< \brief Transition to "Idle" state */
59 RSM_ST_SYNC_REQ, /*!< \brief Transition to "Sync Request" state */
60 RSM_ST_NTF_REQ, /*!< \brief Transition to "Notification Request" state */
61 RSM_ST_NTF_CLEAR, /*!< \brief Transition to "Notification Clear" state */
62 RSM_ST_NTF_ALL, /*!< \brief Transition to "All Notification" state */
63 RSM_ST_NTF_GPIO, /*!< \brief Transition to "Gpio Notification" state */
64 RSM_ST_SYNC_SUCC, /*!< \brief Transition to "Sync Success" state */
65 RSM_ST_SYNC_ERR /*!< \brief Transition to "Sync Error" state */
67 } Rsm_StateTransition_t;
69 /*------------------------------------------------------------------------------------------------*/
71 /*------------------------------------------------------------------------------------------------*/
72 /*! \brief Stores data required by RSM during initialization. */
73 typedef struct Rsm_InitData_
75 CBase *base_ptr; /*!< \brief Reference to base instance */
76 CInic *inic_ptr; /*!< \brief Reference to INIC instance */
77 CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
81 /*! \brief Stores information required for a RSM device. */
82 typedef struct Rsm_DeviceInfos_
84 /*! \brief State of the device */
85 Rsm_DevSyncState_t sync_state;
86 /*! \brief next state transition */
87 Rsm_StateTransition_t next_st;
88 /*! \brief stores the current result */
89 Rsm_Result_t curr_result;
90 /*! \brief stores the current user data that'll be passes to curr_res_cb_fptr */
91 void * curr_user_data;
92 /*! \brief current result callback function ptr */
93 Rsm_ResultCb_t curr_res_cb_fptr;
97 /*! \brief Stores parameter used for signaling RSM event. */
98 typedef struct Rsm_EventParam_
100 /*! \brief own current device address */
101 uint16_t own_device_address;
102 /*! \brief max node position */
103 uint8_t max_node_pos;
104 /*! \brief Result observer used for sockets, ports and connections */
105 CSingleObserver stdresult_observer;
106 /*! \brief Observer used to monitor ICM or MCM Tx Message objects availability */
107 CObserver txavailability_observer;
108 /*! \brief Observer used to monitor MNS initialization result */
109 CMaskedObserver ucsinit_observer;
110 /*! \brief Observe MOST Network status in Net module */
111 CMaskedObserver nwstatus_observer;
112 /*! \brief Own subject to notify the SyncLost event */
117 /*! \brief Class structure of the Remote Sync Management. */
118 typedef struct CRemoteSyncManagement_
120 /*! \brief Reference to an INIC instance */
122 /*! \brief Reference to a base instance */
124 /*! \brief Reference to a network instance */
125 CNetworkManagement *net_ptr;
126 /*! \brief RSM DeviceInfos list */
127 Rsm_DeviceInfos_t dev_infos;
128 /*! \brief stores the last synclost cause */
129 Rsm_SyncLostCause_t last_synclost_cause;
130 /*! \brief Parameter object for the RSM Event */
131 Rsm_EventParam_t event_param;
132 /*! \brief Service instance for the scheduler */
135 } CRemoteSyncManagement;
137 /*------------------------------------------------------------------------------------------------*/
138 /* Prototypes of class CRemoteSyncManagement */
139 /*------------------------------------------------------------------------------------------------*/
140 extern void Rsm_Ctor(CRemoteSyncManagement * self, Rsm_InitData_t * init_ptr);
141 extern void Rsm_AddObserver(CRemoteSyncManagement * self, CObserver * obs);
142 extern void Rsm_DelObserver(CRemoteSyncManagement * self, CObserver * obs_ptr);
143 extern Ucs_Return_t Rsm_SyncDev(CRemoteSyncManagement * self, void* user_data, Rsm_ResultCb_t sync_complete_fptr);
144 extern Rsm_DevSyncState_t Rsm_GetDevState(CRemoteSyncManagement * self);
145 extern void Rsm_ReportSyncLost (CRemoteSyncManagement * self);
151 #endif /* #ifndef UCS_RSM_H */
158 /*------------------------------------------------------------------------------------------------*/
160 /*------------------------------------------------------------------------------------------------*/