ISSDK  1.8
IoT Sensing Software Development Kit
Macros | Functions | Variables
mma865x_freefall-detection.c File Reference

The mma865x_freefall-detection.c file implements the ISSDK MMA865x sensor example demonstrating configuring MMA8652 Accel and enabling detection of freefall event. More...

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "Driver_I2C.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "mma865x_drv.h"
Include dependency graph for mma865x_freefall-detection.c:

Go to the source code of this file.

Macros

#define FF_MT_WT_DBCNT   0x18 /* Debounce count value. */
 
#define FF_MT_THS_VALUE   0x08 /* Threshold Value. */
 

Functions

void mma865x_isr_callback (void *pUserData)
 This is the Sensor ISR implementation. More...
 
int main (void)
 This is the The main function implementation. More...
 

Variables

const registerwritelist_t cMma865xConfigFreeFall []
 Register settings for freefall detection. More...
 
const registerreadlist_t cMma865xFreeFallEvent [] = {{.readFrom = MMA865x_FF_MT_SRC, .numBytes = 1}, __END_READ_DATA__}
 Address of Freefall Status Register. More...
 
volatile bool gMma865xIntFlag = false
 

Detailed Description

The mma865x_freefall-detection.c file implements the ISSDK MMA865x sensor example demonstrating configuring MMA8652 Accel and enabling detection of freefall event.

Definition in file mma865x_freefall-detection.c.

Macro Definition Documentation

◆ FF_MT_THS_VALUE

#define FF_MT_THS_VALUE   0x08 /* Threshold Value. */

Definition at line 43 of file mma865x_freefall-detection.c.

◆ FF_MT_WT_DBCNT

#define FF_MT_WT_DBCNT   0x18 /* Debounce count value. */

Definition at line 42 of file mma865x_freefall-detection.c.

Function Documentation

◆ main()

int main ( void  )

This is the The main function implementation.


This function invokes board initializes routines, then then brings up the sensor and finally enters an endless loop to continuously read available samples.

Parameters
[in]voidThis is no input parameter.
Returns
void There is no return value.
Constraints:
None

No

Initialize MMA865x pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize the MMA865x sensor driver.

Set the task to be executed while waiting for I2C transactions to complete.

Configure the MMA865x sensor for Freefall detection Mode.

Clear the event flag, it will be set again by the ISR.

Display that a freefall event has been detected.

Definition at line 105 of file mma865x_freefall-detection.c.

References BOARD_BootClockRUN, BOARD_InitDebugConsole(), BOARD_InitPins(), Driver_GPIO_KSDK, gMma865xIntFlag, GPIO_DIRECTION_IN, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, I2Cdrv, int32_t(), MMA8652_I2C_ADDR, MMA8652_INT1, MMA8652_WHOAMI_VALUE, MMA865x_I2C_Configure(), MMA865x_I2C_Initialize(), MMA865x_I2C_SetIdleTask(), mma865x_isr_callback(), pGpioDriver, GENERIC_DRIVER_GPIO::pin_init, SENSOR_ERROR_NONE, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), and status.

Here is the call graph for this function:

◆ mma865x_isr_callback()

void mma865x_isr_callback ( void *  pUserData)

This is the Sensor ISR implementation.


This function sets the flag which indicates if a new sample(s) is available for reading or new event has occurred.

Parameters
[in]pUserDataThis is a void pointer to the instance of the user specific data structure for the ISR.
Returns
void There is no return value.
Constraints:
None

Yes

Set flag to indicate Sensor has signalled data ready.

Definition at line 91 of file mma865x_freefall-detection.c.

References gMma865xIntFlag.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ cMma865xConfigFreeFall

const registerwritelist_t cMma865xConfigFreeFall[]
Initial value:
={
#define MMA865x_CTRL_REG1_DR_MASK
Definition: mma865x.h:1534
#define MMA865x_FF_MT_CFG_YEFE_MASK
Definition: mma865x.h:854
#define MMA865x_CTRL_REG1_DR_200HZ
Definition: mma865x.h:1550
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
Definition: mma865x.h:1851
#define MMA865x_XYZ_DATA_CFG_FS_MASK
Definition: mma865x.h:530
#define MMA865x_FF_MT_CFG_XEFE_EN
Definition: mma865x.h:881
#define MMA865x_FF_MT_THS_THS_MASK
Definition: mma865x.h:983
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MMA865x_CTRL_REG3_IPOL_MASK
Definition: mma865x.h:1664
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
Definition: mma865x.h:994
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
Definition: mma865x.h:1701
#define MMA865x_FF_MT_CFG_ZEFE_EN
Definition: mma865x.h:875
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
Definition: mma865x.h:1776
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
Definition: mma865x.h:1743
#define MMA865x_CTRL_REG1_ACTIVE_MASK
Definition: mma865x.h:1528
#define MMA865x_CTRL_REG1_ACTIVE_ACTIVATED
Definition: mma865x.h:1559
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_MASK
Definition: mma865x.h:1818
#define MMA865x_FF_MT_CFG_XEFE_MASK
Definition: mma865x.h:851
#define FF_MT_THS_VALUE
#define MMA865x_XYZ_DATA_CFG_FS_2G
Definition: mma865x.h:542
#define MMA865x_FF_MT_CFG_ZEFE_MASK
Definition: mma865x.h:857
#define MMA865x_FF_MT_CFG_OAE_MASK
Definition: mma865x.h:860
#define MMA865x_FF_MT_THS_DBCNTM_MASK
Definition: mma865x.h:986
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
Definition: mma865x.h:872
#define FF_MT_WT_DBCNT
#define MMA865x_FF_MT_CFG_YEFE_EN
Definition: mma865x.h:878

Register settings for freefall detection.

Definition at line 49 of file mma865x_freefall-detection.c.

◆ cMma865xFreeFallEvent

const registerreadlist_t cMma865xFreeFallEvent[] = {{.readFrom = MMA865x_FF_MT_SRC, .numBytes = 1}, __END_READ_DATA__}

Address of Freefall Status Register.

Definition at line 72 of file mma865x_freefall-detection.c.

◆ gMma865xIntFlag

volatile bool gMma865xIntFlag = false

Definition at line 77 of file mma865x_freefall-detection.c.

Referenced by main(), and mma865x_isr_callback().