ISSDK  1.8
IoT Sensing Software Development Kit
Macros | Functions | Variables
fxls8962_orientation_detection.c File Reference

The fxls8962_orientation_detection.c file implements the ISSDK FXLS8962 sensor driver example demonstration for Motion Activated Orientation detection. More...

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "Driver_I2C.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "fxls8962_drv.h"
#include "systick_utils.h"
Include dependency graph for fxls8962_orientation_detection.c:

Go to the source code of this file.

Macros

#define MD_SDCD_WT_DBCNT   0x00 /* Debounce count value. */
 
#define OT_SDCD_WT_DBCNT   0x09 /* Debounce count value. */
 
#define SDCD_LTHS_LSB   0xC0 /* Lower Threshold LSB value. */
 
#define SDCD_LTHS_MSB   0x0F /* Lower Threshold MSB value. */
 
#define SDCD_UTHS_LSB   0x40 /* Upper Threshold LSB value. */
 
#define SDCD_UTHS_MSB   0x00 /* Upper Threshold MSB value. */
 

Functions

void fxls8962_int_callback (void *pUserData)
 This is the Sensor Data Ready ISR implementation. More...
 
int main (void)
 This is the The main function implementation. More...
 

Variables

const registerwritelist_t cFxls8962ConfigMotionDetect []
 Register Start Motion Detect Mode Register Write List. More...
 
const registerwritelist_t cFxls8962ConfigOrientDetect []
 Register Start Motion Detect Mode Register Write List. More...
 
const registerreadlist_t cFxls8962SDCDEvent []
 Address of SDCD Status Register. More...
 
const registerreadlist_t cFxls8962OutputOrientStatus []
 
volatile bool gFxls8962EventReady
 

Detailed Description

The fxls8962_orientation_detection.c file implements the ISSDK FXLS8962 sensor driver example demonstration for Motion Activated Orientation detection.

Definition in file fxls8962_orientation_detection.c.

Macro Definition Documentation

◆ MD_SDCD_WT_DBCNT

#define MD_SDCD_WT_DBCNT   0x00 /* Debounce count value. */

Definition at line 39 of file fxls8962_orientation_detection.c.

◆ OT_SDCD_WT_DBCNT

#define OT_SDCD_WT_DBCNT   0x09 /* Debounce count value. */

Definition at line 40 of file fxls8962_orientation_detection.c.

◆ SDCD_LTHS_LSB

#define SDCD_LTHS_LSB   0xC0 /* Lower Threshold LSB value. */

Definition at line 41 of file fxls8962_orientation_detection.c.

◆ SDCD_LTHS_MSB

#define SDCD_LTHS_MSB   0x0F /* Lower Threshold MSB value. */

Definition at line 42 of file fxls8962_orientation_detection.c.

◆ SDCD_UTHS_LSB

#define SDCD_UTHS_LSB   0x40 /* Upper Threshold LSB value. */

Definition at line 43 of file fxls8962_orientation_detection.c.

◆ SDCD_UTHS_MSB

#define SDCD_UTHS_MSB   0x00 /* Upper Threshold MSB value. */

Definition at line 44 of file fxls8962_orientation_detection.c.

Function Documentation

◆ fxls8962_int_callback()

void fxls8962_int_callback ( void *  pUserData)

This is the Sensor Data Ready ISR implementation.


This function sets the flag which indicates if a new sample(s) is available for reading.

Parameters
[in]pUserDataThis is a void pointer to the instance of the user specific data structure for the ISR.
Returns
void There is no return value.
Constraints:
None

Yes

Set flag to indicate Sensor has signalled data ready.

Definition at line 122 of file fxls8962_orientation_detection.c.

References gFxls8962EventReady.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( void  )

This is the The main function implementation.


This function invokes board initializes routines, then then brings up the sensor and finally enters an endless loop to continuously read available samples.

Parameters
[in]voidThis is no input parameter.
Returns
void There is no return value.
Constraints:
None

No

Initialize the MCU hardware.

Initialize FXLS8962 pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize FXLS8962 sensor driver.

Set the task to be executed while waiting for I2C transactions to complete.

Clear the data ready flag, it will be set again by the ISR.

Display that a Motion event has been detected.

Read the Orientation Status from the FXLS8962.

Definition at line 136 of file fxls8962_orientation_detection.c.

References BOARD_BootClockRUN, BOARD_InitDebugConsole(), BOARD_InitPins(), BOARD_SystickEnable(), Driver_GPIO_KSDK, FXLS8962_I2C_ADDR, FXLS8962_I2C_Configure(), FXLS8962_I2C_Initialize(), FXLS8962_I2C_ReadData(), FXLS8962_I2C_SetIdleTask(), FXLS8962_INT1, fxls8962_int_callback(), FXLS8962_ORIENT_STATUS_BAFRO_BACK, FXLS8962_ORIENT_STATUS_BAFRO_FRONT, FXLS8962_ORIENT_STATUS_BAFRO_MASK, FXLS8962_ORIENT_STATUS_LAPO_DOWN, FXLS8962_ORIENT_STATUS_LAPO_LEFT, FXLS8962_ORIENT_STATUS_LAPO_MASK, FXLS8962_ORIENT_STATUS_LAPO_RIGHT, FXLS8962_ORIENT_STATUS_LAPO_UP, FXLS8962_ORIENT_STATUS_LO_DETECTED, FXLS8962_ORIENT_STATUS_LO_MASK, FXLS8962_ORIENT_STATUS_LO_NOT_DETECTED, FXLS8962_ORIENT_STATUS_NEW_ORIENT_CHANGED, FXLS8962_ORIENT_STATUS_NEW_ORIENT_MASK, FXLS8962_SDCD_INT_SRC2_WT_EA_EVENT_YES, FXLS8962_SDCD_INT_SRC2_WT_EA_MASK, FXLS8962_WHOAMI_VALUE, fxls8962Driver, gFxls8962EventReady, GPIO_DIRECTION_IN, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, I2Cdrv, int32_t(), pGpioDriver, GENERIC_DRIVER_GPIO::pin_init, SENSOR_ERROR_NONE, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), and status.

