Initial Commit
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_encoder.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 Declaration of message encoder
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup  G_ENCODER
28  * @{
29  */
30
31 #ifndef UCS_ENCODER_H
32 #define UCS_ENCODER_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_message.h"
38
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43
44 /*------------------------------------------------------------------------------------------------*/
45 /* Defines                                                                                        */
46 /*------------------------------------------------------------------------------------------------*/
47 #define ENC_MAX_SIZE_CONTENT    16U     /*!< \brief Maximum content size in bytes, quadlet aligned */
48
49 /*------------------------------------------------------------------------------------------------*/
50 /* Types                                                                                          */
51 /*------------------------------------------------------------------------------------------------*/
52 /*! \brief  Retrieves the size of a MOST message header
53  *  \return The size of the MOST message header in bytes.
54  */
55 typedef uint8_t (*Enc_GetSize_t)(void);
56
57 /*! \brief  Retrieves the content type of a MOST message header
58  *  \return The content type of the MOST message header in bytes.
59  */
60 typedef uint8_t (*Enc_GetContType_t)(void);
61
62 /*! \brief  Encodes a message telegram to the MOST message header 
63  *  \param  tel_ptr     Reference to the Msg_MostTel_t structure 
64  *  \param  header      The header buffer 
65  */
66 typedef void    (*Enc_Encode_t)(Msg_MostTel_t *tel_ptr, uint8_t header[]);
67
68 /*! \brief  Decodes a MOST message header to a message telegram structure 
69  *  \param  tel_ptr     Reference to the Msg_MostTel_t structure 
70  *  \param  header      The header buffer 
71  */
72 typedef void    (*Enc_Decode_t)(Msg_MostTel_t *tel_ptr, uint8_t header[]);
73
74 /*------------------------------------------------------------------------------------------------*/
75 /* Structures                                                                                     */
76 /*------------------------------------------------------------------------------------------------*/
77 /*! \brief      Identifier for a MOST Message Content */
78 typedef enum Enc_MsgContent_
79 {
80     ENC_CONTENT_00 = 0x00,  /*!< \brief Content Type "0x00": Uncompressed, excluding retry values */
81     ENC_CONTENT_80 = 0x80,  /*!< \brief Content Type "0x80": Compressed, excluding retry values */
82     ENC_CONTENT_81 = 0x81   /*!< \brief Content Type "0x81": Compressed, including retry values */
83
84 } Enc_MsgContent_t;
85
86 /*! \brief      Interface for message encoder */
87 typedef struct IEncoder_
88 {
89     Enc_MsgContent_t    content_type;   /*!< \brief Retrieves the content type of the MOST message header */
90     uint8_t             pm_hdr_sz;      /*!< \brief Retrieves the size of the Port Message header */
91     uint8_t             msg_hdr_sz;     /*!< \brief Retrieves the size of the MOST message header */
92     Enc_Encode_t        encode_fptr;    /*!< \brief Function required to encode a MOST message header */
93     Enc_Decode_t        decode_fptr;    /*!< \brief Function required to decode a MOST message header */
94
95 } IEncoder;
96
97 /*------------------------------------------------------------------------------------------------*/
98 /* Function prototypes                                                                            */
99 /*------------------------------------------------------------------------------------------------*/
100 extern IEncoder *Enc_GetEncoder(Enc_MsgContent_t type);
101
102 #ifdef __cplusplus
103 }                                                   /* extern "C" */
104 #endif
105
106 #endif /* #ifndef UCS_ENCODER_H */
107
108 /*!
109  * @}
110  * \endcond
111  */
112
113 /*------------------------------------------------------------------------------------------------*/
114 /* End of file                                                                                    */
115 /*------------------------------------------------------------------------------------------------*/
116