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

The demo_11_axis_mult2b.c file implements the ISSDK MMA8652, MAG3110, FXAS21002 and MPL3115 sensors 11-Axis demo example demonstration using Bluetooth. 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 "mag3110_drv.h"
#include "mpl3115_drv.h"
#include "mma865x_drv.h"
#include "fxas21002_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for demo_11_axis_mult2b.c:

Go to the source code of this file.

Macros

#define MPL3115_PADDING_SIZE   (1)
 
#define MPL3115_PRESSURE_DATA_SIZE   (3)
 
#define MPL3115_TEMPERATURE_DATA_SIZE   (2)
 
#define STREAMING_PKT_TIMESTAMP_LEN   (4)
 
#define MMA865x_DATA_SIZE   (6)
 
#define MAG3110_DATA_SIZE   (6)
 
#define FXAS21002_DATA_SIZE   (FXAS21002_GYRO_DATA_SIZE)
 
#define MPL3115_DATA_SIZE   (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE)
 
#define STREAMING_PAYLOAD_LEN
 
#define APPLICATION_NAME   "11 Axis Sensor 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 FF_MT_WT_DBCNT   0x32 /* Debounce count value. */
 
#define FF_MT_THS_VALUE   0x03 /* Threshold Value. */
 
#define SDCD_FF_EVT_ID   (0x01)
 
#define P_THS_EVENT_ID   (0x02)
 
#define EVENT_PAYLOAD_LEN   (1)
 

Functions

void fxas21002_int_data_ready_callback (void *pUserData)
 
void mma865x_int_event_ready_callback (void *pUserData)
 This is the Sensor WT Event Ready ISR implementation. More...
 
void mpl3115_int_event_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 cMma865xConfigFreeFall []
 Register settings for freefall detection and poll mode. More...
 
const registerreadlist_t cMma865xOutputValues []
 
const registerreadlist_t cMma865xFreeFallEvent [] = {{.readFrom = MMA865x_FF_MT_SRC, .numBytes = 1}, __END_READ_DATA__}
 Address of Freefall Status Register. More...
 
const registerwritelist_t cMag3110ConfigNormal []
 Register settings for Normal (non buffered) mode. More...
 
const registerreadlist_t cMag3110OutputNormal []
 Address and size of Raw Magnetic Data in Normal Mode. More...
 
const registerwritelist_t fxas21002_Config_Normal []
 
const registerreadlist_t fxas21002_Output_Values []
 
const registerwritelist_t cMpl3115SetOST []
 Register settings for Triggring One-Shot Sampling. More...
 
const registerreadlist_t mpl3115_Output_Values []
 Address and size of Raw Pressure+Temperature 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 bFxas21002DataReady = false
 
volatile bool bMult2bReady = false
 
volatile bool bMma865xEventReady = false
 
volatile bool bMpl3115EventReady = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The demo_11_axis_mult2b.c file implements the ISSDK MMA8652, MAG3110, FXAS21002 and MPL3115 sensors 11-Axis demo example demonstration using Bluetooth.

Definition in file demo_11_axis_mult2b.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "11 Axis Sensor Demo"

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

Definition at line 59 of file demo_11_axis_mult2b.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 61 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ EVENT_PAYLOAD_LEN

#define EVENT_PAYLOAD_LEN   (1)

Definition at line 72 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ FF_MT_THS_VALUE

#define FF_MT_THS_VALUE   0x03 /* Threshold Value. */

Definition at line 68 of file demo_11_axis_mult2b.c.

◆ FF_MT_WT_DBCNT

#define FF_MT_WT_DBCNT   0x32 /* Debounce count value. */

Definition at line 67 of file demo_11_axis_mult2b.c.

◆ FXAS21002_DATA_SIZE

#define FXAS21002_DATA_SIZE   (FXAS21002_GYRO_DATA_SIZE)

Definition at line 51 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MAG3110_DATA_SIZE

#define MAG3110_DATA_SIZE   (6)

Definition at line 50 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MMA865x_DATA_SIZE

#define MMA865x_DATA_SIZE   (6)

Definition at line 49 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MPL3115_DATA_SIZE

#define MPL3115_DATA_SIZE   (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE)

Definition at line 52 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MPL3115_PADDING_SIZE

#define MPL3115_PADDING_SIZE   (1)

Definition at line 44 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MPL3115_PRESSURE_DATA_SIZE

