19 #include "clock_config.h" 21 #include "fsl_debug_console.h" 26 #include "Driver_I2C.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 39 #define MD_SDCD_WT_DBCNT 0x00 40 #define OT_SDCD_WT_DBCNT 0x09 41 #define SDCD_LTHS_LSB 0xC0 42 #define SDCD_LTHS_MSB 0x0F 43 #define SDCD_UTHS_LSB 0x40 44 #define SDCD_UTHS_MSB 0x00 140 uint8_t orientStatus;
152 PRINTF(
"\r\n ISSDK FXLS8962 sensor driver example for Orientation and Motion Detection.\r\n");
159 if (ARM_DRIVER_OK != status)
161 PRINTF(
"\r\n I2C Initialization Failed\r\n");
166 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
167 if (ARM_DRIVER_OK != status)
169 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
174 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
175 if (ARM_DRIVER_OK != status)
177 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
186 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
189 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
200 PRINTF(
"\r\n Write FXLS8962 Motion Configuration Failed!\r\n");
206 PRINTF(
"\r\n Waiting for Motion | MCU going to Deep Sleep Mode ...\r\n");
223 PRINTF(
"\r\n Motion detected ...\r\n");
229 PRINTF(
"\r\n Write FXLS8962 Orientation Configuration Failed!\r\n");
232 motionDetect =
false;
237 if (ARM_DRIVER_OK != status)
239 PRINTF(
"\r\n Read Orientation Failed!\r\n");
249 PRINTF(
"\r\n Portrait Up ...\r\n");
253 PRINTF(
"\r\n Portrait Down ...\r\n");
257 PRINTF(
"\r\n Landscape Right ...\r\n");
261 PRINTF(
"\r\n Landscape Left ...\r\n");
265 if (((orientStatus & FXLS8962_ORIENT_STATUS_NEW_ORIENT_MASK) ==
271 PRINTF(
"\r\n Front Side ...\r\n");
275 PRINTF(
"\r\n Back Side ...\r\n");
280 if (ARM_DRIVER_OK != status)
282 PRINTF(
"\r\n Read SDCD Failed!\r\n");
const registerwritelist_t cFxls8962ConfigOrientDetect[]
Register Start Motion Detect Mode Register Write List.
#define FXLS8962_INT_EN_DRDY_EN_EN
#define FXLS8962_SDCD_CONFIG1_Y_WT_EN_EN
#define FXLS8962_SDCD_INT_SRC2_WT_EA_EVENT_YES
const registerwritelist_t cFxls8962ConfigMotionDetect[]
Register Start Motion Detect Mode Register Write List.
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_DIS
volatile bool gFxls8962EventReady
#define FXLS8962_ORIENT_STATUS_LAPO_UP
#define FXLS8962_ORIENT_STATUS_LAPO_RIGHT
This structure defines the Write command List.
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_0_781HZ
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define FXLS8962_INT_EN_SDCD_OT_EN_EN
#define FXLS8962_ORIENT_STATUS_LO_MASK
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
#define FXLS8962_SDCD_CONFIG1_WT_ELE_EN
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_EN
#define FXLS8962_ORIENT_STATUS_LO_DETECTED
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.
#define FXLS8962_SDCD_CONFIG2_OT_DBCTM_CLEARED
Access structure of the GPIO Driver.
#define __END_WRITE_DATA__
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define FXLS8962_ORIENT_STATUS_LAPO_DOWN
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_MASK
This defines the sensor specific information for I2C.
#define FXLS8962_ORIENT_STATUS_NEW_ORIENT_MASK
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_MASK
#define FXLS8962_SDCD_CONFIG2_SDCD_EN_EN
#define I2C_S_SIGNAL_EVENT
#define FXLS8962_SDCD_INT_SRC2_WT_EA_MASK
#define BOARD_BootClockRUN
#define FXLS8962_ORIENT_STATUS_NEW_ORIENT_CHANGED
fxls8962_i2c_sensorhandle_t fxls8962Driver
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
const registerreadlist_t cFxls8962SDCDEvent[]
Address of SDCD Status Register.
void fxls8962_int_callback(void *pUserData)
This is the Sensor Data Ready ISR implementation.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
GENERIC_DRIVER_GPIO * pGpioDriver
#define FXLS8962_ORIENT_STATUS_LAPO_MASK
#define FXLS8962_ORIENT_STATUS_LO_NOT_DETECTED
#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.
const registerreadlist_t cFxls8962OutputOrientStatus[]
#define FXLS8962_ORIENT_STATUS_BAFRO_BACK
#define FXLS8962_SDCD_CONFIG1_Z_WT_EN_EN
#define FXLS8962_SDCD_CONFIG1_X_OT_EN_EN
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_EN
void BOARD_SystickEnable(void)
Function to enable systicks framework.
int32_t FXLS8962_I2C_Configure(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
int main(void)
This is the The main function implementation.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
#define FXLS8962_SDCD_CONFIG1_X_WT_EN_EN
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define FXLS8962_SDCD_CONFIG2_WT_DBCTM_CLEARED
This structure defines the Read command List.
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_1_563HZ
#define FXLS8962_SDCD_CONFIG1_Z_OT_EN_EN
#define I2C_S_DEVICE_INDEX
#define FXLS8962_ORIENT_STATUS_BAFRO_FRONT
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
#define FXLS8962_SDCD_CONFIG2_REF_UPDM_SDCD_REF
void BOARD_InitDebugConsole(void)
#define FXLS8962_WHOAMI_VALUE
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define FXLS8962_ORIENT_STATUS_LAPO_LEFT
#define FXLS8962_ORIENT_STATUS_BAFRO_MASK
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_DIS
#define FXLS8962_SDCD_CONFIG1_Y_OT_EN_EN