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