44 #include "fsl_lptmr.h" 45 #include "clock_config.h" 46 #include "fsl_debug_console.h" 49 #include "Driver_I2C.h" 52 #include "issdk_hal.h" 59 #define SAMPLING_RATE_us (100000) 60 #define FXLC95000_SAMPLE_SIZE (10) 61 #define fxlc95000_odr_callback LPTMR0_IRQHandler 76 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
77 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
83 {StopDataCmd, 0,
sizeof(StopDataCmd)},
87 {StartDataCmd, 0,
sizeof(StartDataCmd)},
105 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
115 lptmr_config_t lptmrConfig;
129 LPTMR_GetDefaultConfig(&lptmrConfig);
130 LPTMR_Init(LPTMR0, &lptmrConfig);
131 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
132 LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(
SAMPLING_RATE_us, CLOCK_GetFreq(kCLOCK_LpoClk)));
133 EnableIRQ(LPTMR0_IRQn);
135 PRINTF(
"\r\n ISSDK FXLC95000 sensor driver example for Normal Mode. \r\n");
139 if (ARM_DRIVER_OK != status)
141 PRINTF(
"\r\n I2C Initialization Failed\r\n");
146 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
147 if (ARM_DRIVER_OK != status)
149 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
154 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
155 if (ARM_DRIVER_OK != status)
157 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
166 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
169 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
180 PRINTF(
"\r\n FXLC95000 MBox Configuration Failed, Err = %d \r\n", status);
187 PRINTF(
"\r\n FXLC95000 Sensor Configuration Failed, Err = %d \r\n", status);
190 PRINTF(
"\r\n Successfully Applied FXLC95000 Sensor Configuration\r\n");
192 LPTMR_StartTimer(LPTMR0);
207 if (ARM_DRIVER_OK != status)
209 PRINTF(
"\r\n Read Failed. \r\n");
214 rawData.
timestamp = ((uint32_t)data[3] << 24) | ((uint32_t)data[2] << 16) | ((uint16_t)data[1] << 8) | data[0];
215 rawData.
accel[0] = ((int16_t)data[5] << 8) | data[4];
216 rawData.
accel[1] = ((int16_t)data[7] << 8) | data[6];
217 rawData.
accel[2] = ((int16_t)data[9] << 8) | data[8];
219 PRINTF(
"\r\n Timestamp = 0x%X \r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
timestamp, rawData.
accel[0],
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
This structure defines the fxlc95000 pedometer data buffer.
const registercommandlist_t cFxlc95000ConfigSensor[]
#define FXLC95000_I2C_ADDR
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.
#define BOARD_BootClockRUN
int main(void)
Main function.
uint8_t data[FXLS8962_DATA_SIZE]
void BOARD_InitDebugConsole(void)
const registerreadlist_t cFxlc95000ReadSample[]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define __END_READ_DATA__
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
#define FXLC95000_SAMPLE_SIZE
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
#define ASK_USER_TO_RESUME(x)
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
#define __END_WRITE_CMD__
const uint8_t cFxlc95000_SetODR_Cmd[]
void FXLC95000_I2C_SetIdleTask(fxlc95000_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
int32_t FXLC95000_I2C_CommandResponse(fxlc95000_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define I2C_S_DEVICE_INDEX
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
int32_t FXLC95000_I2C_Initialize(fxlc95000_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint16_t buildId)
The interface function to initialize the sensor.
fxls8962_acceldataUser_t rawData
const registercommandlist_t cFxlc95000ConfigMBox[]
#define FXLC95000_BUILD_ID
The FXLC95000 BCD encoded ISF1.1_95k_Build_ID.
This structure defines the Read command List.
#define fxlc95000_odr_callback
volatile bool gFxlc95000DataRead
This defines the sensor specific information for I2C.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
This structure defines the Block command List.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
const uint8_t cFxlc95000_SetResolution_Cmd[]
#define I2C_S_SIGNAL_EVENT
const uint8_t cFxlc95000_SetRange_Cmd[]
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.