ISSDK  1.8
IoT Sensing Software Development Kit
mma845x_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 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 mma845x_drv.h
11  * @brief The mma845x_drv.h file describes the MMA845x driver interface and structures.
12  */
13 
14 #ifndef MMA845x_DRV_H_
15 #define MMA845x_DRV_H_
16 
17 /* Standard C Includes */
18 #include <stdint.h>
19 
20 /* ISSDK Includes */
21 #include "mma845x.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 mma845x 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 /*! @def MMA845x_ACCEL_DATA_SIZE
45  * @brief The size of the MMA845x accel data.
46  */
47 #define MMA845x_ACCEL_DATA_SIZE (0x06)
48 
49 /*******************************************************************************
50  * APIs
51  ******************************************************************************/
52 /*! @brief The interface function to initialize the sensor.
53  * @details This function initialize the sensor and sensor handle.
54  * @param[in] pSensorHandle handle to the sensor.
55  * @param[in] pBus pointer to the CMSIS API compatible I2C bus object.
56  * @param[in] index the I2C device number.
57  * @param[in] sAddress slave address of the device on the bus.
58  * @param[in] whoami WHO_AM_I value of the device.
59  * @constraints This should be the first API to be called.
60  * Application has to ensure that previous instances of these APIs have exited before invocation.
61  * @reeentrant No
62  * @return ::MMA845x_I2C_Initialize() returns the status.
63  */
65  mma845x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi);
66 
67 /*! @brief : The interface function to set the I2C Idle Task.
68  * @param[in] : mma845x_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
69  * @param[in] : registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
70  * @param[in] : void *userParam, the pointer to the user idle ftask parameters.
71  * @return void.
72  * @constraints This can be called any number of times only after MMA845x_I2C_Initialize().
73  * Application has to ensure that previous instances of these APIs have exited before invocation.
74  * @reeentrant No
75  */
77  registeridlefunction_t idleTask,
78  void *userParam);
79 
80 /*! @brief The interface function to configure he sensor.
81  * @details This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.
82  * @param[in] pSensorHandle handle to the sensor.
83  * @param[in] pRegWriteList pointer to the register list.
84  * @constraints This can be called any number of times only after MMA845x_I2C_Initialize().
85  * Application has to ensure that previous instances of these APIs have exited before invocation.
86  * @reeentrant No
87  * @return ::MMA845x_I2C_Configure() returns the status.
88  */
90 
91 /*! @brief The interface function to read the sensor data.
92  * @details This function read the sensor data out from the device and returns raw data in a byte stream.
93  * @param[in] pSensorHandle handle to the sensor.
94  * @param[in] pReadList pointer to the list of device registers and values to read.
95  * @param[out] pBuffer buffer which holds raw sensor data.This buffer may be back to back databuffer based
96  * command read in the list.
97  * @constraints This can be called any number of times only after MMA845x_I2C_Initialize().
98  * Application has to ensure that previous instances of these APIs have exited before invocation.
99  * @reeentrant No
100  * @return ::MMA845x_I2C_ReadData() returns the status.
101  */
103  const registerreadlist_t *pReadList,
104  uint8_t *pBuffer);
105 
106 /*! @brief The interface function to De Initialize sensor..
107  * @details This function made sensor in a power safe state and de initialize its handle.
108  * @param[in] pSensorHandle handle to the sensor.
109  * @constraints This can be called only after MMA845x_I2C_Initialize() has been called.
110  * Application has to ensure that previous instances of these APIs have exited before invocation.
111  * @reeentrant No
112  * @return ::MMA845x_I2C_Deinit() returns the status.
113  */
115 
116 #endif // MMA845x_DRV_H_
ARM_DRIVER_I2C * pCommDrv
Definition: mma845x_drv.h:32
The mma845x.h contains the MMA845x sensor register definitions and its bit mask.
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 mma845x raw data buffer.
Definition: mma845x_drv.h:38
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
int32_t MMA845x_I2C_ReadData(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
Definition: mma845x_drv.c:104
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
registerDeviceInfo_t deviceInfo
Definition: mma845x_drv.h:31
int32_t MMA845x_I2C_Deinit(mma845x_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
Definition: mma845x_drv.c:133
int32_t MMA845x_I2C_Initialize(mma845x_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: mma845x_drv.c:22
This structure defines the Read command List.
Definition: sensor_drv.h:78
int32_t MMA845x_I2C_Configure(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Definition: mma845x_drv.c:61
void MMA845x_I2C_SetIdleTask(mma845x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
Definition: mma845x_drv.c:53
This defines the sensor specific information.
Definition: mma845x_drv.h:29
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...