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 /*------------------------------------------------------------------------------------------------*/
24 * \brief Internal header file of UNICENS API class
25 * \cond UCS_INTERNAL_DOC
26 * \addtogroup G_UCS_CLASS
32 /*------------------------------------------------------------------------------------------------*/
34 /*------------------------------------------------------------------------------------------------*/
35 #include "ucs_class_pb.h"
37 #include "ucs_pmfifo.h"
38 #include "ucs_pmchannel.h"
39 #include "ucs_pmevent.h"
40 #include "ucs_transceiver.h"
41 #include "ucs_factory.h"
45 #include "ucs_attach.h"
46 #include "ucs_nodedis.h"
47 #include "ucs_bc_diag.h"
48 #include "ucs_sys_diag.h"
55 #include "ucs_nodeobserver.h"
62 /*------------------------------------------------------------------------------------------------*/
64 /*------------------------------------------------------------------------------------------------*/
65 /*! \brief Assignable callback function which is invoked to filter Rx messages
66 * \details Filtering is a synchronous operation. Hence, it is not possible to keep a message
67 * object for delayed processing. The invoked function has to decide whether a
68 * message shall be discarded and freed to the Rx pool. Therefore, it has to return
69 * \c true. By returning \ false, the message will be received in the usual way.
70 * \param tel_ptr Reference to the message object
71 * \param user_ptr User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
72 * \return Returns \c true to discard the message and free it to the pool (no-pass). Otherwise, returns
75 typedef bool (*Ucs_RxFilterCb_t)(Msg_MostTel_t *tel_ptr, void *user_ptr);
77 /*! \brief This structure holds instance and related parameters of the base component */
78 typedef struct Ucs_GeneralData_
80 /*! \brief Instance of the Base component */
82 /*! \brief Application callback to request UNICENS service calls */
83 Ucs_RequestServiceCb_t request_service_fptr;
84 /*! \brief Observer to proxy callback request_service_fptr() */
85 CSingleObserver service_request_obs;
86 /*! \brief Application callback to report general errors */
87 Ucs_ErrorCb_t general_error_fptr;
88 /*! \brief Observer to proxy callback general_error_fptr() */
89 CSingleObserver general_error_obs;
90 /*! \brief Application callback to request the current tick count value */
91 Ucs_GetTickCountCb_t get_tick_count_fptr;
92 /*! \brief Observer to proxy callback get_tick_count_fptr() */
93 CSingleObserver get_tick_count_obs;
94 /*! \brief Application callback to start the application timer needed for UNICENS event triggered service call. */
95 Ucs_SetAppTimerCb_t set_application_timer_fptr;
96 /*! \brief Observer to proxy callback set_application_timer_fptr() */
97 CSingleObserver set_application_timer_obs;
101 /*! \brief This structure holds the reference to the local FBlock INIC instance and related parameters */
102 typedef struct Ucs_InicData_
104 /*! \brief Reference to the local Instance of the FBlock INIC component */
106 /*! \brief Instance of the Attach service */
107 CAttachService attach;
108 /*! \brief Observer to proxy callback power_state_fptr() */
109 CObserver device_status_obs;
110 /*! \brief The last known power state, required since no masked observer is available */
111 Ucs_Inic_PowerState_t power_state;
115 /*! \brief This structure holds the Resources Management callback functions */
116 typedef struct Ucs_UcsXrm_
118 /*! \brief Callback function that reports streaming-related information for the MOST Network
119 * Port, including the state of the port and available streaming bandwidth.
121 Ucs_Xrm_Most_PortStatusCb_t most_port_status_fptr;
122 /*! \brief Observer to proxy callback most_port_status_fptr() */
123 CObserver most_port_status_obs;
127 /*! \brief This structure holds the Network Management instance and related parameters */
128 typedef struct Ucs_NetData_
130 /*! \brief Instance of the Network Management */
131 CNetworkManagement inst;
132 /*! \brief Application callback for NetworkStartup() */
133 Ucs_StdResultCb_t startup_fptr;
134 /*! \brief Observer to proxy callback startup_fptr() */
135 CSingleObserver startup_obs;
136 /*! \brief Application callback for NetworkShutdown() */
137 Ucs_StdResultCb_t shutdown_fptr;
138 /*! \brief Observer to proxy callback shutdown_fptr() */
139 CSingleObserver shutdown_obs;
140 /*! \brief Application callback for NetworkForceNotAvailable() */
141 Ucs_StdResultCb_t force_na_fptr;
142 /*! \brief Observer to proxy callback force_na_fptr() */
143 CSingleObserver force_na_obs;
144 /*! \brief Application callback for NetworkFrameCounterGet() */
145 Ucs_Network_FrameCounterCb_t frame_counter_fptr;
146 /*! \brief Observer to proxy callback frame_counter_fptr() */
147 CSingleObserver frame_counter_obs;
148 /*! \brief Application callback to report network status */
149 Ucs_Network_StatusCb_t status_fptr;
150 /*! \brief Observer to proxy callback status_fptr() */
151 CMaskedObserver status_obs;
153 /*! \brief Application callback for NetworkForceNotAvailable() */
154 Ucs_StdResultCb_t force_na_fptr;
155 /*! \brief Observer to proxy callback force_na_fptr() */
156 CSingleObserver force_na_obs;
162 /*! \brief This structure holds attach process related parameters */
163 typedef struct Ucs_AtsData_
165 /*! \brief Instance of the Attach service */
167 /*! \brief Function pointer to start the attach process */
168 /* Ucs_StartAttachCb_t start_attach_fptr; */
169 /*! \brief Reference to instance used during the attach process */
170 /*void *attach_inst_ptr;*/
175 typedef struct Ucs_MsgData_
177 /*! \brief The MCM FIFO */
179 /*! \brief The MCM communication module */
180 CTransceiver mcm_transceiver;
181 /*! \brief Application message distributor */
183 /*! \brief Memory allocator required for the application message service */
184 Ams_MemAllocator_t ams_allocator;
185 /*! \brief Application message pool */
186 CAmsMsgPool ams_pool;
187 /*! \brief Application message service */
189 /*! \brief Static memory management */
190 CStaticMemoryManager smm;
191 /*! \brief Observer to proxy callback tx_message_freed_fptr() */
192 CObserver ams_tx_freed_obs;
193 /*! \brief Signals that tx_message_freed_fptr() must be called as soon as
194 * a Tx message object is freed the next time.
196 bool ams_tx_alloc_failed;
197 /*! \brief Command Interpreter */
203 /*------------------------------------------------------------------------------------------------*/
205 /*------------------------------------------------------------------------------------------------*/
206 /*! \brief The class CUcs representing the UNICENS API */
209 /*! \brief Stores the instance id, which is generated by Ucs_CreateInstance() */
211 /*! \brief User reference that needs to be passed in every callback function */
213 /*! \brief Backup of initialization data */
214 Ucs_InitData_t init_data;
215 /*! \brief Stores the init result callback function */
216 Ucs_InitResultCb_t init_result_fptr;
217 /*! \brief Observer to proxy callback init_result_fptr() */
218 CSingleObserver init_result_obs;
219 /*! \brief Stores the result callback function for Ucs_Stop() */
220 Ucs_StdResultCb_t uninit_result_fptr;
221 /*! \brief Observer to proxy callback uninit_result_fptr() */
222 CMaskedObserver uninit_result_obs;
223 /*! \brief General data required for base component */
224 Ucs_GeneralData_t general;
226 /*! \brief Instance of port message channel (service) */
228 /*! \brief Instance of port message event handler */
230 /*! \brief Instance of port message FIFOs */
232 /*! \brief The ICM FIFO */
234 /*! \brief The RCM FIFO */
236 /*! \brief The ICM communication module */
237 CTransceiver icm_transceiver;
238 /*! \brief The RCM communication module */
239 CTransceiver rcm_transceiver;
240 /*! \brief Factory component instance */
242 /*! \brief INIC Resources Management callbacks functions */
244 /*!< \brief The XRM Pool instance */
246 /*!< \brief The Routes Management instance */
247 CRouteManagement rtm;
248 /*!< \brief The EndPoints Management instance */
249 CEndpointManagement epm;
250 /*! \brief FBlock INIC instance and related parameters */
252 /*! \brief Network Management instance and related parameters */
254 /*! \brief FBlock EXC component instance and related parameters */
256 /*! \brief System diagnosis component instance and related parameters */
258 /*! \brief Node Discovery instance and related parameters */
260 /*! \brief BackChannel Diagnosis instance and related parameters */
261 CBackChannelDiag bcd;
262 /*! \brief Programming Interface instance and parameters */
264 /*! \brief Application Message related Data */
266 /*! \brief The manager instance */
268 /*! \brief The node observer instance */
270 /*! \brief Filter callback required for unit testing*/
271 Ucs_RxFilterCb_t rx_filter_fptr;
273 /*! \brief Is \c true if initialization completed successfully */
278 /*------------------------------------------------------------------------------------------------*/
279 /* Unit tests only */
280 /*------------------------------------------------------------------------------------------------*/
281 extern void Ucs_AssignRxFilter(Ucs_Inst_t *self, Ucs_RxFilterCb_t callback_fptr);
287 #endif /* UCS_CLASS_H */
294 /*------------------------------------------------------------------------------------------------*/
296 /*------------------------------------------------------------------------------------------------*/