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

The data_logger_demo.c file implements the ISSDK Data Logger for RD-KL25-AGMP01 example demonstration with one sensor in Interrupt mode and other two in polling mode. MPL3115 is in One-Shot Poll Mode. FXOS8700 is @200Hz Hybrid Poll Mode. FXAS21002 is @200Hz Interrupt Mode. Data from MPL3115, FXOS8700 and FXAS21002 is only read when INT from FXAS21002 is received. The FXAS21002 ODR serves as the application ODR time keeper. 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 "mpl3115_drv.h"
#include "fxos8700_drv.h"
#include "fxas21002_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for data_logger_demo.c:

Go to the source code of this file.

Macros

#define STREAMING_PKT_TIMESTAMP_LEN   (4)
 
#define FXOS8700_ACCEL_DATA_SIZE   (6)
 
#define FXOS8700_MAG_DATA_SIZE   (6)
 
#define MPL3115_PADDING_SIZE   (1)
 
#define MPL3115_PRESSURE_DATA_SIZE   (3)
 
#define MPL3115_TEMPERATURE_DATA_SIZE   (2)
 
#define FXOS8700_DATA_SIZE   (FXOS8700_ACCEL_DATA_SIZE + FXOS8700_MAG_DATA_SIZE)
 
#define FXAS21002_DATA_SIZE   (FXAS21002_GYRO_DATA_SIZE)
 
#define MPL3115_DATA_SIZE   (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE)
 
#define LED_TOGGLE_RATE   (100)
 
#define STREAMING_PAYLOAD_LEN   (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + MPL3115_PADDING_SIZE)
 
#define STREAMING_PAYLOAD_SHORT_LEN   (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE)
 
#define nmi_handler   NMI_Handler
 
#define APPLICATION_NAME   "Generic Data Logger 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...
 

Functions

void nmi_handler (void *pUserData)
 
