Ignore packaging and Netbeans launcher
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_pmfifos.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 class CPmFifos
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_PMFIFOS
28  * @{
29  */
30
31 #ifndef UCS_PMFIFOS_H
32 #define UCS_PMFIFOS_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_rules.h"
38 #include "ucs_base.h"
39 #include "ucs_pmfifo.h"
40 #include "ucs_pmchannel.h"
41
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #endif
46
47 /*------------------------------------------------------------------------------------------------*/
48 /* Macros                                                                                         */
49 /*------------------------------------------------------------------------------------------------*/
50 #define FIFOS_SYNC_TIMEOUT      50U     /*!< \brief Synchronization timeout in milliseconds */
51 #define FIFOS_SYNC_RETRIES      40U     /*!< \brief Maximum number of synchronization retries after timeout */
52 #define FIFOS_UNSYNC_TIMEOUT    200U    /*!< \brief Un-synchronization timeout in milliseconds */
53 #define FIFOS_UNSYNC_RETRIES    0U      /*!< \brief Un-synchronization retries */
54
55 /*------------------------------------------------------------------------------------------------*/
56 /* Internal types                                                                                 */
57 /*------------------------------------------------------------------------------------------------*/
58 /*! \brief The synchronization status of all FIFOs */
59 typedef enum Fifos_SyncState_
60
61     FIFOS_S_UNSYNCED,               /*!< \brief Not all FIFOs are synchronized  */
62     FIFOS_S_SYNCING,                /*!< \brief FIFOs synchronization has started */
63     FIFOS_S_SYNCED,                 /*!< \brief All FIFOs are synchronized */
64     FIFOS_S_UNSYNCING               /*!< \brief FIFOs un-synchronization has started */
65
66 } Fifos_SyncState_t;
67
68 /*! \brief  PMS Events */
69 typedef enum Fifos_Event_
70 {
71     FIFOS_EV_SYNC_LOST = 0,         /*!< \brief Synchronization of at least one FIFO is lost */
72     FIFOS_EV_SYNC_ESTABLISHED = 1,  /*!< \brief Synchronization of all FIFOs is established */
73     FIFOS_EV_SYNC_FAILED = 2,       /*!< \brief The initial synchronization of FIFOs failed */
74     FIFOS_EV_UNSYNC_COMPLETE = 3,   /*!< \brief Un-synchronization of all FIFOs has succeeded */
75     FIFOS_EV_UNSYNC_FAILED = 4      /*!< \brief Un-synchronization of all FIFOs has failed */
76
77 } Fifos_Event_t;
78
79 /*! \brief The class CPmFifos*/
80 typedef struct CPmFifos_
81 {
82     CBase      *base_ptr;               /*!< \brief Reference to base object */
83     uint8_t     ucs_inst_id;            /*!< \brief UNICENS instance ID */
84     CPmChannel *channel_ptr;            /*!< \brief UNICENS instance ID */
85
86     CPmFifo *fifos[PMP_MAX_NUM_FIFOS];  /*!< \brief Reference to assigned FIFOs */
87
88     CObserver           obs_icm;        /*!< \brief Observes ICM synchronization state */
89     CObserver           obs_rcm;        /*!< \brief Observes ICM synchronization state */
90     CObserver           obs_mcm;        /*!< \brief Observes MCM synchronization state */
91     Fifos_SyncState_t   state;          /*!< \brief The Overall synchronization state */
92     uint8_t             sync_cnt;       /*!< \brief The current count of synchronization command */
93
94     uint8_t             cmd_retries;    /*!< \brief The number of sync/un-sync retries */
95     uint16_t            cmd_timeout;    /*!< \brief The the timeout to retry sync/un-sync */
96     bool                unsync_initial; /*!< \brief Specifies if un-sync complete shall un-initialize the channel */
97
98     CSubject    event_subject;          /*!< \brief Subject to report synchronization result */
99     CTimer      init_timer;             /*!< \brief Timer elapses on synchronization timeout */
100
101 } CPmFifos;
102
103 /*------------------------------------------------------------------------------------------------*/
104 /* Function prototypes                                                                            */
105 /*------------------------------------------------------------------------------------------------*/
106 extern void Fifos_Ctor(CPmFifos *self, CBase *base_ptr, CPmChannel *channel_ptr, CPmFifo *icm_fifo_ptr, CPmFifo *mcm_fifo_ptr, CPmFifo *rcm_fifo_ptr);
107 extern void Fifos_AddEventObserver(CPmFifos *self, CObserver *obs_ptr);
108 extern void Fifos_RemoveEventObserver(CPmFifos *self, CObserver *obs_ptr);
109 extern void Fifos_Synchronize(CPmFifos *self, bool reset_cnt, bool force_sync);
110 extern void Fifos_Unsynchronize(CPmFifos *self, bool reset_cnt, bool initial);
111 extern void Fifos_ForceTermination(CPmFifos *self);
112 extern void Fifos_ConfigureSyncParams(CPmFifos *self, uint8_t retries, uint16_t timeout);
113
114 #ifdef __cplusplus
115 }                                                   /* extern "C" */
116 #endif
117
118 #endif                                              /* UCS_PMFIFOS_H */
119
120 /*!
121  * @}
122  * \endcond
123  */
124
125 /*------------------------------------------------------------------------------------------------*/
126 /* End of file                                                                                    */
127 /*------------------------------------------------------------------------------------------------*/
128