20 #include "clock_config.h"    21 #include "fsl_debug_console.h"    26 #include "Driver_I2C.h"    31 #include "issdk_hal.h"    33 #include "gpio_driver.h"    39 #define MT_FF_MT_THS 0x15      40 #define ASLP_COUNTER 0x10       41 #define MMA865x_DATA_SIZE 6     88 const char *
pActivity[5] = {
"Unknown ", 
"Rest    ", 
"Walking ", 
"Jogging ", 
"Running "};
    99     .bits = {.config = 1},
   108             .filtertime = 2, .male = 1,
   147     uint16_t lastReportedSteps;
   162     PRINTF(
"\r\n ISSDK MMA865x sensor driver example for Motion Activated Pedometer.\r\n");
   172     if (ARM_DRIVER_OK != status)
   174         PRINTF(
"\r\n I2C Initialization Failed\r\n");
   179     status = I2Cdrv->PowerControl(ARM_POWER_FULL);
   180     if (ARM_DRIVER_OK != status)
   182         PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
   187     status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
   188     if (ARM_DRIVER_OK != status)
   190         PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
   199         PRINTF(
"\r\n Sensor Initialization Failed\r\n");
   208                               mma865xDriver.
slaveAddress, cMma865xCommonConfiguration);
   211         PRINTF(
"\r\n Write MMA865x Initialization Failed.\r\n");
   217     PRINTF(
"\r\n Pedometer successfully Initialized and Ready for measurements.");
   228             PRINTF(
"\r\n Write MMA865x Motion Configuration Failed!\r\n");
   234         PRINTF(
"\r\n\r\n Waiting for Motion | MCU switching to Sleep Mode ...\r\n");
   251             if (ARM_DRIVER_OK != status)
   253                 PRINTF(
"\r\n Read INT SRC Failed!\r\n");
   262                     PRINTF(
" Motion detected...\r\n");
   268                         PRINTF(
"\r\n Write MMA865x DRDY Configuration Failed.\r\n");
   271                     motionDetect = 
