ISSDK  1.7
IoT Sensing Software Development Kit
sensor_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 sensor_io_i2c.h
37  * @brief The sensor_io_i2c.h file declares low-level interface functions for reading
38  * and writing sensor registers.
39  */
40 
41 #ifndef __SENSOR_IO_I2C_H
42 #define __SENSOR_IO_I2C_H
43 
44 #include <stdint.h>
45 #include <stdbool.h>
46 #include "Driver_I2C.h"
47 #include "register_io_i2c.h"
48 
49 /*******************************************************************************
50  * API
51  ******************************************************************************/
52 /*! @brief Write commands to a sensor
53 
54  * @param[in] pCommDrv pointer to the I2C ARM driver to use
55  * @param[in] devInfo The I2C device number and idle function.
56  * @param[in] slaveAddress the I2C slave address to write to
57  * @param[in] pCommandList a list of one or more commands to write
58  * @param[in] error_mask The mask for Error Code Bits in CoCo Byte
59  *
60  * @return returns the execution status of the operation using ::ESensorErrors
61  */
62 int32_t Sensor_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv,
63  registerDeviceInfo_t *devInfo,
64  uint16_t slaveAddress,
65  const registercommandlist_t *pCommandList,
66  uint8_t error_mask);
67 
68 /*! @brief Write register data to a sensor
69 
70  * @param[in] pCommDrv pointer to the I2C ARM driver to use
71  * @param[in] devInfo The I2C device number and idle function.
72  * @param[in] slaveAddress the I2C slave address to write to
73  * @param[in] pRegWriteList a list of one or more register/value pairs to write
74  *
75  * @return returns the execution status of the operation using ::ESensorErrors
76  */
77 int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv,
78  registerDeviceInfo_t *devInfo,
79  uint16_t slaveAddress,
80  const registerwritelist_t *pRegWriteList);
81 
82 /*! @brief Read register data from a sensor
83 
84  * @param[in] pCommDrv pointer to the I2C ARM driver to use
85  * @param[in] devInfo The I2C device number and idle function.
86  * @param[in] slaveAddress the I2C slave address to read from
87  * @param[in] pReadList a list of one or more register addresses and lengths to read
88  * @param[in] pOutBuffer a pointer of sufficient size to contain the requested read data
89  *
90  *
91  * @return returns the execution status of the operation using ::ESensorErrors
92  */
93 int32_t Sensor_I2C_Read(ARM_DRIVER_I2C *pCommDrv,
94  registerDeviceInfo_t *devInfo,
95  uint16_t slaveAddress,
96  const registerreadlist_t *pReadList,
97  uint8_t *pOutBuffer);
98 
99 #endif /* __SENSOR_IO_I2C_H */
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.
Definition: sensor_io_i2c.c:97
int32_t Sensor_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
int32_t Sensor_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registercommandlist_t *pCommandList, uint8_t error_mask)
Write commands to a sensor.
Definition: sensor_io_i2c.c:50
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
This structure defines the Write command List.
Definition: sensor_drv.h:94
This structure defines the Read command List.
Definition: sensor_drv.h:104
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:128
This structure defines the Block command List.
Definition: sensor_drv.h:113