#define MPL3115_PRESSURE_DATA_SIZE   (3)

Definition at line 45 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ MPL3115_TEMPERATURE_DATA_SIZE

#define MPL3115_TEMPERATURE_DATA_SIZE   (2)

Definition at line 46 of file demo_11_axis_mult2b.c.

◆ P_THS_EVENT_ID

#define P_THS_EVENT_ID   (0x02)

Definition at line 71 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ SDCD_FF_EVT_ID

#define SDCD_FF_EVT_ID   (0x01)

Definition at line 70 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ STREAMING_PAYLOAD_LEN

#define STREAMING_PAYLOAD_LEN
Value:
MPL3115_PADDING_SIZE)
#define MAG3110_DATA_SIZE
#define STREAMING_PKT_TIMESTAMP_LEN
#define MPL3115_DATA_SIZE
#define FXAS21002_DATA_SIZE
#define MMA865x_DATA_SIZE

Definition at line 54 of file demo_11_axis_mult2b.c.

Referenced by main().

◆ STREAMING_PKT_TIMESTAMP_LEN

#define STREAMING_PKT_TIMESTAMP_LEN   (4)

Definition at line 48 of file demo_11_axis_mult2b.c.

Referenced by main().

Function Documentation

◆ fxas21002_int_data_ready_callback()

void fxas21002_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 169 of file demo_11_axis_mult2b.c.

References bFxas21002DataReady.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize FXAS21002 INT1 pin used by FRDM board

Initialize MMA865x INT1 pin used by FRDM board

Initialize INT1 MAG3110 used on FRDM board. NOTE: INT1 of MPL3115 pin on MULT2B maps to PTA0 of K64F which is used as OpenSDA CLK. Hence, we will wire connect INT1_MPL3115 to INT_MAG (J5_Pin3 to J3_Pin2) and use INT1_MAG3110 handle instead.

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 the MMA865x sensor driver.

Initialize MAG3110 sensor driver.

Initialize the FXAS21002 sensor driver.

Initialize the MPL3115 sensor driver.

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

Configure the FXLS8962 sensor.

Configure the MAG3110 sensor driver.

Configure the FXAS21002 sensor driver.

In One-Shot Mode we do not need to Configure MPL3115, instead we will set OST bit directly.

Initialize streaming and assign a Stream ID.

Populate streaming header.

Populate event header.

Read the Freefall event FLAGs from FXLS8962 to clear INT2.

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

Read new raw sensor data from the MMA865x.

Read raw sensor data from the MAG3110.

Read the raw sensor data from the FXAS21002.

Read raw sensor data from the MPL3115.

Definition at line 270 of file demo_11_axis_mult2b.c.

References mma865x_acceldata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bFxas21002DataReady, bMma865xEventReady, bMpl3115EventReady, bMult2bReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mag3110_i2c_sensorhandle_t::deviceInfo, mma865x_i2c_sensorhandle_t::deviceInfo, mpl3115_i2c_sensorhandle_t::deviceInfo, fxas21002_i2c_sensorhandle_t::deviceInfo, embAppName, EVENT_PAYLOAD_LEN, EVENT_STREAM_ID, FXAS21002_DATA_SIZE, FXAS21002_I2C_ADDR, FXAS21002_I2C_Configure(), FXAS21002_I2C_Initialize(), FXAS21002_I2C_ReadData(), FXAS21002_I2C_SetIdleTask(), FXAS21002_INT1, fxas21002_int_data_ready_callback(), FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, gStreamID, gSystick, fxas21002_gyrodata_t::gyro, HOST_B_DRIVER, HOST_B_SIGNAL_EVENT, HOST_FORMAT_HDLC, Host_IO_Add_ISO_Header(), Host_IO_Init(), Host_IO_Receive(), Host_IO_Send(), I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), mag3110_magdata_t::mag, MAG3110_CalibrateHardIronOffset(), MAG3110_DATA_SIZE, MAG3110_I2C_ADDR, MAG3110_I2C_Configure(), MAG3110_I2C_Initialize(), MAG3110_I2C_ReadData(), MAG3110_I2C_SetIdleTask(), MAG3110_INT1, MAG3110_WHOAMI_VALUE, MMA8652_I2C_ADDR, MMA8652_INT1, MMA8652_WHOAMI_VALUE, MMA865x_DATA_SIZE, MMA865x_FF_MT_SRC_EA_DETECTED, MMA865x_FF_MT_SRC_EA_MASK, MMA865x_I2C_Configure(), MMA865x_I2C_Initialize(), MMA865x_I2C_ReadData(), MMA865x_I2C_SetIdleTask(), mma865x_int_event_ready_callback(), MPL3115_DATA_SIZE, MPL3115_I2C_ADDR, MPL3115_I2C_Initialize(), MPL3115_I2C_ReadData(), MPL3115_I2C_SetIdleTask(), mpl3115_int_event_ready_callback(), MPL3115_PADDING_SIZE, MPL3115_PRESSURE_DATA_SIZE, MPL3115_WHOAMI_VALUE, P_THS_EVENT_ID, mag3110_i2c_sensorhandle_t::pCommDrv, mma865x_i2c_sensorhandle_t::pCommDrv, mpl3115_i2c_sensorhandle_t::pCommDrv, fxas21002_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, mpl3115_pressuredata_t::pressure, process_host_command(), SDCD_FF_EVT_ID, SENSOR_ERROR_NONE, Sensor_I2C_Write(), SHIELD_NAME, shieldString, mpl3115_i2c_sensorhandle_t::slaveAddress, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, STREAMING_PAYLOAD_LEN, STREAMING_PKT_TIMESTAMP_LEN, streamingPacket, mpl3115_pressuredata_t::temperature, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mma865x_int_event_ready_callback()

