ISSDK  1.8
IoT Sensing Software Development Kit
Macros | Functions | Variables
pedometer_stepcount_motion_mma8652.c File Reference
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "Driver_I2C.h"
#include "issdk_hal.h"
#include "pedometer.h"
#include "gpio_driver.h"
#include "mma865x_drv.h"
Include dependency graph for pedometer_stepcount_motion_mma8652.c:

Go to the source code of this file.

Macros

#define MT_FF_MT_THS   0x15 /* Threshold Value. */
 
#define ASLP_COUNTER   0x10 /* Auto Sleep after ~5s. */
 
#define MMA865x_DATA_SIZE   6 /* 2-byte Accel x,y,z each */
 

Functions

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

Variables

const registerwritelist_t cMma865xCommonConfiguration []
 MMA865x Motion based Pedometer Register Write List. More...
 
const registerwritelist_t cMma865xConfigMotionDetect []
 MMA865x Motion Detect Mode Register Write List. More...
 
const registerwritelist_t cMma865xConfigDataReady []
 MMA865x DRDY and ASLP Detect Mode Register Write List. More...
 
const registerreadlist_t cMma865xINTSrc [] = {{.readFrom = MMA865x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__}
 Address of INT Source Register. More...
 
const registerreadlist_t cMma865xOutput [] = {{.readFrom = MMA865x_OUT_X_MSB, .numBytes = MMA865x_DATA_SIZE}, __END_READ_DATA__}
 Address of Data Output Registers. More...
 
const char * pActivity [5] = {"Unknown ", "Rest ", "Walking ", "Jogging ", "Running "}
 Pedometer Mode Name Strings. More...
 
volatile bool gMma865xEventReady = false
 
pedometer_config_t cPedoConfig
 

Macro Definition Documentation

◆ ASLP_COUNTER

#define ASLP_COUNTER   0x10 /* Auto Sleep after ~5s. */

Definition at line 40 of file pedometer_stepcount_motion_mma8652.c.

◆ MMA865x_DATA_SIZE

#define MMA865x_DATA_SIZE   6 /* 2-byte Accel x,y,z each */

Definition at line 41 of file pedometer_stepcount_motion_mma8652.c.

Referenced by main().

◆ MT_FF_MT_THS

#define MT_FF_MT_THS   0x15 /* Threshold Value. */

Definition at line 39 of file pedometer_stepcount_motion_mma8652.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 the MCU hardware.

Initialize MMA865x pin used by FRDM board

Initialize RGB LED pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize MMA865x sensor driver.

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

Initialize the pedometer

Configure the pedometer

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

Read the INT_SRC from the MMA865x.

Display that a Motion event has been detected.

Read the Output from the MMA865x.

Convert the raw sensor data for feeding to pedometer algorithm.

Execute the pedometer Algorithm

Definition at line 143 of file pedometer_stepcount_motion_mma8652.c.

References mma865x_acceldata_t::accel, pedometer_t::pedometer_status_tag::bits, BOARD_BootClockRUN, BOARD_InitDebugConsole(), BOARD_InitPins(), pedometer_t::pedometer_status_tag::calories, GENERIC_DRIVER_GPIO::clr_pin, data, mma865x_i2c_sensorhandle_t::deviceInfo, pedometer_t::pedometer_status_tag::distance, Driver_GPIO_KSDK, gMma865xEventReady, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, I2Cdrv, int32_t(), MMA8652_I2C_ADDR, MMA8652_INT1, MMA8652_WHOAMI_VALUE, MMA865x_DATA_SIZE, MMA865x_I2C_Configure(), MMA865x_I2C_Initialize(), MMA865x_I2C_ReadData(), MMA865x_I2C_SetIdleTask(), mma865x_int_callback(), MMA865x_INT_SOURCE_SRC_ASLP_MASK, MMA865x_INT_SOURCE_SRC_ASLP_READY, MMA865x_INT_SOURCE_SRC_FF_MT_MASK, MMA865x_INT_SOURCE_SRC_FF_MT_READY, pActivity, mma865x_i2c_sensorhandle_t::pCommDrv, pedometer_configure(), pedometer_init(), pedometer_run(), pGpioDriver, GENERIC_DRIVER_GPIO::pin_init, rawData, SENSOR_ERROR_NONE, Sensor_I2C_Write(), GENERIC_DRIVER_GPIO::set_pin, mma865x_i2c_sensorhandle_t::slaveAddress, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), pedometer_t::pedometer_status_tag::speed, pedometer_t::pedometer_status_tag::status, pedometer_t::status, status, pedometer_t::pedometer_status_tag::stepcount, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mma865x_int_callback()

void mma865x_int_callback ( void *  pUserData)

This is the Sensor Event Ready ISR implementation.


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

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 signaled event ready.

