44 #include "clock_config.h" 45 #include "fsl_debug_console.h" 48 #include "Driver_I2C.h" 51 #include "issdk_hal.h" 58 #define RAW_ACCEL_DATA_SIZE (6) 84 .bits = {.config = 1},
127 PRINTF(
"\r\n ISSDK Pedometer Example using MMA8451 sensor as the acceleration source\r\n");
131 if (ARM_DRIVER_OK != status)
133 PRINTF(
"\r\n I2C Initialization Failed\r\n");
138 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
139 if (ARM_DRIVER_OK != status)
141 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
146 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
147 if (ARM_DRIVER_OK != status)
149 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
158 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
161 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
170 PRINTF(
"\r\n MMA845x Sensor Configuration Failed, Err = %d\r\n", status);
175 PRINTF(
"\r\n Successfully Applied MMA845x Sensor Configuration\r\n");
195 if (ARM_DRIVER_OK != status)
201 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
202 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
203 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer.
This defines the configuration structure of the pedometer.
The pedometer.h file contains the interface and structure definitions for pedometer application...
#define __END_WRITE_DATA__
#define PEDO_FREQHZ_DEFAULT
This defines the sensor specific information.
#define BOARD_BootClockRUN
uint8_t data[FXLS8962_DATA_SIZE]
This defines the acceleration input data for the pedometer.
void BOARD_InitDebugConsole(void)
#define PEDO_STEP_THRESHOLD_DEFAULT
const registerwritelist_t mma845x_Config_Normal[]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
int32_t MMA845x_I2C_Initialize(mma845x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
#define __END_READ_DATA__
This defines the pedometer instance.
This structure defines the mma845x raw data buffer.
#define MMA845x_F_SETUP_F_MODE_FIFODISABLED
#define PEDO_SPEED_PERIOD_DEFAULT
debounce_count_t sleepcount_threshold
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer.
const registerreadlist_t mma845x_Data_Ready[]
#define MMA845x_CTRL_REG1_DR_50HZ
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm.
#define MMA845x_CTRL_REG2_SMODS_HIGHRES
#define I2C_S_DEVICE_INDEX
int32_t MMA845x_I2C_ReadData(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define MMA845x_CTRL_REG1_MODE_STANDBY
int32_t MMA845x_I2C_Configure(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
const registerreadlist_t mma845x_Output_Values[]
#define MMA845x_STATUS_ZYXDR_MASK
struct pedometer_t::pedometer_status_tag status
fxls8962_acceldataUser_t rawData
#define PEDO_FILTER_STEPS_DEFAULT
This structure defines the Write command List.
This structure defines the Read command List.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
void MMA845x_I2C_SetIdleTask(mma845x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA845x_ACCEL_DATA_SIZE
The size of the MMA845x accel data.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define I2C_S_SIGNAL_EVENT
#define MMA8451_WHO_AM_I_WHOAMI_VALUE
The mma845x_drv.h file describes the MMA845x driver interface and structures.
int main(void)
Main function.
#define PEDO_FILTER_TIME_DEFAULT