Ignore packaging and Netbeans launcher
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_eh.h
1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491                                                                            */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
4 /*                                                                                                */
5 /* This program is free software: you can redistribute it and/or modify                           */
6 /* it under the terms of the GNU General Public License as published by                           */
7 /* the Free Software Foundation, either version 2 of the License, or                              */
8 /* (at your option) any later version.                                                            */
9 /*                                                                                                */
10 /* This program is distributed in the hope that it will be useful,                                */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
13 /* GNU General Public License for more details.                                                   */
14 /*                                                                                                */
15 /* You should have received a copy of the GNU General Public License                              */
16 /* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
17 /*                                                                                                */
18 /* You may also obtain this software under a propriety license from Microchip.                    */
19 /* Please contact Microchip for further information.                                              */
20 /*------------------------------------------------------------------------------------------------*/
21
22 /*!
23  * \file
24  * \brief Internal header file of the event handler.
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_EH
28  * @{
29  */
30
31 #ifndef UCS_EH_H
32 #define UCS_EH_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_eh_pb.h"
38 #include "ucs_obs.h"
39 #include "ucs_trace.h"
40
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45
46 /*------------------------------------------------------------------------------------------------*/
47 /* Definitions                                                                                    */
48 /*------------------------------------------------------------------------------------------------*/
49 /*! \brief A control FIFO synchronization is lost. When this event occurs the PMS still waits 
50  *         until all FIFOs are unsynchronized. So this event is no termination event.
51  */
52 #define EH_E_SYNC_LOST              0x0001U
53 /*! \brief INIC Build-In-Self-Test failed
54  */
55 #define EH_E_BIST_FAILED            0x0002U
56 /*! \brief Notifies completed un-synchronization of Port Message FIFOs
57  */
58 #define EH_E_UNSYNC_COMPLETE        0x0004U
59 /*! \brief Notifies that the Port Message Channel was not able to un-synchronize its FIFOs 
60  *         within a definite time
61  */
62 #define EH_E_UNSYNC_FAILED          0x0008U
63 /*! \brief UNICENS initialization succeeded
64  */
65 #define EH_E_INIT_SUCCEEDED         0x0010U
66 /*! \brief UNICENS initialization failed
67  */
68 #define EH_E_INIT_FAILED            0x0020U
69
70 /*! \brief Mask including all events that lead to the termination of the UCS
71  */
72 #define EH_M_TERMINATION_EVENTS     (EH_E_UNSYNC_COMPLETE | EH_E_UNSYNC_FAILED | \
73                                      EH_E_BIST_FAILED | EH_E_INIT_FAILED)
74
75 /*! \brief Bitmask to identify all internal event codes
76  */
77 #define EH_M_ALL_EVENTS             (EH_M_TERMINATION_EVENTS | EH_E_INIT_SUCCEEDED | EH_E_SYNC_LOST)
78
79 /*------------------------------------------------------------------------------------------------*/
80 /* Type definitions                                                                               */
81 /*------------------------------------------------------------------------------------------------*/
82 /*! \brief Function signature used for callback functions which notifies the event handler 
83  *         observers.
84  *  \param self             Instance pointer
85  *  \param event_code       Reported event code
86  */
87 typedef void (*Ehobs_UpdateCb_t)(void *self, uint32_t event_code);
88
89 /*------------------------------------------------------------------------------------------------*/
90 /* Structures                                                                                     */
91 /*------------------------------------------------------------------------------------------------*/
92 /*! \brief  Class structure of the event handler. */
93 typedef struct CEventHandler_
94 {
95     /*! \brief Subject used for internal events */
96     CSubject internal_event_subject;
97     /*! \brief Single subject to report error to application */
98     CSingleSubject public_error_subject;
99     /*! \brief UNICENS instance ID */
100     void * ucs_user_ptr;
101
102 } CEventHandler;
103
104 /*------------------------------------------------------------------------------------------------*/
105 /* Prototypes of class CEventHandler                                                              */
106 /*------------------------------------------------------------------------------------------------*/
107 extern void Eh_Ctor(CEventHandler *self, void *ucs_user_ptr);
108 extern void Eh_AddObsrvPublicError(CEventHandler *self, CSingleObserver *obs_ptr);
109 extern void Eh_DelObsrvPublicError(CEventHandler *self);
110 extern void Eh_ReportEvent(CEventHandler *self, uint32_t event_code);
111 extern void Eh_AddObsrvInternalEvent(CEventHandler *self, CMaskedObserver *obs_ptr);
112 extern void Eh_DelObsrvInternalEvent(CEventHandler *self, CMaskedObserver *obs_ptr);
113
114 #ifdef __cplusplus
115 }   /* extern "C" */
116 #endif
117
118 #endif  /* #ifndef UCS_EH_H */
119
120 /*!
121  * @}
122  * \endcond
123  */
124
125 /*------------------------------------------------------------------------------------------------*/
126 /* End of file                                                                                    */
127 /*------------------------------------------------------------------------------------------------*/
128