![]() |
ISSDK
1.7
IoT Sensing Software Development Kit
|
#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"
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 |
#define ASLP_COUNTER 0x10 /* Auto Sleep after ~5s. */ |
Definition at line 62 of file pedometer_stepcount_motion_mma8652.c.
#define MMA865x_DATA_SIZE 6 /* 2-byte Accel x,y,z each */ |
Definition at line 63 of file pedometer_stepcount_motion_mma8652.c.
Referenced by main().
#define MT_FF_MT_THS 0x15 /* Threshold Value. */ |
Definition at line 61 of file pedometer_stepcount_motion_mma8652.c.
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.
[in] | void | This is no input parameter. |
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 165 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, 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_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.
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.
[in] | pUserData | This is a void pointer to the instance of the user specific data structure for the ISR. |
Set flag to indicate Sensor has signaled event ready.
Definition at line 151 of file pedometer_stepcount_motion_mma8652.c.
References gMma865xEventReady.
Referenced by main().
const registerwritelist_t cMma865xCommonConfiguration[] |
MMA865x Motion based Pedometer Register Write List.
Definition at line 69 of file pedometer_stepcount_motion_mma8652.c.
const registerwritelist_t cMma865xConfigDataReady[] |
MMA865x DRDY and ASLP Detect Mode Register Write List.
Definition at line 95 of file pedometer_stepcount_motion_mma8652.c.
const registerwritelist_t cMma865xConfigMotionDetect[] |
MMA865x Motion Detect Mode Register Write List.
Definition at line 86 of file pedometer_stepcount_motion_mma8652.c.
const registerreadlist_t cMma865xINTSrc[] = {{.readFrom = MMA865x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__} |
Address of INT Source Register.
Definition at line 104 of file pedometer_stepcount_motion_mma8652.c.
const registerreadlist_t cMma865xOutput[] = {{.readFrom = MMA865x_OUT_X_MSB, .numBytes = MMA865x_DATA_SIZE}, __END_READ_DATA__} |
Address of Data Output Registers.
Definition at line 107 of file pedometer_stepcount_motion_mma8652.c.
pedometer_config_t cPedoConfig |
Definition at line 118 of file pedometer_stepcount_motion_mma8652.c.
volatile bool gMma865xEventReady = false |
Definition at line 115 of file pedometer_stepcount_motion_mma8652.c.
Referenced by main(), and mma865x_int_callback().
const char* pActivity[5] = {"Unknown ", "Rest ", "Walking ", "Jogging ", "Running "} |
Pedometer Mode Name Strings.
Definition at line 110 of file pedometer_stepcount_motion_mma8652.c.
Referenced by main().