Here is the call graph for this function:

Variable Documentation

◆ cFxls8962ConfigMotionDetect

const registerwritelist_t cFxls8962ConfigMotionDetect[]
Initial value:
= {
0},
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_DIS
Definition: fxls8962.h:664
#define SDCD_LTHS_MSB
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_0_781HZ
Definition: fxls8962.h:569
#define FXLS8962_INT_EN_SDCD_OT_EN_EN
Definition: fxls8962.h:861
#define SDCD_UTHS_LSB
#define FXLS8962_SDCD_CONFIG2_OT_DBCTM_CLEARED
Definition: fxls8962.h:1642
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_MASK
Definition: fxls8962.h:627
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_MASK
Definition: fxls8962.h:1190
#define FXLS8962_SDCD_CONFIG2_SDCD_EN_EN
Definition: fxls8962.h:1628
#define SDCD_UTHS_MSB
#define FXLS8962_SDCD_CONFIG1_X_OT_EN_EN
Definition: fxls8962.h:1548
#define FXLS8962_SDCD_CONFIG2_WT_DBCTM_CLEARED
Definition: fxls8962.h:1648
#define MD_SDCD_WT_DBCNT
#define FXLS8962_SDCD_CONFIG1_Z_OT_EN_EN
Definition: fxls8962.h:1556
#define FXLS8962_SDCD_CONFIG2_REF_UPDM_SDCD_REF
Definition: fxls8962.h:1633
#define SDCD_LTHS_LSB
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_DIS
Definition: fxls8962.h:1205
#define FXLS8962_SDCD_CONFIG1_Y_OT_EN_EN
Definition: fxls8962.h:1552

Register Start Motion Detect Mode Register Write List.

Definition at line 50 of file fxls8962_orientation_detection.c.

◆ cFxls8962ConfigOrientDetect

const registerwritelist_t cFxls8962ConfigOrientDetect[]
Initial value:
= {
0},
0},
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
#define FXLS8962_SDCD_CONFIG1_Y_WT_EN_EN
Definition: fxls8962.h:1564
#define SDCD_LTHS_MSB
#define FXLS8962_SDCD_CONFIG1_WT_ELE_EN
Definition: fxls8962.h:1544
#define SDCD_UTHS_LSB
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_EN
Definition: fxls8962.h:666
#define FXLS8962_SDCD_CONFIG2_OT_DBCTM_CLEARED
Definition: fxls8962.h:1642
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
#define FXLS8962_SENS_CONFIG4_DRDY_PUL_MASK
Definition: fxls8962.h:627
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_MASK
Definition: fxls8962.h:1190
#define FXLS8962_SDCD_CONFIG2_SDCD_EN_EN
Definition: fxls8962.h:1628
#define SDCD_UTHS_MSB
#define OT_SDCD_WT_DBCNT
#define FXLS8962_SDCD_CONFIG1_Z_WT_EN_EN
Definition: fxls8962.h:1568
#define FXLS8962_ORIENT_CONFIG_ORIENT_ENABLE_EN
Definition: fxls8962.h:1206
#define FXLS8962_SDCD_CONFIG1_X_WT_EN_EN
Definition: fxls8962.h:1560
#define FXLS8962_SDCD_CONFIG2_WT_DBCTM_CLEARED
Definition: fxls8962.h:1648
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_1_563HZ
Definition: fxls8962.h:568
#define FXLS8962_SDCD_CONFIG2_REF_UPDM_SDCD_REF
Definition: fxls8962.h:1633
#define SDCD_LTHS_LSB

Register Start Motion Detect Mode Register Write List.

Definition at line 74 of file fxls8962_orientation_detection.c.

◆ cFxls8962OutputOrientStatus

const registerreadlist_t cFxls8962OutputOrientStatus[]
Initial value:
= {{.readFrom = FXLS8962_ORIENT_STATUS, .numBytes = 1},
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Definition at line 103 of file fxls8962_orientation_detection.c.

◆ cFxls8962SDCDEvent

const registerreadlist_t cFxls8962SDCDEvent[]
Initial value:
= {{.readFrom = FXLS8962_SDCD_INT_SRC2, .numBytes = 1},
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Address of SDCD Status Register.

Definition at line 100 of file fxls8962_orientation_detection.c.

◆ gFxls8962EventReady

volatile bool gFxls8962EventReady

Definition at line 109 of file fxls8962_orientation_detection.c.

Referenced by fxls8962_int_callback(), and main().