Definition at line 129 of file pedometer_stepcount_motion_mma8652.c.

References gMma865xEventReady.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ cMma865xCommonConfiguration

const registerwritelist_t cMma865xCommonConfiguration[]
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_REG5_INT_CFG_DRDY_MASK
Definition: mma865x.h:1815
#define MMA865x_CTRL_REG3_WAKE_FF_MT_MASK
Definition: mma865x.h:1667
#define MMA865x_CTRL_REG1_ASLP_RATE_1_56HZ
Definition: mma865x.h:1547
#define MMA865x_CTRL_REG1_DR_50HZ
Definition: mma865x.h:1552
#define MMA865x_CTRL_REG5_INT_CFG_DRDY_INT1
Definition: mma865x.h:1853
#define MMA865x_FF_MT_CFG_XEFE_EN
Definition: mma865x.h:881
#define MMA865x_CTRL_REG5_INT_CFG_ASLP_MASK
Definition: mma865x.h:1833
#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_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_FF_MT_CFG_XEFE_MASK
Definition: mma865x.h:851
#define MMA865x_CTRL_REG3_PP_OD_MASK
Definition: mma865x.h:1661
#define MMA865x_FF_MT_CFG_OAE_MOTION
Definition: mma865x.h:873
#define MMA865x_CTRL_REG2_SMODS_MASK
Definition: mma865x.h:1598
#define MMA865x_CTRL_REG1_ASLP_RATE_MASK
Definition: mma865x.h:1537
#define MMA865x_FF_MT_CFG_ZEFE_MASK
Definition: mma865x.h:857
#define MMA865x_CTRL_REG2_SMODS_LP
Definition: mma865x.h:1618
#define MMA865x_CTRL_REG2_SLPE_MASK
Definition: mma865x.h:1595
#define MMA865x_CTRL_REG3_PP_OD_PUSH_PULL
Definition: mma865x.h:1702
#define MMA865x_CTRL_REG2_SLPE_EN
Definition: mma865x.h:1620
#define MMA865x_FF_MT_CFG_OAE_MASK
Definition: mma865x.h:860
#define MMA865x_CTRL_REG3_WAKE_FF_MT_EN
Definition: mma865x.h:1699
#define MMA865x_CTRL_REG5_INT_CFG_ASLP_INT1
Definition: mma865x.h:1841
#define MMA865x_FF_MT_CFG_YEFE_EN
Definition: mma865x.h:878

MMA865x Motion based Pedometer Register Write List.

Definition at line 47 of file pedometer_stepcount_motion_mma8652.c.

◆ cMma865xConfigDataReady

const registerwritelist_t cMma865xConfigDataReady[]
Initial value:

MMA865x DRDY and ASLP Detect Mode Register Write List.

Definition at line 73 of file pedometer_stepcount_motion_mma8652.c.

◆ cMma865xConfigMotionDetect

const registerwritelist_t cMma865xConfigMotionDetect[]
Initial value:

MMA865x Motion Detect Mode Register Write List.

Definition at line 64 of file pedometer_stepcount_motion_mma8652.c.

◆ cMma865xINTSrc

const registerreadlist_t cMma865xINTSrc[] = {{.readFrom = MMA865x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__}

Address of INT Source Register.

Definition at line 82 of file pedometer_stepcount_motion_mma8652.c.

◆ cMma865xOutput

const registerreadlist_t cMma865xOutput[] = {{.readFrom = MMA865x_OUT_X_MSB, .numBytes = MMA865x_DATA_SIZE}, __END_READ_DATA__}

Address of Data Output Registers.

Definition at line 85 of file pedometer_stepcount_motion_mma8652.c.

◆ cPedoConfig

pedometer_config_t cPedoConfig
Initial value:
=
{
.sleepcount_threshold = 1,
.bits = {.config = 1},
.keynetik =
{
.steplength = 0,
.height = 175,
.weight = 80,
.filtersteps = 1,
.bits =
{
.filtertime = 2, .male = 1,
},
.speedperiod = 3,
.stepthreshold = 0,
},
.stepcoalesce = 1,
.oneG = PEDO_ONEG_2G,
.frequency = 50,
}
#define PEDO_ONEG_2G
Definition: pedometer.h:30

Definition at line 96 of file pedometer_stepcount_motion_mma8652.c.

◆ gMma865xEventReady

volatile bool gMma865xEventReady = false

Definition at line 93 of file pedometer_stepcount_motion_mma8652.c.

Referenced by main(), and mma865x_int_callback().

◆ pActivity

const char* pActivity[5] = {"Unknown ", "Rest ", "Walking ", "Jogging ", "Running "}

Pedometer Mode Name Strings.

Definition at line 88 of file pedometer_stepcount_motion_mma8652.c.

Referenced by main().