Merge pull request #2 from ronan22/master
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_dec.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 Command Decoder Module.
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_DEC_INT
28  * @{
29  */
30
31 #ifndef UCS_DEC_H
32 #define UCS_DEC_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_dl.h"
38 #include "ucs_message.h"
39 /*#include "ucs_ams.h"*/
40
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45
46 /*------------------------------------------------------------------------------------------------*/
47 /* Constants                                                                                      */
48 /*------------------------------------------------------------------------------------------------*/
49 /*! \brief Stores FktID and OPType in one 16 bit value */
50 #define DEC_FKTOP(a,b) ((uint16_t)((((uint16_t)((a)<<4)) & (uint16_t)0xFFF0)) | ((uint16_t)(((uint16_t)(b)) & (uint16_t)0x000F))) /* parasoft-suppress  MISRA2004-19_7 "Is used in arrays and therefore cannot be converted to inline function." */
51
52 /*! \brief Denotes the end of an FktOp table */
53 #define DEC_FKTOP_TERMINATION   0xFFFFU
54
55 /*------------------------------------------------------------------------------------------------*/
56 /* Enumerations                                                                                   */
57 /*------------------------------------------------------------------------------------------------*/
58 /*! \brief Return codes used for decoding functions */
59 /* Attention: these values are used as error descriptor in error messages and
60               must therefore not changed!
61 */
62 typedef enum Dec_Return_
63 {
64     DEC_RET_SUCCESS          = 0x00,        /*!< \brief Operation successfully completed */
65     DEC_RET_FKTID_NOT_FOUND  = 0x03,        /*!< \brief FunctionID not found */
66     DEC_RET_OPTYPE_NOT_FOUND = 0x04         /*!< \brief Operation Type not found */
67
68 } Dec_Return_t;
69
70
71 /*------------------------------------------------------------------------------------------------*/
72 /* Types                                                                                          */
73 /*------------------------------------------------------------------------------------------------*/
74 typedef void (*Dec_IcmCb_t)(void *self, Msg_MostTel_t *msg_ptr);
75 typedef void (*Dec_RcmCb_t)(void *self, Msg_MostTel_t *msg_ptr);
76
77
78
79
80 /*------------------------------------------------------------------------------------------------*/
81 /* Structures                                                                                     */
82 /*------------------------------------------------------------------------------------------------*/
83 /*! \brief   Structure of an FktID_OpType element for FBlock INIC */
84 typedef struct Dec_FktOpIcm_
85 {
86     /*!< \brief FktID and OPType (combined to a 16-bit value) */
87     uint16_t fkt_op;
88     /*!< \brief pointer to the belonging handler function */
89     Dec_IcmCb_t handler_function_ptr;
90
91 } Dec_FktOpIcm_t;
92
93 /*! \brief   Structure of an FktID_OpType element for internal INIC Shadow FBlocks e.g. FBlock EXC*/
94 typedef struct Dec_FktOpIsh_
95 {
96     /*! \brief FktID and OPType (combined to a 16-bit value) */
97     uint16_t fkt_op;
98     /*! \brief pointer to the belonging handler function */
99     Dec_RcmCb_t handler_function_ptr;
100
101 } Dec_FktOpIsh_t;
102
103
104 /*------------------------------------------------------------------------------------------------*/
105 /* Prototypes                                                                                     */
106 /*------------------------------------------------------------------------------------------------*/
107 extern Dec_Return_t Dec_SearchFktOpIcm(Dec_FktOpIcm_t const list[], uint16_t *index_ptr,
108                                        uint16_t function_id, Ucs_OpType_t op_type);
109 extern Dec_Return_t Dec_SearchFktOpIsh(Dec_FktOpIsh_t const list[], uint16_t *index_ptr,
110                                        uint16_t function_id, Ucs_OpType_t op_type);
111
112 #ifdef __cplusplus
113 }   /* extern "C" */
114 #endif
115
116 #endif  /* #ifndef UCS_DEC_H */
117
118 /*!
119  * @}
120  * \endcond
121  */
122
123 /*------------------------------------------------------------------------------------------------*/
124 /* End of file                                                                                    */
125 /*------------------------------------------------------------------------------------------------*/
126