void mma865x_int_event_ready_callback ( void *  pUserData)

This is the Sensor WT Event Ready ISR implementation.

Set flag to indicate Sensor has signalled event ready.

Definition at line 175 of file demo_11_axis_mult2b.c.

References bMma865xEventReady.

Referenced by main().

Here is the caller graph for this function:

◆ mpl3115_int_event_ready_callback()

void mpl3115_int_event_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 181 of file demo_11_axis_mult2b.c.

References bMpl3115EventReady.

Referenced by main().

Here is the caller 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

◆ bFxas21002DataReady

volatile bool bFxas21002DataReady = false

Definition at line 159 of file demo_11_axis_mult2b.c.

Referenced by fxas21002_int_data_ready_callback(), and main().

◆ bMma865xEventReady

volatile bool bMma865xEventReady = false

Definition at line 159 of file demo_11_axis_mult2b.c.

Referenced by main(), and mma865x_int_event_ready_callback().

◆ bMpl3115EventReady

volatile bool bMpl3115EventReady = false

Definition at line 160 of file demo_11_axis_mult2b.c.

Referenced by main(), and mpl3115_int_event_ready_callback().

◆ bMult2bReady

volatile bool bMult2bReady = false

Definition at line 159 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 157 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 159 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ cMag3110ConfigNormal