void fxas21002_isr (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 fxos8700_Config_Hybrid []
 
const registerreadlist_t fxos8700_Output_values []
 
const registerwritelist_t fxas21002_Config_Isr []
 
const registerreadlist_t fxas21002_Output_Values []
 
const registerwritelist_t cMpl3115SetOST []
 Register settings for Triggring One-Shot Sampling. More...
 
const registerreadlist_t cMpl3115GetOST [] = {{.readFrom = MPL3115_CTRL_REG1, .numBytes = 1}, __END_READ_DATA__}
 Address of Register containing OST Bit. 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 bDataLoggerReady = false
 
uint8_t gPrimaryStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The data_logger_demo.c file implements the ISSDK Data Logger for RD-KL25-AGMP01 example demonstration with one sensor in Interrupt mode and other two in polling mode. MPL3115 is in One-Shot Poll Mode. FXOS8700 is @200Hz Hybrid Poll Mode. FXAS21002 is @200Hz Interrupt Mode. Data from MPL3115, FXOS8700 and FXAS21002 is only read when INT from FXAS21002 is received. The FXAS21002 ODR serves as the application ODR time keeper.

Definition in file data_logger_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "Generic Data Logger Demo"

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

Definition at line 69 of file data_logger_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 71 of file data_logger_demo.c.

Referenced by main().

◆ FXAS21002_DATA_SIZE

#define FXAS21002_DATA_SIZE   (FXAS21002_GYRO_DATA_SIZE)

Definition at line 56 of file data_logger_demo.c.

Referenced by main().

◆ FXOS8700_ACCEL_DATA_SIZE

#define FXOS8700_ACCEL_DATA_SIZE   (6)

Definition at line 49 of file data_logger_demo.c.

Referenced by main().

◆ FXOS8700_DATA_SIZE

#define FXOS8700_DATA_SIZE   (FXOS8700_ACCEL_DATA_SIZE + FXOS8700_MAG_DATA_SIZE)

Definition at line 55 of file data_logger_demo.c.

Referenced by main().

◆ FXOS8700_MAG_DATA_SIZE

#define FXOS8700_MAG_DATA_SIZE   (6)

Definition at line 50 of file data_logger_demo.c.

◆ LED_TOGGLE_RATE

#define LED_TOGGLE_RATE   (100)

Definition at line 60 of file data_logger_demo.c.

Referenced by main().

◆ MPL3115_DATA_SIZE

#define MPL3115_DATA_SIZE   (MPL3115_PRESSURE_DATA_SIZE + MPL3115_TEMPERATURE_DATA_SIZE)

Definition at line 57 of file data_logger_demo.c.

Referenced by main().

◆ MPL3115_PADDING_SIZE

#define MPL3115_PADDING_SIZE   (1)

Definition at line 51 of file data_logger_demo.c.

Referenced by main().

◆ MPL3115_PRESSURE_DATA_SIZE

#define MPL3115_PRESSURE_DATA_SIZE   (3)

Definition at line 52 of file data_logger_demo.c.

Referenced by main().

◆ MPL3115_TEMPERATURE_DATA_SIZE

#define MPL3115_TEMPERATURE_DATA_SIZE   (2)

Definition at line 53 of file data_logger_demo.c.

◆ nmi_handler

#define nmi_handler   NMI_Handler

Definition at line 66 of file data_logger_demo.c.

◆ STREAMING_PAYLOAD_LEN

Definition at line 61 of file data_logger_demo.c.

Referenced by main().

◆ STREAMING_PAYLOAD_SHORT_LEN

#define STREAMING_PAYLOAD_SHORT_LEN   (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE)

Definition at line 63 of file data_logger_demo.c.

Referenced by main().

◆ STREAMING_PKT_TIMESTAMP_LEN

#define STREAMING_PKT_TIMESTAMP_LEN   (4)

Definition at line 48 of file data_logger_demo.c.

Referenced by main().

Function Documentation

◆ fxas21002_isr()

void fxas21002_isr ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 138 of file data_logger_demo.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 INT1 FXAS21002 pin used by RD board

Initialize GREEN LED pin used by RD 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 MPL3115 sensor driver.

Initialize the FXOS8700 sensor driver.

Initialize the FXAS21002 sensor driver.

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

Configure the fxos8700 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 IDs.

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

Read the raw sensor data from the fxos8700.

Read the raw sensor data from the FXAS21002.

MPL3115 is in One-Shot Mode so we have to trigger acquizition of new sample based on OST bit.

Read raw sensor data from the MPL3115.

Populate streaming header.

Definition at line 227 of file data_logger_demo.c.

References fxos8700_accelmagdata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bDataLoggerReady, bFxas21002DataReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mpl3115_i2c_sensorhandle_t::deviceInfo, fxos8700_i2c_sensorhandle_t::deviceInfo, fxas21002_i2c_sensorhandle_t::deviceInfo, embAppName, FXAS21002_DATA_SIZE, FXAS21002_I2C_ADDR, FXAS21002_I2C_Configure(), FXAS21002_I2C_Initialize(), FXAS21002_I2C_ReadData(), FXAS21002_I2C_SetIdleTask(), fxas21002_isr(), FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE, FXOS8700_ACCEL_DATA_SIZE, FXOS8700_DATA_SIZE, FXOS8700_I2C_ADDR, FXOS8700_I2C_Configure(), FXOS8700_I2C_Initialize(), FXOS8700_I2C_ReadData(), FXOS8700_I2C_SetIdleTask(), FXOS8700_WHO_AM_I_PROD_VALUE, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, gPrimaryStreamID, gSystick, fxas21002_gyrodata_t::gyro, 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, INT1_FXAS21002, int32_t(), LED_GREEN, LED_TOGGLE_RATE, fxos8700_accelmagdata_t::mag, MPL3115_CTRL_REG1_OST_MASK, MPL3115_CTRL_REG1_OST_RESET, MPL3115_DATA_SIZE, MPL3115_I2C_ADDR, MPL3115_I2C_Initialize(), MPL3115_I2C_ReadData(), MPL3115_I2C_SetIdleTask(), MPL3115_PADDING_SIZE, MPL3115_PRESSURE_DATA_SIZE, MPL3115_WHOAMI_VALUE, mpl3115_i2c_sensorhandle_t::pCommDrv, fxos8700_i2c_sensorhandle_t::pCommDrv, fxas21002_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, mpl3115_pressuredata_t::pressure, process_host_command(), SENSOR_ERROR_NONE, Sensor_I2C_Write(), GENERIC_DRIVER_GPIO::set_pin, SHIELD_NAME, shieldString, mpl3115_i2c_sensorhandle_t::slaveAddress, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, STREAMING_PAYLOAD_LEN, STREAMING_PAYLOAD_SHORT_LEN, STREAMING_PKT_TIMESTAMP_LEN, streamingPacket, mpl3115_pressuredata_t::temperature, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ nmi_handler()

void nmi_handler ( void *  pUserData)

Handler for NMI Interrupt.

Definition at line 132 of file data_logger_demo.c.

◆ process_host_command()

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

Variable Documentation

◆ bDataLoggerReady

volatile bool bDataLoggerReady = false

Definition at line 123 of file data_logger_demo.c.

Referenced by main(), and process_host_command().

◆ bFxas21002DataReady

volatile bool bFxas21002DataReady = false

Definition at line 123 of file data_logger_demo.c.

Referenced by fxas21002_isr(), and main().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 121 of file data_logger_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 123 of file data_logger_demo.c.

Referenced by main(), and process_host_command().

◆ cMpl3115GetOST

const registerreadlist_t cMpl3115GetOST[] = {{.readFrom = MPL3115_CTRL_REG1, .numBytes = 1}, __END_READ_DATA__}

Address of Register containing OST Bit.

Definition at line 112 of file data_logger_demo.c.

◆ cMpl3115SetOST

const registerwritelist_t cMpl3115SetOST[]
Initial value:
= {
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MPL3115_CTRL_REG1_OST_MASK
Definition: mpl3115.h:849
#define MPL3115_CTRL_REG1_OST_SET
Definition: mpl3115.h:871

Register settings for Triggring One-Shot Sampling.

Definition at line 106 of file data_logger_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 122 of file data_logger_demo.c.

Referenced by main(), and process_host_command().

◆ fxas21002_Config_Isr

const registerwritelist_t fxas21002_Config_Isr[]
Initial value:

Prepare the register write list to configure FXAS21002 in Interrupt Mode.

Definition at line 92 of file data_logger_demo.c.

◆ fxas21002_Output_Values

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

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

Definition at line 102 of file data_logger_demo.c.

◆ fxos8700_Config_Hybrid

const registerwritelist_t fxos8700_Config_Hybrid[]
Initial value:
= {
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_MASK
Definition: fxos8700.h:2634
#define FXOS8700_M_CTRL_REG1_M_HMS_MASK
Definition: fxos8700.h:2547
#define FXOS8700_CTRL_REG1_DR_MASK
Definition: fxos8700.h:1504
#define FXOS8700_M_CTRL_REG1_M_HMS_HYBRID_MODE
Definition: fxos8700.h:2595
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_HYBRID_MODE
Definition: fxos8700.h:2641
#define FXOS8700_M_CTRL_REG1_M_ACAL_EN
Definition: fxos8700.h:2566
#define FXOS8700_M_CTRL_REG1_M_ACAL_MASK
Definition: fxos8700.h:2559
#define FXOS8700_CTRL_REG1_DR_HYBRID_200_HZ
Definition: fxos8700.h:1527
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_DISABLE
Definition: fxos8700.h:2667
#define FXOS8700_M_CTRL_REG2_M_RST_CNT_MASK
Definition: fxos8700.h:2622

Prepare the register write list to configure FXOS8700 in Hybrid mode.

Definition at line 77 of file data_logger_demo.c.

◆ fxos8700_Output_values

const registerreadlist_t fxos8700_Output_values[]
Initial value:
= {{.readFrom = FXOS8700_OUT_X_MSB, .numBytes = FXOS8700_DATA_SIZE},
#define __END_READ_DATA__
Definition: sensor_drv.h:51
#define FXOS8700_DATA_SIZE

Command definition to read the Accel + Mag Data

Definition at line 88 of file data_logger_demo.c.

◆ gPrimaryStreamID

uint8_t gPrimaryStreamID

Definition at line 124 of file data_logger_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 125 of file data_logger_demo.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 115 of file data_logger_demo.c.

◆ pGpioDriver

Definition at line 126 of file data_logger_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 121 of file data_logger_demo.c.

Referenced by main(), and process_host_command().