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

Go to the source code of this file.

Macros

#define SDCD_LTHS_LSB   0xA0 /* Lower Threshold LSB value. */
 
#define SDCD_LTHS_MSB   0x0F /* Lower Threshold MSB value. */
 
#define SDCD_UTHS_LSB   0x40 /* Upper Threshold LSB value. */
 
#define SDCD_UTHS_MSB   0x00 /* Upper Threshold MSB value. */
 
#define ASLP_COUNT_LSB   0xFA /* Auto Sleep after 5s @50Hz Wake ODR */
 
#define ASLP_COUNT_MSB   0x00 /* Auto Sleep after 5s @50Hz Wake ODR */
 
#define FXLS8962_DATA_SIZE   6 /* 2 byte X,Y,Z Axis Data each. */
 

Functions

void fxls8962_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 cFxls8962ConfigInitialize []
 FXLS8962 Motion based Pedometer Register Write List. More...
 
const registerwritelist_t cFxls8962ConfigMotionDetect []
 FXLS8962 Motion Detect Mode Register Write List. More...
 
const registerwritelist_t cFxls8962ConfigDataReady []
 FXLS8962 DRDY and ASLP Detect Mode Register Write List. More...
 
const registerreadlist_t cFxls8962INTStatus [] = {{.readFrom = FXLS8962_INT_STATUS, .numBytes = 1}, __END_READ_DATA__}
 Address of INT Status Register. More...
 