const registerwritelist_t cMag3110ConfigNormal[]
Initial value:
= {
#define MAG3110_CTRL_REG1_OS_OSR_16
Definition: mag3110.h:417
#define MAG3110_CTRL_REG2_MAG_RST_EN
Definition: mag3110.h:471
#define MAG3110_CTRL_REG2_MAG_RST_MASK
Definition: mag3110.h:458
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MAG3110_CTRL_REG1_DR_ODR_1
Definition: mag3110.h:422
#define MAG3110_CTRL_REG1_DR_MASK
Definition: mag3110.h:404
#define MAG3110_CTRL_REG1_OS_MASK
Definition: mag3110.h:401
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
Definition: mag3110.h:464
#define MAG3110_CTRL_REG2_RAW_RAW
Definition: mag3110.h:474
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
Definition: mag3110.h:477
#define MAG3110_CTRL_REG2_RAW_MASK
Definition: mag3110.h:461

Register settings for Normal (non buffered) mode.

Definition at line 111 of file demo_11_axis_mult2b.c.

◆ cMag3110OutputNormal

const registerreadlist_t cMag3110OutputNormal[]
Initial value:
= {{.readFrom = MAG3110_OUT_X_MSB, .numBytes = MAG3110_DATA_SIZE},
#define MAG3110_DATA_SIZE
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Address and size of Raw Magnetic Data in Normal Mode.

Definition at line 121 of file demo_11_axis_mult2b.c.

◆ cMma865xConfigFreeFall

const registerwritelist_t cMma865xConfigFreeFall[]
Initial value:
=
{
#define MMA865x_CTRL_REG1_DR_MASK
Definition: mma865x.h:1534
#define MMA865x_FF_MT_CFG_YEFE_MASK
Definition: mma865x.h:854
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_INT1
Definition: mma865x.h:1851
#define MMA865x_XYZ_DATA_CFG_FS_MASK
Definition: mma865x.h:530
#define MMA865x_CTRL_REG1_DR_50HZ
Definition: mma865x.h:1552
#define MMA865x_FF_MT_CFG_XEFE_EN
Definition: mma865x.h:881
#define MMA865x_FF_MT_THS_THS_MASK
Definition: mma865x.h:983
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MMA865x_CTRL_REG3_IPOL_MASK
Definition: mma865x.h:1664
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
Definition: mma865x.h:994
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
Definition: mma865x.h:1701
#define MMA865x_FF_MT_CFG_ZEFE_EN
Definition: mma865x.h:875
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
Definition: mma865x.h:1776
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_MASK
Definition: mma865x.h:1743
#define MMA865x_CTRL_REG2_MODS_MASK
Definition: mma865x.h:1592
#define FF_MT_WT_DBCNT
#define MMA865x_CTRL_REG5_INT_CFG_FF_MT_MASK
Definition: mma865x.h:1818
#define MMA865x_FF_MT_CFG_XEFE_MASK
Definition: mma865x.h:851
#define MMA865x_CTRL_REG2_MODS_HR
Definition: mma865x.h:1623
#define FF_MT_THS_VALUE
#define MMA865x_XYZ_DATA_CFG_FS_2G
Definition: mma865x.h:542
#define MMA865x_FF_MT_CFG_ZEFE_MASK
Definition: mma865x.h:857
#define MMA865x_FF_MT_CFG_ELE_MASK
Definition: mma865x.h:863
#define MMA865x_FF_MT_CFG_OAE_MASK
Definition: mma865x.h:860
#define MMA865x_FF_MT_THS_DBCNTM_MASK
Definition: mma865x.h:986
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
Definition: mma865x.h:872
#define MMA865x_FF_MT_CFG_ELE_EN
Definition: mma865x.h:871
#define MMA865x_FF_MT_CFG_YEFE_EN
Definition: mma865x.h:878

Register settings for freefall detection and poll mode.

Definition at line 78 of file demo_11_axis_mult2b.c.

◆ cMma865xFreeFallEvent

const registerreadlist_t cMma865xFreeFallEvent[] = {{.readFrom = MMA865x_FF_MT_SRC, .numBytes = 1}, __END_READ_DATA__}

Address of Freefall Status Register.

Definition at line 108 of file demo_11_axis_mult2b.c.

◆ cMma865xOutputValues

const registerreadlist_t cMma865xOutputValues[]
Initial value:
= {{.readFrom = MMA865x_OUT_X_MSB, .numBytes = MMA865x_DATA_SIZE},
#define MMA865x_DATA_SIZE
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Prepare the register read list to read the raw Accel data from MMA865x.

Definition at line 104 of file demo_11_axis_mult2b.c.

◆ cMpl3115SetOST

const registerwritelist_t cMpl3115SetOST[]
Initial value:

Register settings for Triggring One-Shot Sampling.

Definition at line 139 of file demo_11_axis_mult2b.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 158 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ fxas21002_Config_Normal

const registerwritelist_t fxas21002_Config_Normal[]
Initial value:

Prepare the register write list to configure FXAS21002 in non-FIFO mode.

Definition at line 125 of file demo_11_axis_mult2b.c.

◆ fxas21002_Output_Values

const registerreadlist_t fxas21002_Output_Values[]
Initial value:
= {
#define FXAS21002_DATA_SIZE
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Prepare the register read list to read the raw gyro data from the FXAS21002.

Definition at line 135 of file demo_11_axis_mult2b.c.

◆ gStreamID

uint8_t gStreamID

Definition at line 161 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 162 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().

◆ mpl3115_Output_Values

const registerreadlist_t mpl3115_Output_Values[]
Initial value:
= {{.readFrom = MPL3115_OUT_P_MSB, .numBytes = MPL3115_DATA_SIZE},
#define MPL3115_DATA_SIZE
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Address and size of Raw Pressure+Temperature Data in Normal Mode.

Definition at line 151 of file demo_11_axis_mult2b.c.

◆ pGpioDriver

Definition at line 163 of file demo_11_axis_mult2b.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 157 of file demo_11_axis_mult2b.c.

Referenced by main(), and process_host_command().