ISSDK  1.8
IoT Sensing Software Development Kit
Data Structures | Macros | Functions | Variables
fxls8962_demo.c File Reference

The fxls8962_demo.c file implements the ISSDK FXLS8962 sensor demo example demonstration with interrupt mode. More...

#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "Driver_I2C.h"
#include "Driver_USART.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "fxls8962_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for fxls8962_demo.c:

Go to the source code of this file.

Data Structures

struct  fxls8962_acceldataUser_t
 This structure defines the fxls8962 raw data buffer. More...
 

Macros

#define FXLS8962_DATA_SIZE   8
 
#define FXLS8962_STREAM_DATA_SIZE   12
 
#define FXLS8962_STREAM_SELF_TEST_SIZE   18
 
#define APPLICATION_NAME   "FXLS8962 Accelerometer Demo"
 Unique Name for this application which should match the target GUI pkg name. More...
 
#define APPLICATION_VERSION   "2.5"
 Version to distinguish between instances the same application based on target Shield and updates. More...
 
#define HOST_CMD_RESET   6 /* 6 (Reset Sensor) */
 
#define HOST_CMD_SELFTEST   7 /* 7 (Self Test Sensor) */
 

Functions

void fxls8962_int_data_ready_callback (void *pUserData)
 
bool process_host_command (uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
 
int main (void)
 Main function. More...
 

Variables

const registerwritelist_t cFxls8962ConfigNormal []
 Register settings for Interrupt (non buffered) mode. More...
 
const registerwritelist_t cFxls8962ConfigNormal2 []
 Register settings for Interrupt (non buffered) mode. More...
 
const registerwritelist_t cFxls896216G []
 
const registerwritelist_t cFxls8962STXP []
 Register settings for Self-Test in X Axis (Positive polarity). More...
 
const registerwritelist_t cFxls8962STXN []
 Register settings for Self-Test in X Axis (Negative polarity). More...
 
const registerwritelist_t cFxls8962STYP []
 Register settings for Self-Test in Y Axis (Positive polarity). More...
 
const registerwritelist_t cFxls8962STYN []
 Register settings for Self-Test in Y Axis (Negative polarity). More...
 
const registerwritelist_t cFxls8962STZP []
 Register settings for Self-Test in Z Axis (Positive polarity). More...
 
const registerwritelist_t cFxls8962STZN []
 Register settings for Self-Test in Z Axis (Negative polarity). More...
 
const registerreadlist_t cFxls8962OutputNormal []
 Address of Raw Accel Data in Normal Mode. More...
 
char boardString [ADS_MAX_STRING_LENGTH] = {0}
 
char shieldString [ADS_MAX_STRING_LENGTH] = {0}
 
char embAppName [ADS_MAX_STRING_LENGTH] = {0}
 
volatile bool bStreamingEnabled = false
 
volatile bool bFxls8962DataReady = false
 
volatile bool bFxls8962Ready = false
 
uint8_t gStreamID
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 
uint8_t data [FXLS8962_DATA_SIZE]
 
uint8_t streamingPacket [STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
 
uint8_t streamingPacket1 [STREAMING_HEADER_LEN+FXLS8962_STREAM_SELF_TEST_SIZE]
 
fxls8962_acceldataUser_t rawData = {.timestamp = 0}
 
fxls8962_i2c_sensorhandle_t fxls8962Driver
 
int32_t status
 
int32_t gSystick
 
int st_on =0
 
int st_sample =0
 
int16_t st_xp
 
int16_t st_yp
 
int16_t st_zp
 
int16_t st_xn
 
int16_t st_yn
 
int16_t st_zn
 
int16_t st_dx
 
int16_t st_dy
 
float fsr_scale
 

Detailed Description

The fxls8962_demo.c file implements the ISSDK FXLS8962 sensor demo example demonstration with interrupt mode.

Definition in file fxls8962_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "FXLS8962 Accelerometer Demo"

Unique Name for this application which should match the target GUI pkg name.

Definition at line 45 of file fxls8962_demo.c.

Referenced by main().

◆ APPLICATION_VERSION

#define APPLICATION_VERSION   "2.5"

Version to distinguish between instances the same application based on target Shield and updates.

Definition at line 47 of file fxls8962_demo.c.

Referenced by main().

◆ FXLS8962_DATA_SIZE

#define FXLS8962_DATA_SIZE   8

Definition at line 41 of file fxls8962_demo.c.

Referenced by main().

◆ FXLS8962_STREAM_DATA_SIZE

#define FXLS8962_STREAM_DATA_SIZE   12

Definition at line 42 of file fxls8962_demo.c.

Referenced by main().

◆ FXLS8962_STREAM_SELF_TEST_SIZE

#define FXLS8962_STREAM_SELF_TEST_SIZE   18

Definition at line 43 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ HOST_CMD_RESET

#define HOST_CMD_RESET   6 /* 6 (Reset Sensor) */

Definition at line 48 of file fxls8962_demo.c.

Referenced by process_host_command().

◆ HOST_CMD_SELFTEST

#define HOST_CMD_SELFTEST   7 /* 7 (Self Test Sensor) */

Definition at line 49 of file fxls8962_demo.c.

Referenced by process_host_command().

Function Documentation

◆ fxls8962_int_data_ready_callback()

void fxls8962_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 186 of file fxls8962_demo.c.

References bFxls8962DataReady.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize FXLS8962 pin used by FRDM board

Initialize RGB LED pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize the UART driver.

Set the UART Power mode.

Set UART Baud Rate.

Initialize FXLS8962 sensor driver.

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

Configure the FXLS8962 sensor.

Initialize streaming and assign a Stream ID.

Populate streaming header.

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

Read new raw sensor data from the FXLS8962.

Convert the raw sensor data to signed 16-bit container for display to the debug port.

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

Read new raw sensor data from the FXLS8962.

Convert the raw sensor data to signed 16-bit container for display to the debug port.

Definition at line 378 of file fxls8962_demo.c.

References fxls8962_acceldataUser_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bFxls8962DataReady, bFxls8962Ready, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, fxls8962_i2c_sensorhandle_t::deviceInfo, embAppName, FXLS8962_DATA_SIZE, FXLS8962_I2C_ADDR, FXLS8962_I2C_Configure(), FXLS8962_I2C_Initialize(), FXLS8962_I2C_ReadData(), FXLS8962_I2C_SetIdleTask(), FXLS8962_INT1, fxls8962_int_data_ready_callback(), FXLS8962_STREAM_DATA_SIZE, FXLS8962_STREAM_SELF_TEST_SIZE, FXLS8962_WHOAMI_VALUE, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, gStreamID, gSystick, HOST_FORMAT_HDLC, Host_IO_Add_ISO_Header(), Host_IO_Init(), Host_IO_Receive(), Host_IO_Send(), HOST_S_DRIVER, HOST_S_SIGNAL_EVENT, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), fxls8962_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), Register_I2C_Write(), fxls8962_acceldataUser_t::sdcd, fxls8962_acceldataUser_t::selftest, SENSOR_ERROR_NONE, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), st_on, st_sample, st_xn, st_xp, st_yn, st_yp, st_zn, st_zp, status, STREAMING_HEADER_LEN, streamingPacket, streamingPacket1, fxls8962_acceldataUser_t::temp, fxls8962_acceldataUser_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ process_host_command()

