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 the event handler.
26 * \cond UCS_INTERNAL_DOC
34 /*------------------------------------------------------------------------------------------------*/
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_eh_pb.h"
39 #include "ucs_trace.h"
46 /*------------------------------------------------------------------------------------------------*/
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.
52 #define EH_E_SYNC_LOST 0x0001U
53 /*! \brief INIC Build-In-Self-Test failed
55 #define EH_E_BIST_FAILED 0x0002U
56 /*! \brief Notifies completed un-synchronization of Port Message FIFOs
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
62 #define EH_E_UNSYNC_FAILED 0x0008U
63 /*! \brief UNICENS initialization succeeded
65 #define EH_E_INIT_SUCCEEDED 0x0010U
66 /*! \brief UNICENS initialization failed
68 #define EH_E_INIT_FAILED 0x0020U
70 /*! \brief Mask including all events that lead to the termination of the UCS
72 #define EH_M_TERMINATION_EVENTS (EH_E_UNSYNC_COMPLETE | EH_E_UNSYNC_FAILED | \
73 EH_E_BIST_FAILED | EH_E_INIT_FAILED)
75 /*! \brief Bitmask to identify all internal event codes
77 #define EH_M_ALL_EVENTS (EH_M_TERMINATION_EVENTS | EH_E_INIT_SUCCEEDED | EH_E_SYNC_LOST)
79 /*------------------------------------------------------------------------------------------------*/
80 /* Type definitions */
81 /*------------------------------------------------------------------------------------------------*/
82 /*! \brief Function signature used for callback functions which notifies the event handler
84 * \param self Instance pointer
85 * \param event_code Reported event code
87 typedef void (*Ehobs_UpdateCb_t)(void *self, uint32_t event_code);
89 /*------------------------------------------------------------------------------------------------*/
91 /*------------------------------------------------------------------------------------------------*/
92 /*! \brief Class structure of the event handler. */
93 typedef struct CEventHandler_
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 */
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);
118 #endif /* #ifndef UCS_EH_H */
125 /*------------------------------------------------------------------------------------------------*/
127 /*------------------------------------------------------------------------------------------------*/