![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
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"
Go to the source code of this file.
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_GPIO * | pGpioDriver = &Driver_GPIO_KSDK |
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.
#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().
#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().
#define FXAS21002_DATA_SIZE (FXAS21002_GYRO_DATA_SIZE) |
Definition at line 56 of file data_logger_demo.c.
Referenced by main().
#define FXOS8700_ACCEL_DATA_SIZE (6) |
Definition at line 49 of file data_logger_demo.c.
Referenced by main().
#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().
#define FXOS8700_MAG_DATA_SIZE (6) |
Definition at line 50 of file data_logger_demo.c.
#define LED_TOGGLE_RATE (100) |
Definition at line 60 of file data_logger_demo.c.
Referenced by main().
#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().
#define MPL3115_PADDING_SIZE (1) |
Definition at line 51 of file data_logger_demo.c.
Referenced by main().
#define MPL3115_PRESSURE_DATA_SIZE (3) |
Definition at line 52 of file data_logger_demo.c.
Referenced by main().
#define MPL3115_TEMPERATURE_DATA_SIZE (2) |
Definition at line 53 of file data_logger_demo.c.
#define nmi_handler NMI_Handler |
Definition at line 66 of file data_logger_demo.c.
#define STREAMING_PAYLOAD_LEN (STREAMING_PKT_TIMESTAMP_LEN + FXOS8700_DATA_SIZE + FXAS21002_DATA_SIZE + MPL3115_DATA_SIZE + MPL3115_PADDING_SIZE) |
Definition at line 61 of file data_logger_demo.c.
Referenced by main().
#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().
#define STREAMING_PKT_TIMESTAMP_LEN (4) |
Definition at line 48 of file data_logger_demo.c.
Referenced by main().
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().
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.
void nmi_handler | ( | void * | pUserData | ) |
Handler for NMI Interrupt.
Definition at line 132 of file data_logger_demo.c.
bool process_host_command | ( | uint8_t | tag, |
uint8_t * | hostCommand, | ||
uint8_t * | hostResponse, | ||
size_t * | hostMsgSize, | ||
size_t | respBufferSize | ||
) |
Definition at line 144 of file data_logger_demo.c.
References bDataLoggerReady, BOARD_SystickStart(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, embAppName, gPrimaryStreamID, 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, LED_GREEN, and shieldString.
Referenced by Host_IO_Receive(), and main().
volatile bool bDataLoggerReady = false |
Definition at line 123 of file data_logger_demo.c.
Referenced by main(), and process_host_command().
volatile bool bFxas21002DataReady = false |
Definition at line 123 of file data_logger_demo.c.
Referenced by fxas21002_isr(), and main().
char boardString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 121 of file data_logger_demo.c.
Referenced by main(), and process_host_command().
volatile bool bStreamingEnabled = false |
Definition at line 123 of file data_logger_demo.c.
Referenced by main(), and process_host_command().
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.
const registerwritelist_t cMpl3115SetOST[] |
Register settings for Triggring One-Shot Sampling.
Definition at line 106 of file data_logger_demo.c.
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 122 of file data_logger_demo.c.
Referenced by main(), and process_host_command().
const registerwritelist_t fxas21002_Config_Isr[] |
Prepare the register write list to configure FXAS21002 in Interrupt Mode.
Definition at line 92 of file data_logger_demo.c.
const registerreadlist_t fxas21002_Output_Values[] |
Prepare the register read list to read the raw gyro data from the FXAS21002.
Definition at line 102 of file data_logger_demo.c.
const registerwritelist_t fxos8700_Config_Hybrid[] |
Prepare the register write list to configure FXOS8700 in Hybrid mode.
Definition at line 77 of file data_logger_demo.c.
const registerreadlist_t fxos8700_Output_values[] |
Command definition to read the Accel + Mag Data
Definition at line 88 of file data_logger_demo.c.
uint8_t gPrimaryStreamID |
Definition at line 124 of file data_logger_demo.c.
Referenced by main(), and process_host_command().
int32_t gSystick |
Definition at line 125 of file data_logger_demo.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 115 of file data_logger_demo.c.
GENERIC_DRIVER_GPIO* pGpioDriver = &Driver_GPIO_KSDK |
Definition at line 126 of file data_logger_demo.c.
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 121 of file data_logger_demo.c.
Referenced by main(), and process_host_command().