ISSDK  1.7
IoT Sensing Software Development Kit
mma8491q_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 mma8491q_drv.h
37  * @brief The mma8491q_drv.h file describes the MMA8491Q driver interface and structures.
38  */
39 
40 #ifndef MMA8491Q_FI_H_
41 #define MMA8491Q_FI_H_
42 
43 /* Standard C Includes */
44 #include <stdint.h>
45 
46 /* ISSDK Includes */
47 #include "mma8491q.h"
48 #include "sensor_io_i2c.h"
49 #include "register_io_i2c.h"
50 
51 /*******************************************************************************
52  * Definitions
53  ******************************************************************************/
54 /*! @brief This defines the function pointers and sensor specific information. */
55 typedef struct
56 {
57  registerDeviceInfo_t deviceInfo; /*!< I2C device context. */
58  ARM_DRIVER_I2C *pCommDrv; /*!< Pointer to the i2c driver. */
59  bool isInitialized; /*!< Init status.*/
60  uint16_t slaveAddress; /*!< slave address.*/
62 
63 /*! @brief This structure defines the mma8491q data buffer.*/
64 typedef struct
65 {
66  uint32_t timestamp; /*!< Time stamp value in micro-seconds. */
67  int16_t accel[3]; /*! Sensor Acceleration output: signed 14-bits. */
68  uint8_t tilt[3]; /*! 3-Axis Tilt output. */
70 
71 /*! @brief This structure stores the Sensor's context parameters. */
72 typedef struct
73 {
74  uint64_t adjustedODR; /*! The actual ODR calculated considering T_On and T_Rst. */
75  void *pGpioEN; /*! The GPIO handle for the EN Pin. */
76  uint8_t sensorMode; /*! The current operating Mode of the Sensor. */
77  volatile bool inTransition; /*! The Flag indicating Sensor is undergoing Transition to another mode as a result of
78  EN pin toggling. */
80 
81 /*! @brief This enum lists the MMA8491Q operating Modes. */
82 enum
83 {
87 };
88 
89 #define MMA8491Q_DATA_SIZE (6) /* 2 byte X,Y,Z Axis Data each. */
90 
91 /*******************************************************************************
92  * APIs
93  ******************************************************************************/
94 /*! @brief The interface function to initialize the sensor.
95  * @details This function initialize the sensor and sensor handle.
96  * @param[in] pSensorHandle handle to the sensor.
97  * @param[in] pBus pointer to the CMSIS API compatible I2C bus object.
98  * @param[in] index the I2C device number.
99  * @param[in] sAddress slave address of the device on the bus.
100  * @param[in] whoami WHO_AM_I value of the device.
101  * @constraints This should be the first API to be called.
102  * Application has to ensure that previous instances of these APIs have exited before invocation.
103  * @reeentrant No
104  * @return ::MMA8491Q_I2C_Initialize() returns the status.
105  */
107  ARM_DRIVER_I2C *pBus,
108  uint8_t index,
109  uint16_t sAddress);
110 
111 /*! @brief : The interface function to set the I2C Idle Task.
112  * @param[in] : mma8491q_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
113  * @param[in] : registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
114  * @param[in] : void *userParam, the pointer to the user idle ftask parameters.
115  * @return void.
116  * @constraints This can be called any number of times only after MMA8491Q_I2C_Initialize().
117  * Application has to ensure that previous instances of these APIs have exited before invocation.
118  * @reeentrant No
119  */
121  registeridlefunction_t idleTask,
122  void *userParam);
123 
124 /*! @brief The interface function to read the sensor data.
125  * @details This function read the sensor data out from the device and returns raw data in a byte stream.
126  * @param[in] pSensorHandle handle to the sensor.
127  * @param[in] pReadList pointer to the list of device registers and values to read.
128  * @param[out] pBuffer buffer which holds raw sensor data.This buffer may be back to back databuffer based
129  * command read in the list.
130  * @constraints This can be called any number of times only after MMA8491Q_I2C_Initialize().
131  * Application has to ensure that previous instances of these APIs have exited before invocation.
132  * @reeentrant No
133  * @return ::MMA8491Q_I2C_ReadData() returns the status .
134  */
135 
137  const registerreadlist_t *pReadList,
138  uint8_t *pBuffer);
139 
140 #endif // MMA8491Q_FI_H_
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
ARM_DRIVER_I2C * pCommDrv
Definition: mma8491q_drv.h:58
void MMA8491Q_I2C_SetIdleTask(mma8491q_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mma8491q_drv.c:82
int32_t MMA8491Q_I2C_Initialize(mma8491q_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress)
The interface function to initialize the sensor.
Definition: mma8491q_drv.c:48
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:123
registerDeviceInfo_t deviceInfo
Definition: mma8491q_drv.h:57
volatile bool inTransition
Definition: mma8491q_drv.h:77
The mma8491q.h contains the MMA8491Q Multifunction Digital Accelerometer register definitions...
This defines the function pointers and sensor specific information.
Definition: mma8491q_drv.h:55
This structure stores the Sensor&#39;s context parameters.
Definition: mma8491q_drv.h:72
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int32_t MMA8491Q_I2C_ReadData(mma8491q_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: mma8491q_drv.c:90
This structure defines the Read command List.
Definition: sensor_drv.h:104
This structure defines the mma8491q data buffer.
Definition: mma8491q_drv.h:64
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:128
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...
uint64_t adjustedODR
Definition: mma8491q_drv.h:74