19 #include "clock_config.h" 21 #include "fsl_lptmr.h" 22 #include "fsl_debug_console.h" 27 #include "issdk_hal.h" 28 #include "gpio_driver.h" 35 #include "Driver_SPI.h" 40 #define SAMPLING_RATE_us (100000) 41 #define FXLC95000_SAMPLE_SIZE (10) 42 #define fxlc95000_odr_callback LPTMR0_IRQHandler 57 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
58 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
64 {StopDataCmd, 0,
sizeof(StopDataCmd)},
68 {StartDataCmd, 0,
sizeof(StartDataCmd)},
86 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
96 lptmr_config_t lptmrConfig;
110 LPTMR_GetDefaultConfig(&lptmrConfig);
111 LPTMR_Init(LPTMR0, &lptmrConfig);
112 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
113 LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(
SAMPLING_RATE_us, CLOCK_GetFreq(kCLOCK_LpoClk)));
114 EnableIRQ(LPTMR0_IRQn);
116 PRINTF(
"\r\n ISSDK FXLC95000 sensor driver example for SPI Mode. \r\n");
120 if (ARM_DRIVER_OK != status)
122 PRINTF(
"\r\n SPI Initialization Failed\r\n");
127 status = pSPIdriver->PowerControl(ARM_POWER_FULL);
128 if (ARM_DRIVER_OK != status)
130 PRINTF(
"\r\n SPI Power Mode setting Failed\r\n");
135 status = pSPIdriver->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0,
SPI_S_BAUDRATE);
136 if (ARM_DRIVER_OK != status)
138 PRINTF(
"\r\n SPI Control Mode setting Failed\r\n");
147 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
150 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
161 PRINTF(
"\r\n FXLC95000 MBox Configuration Failed, Err = %d \r\n", status);
169 PRINTF(
"\r\n FXLC95000 Sensor Configuration Failed, Err = %d \r\n", status);
172 PRINTF(
"\r\n Successfully Applied FXLC95000 Sensor Configuration\r\n");
174 LPTMR_StartTimer(LPTMR0);
189 if (ARM_DRIVER_OK != status)
191 PRINTF(
"\r\n Read Failed. \r\n");
196 rawData.
timestamp = ((uint32_t)data[3] << 24) | ((uint32_t)data[2] << 16) | ((uint16_t)data[1] << 8) | data[0];
197 rawData.
accel[0] = ((int16_t)data[5] << 8) | data[4];
198 rawData.
accel[1] = ((int16_t)data[7] << 8) | data[6];
199 rawData.
accel[2] = ((int16_t)data[9] << 8) | data[8];
201 PRINTF(
"\r\n Timestamp = 0x%X \r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
timestamp, rawData.
accel[0],
const uint8_t cFxlc95000_SetRange_Cmd[]
void FXLC95000_SPI_SetIdleTask(fxlc95000_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
#define ASK_USER_TO_RESUME(x)
int32_t FXLC95000_SPI_Initialize(fxlc95000_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSpiSelect, void *pSlaveSelect, void *pReset, uint16_t buildId)
The interface function to initialize the sensor.
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
#define FXLC95000_RST_GPIO
This structure defines the Block command List.
This structure defines the fxlc95000 pedometer data buffer.
volatile bool gFxlc95000DataRead
#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.
#define SPI_S_BAUDRATE
Transfer baudrate - 500k.
const registercommandlist_t cFxlc95000ConfigMBox[]
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
#define SPI_S_DEVICE_INDEX
const uint8_t cFxlc95000_SetResolution_Cmd[]
#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.
const uint8_t cFxlc95000_SetODR_Cmd[]
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
#define FXLC95000_SSB_IO3
#define __END_WRITE_CMD__
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
fxos8700_accelmagdata_t rawData
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
#define FXLC95000_SAMPLE_SIZE
const registercommandlist_t cFxlc95000ConfigSensor[]
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
#define fxlc95000_odr_callback
This structure defines the Read command List.
#define SPI_S_SIGNAL_EVENT
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
This defines the sensor specific information for SPI.
int32_t FXLC95000_SPI_CommandResponse(fxlc95000_spi_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
int main(void)
Main function.
const registerreadlist_t cFxlc95000ReadSample[]
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.