Merge pull request #2 from ronan22/master
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_cmd_pb.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 Header file of the Command Interpreter.
25  *
26  */
27
28
29 #ifndef UCS_CMD_PB_H
30 #define UCS_CMD_PB_H
31
32 #include "ucs_ams_pb.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39
40
41 /*------------------------------------------------------------------------------------------------*/
42 /* Constants                                                                                          */
43 /*------------------------------------------------------------------------------------------------*/
44 /*! \brief Denotes the end of an MessageId Table
45  *  \ingroup G_UCS_CMD_TYPES
46  */
47 #define UCS_CMD_MSGID_TERMINATION   0xFFFFU
48
49
50
51 /*------------------------------------------------------------------------------------------------*/
52 /* Enumerators                                                                                    */
53 /*------------------------------------------------------------------------------------------------*/
54 /*! \brief Result codes used for Command Interpreter API functions
55  *  \ingroup G_UCS_CMD_TYPES
56  */
57 typedef enum Ucs_Cmd_Return_
58 {
59     UCS_CMD_RET_SUCCESS             = 0x00,     /*!< Operation successfully completed */
60     UCS_CMD_RET_ERR_MSGID_NOTAVAIL  = 0x01,     /*!< MessageId not found */
61     UCS_CMD_RET_ERR_TX_BUSY         = 0x02,     /*!< No free Tx buffer available */
62     UCS_CMD_RET_ERR_APPL            = 0x03,     /*!< Application handler function reports custom error */
63     UCS_CMD_RET_ERR_ALREADY_ENTERED = 0x04,     /*!< MessageId Table already connected */
64     UCS_CMD_RET_ERR_NULL_PTR        = 0x05      /*!< NULL pointer used as argument */
65 } Ucs_Cmd_Return_t;
66
67 /*------------------------------------------------------------------------------------------------*/
68 /* Types                                                                                          */
69 /*------------------------------------------------------------------------------------------------*/
70 /*! \brief Type definition of user handler functions
71  *  \param   msg_rx_ptr     Reference to the received message
72  *  \param   user_ptr      User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
73  *  \return  Possible return values are shown in the table below.
74  *  Value                           | Description 
75  *  ------------------------------- | ------------------------------------
76  *  UCS_CMD_RET_SUCCESS             | The handler function succeeded.
77  *  UCS_CMD_RET_ERR_TX_BUSY         | The handler function could not send an answer because no free Tx Buffer was available.
78  *  UCS_CMD_RET_ERR_APPL            | An error happened in handler function. 
79  *  \note    The application must not return other values than the ones listed above.
80  *  \ingroup G_UCS_CMD_TYPES
81  */
82 typedef Ucs_Cmd_Return_t (*Ucs_Cmd_Handler_Function_t)(Ucs_AmsRx_Msg_t *msg_rx_ptr, void *user_ptr);
83
84
85
86 /*------------------------------------------------------------------------------------------------*/
87 /* Structures                                                                                     */
88 /*------------------------------------------------------------------------------------------------*/
89
90 /*! \brief   Structure of a single element of the MessageId Table
91  *  \details The application provides a MessageId Table which contains all supported MessageIds
92  *           with their belonging handler functions. The MessageId Table is an array of several 
93  *           Ucs_Cmd_MsgId_t elements. It has to end with a termination entry with the 
94  *           value {\ref UCS_CMD_MSGID_TERMINATION, NULL}.
95  *  \ingroup G_UCS_CMD_TYPES
96  */
97 typedef struct Ucs_Cmd_MsgId_
98 {
99     /*! \brief MessageId */
100     uint16_t msg_id;
101     /*! \brief Pointer to the belonging handler function */
102     Ucs_Cmd_Handler_Function_t handler_function_ptr;
103
104 } Ucs_Cmd_MsgId_t;
105
106
107
108
109 /*------------------------------------------------------------------------------------------------*/
110 /* Prototypes                                                                                     */
111 /*------------------------------------------------------------------------------------------------*/
112
113
114
115 #ifdef __cplusplus
116 }   /* extern "C" */
117 #endif
118
119 #endif /* UCS_CMD_PB_H */
120
121 /*------------------------------------------------------------------------------------------------*/
122 /* End of file                                                                                    */
123 /*------------------------------------------------------------------------------------------------*/
124