17 #include "clock_config.h" 19 #include "fsl_lptmr.h" 20 #include "fsl_debug_console.h" 23 #include "Driver_I2C.h" 26 #include "issdk_hal.h" 33 #define SAMPLING_RATE_us (100000) 34 #define FXLC95000_SAMPLE_SIZE (10) 35 #define fxlc95000_odr_callback LPTMR0_IRQHandler 50 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
51 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
57 {StopDataCmd, 0,
sizeof(StopDataCmd)},
61 {StartDataCmd, 0,
sizeof(StartDataCmd)},
79 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
89 lptmr_config_t lptmrConfig;
103 LPTMR_GetDefaultConfig(&lptmrConfig);
104 LPTMR_Init(LPTMR0, &lptmrConfig);
105 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
106 LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(
SAMPLING_RATE_us, CLOCK_GetFreq(kCLOCK_LpoClk)));
107 EnableIRQ(LPTMR0_IRQn);
109 PRINTF(
"\r\n ISSDK FXLC95000 sensor driver example for Normal Mode. \r\n");
113 if (ARM_DRIVER_OK != status)
115 PRINTF(
"\r\n I2C Initialization Failed\r\n");
120 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
121 if (ARM_DRIVER_OK != status)
123 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
128 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
129 if (ARM_DRIVER_OK != status)
131 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
140 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
143 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
154 PRINTF(
"\r\n FXLC95000 MBox Configuration Failed, Err = %d \r\n", status);
161 PRINTF(
"\r\n FXLC95000 Sensor Configuration Failed, Err = %d \r\n", status);
164 PRINTF(
"\r\n Successfully Applied FXLC95000 Sensor Configuration\r\n");
166 LPTMR_StartTimer(LPTMR0);
181 if (ARM_DRIVER_OK != status)
183 PRINTF(
"\r\n Read Failed. \r\n");
188 rawData.
timestamp = ((uint32_t)data[3] << 24) | ((uint32_t)data[2] << 16) | ((uint16_t)data[1] << 8) | data[0];
189 rawData.
accel[0] = ((int16_t)data[5] << 8) | data[4];
190 rawData.
accel[1] = ((int16_t)data[7] << 8) | data[6];
191 rawData.
accel[2] = ((int16_t)data[9] << 8) | data[8];
193 PRINTF(
"\r\n Timestamp = 0x%X \r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
timestamp, rawData.
accel[0],
#define ASK_USER_TO_RESUME(x)
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
const uint8_t cFxlc95000_SetResolution_Cmd[]
const registerreadlist_t cFxlc95000ReadSample[]
volatile bool gFxlc95000DataRead
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
This structure defines the Block command List.
This structure defines the fxlc95000 pedometer data buffer.
#define FXLC95000_I2C_ADDR
const uint8_t cFxlc95000_SetRange_Cmd[]
const registercommandlist_t cFxlc95000ConfigMBox[]
#define FXLC95000_BUILD_ID
The FXLC95000 BCD encoded ISF1.1_95k_Build_ID.
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
This defines the sensor specific information for I2C.
#define I2C_S_SIGNAL_EVENT
#define fxlc95000_odr_callback
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.
void FXLC95000_I2C_SetIdleTask(fxlc95000_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define BOARD_BootClockRUN
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define FXLC95000_SAMPLE_SIZE
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
#define __END_WRITE_CMD__
const uint8_t cFxlc95000_SetODR_Cmd[]
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
const registercommandlist_t cFxlc95000ConfigSensor[]
fxos8700_accelmagdata_t rawData
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
This structure defines the Read command List.
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.
int main(void)
Main function.
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.