bool process_host_command ( uint8_t  tag,
uint8_t *  hostCommand,
uint8_t *  hostResponse,
size_t *  hostMsgSize,
size_t  respBufferSize 
)

Variable Documentation

◆ bFxls8962DataReady

volatile bool bFxls8962DataReady = false

Definition at line 171 of file fxls8962_demo.c.

Referenced by fxls8962_int_data_ready_callback(), and main().

◆ bFxls8962Ready

volatile bool bFxls8962Ready = false

Definition at line 171 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 169 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 171 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ cFxls896216G

const registerwritelist_t cFxls896216G[]
Initial value:

Definition at line 101 of file fxls8962_demo.c.

◆ cFxls8962ConfigNormal

const registerwritelist_t cFxls8962ConfigNormal[]
Initial value:
= {
{FXLS8962_SENS_CONFIG2, 0x00, 0x00},
{0x38,0x05,0x00},
{0x2F,0x38,0x00},
{0x30,0xD8,0x00},
{0x33,0xC0,0x00},
{0x34,0x0F,0x00},
{0x35,0x40,0x00},
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
Definition: fxls8962.h:496
#define FXLS8962_INT_EN_DRDY_EN_MASK
Definition: fxls8962.h:850
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_12_5HZ
Definition: fxls8962.h:565
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
Definition: fxls8962.h:442
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
Definition: fxls8962.h:432
#define FXLS8962_SENS_CONFIG1_FSR_4G
Definition: fxls8962.h:455
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
Definition: fxls8962.h:521
#define FXLS8962_SENS_CONFIG1_FSR_MASK
Definition: fxls8962.h:423

Register settings for Interrupt (non buffered) mode.

Definition at line 65 of file fxls8962_demo.c.

◆ cFxls8962ConfigNormal2

const registerwritelist_t cFxls8962ConfigNormal2[]
Initial value:
= {
{0x38,0x05,0x00},
#define FXLS8962_INT_EN_DRDY_EN_EN
Definition: fxls8962.h:857
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
Definition: fxls8962.h:496
#define FXLS8962_INT_EN_DRDY_EN_MASK
Definition: fxls8962.h:850
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
Definition: fxls8962.h:551
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_12_5HZ
Definition: fxls8962.h:565
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
Definition: fxls8962.h:442
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
Definition: fxls8962.h:432
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
Definition: fxls8962.h:521

Register settings for Interrupt (non buffered) mode.

Definition at line 88 of file fxls8962_demo.c.

◆ cFxls8962OutputNormal

const registerreadlist_t cFxls8962OutputNormal[]
Initial value:
= {{.readFrom = FXLS8962_INT_STATUS, .numBytes = FXLS8962_DATA_SIZE},
#define FXLS8962_DATA_SIZE
Definition: fxls8962_demo.c:41
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Address of Raw Accel Data in Normal Mode.

Definition at line 163 of file fxls8962_demo.c.

◆ cFxls8962STXN

const registerwritelist_t cFxls8962STXN[]
Initial value:

Register settings for Self-Test in X Axis (Negative polarity).

Definition at line 123 of file fxls8962_demo.c.

◆ cFxls8962STXP

const registerwritelist_t cFxls8962STXP[]
Initial value:

Register settings for Self-Test in X Axis (Positive polarity).

Definition at line 115 of file fxls8962_demo.c.

◆ cFxls8962STYN

const registerwritelist_t cFxls8962STYN[]
Initial value:

Register settings for Self-Test in Y Axis (Negative polarity).

Definition at line 139 of file fxls8962_demo.c.

◆ cFxls8962STYP

const registerwritelist_t cFxls8962STYP[]
Initial value:

Register settings for Self-Test in Y Axis (Positive polarity).

Definition at line 131 of file fxls8962_demo.c.

◆ cFxls8962STZN

const registerwritelist_t cFxls8962STZN[]
Initial value:

Register settings for Self-Test in Z Axis (Negative polarity).

Definition at line 155 of file fxls8962_demo.c.

◆ cFxls8962STZP

const registerwritelist_t cFxls8962STZP[]
Initial value:

Register settings for Self-Test in Z Axis (Positive polarity).

Definition at line 147 of file fxls8962_demo.c.

◆ data

uint8_t data[FXLS8962_DATA_SIZE]

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 170 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ fsr_scale

float fsr_scale

Definition at line 180 of file fxls8962_demo.c.

Referenced by process_host_command().

◆ fxls8962Driver

Definition at line 176 of file fxls8962_demo.c.

Referenced by main().

◆ gStreamID

uint8_t gStreamID

Definition at line 172 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 177 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 173 of file fxls8962_demo.c.

◆ rawData

fxls8962_acceldataUser_t rawData = {.timestamp = 0}

Definition at line 175 of file fxls8962_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 169 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ st_dx

int16_t st_dx

Definition at line 179 of file fxls8962_demo.c.

◆ st_dy

int16_t st_dy

Definition at line 179 of file fxls8962_demo.c.

◆ st_on

int st_on =0

Definition at line 178 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ st_sample

int st_sample =0

Definition at line 178 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ st_xn

int16_t st_xn

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ st_xp

int16_t st_xp

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ st_yn

int16_t st_yn

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ st_yp

int16_t st_yp

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ st_zn

int16_t st_zn

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ st_zp

int16_t st_zp

Definition at line 179 of file fxls8962_demo.c.

Referenced by main().

◆ status

int32_t status

Definition at line 177 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().

◆ streamingPacket

Definition at line 174 of file fxls8962_demo.c.

Referenced by main().

◆ streamingPacket1

Definition at line 174 of file fxls8962_demo.c.

Referenced by main(), and process_host_command().