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 Implementation of the MNS Factory.
26 * \cond UCS_INTERNAL_DOC
31 /*------------------------------------------------------------------------------------------------*/
33 /*------------------------------------------------------------------------------------------------*/
34 #include "ucs_factory.h"
35 #include "ucs_xrm_pv.h"
37 /*------------------------------------------------------------------------------------------------*/
39 /*------------------------------------------------------------------------------------------------*/
40 #define IS_VALID_ADDR(addr) ((UCS_ADDR_LOCAL_DEV == (addr)) || ((0x0FU < (addr)) && (0x300U > (addr))) || ((0x04FFU < (addr)) && (0x0FF0U > (addr)))) /* parasoft-suppress MISRA2004-19_7 "common definition of type cast improves code" */
42 /*------------------------------------------------------------------------------------------------*/
43 /* Internal prototypes */
44 /*------------------------------------------------------------------------------------------------*/
45 static void Fac_ConstructFbi (CFactory * self, CInic * fbi, uint16_t address);
46 static CInic * Fac_SearchFbi(CFactory * self, uint16_t address);
47 static void Fac_ConstructNsm (CFactory * self, CNodeScriptManagement * nsm, uint16_t address);
48 static CRemoteSyncManagement * Fac_SearchRsm(CFactory * self, uint16_t address);
49 static CExtendedResourceManager * Fac_SearchXrm(CFactory * self, uint16_t address);
50 static CGpio * Fac_SearchGpio(CFactory * self, uint16_t address);
51 static CI2c* Fac_SearchI2c(CFactory * self, uint16_t address);
52 static CNodeScriptManagement * Fac_SearchNsm(CFactory * self, uint16_t address);
53 static CInic * Fac_GetUninitializedFbi (CFactory * self);
54 static CNodeScriptManagement * Fac_GetUninitializedNsm (CFactory * self);
55 static CRemoteSyncManagement * Fac_GetUninitializedRsm (CFactory * self);
56 static CExtendedResourceManager * Fac_GetUninitializedXrm (CFactory * self);
57 static CGpio * Fac_GetUninitializedGpio (CFactory * self);
58 static CI2c * Fac_GetUninitializedI2c (CFactory * self);
59 static bool Fac_IsFbiUninitialized(CInic * fbi);
60 static bool Fac_IsRsmUninitialized(CRemoteSyncManagement * rsm);
61 static bool Fac_IsXrmUninitialized(CExtendedResourceManager * xrm);
62 static bool Fac_IsGpioUninitialized(CGpio * gpio);
63 static bool Fac_IsI2cUninitialized(CI2c * i2c);
64 static bool Fac_IsNsmUninitialized(CNodeScriptManagement * nsm);
66 /*------------------------------------------------------------------------------------------------*/
67 /* Implementation of class CFactory */
68 /*------------------------------------------------------------------------------------------------*/
69 /*! \brief Constructor of the MNS Factory class.
70 * \param self Instance pointer
71 * \param init_ptr init data_ptr
73 void Fac_Ctor(CFactory * self, Fac_InitData_t * init_ptr)
76 Rsm_InitData_t rsm_init_data;
78 MISC_MEM_SET(self, 0, sizeof(CFactory));
80 /* set base and net instances */
81 self->base_ptr = init_ptr->base_ptr;
82 self->net_ptr = init_ptr->net_ptr;
83 self->xrmp_ptr = init_ptr->xrmp_ptr;
84 self->icm_transceiver = init_ptr->icm_transceiver;
85 self->rcm_transceiver = init_ptr->rcm_transceiver;
87 rsm_init_data.base_ptr = self->base_ptr;
88 rsm_init_data.net_ptr = self->net_ptr;
90 for (i = 0U; i<FAC_NUM_DEVICES; i++)
92 rsm_init_data.inic_ptr = &self->fbi_list[i];
93 Rsm_Ctor(&self->rsm_list[i], &rsm_init_data);
97 /*------------------------------------------------------------------------------------------------*/
99 /*------------------------------------------------------------------------------------------------*/
100 /*! \brief Returns the XRM instance associated with the given address.
101 * \param self Instance pointer
102 * \param address Address of the device associated with the instance
103 * \param res_debugging_fptr The resources debugging callback function
104 * \param check_unmute_fptr The check unmute callback function
105 * \return a reference to a XRM instance or \c NULL if no appropriate instance has been found.
107 CExtendedResourceManager * Fac_GetXrm(CFactory * self, uint16_t address, Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr)
109 CRemoteSyncManagement * rsm_inst = NULL;
110 CExtendedResourceManager * xrm_inst = NULL;
112 if (IS_VALID_ADDR(address))
114 xrm_inst = Fac_SearchXrm(self, address);
115 if (xrm_inst == NULL)
117 rsm_inst = Fac_GetRsm(self, address);
118 if (rsm_inst != NULL)
120 Xrm_InitData_t xrm_init_data;
121 xrm_inst = Fac_GetUninitializedXrm(self);
122 if (xrm_inst != NULL)
124 xrm_init_data.base_ptr = self->base_ptr;
125 xrm_init_data.net_ptr = self->net_ptr;
126 xrm_init_data.rsm_ptr = rsm_inst;
127 xrm_init_data.inic_ptr = rsm_inst->inic_ptr;
128 xrm_init_data.xrmp_ptr = self->xrmp_ptr;
129 xrm_init_data.check_unmute_fptr = check_unmute_fptr;
130 xrm_init_data.res_debugging_fptr = res_debugging_fptr;
131 Xrm_Ctor(xrm_inst, &xrm_init_data);
135 Xrm_SetResourceDebugCbFn(xrm_inst, res_debugging_fptr);
141 /*! \brief Returns the XRM instance associated with the given address.
142 * \param self Instance pointer
143 * \param address Address of the device associated with the instance
144 * \param check_unmute_fptr The check unmute callback function
145 * \return a reference to a XRM instance or \c NULL if no appropriate instance has been found.
147 CExtendedResourceManager * Fac_GetXrmLegacy(CFactory * self, uint16_t address, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr)
149 return Fac_GetXrm(self, address, NULL, check_unmute_fptr);
153 /*! \brief Returns the XRM instance associated with the resource list.
154 * \note <b>This function should only be used in case of Ucs_Xrm_Destroy() since it's certain in that case that the XRM instance for the given job list already exists!</b>
155 * \param self Instance pointer
156 * \param resource_object_list Reference to the job list
157 * \return a reference to a XRM instance or \c NULL if no appropriate instance has been found.
159 CExtendedResourceManager * Fac_GetXrmByJobList(CFactory * self, UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[])
162 CExtendedResourceManager * ret_xrm = NULL;
164 for(i=0U; i<FAC_NUM_DEVICES; i++)
166 if (Xrm_IsInMyJobList(&self->xrm_list[i], resource_object_list))
168 ret_xrm = &self->xrm_list[i];
176 /*! \brief Returns the FBlock INIC instance associated with the given address.
177 * \param self Instance pointer
178 * \param address Address of the device associated with the instance
179 * \return a reference to a FBI instance or \c NULL if no suitable instance has been found.
181 CInic * Fac_GetInic(CFactory * self, uint16_t address)
183 CInic * fbi_inst = NULL;
185 if (IS_VALID_ADDR(address))
187 fbi_inst = Fac_SearchFbi(self, address);
188 if (fbi_inst == NULL)
190 fbi_inst = Fac_GetUninitializedFbi(self);
191 if (fbi_inst != NULL)
193 Fac_ConstructFbi(self, fbi_inst, address);
201 /*! \brief Returns the CNodeScriptManagement instance associated with the given address.
202 * \param self Instance pointer
203 * \param address Address of the device associated with the instance
204 * \return a reference to a FBI instance or \c NULL if no suitable instance has been found.
206 CNodeScriptManagement * Fac_GetNsm(CFactory * self, uint16_t address)
208 CNodeScriptManagement * nsm_inst = NULL;
210 if (IS_VALID_ADDR(address))
212 nsm_inst = Fac_SearchNsm(self, address);
213 if (nsm_inst == NULL)
215 nsm_inst = Fac_GetUninitializedNsm(self);
216 if (nsm_inst != NULL)
218 Fac_ConstructNsm(self, nsm_inst, address);
226 /*! \brief Returns the RSM instance associated with the given address.
227 * \param self Instance pointer
228 * \param address Address of the device associated with the instance
229 * \return a reference to a RSM instance or \c NULL if no suitable instance has been found.
231 CRemoteSyncManagement * Fac_GetRsm(CFactory * self, uint16_t address)
233 CRemoteSyncManagement * rsm_inst = NULL;
235 if (IS_VALID_ADDR(address))
237 rsm_inst = Fac_SearchRsm(self, address);
238 if (rsm_inst == NULL)
240 rsm_inst = Fac_GetUninitializedRsm(self);
241 if (rsm_inst != NULL)
243 Fac_ConstructFbi(self, rsm_inst->inic_ptr, address);
251 /*! \brief Returns the GPIO instance associated with the given address.
252 * \param self Instance pointer
253 * \param address Address of the device associated with the instance
254 * \param trigger_event_status_fptr User GPIO trigger event status callback function pointer.
255 * \return a reference to a GPIO instance or \c NULL if no suitable instance has been found.
257 CGpio * Fac_GetGpio(CFactory * self, uint16_t address, Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr)
259 CGpio * gpio_inst = NULL;
260 CNodeScriptManagement * nsm_inst = NULL;
262 if (IS_VALID_ADDR(address))
264 gpio_inst = Fac_SearchGpio(self, address);
265 if (NULL == gpio_inst)
267 nsm_inst = Fac_GetNsm(self, address);
268 if (NULL != nsm_inst)
270 Gpio_InitData_t gpio_init_data;
271 gpio_inst = Fac_GetUninitializedGpio(self);
272 if (NULL != gpio_inst)
274 gpio_init_data.nsm_ptr = nsm_inst;
275 gpio_init_data.inic_ptr = nsm_inst->rsm_ptr->inic_ptr;
276 gpio_init_data.trigger_event_status_fptr = trigger_event_status_fptr;
277 Gpio_Ctor(gpio_inst, &gpio_init_data);
286 /*! \brief Returns the I2C instance associated with the given address.
287 * \param self Instance pointer
288 * \param address Address of the device associated with the instance
289 * \param i2c_interrupt_report_fptr User GPIO trigger event status callback function pointer.
290 * \return a reference to an I2C instance or \c NULL if no suitable instance has been found.
292 CI2c * Fac_GetI2c(CFactory * self, uint16_t address, Ucs_I2c_IntEventReportCb_t i2c_interrupt_report_fptr)
294 CI2c * i2c_inst = NULL;
295 CNodeScriptManagement * nsm_inst = NULL;
297 if (IS_VALID_ADDR(address))
299 i2c_inst = Fac_SearchI2c (self, address);
300 if (NULL == i2c_inst)
302 nsm_inst = Fac_GetNsm(self, address);
303 if (nsm_inst != NULL)
305 I2c_InitData_t i2c_init_data;
306 i2c_inst = Fac_GetUninitializedI2c(self);
307 if (NULL != i2c_inst)
309 i2c_init_data.nsm_ptr = nsm_inst;
310 i2c_init_data.inic_ptr = nsm_inst->rsm_ptr->inic_ptr;
311 i2c_init_data.i2c_interrupt_report_fptr = i2c_interrupt_report_fptr;
312 I2c_Ctor(i2c_inst, &i2c_init_data);
321 /*! \brief Searches for the INIC instance associated with the given address and returns It if found.
322 * \param self Instance pointer
323 * \param address Address of the device associated with this instance
324 * \return a reference to the found instance otherwise \c NULL.
326 CInic * Fac_FindInic(CFactory * self, uint16_t address)
328 return Fac_SearchFbi (self, address);
331 /*! \brief Searches for the NSM instance associated with the given address and returns It if found.
332 * \param self Instance pointer
333 * \param address Address of the device associated with this instance
334 * \return a reference to the found instance otherwise \c NULL.
336 CNodeScriptManagement * Fac_FindNsm(CFactory * self, uint16_t address)
338 return Fac_SearchNsm (self, address);
341 /*! \brief Searches for the RSM instance associated with the given address and returns It if found.
342 * \param self Instance pointer
343 * \param address Address of the device associated with this instance
344 * \return a reference to the found instance otherwise \c NULL.
346 CRemoteSyncManagement * Fac_FindRsm(CFactory * self, uint16_t address)
348 return Fac_SearchRsm (self, address);
351 /*! \brief Calls the given function for each instance of inst_type type. If the func_ptr
352 * returns true the loop is stopped.
353 * \param self Reference to a Factory Instance
354 * \param inst_type The instance type to be looked for
355 * \param func_ptr Reference of the callback function which is called for each node
356 * \param user_data_ptr Reference of optional user data pass to the func_ptr
358 void Fac_Foreach(CFactory * self, Fac_Inst_t inst_type, Fac_ForeachFunc_t func_ptr, void *user_data_ptr)
361 void * curr_inst = NULL;
362 bool exit_loop = false;
364 for(j=0U; j<FAC_NUM_DEVICES; j++)
369 curr_inst = &self->fbi_list[j];
370 if (Fac_IsFbiUninitialized((CInic *)curr_inst))
377 curr_inst = &self->rsm_list[j];
378 if (Fac_IsRsmUninitialized((CRemoteSyncManagement *)curr_inst))
385 curr_inst = &self->xrm_list[j];
386 if (Fac_IsXrmUninitialized((CExtendedResourceManager *)curr_inst))
393 curr_inst = &self->gpio_list[j];
394 if (Fac_IsGpioUninitialized((CGpio *)curr_inst))
401 curr_inst = &self->i2c_list[j];
402 if (Fac_IsI2cUninitialized((CI2c *)curr_inst))
412 if (curr_inst != NULL)
414 if (func_ptr(inst_type, curr_inst, user_data_ptr) != false)
431 /*------------------------------------------------------------------------------------------------*/
432 /* Private Methods */
433 /*------------------------------------------------------------------------------------------------*/
434 /*! \brief Search for the FBI instance associated with the given address and return It.
435 * \param self Instance pointer
436 * \param address Address to be looked for
437 * \return a reference to the found FBI or \c NULL if no suitable instance has been found.
439 static CInic * Fac_SearchFbi(CFactory * self, uint16_t address)
441 CInic * found_fbi = NULL;
443 uint16_t tmp_addr = address;
445 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
447 tmp_addr = UCS_ADDR_LOCAL_DEV;
450 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsFbiUninitialized(&self->fbi_list[i])); i++)
452 if (tmp_addr == Inic_GetTargetAddress(&self->fbi_list[i]))
454 found_fbi = &self->fbi_list[i];
462 /*! \brief Search for the NSM instance associated with the given address and return It.
463 * \param self Instance pointer
464 * \param address Address to be looked for
465 * \return a reference to the found NSM or \c NULL if no suitable instance has been found.
467 static CNodeScriptManagement * Fac_SearchNsm(CFactory * self, uint16_t address)
469 CNodeScriptManagement * found_nsm = NULL;
471 uint16_t tmp_addr = address;
473 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
475 tmp_addr = UCS_ADDR_LOCAL_DEV;
478 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsNsmUninitialized(&self->nsm_list[i])); i++)
480 if (tmp_addr == self->nsm_list[i].target_address)
482 found_nsm = &self->nsm_list[i];
490 /*! \brief Search for the RSM instance associated with the given address.
491 * \param self Instance pointer
492 * \param address Address to be looked for
493 * \return a reference to the found RSM or \c NULL if no suitable instance has been found.
495 static CRemoteSyncManagement * Fac_SearchRsm(CFactory * self, uint16_t address)
497 CRemoteSyncManagement * found_rsm = NULL;
499 uint16_t tmp_addr = address;
501 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
503 tmp_addr = UCS_ADDR_LOCAL_DEV;
506 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsFbiUninitialized(self->rsm_list[i].inic_ptr)); i++)
508 if (tmp_addr == Inic_GetTargetAddress(self->rsm_list[i].inic_ptr))
510 found_rsm = &self->rsm_list[i];
518 /*! \brief Search for the XRM instance associated with the given address.
519 * \param self Instance pointer
520 * \param address Address to be looked for
521 * \return a reference to the found XRM or \c NULL if no suitable instance has been found.
523 static CExtendedResourceManager * Fac_SearchXrm(CFactory * self, uint16_t address)
525 CExtendedResourceManager * found_xrm = NULL;
527 uint16_t tmp_addr = address;
529 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
531 tmp_addr = UCS_ADDR_LOCAL_DEV;
534 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsXrmUninitialized(&self->xrm_list[i])); i++)
536 if (tmp_addr == Inic_GetTargetAddress(self->xrm_list[i].rsm_ptr->inic_ptr))
538 found_xrm = &self->xrm_list[i];
546 /*! \brief Search for the Gpio instance associated with the given address.
547 * \param self Instance pointer
548 * \param address Address to be looked for
549 * \return a reference to the found GPIO or \c NULL if no suitable instance has been found.
551 static CGpio * Fac_SearchGpio(CFactory * self, uint16_t address)
553 CGpio * found_gpio = NULL;
555 uint16_t tmp_addr = address;
557 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
559 tmp_addr = UCS_ADDR_LOCAL_DEV;
562 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsGpioUninitialized(&self->gpio_list[i])); i++)
564 if (tmp_addr == Inic_GetTargetAddress(self->gpio_list[i].nsm_ptr->rsm_ptr->inic_ptr))
566 found_gpio = &self->gpio_list[i];
574 /*! \brief Search for the I2c instance associated with the given address.
575 * \param self Instance pointer
576 * \param address Address to be looked for
577 * \return a reference to the found GPIO or \c NULL if no suitable instance has been found.
579 static CI2c * Fac_SearchI2c(CFactory * self, uint16_t address)
581 CI2c * found_i2c = NULL;
583 uint16_t tmp_addr = address;
585 if ((tmp_addr != UCS_ADDR_LOCAL_DEV) && (Net_IsOwnAddress(self->net_ptr, tmp_addr) == NET_IS_OWN_ADDR_NODE))
587 tmp_addr = UCS_ADDR_LOCAL_DEV;
590 for (i = 0U; (i<FAC_NUM_DEVICES) && (!Fac_IsI2cUninitialized(&self->i2c_list[i])); i++)
592 if (tmp_addr == Inic_GetTargetAddress(self->i2c_list[i].nsm_ptr->rsm_ptr->inic_ptr))
594 found_i2c = &self->i2c_list[i];
602 /*! \brief Returns the next free uninitialized XRM instance
603 * \param self Instance pointer
604 * \return a reference to the next free uninitialized XRM instance if found, otherwise \c NULL.
606 static CExtendedResourceManager * Fac_GetUninitializedXrm (CFactory * self)
608 CExtendedResourceManager * tmp_xrm = NULL;
611 for (i = 0U; i<FAC_NUM_DEVICES; i++)
613 if (self->xrm_list[i].rsm_ptr == NULL)
615 tmp_xrm = &self->xrm_list[i];
623 /*! \brief Returns the next free uninitialized FBI instance
624 * \param self Instance pointer
625 * \return a reference to the next free uninitialized FBI instance if found, otherwise \c NULL.
627 static CInic * Fac_GetUninitializedFbi (CFactory * self)
629 CInic * tmp_inic = NULL;
632 for (i = 0U; i<FAC_NUM_DEVICES; i++)
634 if (self->fbi_list[i].base_ptr == NULL)
636 tmp_inic = &self->fbi_list[i];
644 /*! \brief Returns the next free uninitialized NSM instance
645 * \param self Instance pointer
646 * \return a reference to the next free uninitialized NSM instance if found, otherwise \c NULL.
648 static CNodeScriptManagement * Fac_GetUninitializedNsm (CFactory * self)
650 CNodeScriptManagement * tmp_nsm = NULL;
653 for (i = 0U; i<FAC_NUM_DEVICES; i++)
655 if (self->nsm_list[i].base_ptr == NULL)
657 tmp_nsm = &self->nsm_list[i];
665 /*! \brief Returns the next free uninitialized RSM instance
666 * \param self Instance pointer
667 * \return a reference to the next free uninitialized RSM instance if found, otherwise \c NULL.
669 static CRemoteSyncManagement * Fac_GetUninitializedRsm (CFactory * self)
671 CRemoteSyncManagement * tmp_rsm = NULL;
674 for (i = 0U; i<FAC_NUM_DEVICES; i++)
676 if (Inic_GetTargetAddress(self->rsm_list[i].inic_ptr) == 0x0U)
678 tmp_rsm = &self->rsm_list[i];
686 /*! \brief Returns the next free uninitialized GPIO instance
687 * \param self Instance pointer
688 * \return a reference to the next free uninitialized GPIO instance if found, otherwise \c NULL.
690 static CGpio * Fac_GetUninitializedGpio (CFactory * self)
692 CGpio * tmp_gpio = NULL;
695 for (i = 0U; i<FAC_NUM_DEVICES; i++)
697 if (NULL == self->gpio_list[i].nsm_ptr)
699 tmp_gpio = &self->gpio_list[i];
707 /*! \brief Returns the next free uninitialized I2C instance
708 * \param self Instance pointer
709 * \return a reference to the next free uninitialized I2C instance if found, otherwise \c NULL.
711 static CI2c * Fac_GetUninitializedI2c (CFactory * self)
713 CI2c * tmp_i2c = NULL;
716 for (i = 0U; i<FAC_NUM_DEVICES; i++)
718 if (NULL == self->i2c_list[i].nsm_ptr)
720 tmp_i2c = &self->i2c_list[i];
728 /*! \brief Constructs the given FBI instance
729 * \param self the MNS factory Instance pointer
730 * \param fbi the INIC Instance pointer
731 * \param address the device address of this FBlock INIC
733 static void Fac_ConstructFbi (CFactory * self, CInic * fbi, uint16_t address)
735 Inic_InitData_t inic_init_data;
737 if (address == UCS_ADDR_LOCAL_DEV)
739 inic_init_data.xcvr_ptr = self->icm_transceiver;
743 inic_init_data.xcvr_ptr = self->rcm_transceiver;
746 inic_init_data.base_ptr = self->base_ptr;
747 inic_init_data.tgt_addr = address;
749 Inic_Ctor(fbi, &inic_init_data);
752 /*! \brief Constructs the given NSM instance
753 * \param self the MNS factory Instance pointer
754 * \param nsm the NSM Instance pointer
755 * \param address the device address
757 static void Fac_ConstructNsm (CFactory * self, CNodeScriptManagement * nsm, uint16_t address)
759 Nsm_InitData_t nsm_init_data;
761 nsm_init_data.base_ptr = self->base_ptr;
762 nsm_init_data.rcm_ptr = self->rcm_transceiver;
763 nsm_init_data.rsm_ptr = Fac_GetRsm(self, address);
765 Nsm_Ctor(nsm, &nsm_init_data);
768 /*! \brief Checks whether the given FBlock INIC instance is uninitialized
769 * \param fbi the INIC Instance pointer
770 * \return \c true if the given Fbi instance is not initialized, otherwise \c False.
772 static bool Fac_IsFbiUninitialized(CInic * fbi)
774 return (fbi->base_ptr == NULL) ;
777 /*! \brief Checks whether the given NSM instance is uninitialized
778 * \param nsm the NSM Instance pointer
779 * \return \c true if the given NSM instance is not initialized, otherwise \c False.
781 static bool Fac_IsNsmUninitialized(CNodeScriptManagement * nsm)
783 return (nsm->base_ptr == NULL) ;
786 /*! \brief Checks whether the given RSM instance is uninitialized
787 * \param rsm Reference to the RSM instance pointer
788 * \return \c true if the given Fbi instance is not initialized, otherwise \c False.
790 static bool Fac_IsRsmUninitialized(CRemoteSyncManagement * rsm)
792 return Fac_IsFbiUninitialized(rsm->inic_ptr);
795 /*! \brief Checks whether the given XRM instance is uninitialized
796 * \param xrm the XRM Instance pointer
797 * \return \c true if the given XRM instance is not initialized, otherwise \c False.
799 static bool Fac_IsXrmUninitialized(CExtendedResourceManager * xrm)
801 return (xrm->rsm_ptr == NULL) ;
804 /*! \brief Checks whether the given GPIO instance is uninitialized
805 * \param gpio the GPIO Instance pointer
806 * \return \c true if the given GPIO instance is not initialized, otherwise \c False.
808 static bool Fac_IsGpioUninitialized(CGpio * gpio)
810 return (NULL == gpio->nsm_ptr);
813 /*! \brief Checks whether the given I2C instance is uninitialized
814 * \param i2c the I2C Instance pointer
815 * \return \c true if the given I2C instance is not initialized, otherwise \c False.
817 static bool Fac_IsI2cUninitialized(CI2c * i2c)
819 return (NULL == i2c->nsm_ptr);
827 /*------------------------------------------------------------------------------------------------*/
829 /*------------------------------------------------------------------------------------------------*/