![]() |
ISSDK
1.7
IoT Sensing Software Development Kit
|
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"
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... | |
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.
#define APPLICATION_NAME "11 Axis Sensor Demo" |
Unique Name for this application which should match the target GUI pkg name.
Definition at line 85 of file demo_11_axis_mult2b.c.
Referenced by main().
#define APPLICATION_VERSION "2.5" |
Version to distinguish between instances the same application based on target Shield and updates.
Definition at line 87 of file demo_11_axis_mult2b.c.
Referenced by main().
#define EVENT_PAYLOAD_LEN (1) |
Definition at line 98 of file demo_11_axis_mult2b.c.
Referenced by main().
#define FF_MT_THS_VALUE 0x03 /* Threshold Value. */ |
Definition at line 94 of file demo_11_axis_mult2b.c.
#define FF_MT_WT_DBCNT 0x32 /* Debounce count value. */ |
Definition at line 93 of file demo_11_axis_mult2b.c.
#define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE) |
Definition at line 77 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MAG3110_DATA_SIZE (6) |
Definition at line 76 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MMA865x_DATA_SIZE (6) |
Definition at line 75 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MPL3115_DATA_SIZE (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE) |
Definition at line 78 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MPL3115_PADDING_SIZE (1) |
Definition at line 70 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MPL3115_PRESSURE_DATA_SIZE (3) |
Definition at line 71 of file demo_11_axis_mult2b.c.
Referenced by main().
#define MPL3115_TEMPERATURE_DATA_SIZE (2) |
Definition at line 72 of file demo_11_axis_mult2b.c.
#define P_THS_EVENT_ID (0x02) |
Definition at line 97 of file demo_11_axis_mult2b.c.
Referenced by main().
#define SDCD_FF_EVT_ID (0x01) |
Definition at line 96 of file demo_11_axis_mult2b.c.
Referenced by main().
#define STREAMING_PAYLOAD_LEN |
Definition at line 80 of file demo_11_axis_mult2b.c.
Referenced by main().
#define STREAMING_PKT_TIMESTAMP_LEN (4) |
Definition at line 74 of file demo_11_axis_mult2b.c.
Referenced by main().
void fxas21002_int_data_ready_callback | ( | void * | pUserData | ) |
Set flag to indicate Sensor has signalled data ready.
Definition at line 195 of file demo_11_axis_mult2b.c.
References bFxas21002DataReady.
Referenced by 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 296 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_SetPowerModeWait(), status, STREAMING_HEADER_LEN, STREAMING_PAYLOAD_LEN, STREAMING_PKT_TIMESTAMP_LEN, streamingPacket, mpl3115_pressuredata_t::temperature, and GENERIC_DRIVER_GPIO::toggle_pin.
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 201 of file demo_11_axis_mult2b.c.
References bMma865xEventReady.
Referenced by main().
void mpl3115_int_event_ready_callback | ( | void * | pUserData | ) |
Set flag to indicate Sensor has signalled data ready.
Definition at line 207 of file demo_11_axis_mult2b.c.
References bMpl3115EventReady.
Referenced by main().
bool process_host_command | ( | uint8_t | tag, |
uint8_t * | hostCommand, | ||
uint8_t * | hostResponse, | ||
size_t * | hostMsgSize, | ||
size_t | respBufferSize | ||
) |
Definition at line 213 of file demo_11_axis_mult2b.c.
References bMult2bReady, BOARD_SystickStart(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, embAppName, GREEN_LED, gStreamID, gSystick, HOST_CMD_START, HOST_CMD_STOP, HOST_MSG_CMD_ACT_OFFSET, HOST_MSG_LEN_LSB_OFFSET, HOST_PRO_CMD_W_CFG_TAG, HOST_PRO_INT_CMD_TAG, HOST_PRO_INT_DEV_TAG, and shieldString.
Referenced by main().
volatile bool bFxas21002DataReady = false |
Definition at line 185 of file demo_11_axis_mult2b.c.
Referenced by fxas21002_int_data_ready_callback(), and main().
volatile bool bMma865xEventReady = false |
Definition at line 185 of file demo_11_axis_mult2b.c.
Referenced by main(), and mma865x_int_event_ready_callback().
volatile bool bMpl3115EventReady = false |
Definition at line 186 of file demo_11_axis_mult2b.c.
Referenced by main(), and mpl3115_int_event_ready_callback().
volatile bool bMult2bReady = false |
Definition at line 185 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
char boardString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 183 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
volatile bool bStreamingEnabled = false |
Definition at line 185 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
const registerwritelist_t cMag3110ConfigNormal[] |
Register settings for Normal (non buffered) mode.
Definition at line 137 of file demo_11_axis_mult2b.c.
const registerreadlist_t cMag3110OutputNormal[] |
Address and size of Raw Magnetic Data in Normal Mode.
Definition at line 147 of file demo_11_axis_mult2b.c.
const registerwritelist_t cMma865xConfigFreeFall[] |
Register settings for freefall detection and poll mode.
Definition at line 104 of file demo_11_axis_mult2b.c.
const registerreadlist_t cMma865xFreeFallEvent[] = {{.readFrom = MMA865x_FF_MT_SRC, .numBytes = 1}, __END_READ_DATA__} |
Address of Freefall Status Register.
Definition at line 134 of file demo_11_axis_mult2b.c.
const registerreadlist_t cMma865xOutputValues[] |
Prepare the register read list to read the raw Accel data from MMA865x.
Definition at line 130 of file demo_11_axis_mult2b.c.
const registerwritelist_t cMpl3115SetOST[] |
Register settings for Triggring One-Shot Sampling.
Definition at line 165 of file demo_11_axis_mult2b.c.
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 184 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
const registerwritelist_t fxas21002_Config_Normal[] |
Prepare the register write list to configure FXAS21002 in non-FIFO mode.
Definition at line 151 of file demo_11_axis_mult2b.c.
const registerreadlist_t fxas21002_Output_Values[] |
Prepare the register read list to read the raw gyro data from the FXAS21002.
Definition at line 161 of file demo_11_axis_mult2b.c.
uint8_t gStreamID |
Definition at line 187 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
int32_t gSystick |
Definition at line 188 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().
const registerreadlist_t mpl3115_Output_Values[] |
Address and size of Raw Pressure+Temperature Data in Normal Mode.
Definition at line 177 of file demo_11_axis_mult2b.c.
GENERIC_DRIVER_GPIO* pGpioDriver = &Driver_GPIO_KSDK |
Definition at line 189 of file demo_11_axis_mult2b.c.
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 183 of file demo_11_axis_mult2b.c.
Referenced by main(), and process_host_command().