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