ISSDK  1.8
IoT Sensing Software Development Kit
mma865x_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 mma865x_drv.h
11  * @brief The mma865x_drv.h file describes the MMA865x driver interface and structures.
12  */
13 
14 #ifndef MMA865x_DRV_H_
15 #define MMA865x_DRV_H_
16 
17 /* Standard C Includes */
18 #include <stdint.h>
19 
20 /* ISSDK Includes */
21 #include "mma865x.h"
22 #include "sensor_io_i2c.h"
23 #include "register_io_i2c.h"
24 
25 /*******************************************************************************
26  * Definitions
27  ******************************************************************************/
28 /*! @brief This defines the 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 mma865x raw data buffer.*/
38 typedef struct
39 {
40  uint32_t timestamp; /*!< Time stamp value in micro-seconds. */
41  int16_t accel[3]; /*!< The accel data */
43 
44 /*******************************************************************************
45  * APIs
46  ******************************************************************************/
47 /*! @brief The interface function to initialize the sensor.
48  * @details This function initialize the sensor and sensor handle.
49  * @param[in] pSensorHandle handle to the sensor.
50  * @param[in] pBus pointer to the CMSIS API compatible I2C bus object.
51  * @param[in] index the I2C device number.
52  * @param[in] sAddress slave address of the device on the bus.
53  * @param[in] whoami WHO_AM_I value of the device.
54  * @constraints This should be the first API to be called.
55  * Application has to ensure that previous instances of these APIs have exited before invocation.
56  * @reeentrant No
57  * @return ::mma865x_Initialize() returns the status.
58  */
60  mma865x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi);
61 
62 /*! @brief : The interface function to set the I2C Idle Task.
63  * @param[in] : mma865x_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
64  * @param[in] : registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
65  * @param[in] : void *userParam, the pointer to the user idle ftask parameters.
66  * @return void.
67  * @constraints This can be called any number of times only after mma865x_Initialize().
68  * Application has to ensure that previous instances of these APIs have exited before invocation.
69  * @reeentrant No
70  */
72  registeridlefunction_t idleTask,
73  void *userParam);
74 
75 /*! @brief The interface function to configure he sensor.
76  * @details This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
77  * @param[in] pSensorHandle handle to the sensor.
78  * @param[in] pRegWriteList pointer to the register list.
79  * @constraints This can be called any number of times only after MMA865x_I2C_Initialize().
80  * Application has to ensure that previous instances of these APIs have exited before invocation.
81  * @reeentrant No
82  * @return ::mma865x_Configure() returns the status.
83  */
85 
86 /*! @brief The interface function to read the sensor data.
87  * @details This function read the sensor data out from the device and returns raw data in a byte stream.
88  * @param[in] pSensorHandle handle to the sensor.
89  * @param[in] pReadList pointer to the list of device registers and values to read.
90  * @param[out] pBuffer buffer which holds raw sensor data.This buffer may be back to back databuffer based
91  * command read in the list.
92  * @constraints This can be called any number of times only after MMA865x_I2C_Initialize().
93  * Application has to ensure that previous instances of these APIs have exited before invocation.
94  * @reeentrant No
95  * @return ::mma865x_ReadData() returns the status.
96  */
98  const registerreadlist_t *pReadList,
99  uint8_t *pBuffer);
100 
101 /*! @brief The interface function to De Initialize sensor..
102  * @details This function made sensor in a power safe state and de initialize its handle.
103  * @param[in] pSensorHandle handle to the sensor.
104  * @constraints This can be called only after MMA865x_I2C_Initialize() has been called.
105  * Application has to ensure that previous instances of these APIs have exited before invocation.
106  * @reeentrant No
107  * @return ::MMA865x_I2C_DeInit() returns the status.
108  */
110 
111 #endif // MMA865x_DRV_H_
ARM_DRIVER_I2C * pCommDrv
Definition: mma865x_drv.h:32
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
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: mma865x_drv.c:61
This defines the sensor specific information.
Definition: mma865x_drv.h:29
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int32_t MMA865x_I2C_DeInit(mma865x_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
Definition: mma865x_drv.c:135
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
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mma865x_drv.c:53
int32_t MMA865x_I2C_Initialize(mma865x_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: mma865x_drv.c:22
registerDeviceInfo_t deviceInfo
Definition: mma865x_drv.h:31
This structure defines the Read command List.
Definition: sensor_drv.h:78
This structure defines the mma865x raw data buffer.
Definition: mma865x_drv.h:38
int32_t MMA865x_I2C_ReadData(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: mma865x_drv.c:106
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...