ISSDK  1.7
IoT Sensing Software Development Kit
register_io_i2c.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file register_io_i2c.h
37  * @brief The register_io_i2c.h file declares low-level interface functions for reading
38  * and writing sensor registers.
39  */
40 
41 #ifndef __REGISTER_IO_I2C_H__
42 #define __REGISTER_IO_I2C_H__
43 
44 #include "sensor_drv.h"
45 #include "Driver_I2C.h"
46 
47 #if defined(I2C0)
48 /*! @brief The I2C0 device index. */
49 #define I2C0_INDEX 0
50 
51 /*! @brief Defines the I2C signal event handler.
52  * @details The Signal Event Handler function required by register_io_i2c.c.
53  * @param[in] event The I2C event that occured.
54  * @Constraints None
55  * @Reentrant Yes
56  * @return void
57  */
58 void I2C0_SignalEvent_t(uint32_t event);
59 #endif
60 
61 #if defined(I2C1)
62 /*! @brief The I2C1 device index. */
63 #define I2C1_INDEX 1
64 
65 /*! @brief Defines the I2C signal event handler.
66  * @details The Signal Event Handler function required by register_io_i2c.c.
67  * @param[in] event The I2C event that occured.
68  * @Constraints None
69  * @Reentrant Yes
70  * @return void
71  */
72 void I2C1_SignalEvent_t(uint32_t event);
73 #endif
74 
75 #if defined(I2C2)
76 /*! @brief The I2C2 device index. */
77 #define I2C2_INDEX 2
78 
79 /*! @brief Defines the I2C signal event handler.
80  * @details The Signal Event Handler function required by register_io_i2c.c.
81  * @param[in] event The I2C event that occured.
82  * @Constraints None
83  * @Reentrant Yes
84  * @return void
85  */
86 void I2C2_SignalEvent_t(uint32_t event);
87 #endif
88 
89 #if defined(I2C3)
90 /*! @brief The I2C3 device index. */
91 #define I2C3_INDEX 3
92 
93 /*! @brief Defines the I2C signal event handler.
94  * @details The Signal Event Handler function required by register_io_i2c.c.
95  * @param[in] event The I2C event that occured.
96  * @Constraints None
97  * @Reentrant Yes
98  * @return void
99  */
100 void I2C3_SignalEvent_t(uint32_t event);
101 #endif
102 
103 #if defined(I2C4)
104 /*! @brief The I2C4 device index. */
105 #define I2C4_INDEX 4
106 
107 /*! @brief Defines the I2C signal event handler.
108  * @details The Signal Event Handler function required by register_io_i2c.c.
109  * @param[in] event The I2C event that occured.
110  * @Constraints None
111  * @Reentrant Yes
112  * @return void
113  */
114 void I2C4_SignalEvent_t(uint32_t event);
115 #endif
116 
117 #if defined(I2C5)
118 /*! @brief The I2C5 device index. */
119 #define I2C5_INDEX 5
120 
121 /*! @brief Defines the I2C signal event handler.
122  * @details The Signal Event Handler function required by register_io_i2c.c.
123  * @param[in] event The I2C event that occured.
124  * @Constraints None
125  * @Reentrant Yes
126  * @return void
127  */
128 void I2C5_SignalEvent_t(uint32_t event);
129 #endif
130 
131 #if defined(I2C6)
132 /*! @brief The I2C6 device index. */
133 #define I2C6_INDEX 6
134 
135 /*! @brief Defines the I2C signal event handler.
136  * @details The Signal Event Handler function required by register_io_i2c.c.
137  * @param[in] event The I2C event that occured.
138  * @Constraints None
139  * @Reentrant Yes
140  * @return void
141  */
142 void I2C6_SignalEvent_t(uint32_t event);
143 #endif
144 
145 #if defined(I2C7)
146 /*! @brief The I2C7 device index. */
147 #define I2C7_INDEX 7
148 
149 /*! @brief Defines the I2C signal event handler.
150  * @details The Signal Event Handler function required by register_io_i2c.c.
151  * @param[in] event The I2C event that occured.
152  * @Constraints None
153  * @Reentrant Yes
154  * @return void
155  */
156 void I2C7_SignalEvent_t(uint32_t event);
157 #endif
158 
159 /*!
160  * @brief The interface function to write a sensor register.
161  *
162  * @param ARM_DRIVER_I2C *pCommDrv - The I2C driver to use.
163  * @param registerDeviceInfo_t *devInfo - The I2C device number and idle function.
164  * @param uint16_t slaveAddress - the sensor's I2C slave address.
165  * @param uint8_t offset - The register/offset to write to.
166  * @param uint8_t *pBuffer - The buffer containing bytes to write.
167  * @param uint8_t bytesToWrite - A number of bytes to write.
168  *
169  * @return ARM_DRIVER_OK if success or ARM_DRIVER_ERROR if error.
170  */
171 int32_t Register_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv,
172  registerDeviceInfo_t *devInfo,
173  uint16_t slaveAddress,
174  uint8_t offset,
175  const uint8_t *pBuffer,
176  uint8_t bytesToWrite);
177 
178 /*!
179  * @brief The interface function to write a sensor register.
180  *
181  * @param ARM_DRIVER_I2C *pCommDrv - The I2C driver to use.
182  * @param registerDeviceInfo_t *devInfo - The I2C device number and idle function.
183  * @param uint16_t slaveAddress - the sensor's I2C slave address.
184  * @param uint8_t offset - The register/offset to write to
185  * @param uint8_t value - The value to write to the register
186  * @param uint8_t mask - A mask value to use when writing.
187  * A non-zero mask indicates that a read-modify-write operation should be used.
188  * where only the bits set in the mask will be updated according to the value param.
189  * @param bool repeatedStart - Indicates whether to send STOP or REPEATED_START bit after the write
190  *
191  * @return ARM_DRIVER_OK if success or ARM_DRIVER_ERROR if error.
192  */
193 int32_t Register_I2C_Write(ARM_DRIVER_I2C *pCommDrv,
194  registerDeviceInfo_t *devInfo,
195  uint16_t slaveAddress,
196  uint8_t offset,
197  uint8_t value,
198  uint8_t mask,
199  bool repeatedStart);
200 
201 /*!
202  * @brief The interface function to read a sensor register.
203  *
204  * @param ARM_DRIVER_I2C *pCommDrv - The I2C driver to use.
205  * @param registerDeviceInfo_t *devInfo - The I2C device number and idle function.
206  * @param uint16_t slaveAddress - the sensor's I2C slave address.
207  * @param uint8_t offset - The register/offset to read from
208  * @param uint8_t length - The number of bytes to read
209  * @param uint8_t *pOutBuffer - The pointer to the buffer to store the register value read.
210  *
211  * @return ARM_DRIVER_OK if success or ARM_DRIVER_ERROR if error.
212  */
213 int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv,
214  registerDeviceInfo_t *devInfo,
215  uint16_t slaveAddress,
216  uint8_t offset,
217  uint8_t length,
218  uint8_t *pOutBuffer);
219 
220 #endif // __REGISTER_IO_I2C_H__
The sensor_drv.h file contains sensor state and error definitions.
int32_t Register_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to write a sensor register.
int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
int32_t Register_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t value, uint8_t mask, bool repeatedStart)
The interface function to write a sensor register.
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:128