ISSDK  1.7
IoT Sensing Software Development Kit
fxpq3115_drv.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 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 fxpq3115_drv.h
37  * @brief The fxpq3115_drv.h file describes the fxpq3115 driver interface and structures.
38  */
39 
40 #ifndef FXPQ3115_FI_H_
41 #define FXPQ3115_FI_H_
42 
43 /* Standard C Includes */
44 #include <stdint.h>
45 
46 /* ISSDK Includes */
47 #include "fxpq3115.h"
48 #include "sensor_io_i2c.h"
49 #include "register_io_i2c.h"
50 
51 /*******************************************************************************
52  * Macros
53  ******************************************************************************/
54 #define FXPQ3115_PRESSURE_CONV_FACTOR (64) /* Will give Pascals */
55 #define FXPQ3115_ALTITUDE_CONV_FACTOR (65536) /* Will give meters above MSL */
56 #define FXPQ3115_TEMPERATURE_CONV_FACTOR (256) /* Will give °C */
57 
58 /*******************************************************************************
59  * Definitions
60  ******************************************************************************/
61 /*! @brief This defines the sensor specific information. */
62 typedef struct
63 {
64  registerDeviceInfo_t deviceInfo; /*!< I2C device context. */
65  ARM_DRIVER_I2C *pCommDrv; /*!< Pointer to the i2c driver. */
66  bool isInitialized; /*!< Init status.*/
67  uint16_t slaveAddress; /*!< slave address.*/
69 
70 /*! @brief This structure defines the fxpq3115 data buffer in Pressure Mode.*/
71 typedef struct
72 {
73  uint32_t timestamp; /*!< Time stamp value in micro-seconds. */
74  uint32_t pressure; /*!< Sensor pressure output: unsigned 20-bits justified to MSBs. */
75  int16_t temperature; /*!< Sensor temperature output; 2's complement 12-bits justified to MSBs.
76  MS 8-bits are integer degrees Celsius; LS 4-bits are fractional degrees Celsius. */
78 
79 /*! @brief This structure defines the fxpq3115 data buffer in Altitude Mode.*/
80 typedef struct
81 {
82  uint32_t timestamp; /*!< Time stamp value in micro-seconds. */
83  int32_t altitude; /*!< Sensor pressure/altitude output: MS 16-bits are integer meters; LS 4-bits are fractional
84  meters. */
85  int16_t temperature; /*!< Sensor temperature output; 2's complement 12-bits justified to MSBs.
86  MS 8-bits are integer degrees Celsius; LS 4-bits are fractional degrees Celsius. */
88 
89 /*******************************************************************************
90  * APIs
91  ******************************************************************************/
92 /*! @brief The interface function to initialize the sensor.
93  * @details This function initialize the sensor and sensor handle.
94  * @param[in] pSensorHandle handle to the sensor.
95  * @param[in] pBus pointer to the CMSIS API compatible I2C bus object.
96  * @param[in] index the I2C device number.
97  * @param[in] sAddress slave address of the device on the bus.
98  * @param[in] whoami WHO_AM_I value of the device.
99  * @constraints This should be the first API to be called.
100  * Application has to ensure that previous instances of these APIs have exited before invocation.
101  * @reeentrant No
102  * @return ::FXPQ3115_I2C_Initialize() returns the status.
103  */
105  fxpq3115_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi);
106 
107 /*! @brief : The interface function to set the I2C Idle Task.
108  * @param[in] : fxpq3115_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
109  * @param[in] : registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
110  * @param[in] : void *userParam, the pointer to the user idle ftask parameters.
111  * @return void.
112  * @constraints This can be called any number of times only after FXPQ3115_I2C_Initialize().
113  * Application has to ensure that previous instances of these APIs have exited before invocation.
114  * @reeentrant No
115  */
117  registeridlefunction_t idleTask,
118  void *userParam);
119 
120 /*! @brief The interface function to configure he sensor.
121  * @details This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
122  * @param[in] pSensorHandle handle to the sensor.
123  * @param[in] pRegWriteList pointer to the register list.
124  * @constraints This can be called any number of times only after FXPQ3115_I2C_Initialize().
125  * Application has to ensure that previous instances of these APIs have exited before invocation.
126  * @reeentrant No
127  * @return ::FXPQ3115_I2C_Configure() returns the status.
128  */
130 
131 /*! @brief The interface function to read the sensor data.
132  * @details This function read the sensor data out from the device and returns raw data in a byte stream.
133  * @param[in] pSensorHandle handle to the sensor.
134  * @param[in] pReadList pointer to the list of device registers and values to read.
135  * @param[out] pBuffer buffer which holds raw sensor data.This buffer may be back to back databuffer based
136  * command read in the list.
137  * @constraints This can be called only after FXPQ3115_I2C_Initialize().
138  * Application has to ensure that previous instances of these APIs have exited before invocation.
139  * @reeentrant No
140  * @return ::FXPQ3115_I2C_ReadData() returns the status .
141  */
143  const registerreadlist_t *pReadList,
144  uint8_t *pBuffer);
145 
146 /*! @brief The interface function to De Initialize sensor..
147  * @details This function made sensor in a power safe state and de initialize its handle.
148  * @param[in] pSensorHandle handle to the sensor.
149  * @constraints This can be called only after FXPQ3115_I2C_Initialize() has been called.
150  * Application has to ensure that previous instances of these APIs have exited before invocation.
151  * @reeentrant No
152  * @return ::FXPQ3115_I2C_DeInit() returns the status.
153  */
155 
156 #endif // FXPQ3115_FI_H_
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
int32_t FXPQ3115_I2C_Configure(fxpq3115_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: fxpq3115_drv.c:87
registerDeviceInfo_t deviceInfo
Definition: fxpq3115_drv.h:64
This structure defines the fxpq3115 data buffer in Pressure Mode.
Definition: fxpq3115_drv.h:71
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:123
void FXPQ3115_I2C_SetIdleTask(fxpq3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: fxpq3115_drv.c:79
This defines the sensor specific information.
Definition: fxpq3115_drv.h:62
The fxpq3115.h contains the FXPQ3115 Pressure sensor register definitions, access macros...
int32_t FXPQ3115_I2C_ReadData(fxpq3115_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: fxpq3115_drv.c:132
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int32_t FXPQ3115_I2C_DeInit(fxpq3115_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
Definition: fxpq3115_drv.c:161
This structure defines the Write command List.
Definition: sensor_drv.h:94
This structure defines the Read command List.
Definition: sensor_drv.h:104
ARM_DRIVER_I2C * pCommDrv
Definition: fxpq3115_drv.h:65
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:128
This structure defines the fxpq3115 data buffer in Altitude Mode.
Definition: fxpq3115_drv.h:80
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...
int32_t FXPQ3115_I2C_Initialize(fxpq3115_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
Definition: fxpq3115_drv.c:48