Merge pull request #2 from ronan22/master
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_i2c_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 Public header file of the I2c module.
25  * \addtogroup G_UCS_I2C_TYPES
26  * @{
27  */
28
29 #ifndef UCS_I2C_PB_H
30 #define UCS_I2C_PB_H
31
32 /*------------------------------------------------------------------------------------------------*/
33 /* Includes                                                                                       */
34 /*------------------------------------------------------------------------------------------------*/
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40
41 /*------------------------------------------------------------------------------------------------*/
42 /* Enumerators                                                                                    */
43 /*------------------------------------------------------------------------------------------------*/
44 /*! \brief Result codes of the I2C Module. */
45 typedef enum Ucs_I2c_ResultCode_
46 {
47     UCS_I2C_RES_SUCCESS             = 0x00U,   /*!< \brief I2C command succeeded */
48     UCS_I2C_RES_ERR_CMD             = 0x01U,   /*!< \brief I2C command failed due to an INIC function-specific error or a transmission error on the MOST network.
49                                                 *  \details The \em result_type section in Ucs_I2c_ResultDetails_t will provide you with more detailed information concerning the error type.
50                                                 */
51     UCS_I2C_RES_ERR_SYNC            = 0x02U    /*!< \brief Remote synchronization of target device failed.
52                                                 *  \details The \em inic_result section in Ucs_I2c_ResultDetails_t will provide you with more detailed information concerning the error code.
53                                                 */
54 } Ucs_I2c_ResultCode_t;
55
56 /*! \brief This enumerator specifies the kind of result - Target or Transmission. */
57 typedef enum Ucs_I2c_ResultType_
58 {
59     UCS_I2C_RESULT_TYPE_TGT        = 0x00U,     /*!< \brief Specifies the target results, typically INIC function-specific error from target device. */
60     UCS_I2C_RESULT_TYPE_TX         = 0x01U      /*!< \brief Specifies the transmission error information that occurred on the MOST network. */
61
62 } Ucs_I2c_ResultType_t;
63
64 /*------------------------------------------------------------------------------------------------*/
65 /* Structures                                                                                     */
66 /*------------------------------------------------------------------------------------------------*/
67 /*! \brief Detailed information used for I2C results. */
68 typedef struct Ucs_I2c_ResultDetails_
69 {
70     /*! \brief Specifies the type of the current asynchronous result.
71      *  \details The following briefly describes the different types of results available:
72      *              - \b UCS_I2C_RESULT_TYPE_TGT: target results, typically INIC function-specific error found on target device. \n Refer to \em inic_result to get the detailed information.
73      *              - \b UCS_I2C_RESULT_TYPE_TX:  transmission results, typically transmission error on the MOST network. \n Refer to \em tx_result to get the transmission information.
74      */
75     Ucs_I2c_ResultType_t result_type;
76     /*! \brief Holds the status of the transmission. */
77     Ucs_MsgTxStatus_t tx_result;
78     /*! \brief Holds the results of the target device. */
79     Ucs_StdResult_t inic_result;
80
81 } Ucs_I2c_ResultDetails_t;
82
83 /*! \brief Result structure of the I2C Module. */
84 typedef struct Ucs_I2c_Result_
85 {
86     /*! \brief Result code. */
87     Ucs_I2c_ResultCode_t code;
88     /*! \brief Detailed information on the returned result. */
89     Ucs_I2c_ResultDetails_t details;
90
91 } Ucs_I2c_Result_t;
92
93 /*------------------------------------------------------------------------------------------------*/
94 /* Type definitions                                                                               */
95 /*------------------------------------------------------------------------------------------------*/
96 /*! \brief  Callback function type to retrieve the result of the I2c_CreatePort function
97  *  \param  node_address     The node address of the device from where the results come
98  *  \param  i2c_port_handle  The port resource handle.
99  *  \param  result           The operation result
100  *  \param  user_ptr         User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
101  */
102 typedef void (*Ucs_I2c_CreatePortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, Ucs_I2c_Result_t result, void *user_ptr);
103
104 /*! \brief  Callback function type to retrieve the result of the Gpio_ConfigPinMode function
105  *  \param  node_address        The node address of the device from where the results come
106  *  \param  i2c_port_handle     The port resource handle.
107  *  \param  i2c_slave_address   The 7-bit I2C Port slave address of the peripheral to be read.
108  *  \param  data_len            The number of bytes wrote to the I2C address.
109  *  \param  result              The operation result
110  *  \param  user_ptr            User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
111  */
112 typedef void (*Ucs_I2c_WritePortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, uint8_t i2c_slave_address, uint8_t data_len, Ucs_I2c_Result_t result, void *user_ptr);
113
114 /*! \brief  Callback function type to retrieve the result of the Gpio_ConfigPinMode function
115  *  \param  node_address        The node address of the device from where the results come
116  *  \param  i2c_port_handle     The port resource handle.
117  *  \param  i2c_slave_address   The 7-bit I2C Port slave address of the peripheral from which the data have been read.
118  *  \param  data_len            The number of bytes read from the address.
119  *  \param  data_ptr            The reference to the data list.
120  *  \param  result              The operation result
121  *  \param  user_ptr            User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
122  */
123 typedef void (*Ucs_I2c_ReadPortResCb_t)(uint16_t node_address, uint16_t i2c_port_handle, uint8_t i2c_slave_address, uint8_t data_len, uint8_t data_ptr[], Ucs_I2c_Result_t result, void *user_ptr);
124
125 /*! \brief  Callback function type to report the I2C interrupt event
126  *  \param  node_address     The node address of the device from where the interrupt comes
127  *  \param  user_ptr         User reference provided in \ref Ucs_InitData_t "Ucs_InitData_t::user_ptr"
128  */
129 typedef void (*Ucs_I2c_IntEventReportCb_t)(uint16_t node_address, void *user_ptr);
130
131 #ifdef __cplusplus
132 }   /* extern "C" */
133 #endif
134
135 #endif  /* #ifndef UCS_I2C_PB_H */
136
137 /*! @} */
138
139 /*------------------------------------------------------------------------------------------------*/
140 /* End of file                                                                                    */
141 /*------------------------------------------------------------------------------------------------*/
142