ISSDK  1.7
IoT Sensing Software Development Kit
Macros | Functions | Variables
pedometer_stepcount_motion_fxos8700.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 "fxos8700_drv.h"
Include dependency graph for pedometer_stepcount_motion_fxos8700.c:

Go to the source code of this file.

Macros

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

Functions

void fxos8700_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 cFxos8700CommonConfiguration []
 FXOS8700 Motion based Pedometer Register Write List. More...
 
const registerwritelist_t cFxos8700ConfigMotionDetect []
 FXOS8700 Motion Detect Mode Register Write List. More...
 
const registerwritelist_t cFxos8700ConfigDataReady []
 FXOS8700 DRDY and ASLP Detect Mode Register Write List. More...
 
const registerreadlist_t cFxos8700INTSrc [] = {{.readFrom = FXOS8700_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__}
 Address of INT Source Register. More...
 
const registerreadlist_t cFxos8700Output [] = {{.readFrom = FXOS8700_OUT_X_MSB, .numBytes = FXOS8700_ACCEL_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 gFxos8700EventReady = false
 
pedometer_config_t cPedoConfig
 

Macro Definition Documentation

◆ ASLP_COUNTER

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

Definition at line 62 of file pedometer_stepcount_motion_fxos8700.c.

◆ FXOS8700_ACCEL_DATA_SIZE

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

Definition at line 63 of file pedometer_stepcount_motion_fxos8700.c.

Referenced by main().

◆ MT_A_FFMT_THS

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

Definition at line 61 of file pedometer_stepcount_motion_fxos8700.c.

Function Documentation

◆ fxos8700_int_callback()

void fxos8700_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 151 of file pedometer_stepcount_motion_fxos8700.c.

References gFxos8700EventReady.

Referenced by main().

Here is the caller graph for this function:

◆ 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 FXOS8700 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 FXOS8700 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 FXOS8700.

Display that a Motion event has been detected.

Read the Output from the FXOS8700.

Convert the raw sensor data for feeding to pedometer algorithm.

Execute the pedometer Algorithm

Definition at line 165 of file pedometer_stepcount_motion_fxos8700.c.

References fxos8700_accelmagdata_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, fxos8700_i2c_sensorhandle_t::deviceInfo, pedometer_t::pedometer_status_tag::distance, Driver_GPIO_KSDK, FXOS8700_ACCEL_DATA_SIZE, FXOS8700_I2C_ADDR, FXOS8700_I2C_Configure(), FXOS8700_I2C_Initialize(), FXOS8700_I2C_ReadData(), FXOS8700_I2C_SetIdleTask(), FXOS8700_INT1, fxos8700_int_callback(), FXOS8700_INT_SOURCE_SRC_ASLP_MASK, FXOS8700_INT_SOURCE_SRC_FFMT_MASK, FXOS8700_WHO_AM_I_PROD_VALUE, gFxos8700EventReady, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), pActivity, fxos8700_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, fxos8700_i2c_sensorhandle_t::slaveAddress, SMC, 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:

Variable Documentation

◆ cFxos8700CommonConfiguration

const registerwritelist_t cFxos8700CommonConfiguration[]
Initial value:
= {
#define __END_WRITE_DATA__
Definition: sensor_drv.h:71
#define FXOS8700_A_FFMT_CFG_OAE_MOTION
Definition: fxos8700.h:977
#define FXOS8700_CTRL_REG2_SLPE_EN
Definition: fxos8700.h:1621
#define FXOS8700_CTRL_REG3_WAKE_FFMT_EN
Definition: fxos8700.h:1698
#define FXOS8700_A_FFMT_CFG_ZEFE_RAISE_EVENT
Definition: fxos8700.h:979
#define FXOS8700_CTRL_REG2_SMODS_MASK
Definition: fxos8700.h:1600
#define FXOS8700_CTRL_REG3_IPOL_ACTIVE_HIGH
Definition: fxos8700.h:1706
#define FXOS8700_CTRL_REG5_INT_CFG_ASLP_MASK
Definition: fxos8700.h:1831
#define FXOS8700_A_FFMT_CFG_ZEFE_MASK
Definition: fxos8700.h:961
#define FXOS8700_CTRL_REG3_WAKE_FFMT_MASK
Definition: fxos8700.h:1664
#define FXOS8700_CTRL_REG3_PP_OD_PUSH_PULL
Definition: fxos8700.h:1707
#define FXOS8700_A_FFMT_CFG_XEFE_MASK
Definition: fxos8700.h:955
#define FXOS8700_CTRL_REG2_SLPE_MASK
Definition: fxos8700.h:1597
#define FXOS8700_CTRL_REG4_INT_EN_FFMT_MASK
Definition: fxos8700.h:1743
#define FXOS8700_A_FFMT_CFG_YEFE_RAISE_EVENT
Definition: fxos8700.h:982
#define FXOS8700_CTRL_REG5_INT_CFG_DRDY_MASK
Definition: fxos8700.h:1810
#define FXOS8700_A_FFMT_THS_THS_MASK
Definition: fxos8700.h:1059
#define FXOS8700_CTRL_REG1_ASLP_RATE_MASK
Definition: fxos8700.h:1533
#define FXOS8700_A_FFMT_CFG_YEFE_MASK
Definition: fxos8700.h:958
#define FXOS8700_CTRL_REG1_DR_SINGLE_50_HZ
Definition: fxos8700.h:1548
#define FXOS8700_CTRL_REG1_ASLP_RATE_1P56_HZ
Definition: fxos8700.h:1543
#define FXOS8700_CTRL_REG1_DR_MASK
Definition: fxos8700.h:1530
#define FXOS8700_CTRL_REG4_INT_EN_FFMT_EN
Definition: fxos8700.h:1777
#define FXOS8700_A_FFMT_CFG_OAE_MASK
Definition: fxos8700.h:964
#define FXOS8700_CTRL_REG5_INT_CFG_DRDY_INT1
Definition: fxos8700.h:1853
#define FXOS8700_CTRL_REG3_IPOL_MASK
Definition: fxos8700.h:1658
#define FXOS8700_A_FFMT_CFG_XEFE_RAISE_EVENT
Definition: fxos8700.h:985
#define FXOS8700_CTRL_REG2_MODS_LOW_POWER
Definition: fxos8700.h:1626
#define FXOS8700_CTRL_REG3_PP_OD_MASK
Definition: fxos8700.h:1655
#define FXOS8700_CTRL_REG5_INT_CFG_ASLP_INT1
Definition: fxos8700.h:1839

FXOS8700 Motion based Pedometer Register Write List.

Definition at line 69 of file pedometer_stepcount_motion_fxos8700.c.

◆ cFxos8700ConfigDataReady

const registerwritelist_t cFxos8700ConfigDataReady[]
Initial value:

FXOS8700 DRDY and ASLP Detect Mode Register Write List.

Definition at line 95 of file pedometer_stepcount_motion_fxos8700.c.

◆ cFxos8700ConfigMotionDetect

const registerwritelist_t cFxos8700ConfigMotionDetect[]
Initial value:

FXOS8700 Motion Detect Mode Register Write List.

Definition at line 86 of file pedometer_stepcount_motion_fxos8700.c.

◆ cFxos8700INTSrc

const registerreadlist_t cFxos8700INTSrc[] = {{.readFrom = FXOS8700_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__}

Address of INT Source Register.

Definition at line 104 of file pedometer_stepcount_motion_fxos8700.c.

◆ cFxos8700Output

const registerreadlist_t cFxos8700Output[] = {{.readFrom = FXOS8700_OUT_X_MSB, .numBytes = FXOS8700_ACCEL_DATA_SIZE}, __END_READ_DATA__}

Address of Data Output Registers.

Definition at line 107 of file pedometer_stepcount_motion_fxos8700.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:56

Definition at line 118 of file pedometer_stepcount_motion_fxos8700.c.

◆ gFxos8700EventReady

volatile bool gFxos8700EventReady = false

Definition at line 115 of file pedometer_stepcount_motion_fxos8700.c.

Referenced by fxos8700_int_callback(), and main().

◆ pActivity

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

Pedometer Mode Name Strings.

Definition at line 110 of file pedometer_stepcount_motion_fxos8700.c.

Referenced by main().