const registerreadlist_t cFxls8962Output [] = {{.readFrom = FXLS8962_OUT_X_LSB, .numBytes = FXLS8962_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 gFxls8962EventReady = false
 
pedometer_config_t cPedoConfig
 
gpioConfigKSDK_t gpioConfigINT1
 

Macro Definition Documentation

◆ ASLP_COUNT_LSB

#define ASLP_COUNT_LSB   0xFA /* Auto Sleep after 5s @50Hz Wake ODR */

Definition at line 43 of file pedometer_stepcount_motion_fxls8962.c.

◆ ASLP_COUNT_MSB

#define ASLP_COUNT_MSB   0x00 /* Auto Sleep after 5s @50Hz Wake ODR */

Definition at line 44 of file pedometer_stepcount_motion_fxls8962.c.

◆ FXLS8962_DATA_SIZE

#define FXLS8962_DATA_SIZE   6 /* 2 byte X,Y,Z Axis Data each. */

Definition at line 45 of file pedometer_stepcount_motion_fxls8962.c.

Referenced by main().

◆ SDCD_LTHS_LSB

#define SDCD_LTHS_LSB   0xA0 /* Lower Threshold LSB value. */

Definition at line 39 of file pedometer_stepcount_motion_fxls8962.c.

◆ SDCD_LTHS_MSB

#define SDCD_LTHS_MSB   0x0F /* Lower Threshold MSB value. */

Definition at line 40 of file pedometer_stepcount_motion_fxls8962.c.

◆ SDCD_UTHS_LSB

#define SDCD_UTHS_LSB   0x40 /* Upper Threshold LSB value. */

Definition at line 41 of file pedometer_stepcount_motion_fxls8962.c.

◆ SDCD_UTHS_MSB

#define SDCD_UTHS_MSB   0x00 /* Upper Threshold MSB value. */

Definition at line 42 of file pedometer_stepcount_motion_fxls8962.c.

Function Documentation

◆ fxls8962_int_callback()

void fxls8962_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 147 of file pedometer_stepcount_motion_fxls8962.c.

References gFxls8962EventReady.

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 FXLS8962 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 FXLS8962 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 Status from the FXLS8962.

Display that a Motion event has been detected.

Read the Output from the FXLS8962.

Convert the raw sensor data for feeding to pedometer algorithm.

Execute the pedometer Algorithm

Definition at line 161 of file pedometer_stepcount_motion_fxls8962.c.

References fxls8962_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, fxls8962_i2c_sensorhandle_t::deviceInfo, pedometer_t::pedometer_status_tag::distance, Driver_GPIO_KSDK, FXLS8962_DATA_SIZE, FXLS8962_I2C_ADDR, FXLS8962_I2C_Configure(), FXLS8962_I2C_Initialize(), FXLS8962_I2C_ReadData(), FXLS8962_I2C_SetIdleTask(), FXLS8962_INT1, fxls8962_int_callback(), FXLS8962_INT_STATUS_SRC_ASLP_MASK, FXLS8962_INT_STATUS_SRC_SDCD_OT_MASK, FXLS8962_WHOAMI_VALUE, fxls8962Driver, gFxls8962EventReady, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, I2Cdrv, int32_t(), pActivity, fxls8962_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, fxls8962_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:

Variable Documentation

◆ cFxls8962ConfigDataReady

const registerwritelist_t cFxls8962ConfigDataReady[]
Initial value:
= {
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_INT_EN_ASLP_EN_EN
Definition: fxls8962.h:868

FXLS8962 DRDY and ASLP Detect Mode Register Write List.

Definition at line 87 of file pedometer_stepcount_motion_fxls8962.c.

◆ cFxls8962ConfigInitialize

const registerwritelist_t cFxls8962ConfigInitialize[]
Initial value:
= {
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
#define FXLS8962_SENS_CONFIG4_INT_POL_ACT_LOW
Definition: fxls8962.h:678
#define FXLS8962_SDCD_CONFIG2_OT_DBCTM_CLEARED
Definition: fxls8962.h:1642
#define FXLS8962_SENS_CONFIG3_SLEEP_ODR_0_781HZ
Definition: fxls8962.h:582
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
#define FXLS8962_SDCD_CONFIG2_SDCD_EN_EN
Definition: fxls8962.h:1628
#define FXLS8962_SENS_CONFIG4_WK_SDCD_OT_MASK
Definition: fxls8962.h:633
#define FXLS8962_SENS_CONFIG4_WK_SDCD_OT_EN
Definition: fxls8962.h:655
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_50HZ
Definition: fxls8962.h:563
#define FXLS8962_SENS_CONFIG4_INT_POL_MASK
Definition: fxls8962.h:618
#define FXLS8962_SENS_CONFIG3_SLEEP_ODR_MASK
Definition: fxls8962.h:548
#define FXLS8962_SDCD_CONFIG1_X_OT_EN_EN
Definition: fxls8962.h:1548
#define FXLS8962_SDCD_CONFIG2_WT_DBCTM_CLEARED
Definition: fxls8962.h:1648
#define FXLS8962_SDCD_CONFIG1_Z_OT_EN_EN
Definition: fxls8962.h:1556
#define FXLS8962_SDCD_CONFIG2_REF_UPDM_SDCD_REF
Definition: fxls8962.h:1633
#define FXLS8962_INT_EN_ASLP_EN_EN
Definition: fxls8962.h:868
#define FXLS8962_SDCD_CONFIG1_Y_OT_EN_EN
Definition: fxls8962.h:1552

FXLS8962 Motion based Pedometer Register Write List.

Definition at line 51 of file pedometer_stepcount_motion_fxls8962.c.

◆ cFxls8962ConfigMotionDetect

const registerwritelist_t cFxls8962ConfigMotionDetect[]
Initial value:
= {
#define FXLS8962_INT_EN_SDCD_OT_EN_EN
Definition: fxls8962.h:861
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45

FXLS8962 Motion Detect Mode Register Write List.

Definition at line 81 of file pedometer_stepcount_motion_fxls8962.c.

◆ cFxls8962INTStatus

const registerreadlist_t cFxls8962INTStatus[] = {{.readFrom = FXLS8962_INT_STATUS, .numBytes = 1}, __END_READ_DATA__}

Address of INT Status Register.

Definition at line 93 of file pedometer_stepcount_motion_fxls8962.c.

◆ cFxls8962Output

const registerreadlist_t cFxls8962Output[] = {{.readFrom = FXLS8962_OUT_X_LSB, .numBytes = FXLS8962_DATA_SIZE}, __END_READ_DATA__}

Address of Data Output Registers.

Definition at line 96 of file pedometer_stepcount_motion_fxls8962.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 107 of file pedometer_stepcount_motion_fxls8962.c.

◆ gFxls8962EventReady

volatile bool gFxls8962EventReady = false

Definition at line 104 of file pedometer_stepcount_motion_fxls8962.c.

Referenced by fxls8962_int_callback(), and main().

◆ gpioConfigINT1

gpioConfigKSDK_t gpioConfigINT1
Initial value:
=
{
.pinConfig = {kGPIO_DigitalInput, 0},
.portPinConfig = {.pullSelect = kPORT_PullUp, .mux = kPORT_MuxAsGpio},
.interruptMode = kPORT_InterruptFallingEdge,
}

Definition at line 129 of file pedometer_stepcount_motion_fxls8962.c.

◆ pActivity

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

Pedometer Mode Name Strings.

Definition at line 99 of file pedometer_stepcount_motion_fxls8962.c.

Referenced by main().