ISSDK  1.7
IoT Sensing Software Development Kit
Functions
mma865x_drv.c File Reference

The mma865x_drv.c file implements the mma865x functional interface. More...

#include "mma865x_drv.h"
Include dependency graph for mma865x_drv.c:

Go to the source code of this file.

Functions

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. More...
 
void MMA865x_I2C_SetIdleTask (mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
 : The interface function to set the I2C Idle Task. More...
 
int32_t MMA865x_I2C_Configure (mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
 The interface function to configure he sensor. More...
 
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. More...
 
int32_t MMA865x_I2C_DeInit (mma865x_i2c_sensorhandle_t *pSensorHandle)
 The interface function to De Initialize sensor.. More...
 

Detailed Description

The mma865x_drv.c file implements the mma865x functional interface.

Definition in file mma865x_drv.c.

Function Documentation

◆ MMA865x_I2C_Configure()

int32_t MMA865x_I2C_Configure ( mma865x_i2c_sensorhandle_t pSensorHandle,
const registerwritelist_t pRegWriteList 
)

The interface function to configure he sensor.

This function configure the sensor with requested ODR, Range and registers in the regsiter pair array.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pRegWriteListpointer to the register list.
Constraints:
This can be called any number of times only after MMA865x_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
::mma865x_Configure() returns the status.

Validate for the correct handle and register write list.

Check whether sensor handle is initialized before applying configuration.

Apply the Sensor Configuration based on the Register Write List

Put the device into active mode and ready for reading data.

Definition at line 87 of file mma865x_drv.c.

References mma865x_i2c_sensorhandle_t::deviceInfo, int32_t(), mma865x_i2c_sensorhandle_t::isInitialized, MMA865x_CTRL_REG1, MMA865x_CTRL_REG1_ACTIVE_ACTIVATED, MMA865x_CTRL_REG1_ACTIVE_MASK, MMA865x_CTRL_REG1_ACTIVE_STANDBY, mma865x_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, Sensor_I2C_Write(), mma865x_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMA865x_I2C_DeInit()

int32_t MMA865x_I2C_DeInit ( mma865x_i2c_sensorhandle_t pSensorHandle)

The interface function to De Initialize sensor..

This function made sensor in a power safe state and de initialize its handle.

Parameters
[in]pSensorHandlehandle to the sensor.
Constraints:
This can be called only after MMA865x_I2C_Initialize() has been called. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
MMA865x_I2C_DeInit() returns the status.

Check whether sensor handle is initialized before triggering sensor reset.

Trigger sensor device reset.

De-initialize sensor handle.

Definition at line 161 of file mma865x_drv.c.

References mma865x_i2c_sensorhandle_t::deviceInfo, int32_t(), mma865x_i2c_sensorhandle_t::isInitialized, MMA865x_CTRL_REG2, MMA865x_CTRL_REG2_RST_EN, MMA865x_CTRL_REG2_RST_MASK, mma865x_i2c_sensorhandle_t::pCommDrv, Register_I2C_Write(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_WRITE, mma865x_i2c_sensorhandle_t::slaveAddress, and status.

Here is the call graph for this function:

◆ MMA865x_I2C_Initialize()

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.

This function initialize the sensor and sensor handle.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pBuspointer to the CMSIS API compatible I2C bus object.
[in]indexthe I2C device number.
[in]sAddressslave address of the device on the bus.
[in]whoamiWHO_AM_I value of the device.
Constraints:
This should be the first API to be called. Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
::mma865x_Initialize() returns the status.

Check the input parameters.

Read and store the device's WHO_AM_I.

Initialize the sensor handle.

Definition at line 48 of file mma865x_drv.c.

References mma865x_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::deviceInstance, registerDeviceInfo_t::functionParam, registerDeviceInfo_t::idleFunction, int32_t(), mma865x_i2c_sensorhandle_t::isInitialized, MMA865x_WHO_AM_I, mma865x_i2c_sensorhandle_t::pCommDrv, Register_I2C_Read(), SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, mma865x_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMA865x_I2C_ReadData()

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.

This function read the sensor data out from the device and returns raw data in a byte stream.

Parameters
[in]pSensorHandlehandle to the sensor.
[in]pReadListpointer to the list of device registers and values to read.
[out]pBufferbuffer which holds raw sensor data.This buffer may be back to back databuffer based command read in the list.
Constraints:
This can be called any number of times only after MMA865x_I2C_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No
Returns
::mma865x_ReadData() returns the status.

Validate for the correct handle and register read list.

Check whether sensor handle is initialized before reading sensor data.

Parse through the read list and read the data one by one.

Definition at line 132 of file mma865x_drv.c.

References mma865x_i2c_sensorhandle_t::deviceInfo, int32_t(), mma865x_i2c_sensorhandle_t::isInitialized, mma865x_i2c_sensorhandle_t::pCommDrv, SENSOR_ERROR_INIT, SENSOR_ERROR_INVALID_PARAM, SENSOR_ERROR_NONE, SENSOR_ERROR_READ, Sensor_I2C_Read(), mma865x_i2c_sensorhandle_t::slaveAddress, and status.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MMA865x_I2C_SetIdleTask()

void MMA865x_I2C_SetIdleTask ( mma865x_i2c_sensorhandle_t pSensorHandle,
registeridlefunction_t  idleTask,
void *  userParam 
)

: The interface function to set the I2C Idle Task.

Parameters
[in]mma865x_i2c_sensorhandle_t *pSensorHandle, handle to the sensor handle.
[in]registeridlefunction_t idleTask, function pointer to the function to execute on I2C Idle Time.
[in]void *userParam, the pointer to the user idle ftask parameters.
Returns
void.
Constraints:
This can be called any number of times only after mma865x_Initialize(). Application has to ensure that previous instances of these APIs have exited before invocation. No

Definition at line 79 of file mma865x_drv.c.

References mma865x_i2c_sensorhandle_t::deviceInfo, registerDeviceInfo_t::functionParam, and registerDeviceInfo_t::idleFunction.

Referenced by main().

Here is the caller graph for this function: