46 #include "fsl_lptmr.h" 47 #include "clock_config.h" 48 #include "fsl_debug_console.h" 53 #include "issdk_hal.h" 54 #include "gpio_driver.h" 61 #include "Driver_SPI.h" 66 #define SAMPLING_RATE_us (100000) 67 #define FXLC95000_SAMPLE_SIZE (10) 68 #define fxlc95000_odr_callback LPTMR0_IRQHandler 83 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
84 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
90 {StopDataCmd, 0,
sizeof(StopDataCmd)},
94 {StartDataCmd, 0,
sizeof(StartDataCmd)},
112 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
122 lptmr_config_t lptmrConfig;
136 LPTMR_GetDefaultConfig(&lptmrConfig);
137 LPTMR_Init(LPTMR0, &lptmrConfig);
138 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
139 LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(
SAMPLING_RATE_us, CLOCK_GetFreq(kCLOCK_LpoClk)));
140 EnableIRQ(LPTMR0_IRQn);
142 PRINTF(
"\r\n ISSDK FXLC95000 sensor driver example for SPI Mode. \r\n");
146 if (ARM_DRIVER_OK != status)
148 PRINTF(
"\r\n SPI Initialization Failed\r\n");
153 status = pSPIdriver->PowerControl(ARM_POWER_FULL);
154 if (ARM_DRIVER_OK != status)
156 PRINTF(
"\r\n SPI Power Mode setting Failed\r\n");
161 status = pSPIdriver->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0,
SPI_S_BAUDRATE);
162 if (ARM_DRIVER_OK != status)
164 PRINTF(
"\r\n SPI Control Mode setting Failed\r\n");
173 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
176 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
187 PRINTF(
"\r\n FXLC95000 MBox Configuration Failed, Err = %d \r\n", status);
195 PRINTF(
"\r\n FXLC95000 Sensor Configuration Failed, Err = %d \r\n", status);
198 PRINTF(
"\r\n Successfully Applied FXLC95000 Sensor Configuration\r\n");
200 LPTMR_StartTimer(LPTMR0);
215 if (ARM_DRIVER_OK != status)
217 PRINTF(
"\r\n Read Failed. \r\n");
222 rawData.
timestamp = ((uint32_t)data[3] << 24) | ((uint32_t)data[2] << 16) | ((uint16_t)data[1] << 8) | data[0];
223 rawData.
accel[0] = ((int16_t)data[5] << 8) | data[4];
224 rawData.
accel[1] = ((int16_t)data[7] << 8) | data[6];
225 rawData.
accel[2] = ((int16_t)data[9] << 8) | data[8];
227 PRINTF(
"\r\n Timestamp = 0x%X \r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
timestamp, rawData.
accel[0],
void FXLC95000_SPI_SetIdleTask(fxlc95000_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
const registercommandlist_t cFxlc95000ConfigSensor[]
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
This structure defines the fxlc95000 pedometer data buffer.
const registercommandlist_t cFxlc95000ConfigMBox[]
const registerreadlist_t cFxlc95000ReadSample[]
volatile bool gFxlc95000DataRead
#define FXLC95000_RST_GPIO
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.
#define BOARD_BootClockRUN
uint8_t data[FXLS8962_DATA_SIZE]
const uint8_t cFxlc95000_SetRange_Cmd[]
void BOARD_InitDebugConsole(void)
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.
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.
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
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.
#define FXLC95000_SAMPLE_SIZE
#define FXLC95000_SSB_IO3
#define ASK_USER_TO_RESUME(x)
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
#define __END_WRITE_CMD__
#define SPI_S_DEVICE_INDEX
const uint8_t cFxlc95000_SetODR_Cmd[]
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
int main(void)
Main function.
This defines the sensor specific information for SPI.
#define SPI_S_BAUDRATE
Transfer baudrate - 500k.
fxls8962_acceldataUser_t rawData
#define FXLC95000_BUILD_ID
The FXLC95000 BCD encoded ISF1.1_95k_Build_ID.
#define SPI_S_SIGNAL_EVENT
This structure defines the Read command List.
const uint8_t cFxlc95000_SetResolution_Cmd[]
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.
#define fxlc95000_odr_callback
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.