18 #include "clock_config.h" 20 #include "fsl_debug_console.h" 25 #include "Driver_I2C.h" 30 #include "issdk_hal.h" 32 #include "gpio_driver.h" 38 #define FXLS8962_DATA_SIZE 6 58 const char *
pActivity[5] = {
"Unknown ",
"Rest ",
"Walking ",
"Jogging ",
"Running "};
66 .bits = {.config = 1},
88 .portPinConfig = {.pullSelect = kPORT_PullUp, .mux = kPORT_MuxAsGpio},
89 .interruptMode = kPORT_InterruptFallingEdge,
108 uint16_t lastReportedSteps;
123 PRINTF(
"\r\n ISSDK FXLS8962 sensor driver example for Pedometer.\r\n");
130 if (ARM_DRIVER_OK != status)
132 PRINTF(
"\r\n I2C Initialization Failed\r\n");
137 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
138 if (ARM_DRIVER_OK != status)
140 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
145 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
146 if (ARM_DRIVER_OK != status)
148 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
155 if (ARM_DRIVER_OK != status)
157 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
162 PRINTF(
"\r\n Successfully Initialized Gemini with WHO_AM_I = 0x%X\r\n", whoami);
166 PRINTF(
"\r\n Successfully Initialized Timandra with WHO_AM_I = 0x%X\r\n", whoami);
170 PRINTF(
"\r\n Successfully Initialized Newstein with WHO_AM_I = 0x%X\r\n", whoami);
174 PRINTF(
"\r\n Bad WHO_AM_I = 0x%X\r\n", whoami);
186 PRINTF(
"\r\n FXLS8962 Sensor Configuration Failed, Err = %d\r\n", status);
189 PRINTF(
"\r\n Successfully Applied FXLS8962 Sensor Configuration\r\n");
193 PRINTF(
"\r\n Pedometer successfully Initialized.");
194 PRINTF(
"\r\n\r\n Ready for measurements.");
215 if (ARM_DRIVER_OK != status)
217 PRINTF(
"\r\n ERROR : Read Data Failed!\r\n");
222 rawData.
accel[0] = ((int16_t)data[1] << 8) | data[0];
223 rawData.
accel[0] *= 16;
224 rawData.
accel[1] = ((int16_t)data[3] << 8) | data[2];
225 rawData.
accel[1] *= 16;
226 rawData.
accel[2] = ((int16_t)data[5] << 8) | data[4];
227 rawData.
accel[2] *= 16;
239 PRINTF(
"\r\n\r\n | Steps |\r\n");
void(* set_pin)(pinID_t aPinId)
struct pedometer_t::pedometer_status_tag status
This structure defines the fxls8962 raw data buffer.
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer.
The GPIO Configuration KSDK.
This structure defines the Write command List.
The pedometer.h file contains the interface and structure definitions for pedometer application...
#define FXLS8962_SENS_CONFIG1_FSR_2G
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
#define PEDO_FILTER_STEPS_DEFAULT
int32_t FXLS8962_I2C_Initialize(fxls8962_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *whoami)
The interface function to initialize the sensor.
Access structure of the GPIO Driver.
gpioConfigKSDK_t gpioConfigINT1
This defines the configuration structure of the pedometer.
#define __END_WRITE_DATA__
debounce_count_t sleepcount_threshold
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define FXLS8962_INT_STATUS_SRC_DRDY_MASK
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
#define PEDO_FREQHZ_DEFAULT
This defines the sensor specific information for I2C.
#define FXLS8967_WHOAMI_VALUE
gpio_pin_config_t pinConfig
#define I2C_S_SIGNAL_EVENT
This defines the pedometer instance.
const registerreadlist_t cFxls8962Output[]
Address of Data Output Registers.
This defines the acceleration input data for the pedometer.
#define BOARD_BootClockRUN
int main(void)
This is the The main function implementation.
#define PEDO_FILTER_TIME_DEFAULT
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
const registerreadlist_t cFxls8962DRDYEvent[]
Address of DATA Ready Status Register.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
GENERIC_DRIVER_GPIO * pGpioDriver
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
int32_t FXLS8962_I2C_ReadData(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_50HZ
fxos8700_accelmagdata_t rawData
#define FXLS8962_DATA_SIZE
const char * pActivity[5]
Pedometer Mode Name Strings.
void(* toggle_pin)(pinID_t aPinId)
int32_t FXLS8962_I2C_Configure(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define PEDO_SPEED_PERIOD_DEFAULT
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
This structure defines the Read command List.
#define FXLS8962_SENS_CONFIG1_FSR_MASK
gpioHandleKSDK_t GREEN_LED
#define FXLS8974_WHOAMI_VALUE
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm.
#define I2C_S_DEVICE_INDEX
#define PEDO_STEP_THRESHOLD_DEFAULT
const registerwritelist_t cFxls8962ConfigInitialize[]
FXLS8962 Motion based Pedometer Register Write List.
void FXLS8962_I2C_SetIdleTask(fxls8962_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define FXLS8962_I2C_ADDR
void BOARD_InitDebugConsole(void)
#define FXLS8962_WHOAMI_VALUE
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define FXLS8964_WHOAMI_VALUE