false;
   279                 if (ARM_DRIVER_OK != status)
   281                     PRINTF(
"\r\n ERROR : Read Data Failed!\r\n");
   286                 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
   287                 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
   288                 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
   300                         PRINTF(
"\r\n | Steps | Distance |  Speed  | Calories | Activity |\r\n");
   302                     PRINTF(
"\033[K | %5d |    %4dm |  %2dkmph |      %3d | %s |\r",
 void(* set_pin)(pinID_t aPinId)
 
struct pedometer_t::pedometer_status_tag status
 
#define MMA865x_CTRL_REG1_DR_MASK
 
ARM_DRIVER_I2C * pCommDrv
 
#define MMA865x_FF_MT_CFG_YEFE_MASK
 
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer. 
 
#define MMA865x_CTRL_REG5_INT_CFG_DRDY_MASK
 
This structure defines the Write command List. 
 
This defines the sensor specific information. 
 
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
 
The pedometer.h file contains the interface and structure definitions for pedometer application...
 
#define MMA865x_CTRL_REG4_INT_EN_DRDY_DISABLED
 
#define MMA865x_CTRL_REG3_WAKE_FF_MT_MASK
 
#define MMA865x_CTRL_REG1_ASLP_RATE_1_56HZ
 
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
 
const registerwritelist_t cMma865xCommonConfiguration[]
MMA865x Motion based Pedometer Register Write List. 
 
#define MMA865x_CTRL_REG1_DR_50HZ
 
#define MMA865x_CTRL_REG5_INT_CFG_DRDY_INT1
 
#define MMA865x_FF_MT_CFG_XEFE_EN
 
#define MMA865x_INT_SOURCE_SRC_ASLP_MASK
 
#define MMA865x_CTRL_REG5_INT_CFG_ASLP_MASK
 
Access structure of the GPIO Driver. 
 
#define MMA865x_INT_SOURCE_SRC_ASLP_READY
 
This defines the configuration structure of the pedometer. 
 
#define MMA865x_FF_MT_THS_THS_MASK
 
#define __END_WRITE_DATA__
 
debounce_count_t sleepcount_threshold
 
#define MMA865x_CTRL_REG3_IPOL_MASK
 
void(* clr_pin)(pinID_t aPinId)
 
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream. 
 
struct pedometer_t::pedometer_status_tag::@351::@352 bits
 
int32_t MMA865x_I2C_ReadData(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data. 
 
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
 
#define I2C_S_SIGNAL_EVENT
 
#define MMA865x_FF_MT_CFG_ZEFE_EN
 
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
 
#define MMA865x_INT_SOURCE_SRC_FF_MT_READY
 
This defines the pedometer instance. 
 
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
 
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor. 
 
This defines the acceleration input data for the pedometer. 
 
#define BOARD_BootClockRUN
 
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type. 
 
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
 
GENERIC_DRIVER_GPIO * pGpioDriver
 
const registerwritelist_t cMma865xConfigMotionDetect[]
MMA865x Motion Detect Mode Register Write List. 
 
uint8_t data[FXLS8962_DATA_SIZE]
 
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor. 
 
#define MMA865x_CTRL_REG4_INT_EN_ASLP_MASK
 
#define __END_READ_DATA__
 
The mma865x_drv.h file describes the MMA865x driver interface and structures. 
 
const registerreadlist_t cMma865xINTSrc[]
Address of INT Source Register. 
 
#define MMA865x_CTRL_REG4_INT_EN_DRDY_EN
 
fxos8700_accelmagdata_t rawData
 
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_MASK
 
#define MMA865x_FF_MT_CFG_XEFE_MASK
 
pedometer_config_t cPedoConfig
 
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT2
 
#define MMA865x_CTRL_REG3_PP_OD_MASK
 
void mma865x_int_callback(void *pUserData)
This is the Sensor Event Ready ISR implementation. 
 
registerDeviceInfo_t deviceInfo
 
void(* toggle_pin)(pinID_t aPinId)
 
#define MMA865x_FF_MT_CFG_OAE_MOTION
 
volatile bool gMma865xEventReady
 
#define MMA865x_CTRL_REG2_SMODS_MASK
 
const registerwritelist_t cMma865xConfigDataReady[]
MMA865x DRDY and ASLP Detect Mode Register Write List. 
 
#define MMA865x_CTRL_REG1_ASLP_RATE_MASK
 
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
 
#define MMA865x_FF_MT_CFG_ZEFE_MASK
 
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
 
const registerreadlist_t cMma865xOutput[]
Address of Data Output Registers. 
 
union pedometer_t::pedometer_status_tag::@351 status
 
This structure defines the Read command List. 
 
This structure defines the mma865x raw data buffer. 
 
#define MMA865x_DATA_SIZE
 
#define MMA865x_INT_SOURCE_SRC_FF_MT_MASK
 
gpioHandleKSDK_t GREEN_LED
 
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm. 
 
#define MMA865x_CTRL_REG4_INT_EN_ASLP_DISABLED
 
#define I2C_S_DEVICE_INDEX
 
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task. 
 
#define MMA865x_CTRL_REG2_SMODS_LP
 
#define MMA865x_CTRL_REG2_SLPE_MASK
 
#define MMA865x_CTRL_REG3_PP_OD_PUSH_PULL
 
void BOARD_InitDebugConsole(void)
 
#define MMA865x_CTRL_REG2_SLPE_EN
 
#define MMA8652_WHOAMI_VALUE
 
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer. 
 
#define MMA865x_FF_MT_CFG_OAE_MASK
 
int main(void)
This is the The main function implementation. 
 
#define MMA865x_CTRL_REG4_INT_EN_DRDY_MASK
 
int32_t MMA865x_I2C_Initialize(mma865x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor. 
 
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features. 
 
#define MMA865x_CTRL_REG3_WAKE_FF_MT_EN
 
#define MMA865x_CTRL_REG5_INT_CFG_ASLP_INT1
 
#define MMA865x_CTRL_REG4_INT_EN_ASLP_EN
 
const char * pActivity[5]
Pedometer Mode Name Strings. 
 
#define MMA865x_FF_MT_CFG_YEFE_EN