ISSDK  1.7
IoT Sensing Software Development Kit
Macros | Functions | Variables
mpl3115_demo.c File Reference

The mpl3115_demo.c file implements the ISSDK MPL3115 sensor demo example demonstration with One-Shot 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 "mpl3115_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for mpl3115_demo.c:

Go to the source code of this file.

Macros

#define MPL3115_T_ON_MAX   1000 /* MAX Turn On Time after RST */
 
#define MPL3115_DATA_SIZE   5 /* 3 byte Pressure and 2 byte Temperature. */
 
#define MPL3115_STREAM_DATA_SIZE   10 /* 6 byte Data */
 
#define LED_TOGGLE_RATE   100 /* Toggle LED after every 100 samples. */
 
#define APPLICATION_NAME   "Digital Pressure Altimeter Demo (MPL3115)"
 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 mpl3115_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 cMpl3115ConfigINT []
 Register settings for Interrupt (non buffered) Enablement with ONe-Shot Mode. More...
 
const registerwritelist_t cMpl3115SetOST []
 Register settings for Triggring One-Shot Sampling. More...
 
const registerreadlist_t cMpl3115OutputNormal []
 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 bMpl3115DataReady = false
 
volatile bool bMpl3115Ready = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The mpl3115_demo.c file implements the ISSDK MPL3115 sensor demo example demonstration with One-Shot mode.

Definition in file mpl3115_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "Digital Pressure Altimeter Demo (MPL3115)"

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

Definition at line 73 of file mpl3115_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 75 of file mpl3115_demo.c.

Referenced by main().

◆ LED_TOGGLE_RATE

#define LED_TOGGLE_RATE   100 /* Toggle LED after every 100 samples. */

Definition at line 70 of file mpl3115_demo.c.

Referenced by main().

◆ MPL3115_DATA_SIZE

#define MPL3115_DATA_SIZE   5 /* 3 byte Pressure and 2 byte Temperature. */

Definition at line 68 of file mpl3115_demo.c.

Referenced by main().

◆ MPL3115_STREAM_DATA_SIZE

#define MPL3115_STREAM_DATA_SIZE   10 /* 6 byte Data */

Definition at line 69 of file mpl3115_demo.c.

Referenced by main().

◆ MPL3115_T_ON_MAX

#define MPL3115_T_ON_MAX   1000 /* MAX Turn On Time after RST */

Definition at line 67 of file mpl3115_demo.c.

Function Documentation

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize INT1 MPL3115 pin used by FRDM board

Initialize GREEN 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 MPL3115 sensor driver.

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

We do not call MPL3115_I2C_Configure() in this case as we are going to read samples on demand. We explicitly only enable ISR settings.

Initialize streaming and assign a Stream ID.

Populate streaming header.

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

Read raw sensor data from the MPL3115.

Convert the raw sensor data to signed 32-bit and 16-bit containers for display to the debug port.

Definition at line 213 of file mpl3115_demo.c.

References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMpl3115DataReady, bMpl3115Ready, 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, embAppName, 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(), LED_TOGGLE_RATE, MPL3115_DATA_SIZE, MPL3115_I2C_ADDR, MPL3115_I2C_Initialize(), MPL3115_I2C_ReadData(), MPL3115_I2C_SetIdleTask(), MPL3115_INT1, mpl3115_int_data_ready_callback(), MPL3115_STREAM_DATA_SIZE, MPL3115_WHOAMI_VALUE, mpl3115_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, mpl3115_pressuredata_t::pressure, process_host_command(), rawData, SENSOR_ERROR_NONE, Sensor_I2C_Write(), SHIELD_NAME, shieldString, mpl3115_i2c_sensorhandle_t::slaveAddress, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, mpl3115_pressuredata_t::temperature, mpl3115_pressuredata_t::timestamp, fxls8962_acceldataUser_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mpl3115_int_data_ready_callback()

void mpl3115_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 124 of file mpl3115_demo.c.

References bMpl3115DataReady.

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

◆ bMpl3115DataReady

volatile bool bMpl3115DataReady = false

Definition at line 115 of file mpl3115_demo.c.

Referenced by main(), and mpl3115_int_data_ready_callback().

◆ bMpl3115Ready

volatile bool bMpl3115Ready = false

Definition at line 115 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 113 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 115 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ cMpl3115ConfigINT

const registerwritelist_t cMpl3115ConfigINT[]
Initial value:
= {
{MPL3115_CTRL_REG3, MPL3115_CTRL_REG3_IPOL1_HIGH, MPL3115_CTRL_REG3_IPOL1_MASK},
#define MPL3115_CTRL_REG1_SBYB_MASK
Definition: mpl3115.h:846
#define __END_WRITE_DATA__
Definition: sensor_drv.h:71
#define MPL3115_CTRL_REG3_IPOL1_MASK
Definition: mpl3115.h:976
#define MPL3115_CTRL_REG1_ALT_MASK
Definition: mpl3115.h:861
#define MPL3115_CTRL_REG1_OST_SET
Definition: mpl3115.h:871
#define MPL3115_PT_DATA_CFG_PDEFE_ENABLED
Definition: mpl3115.h:567
#define MPL3115_CTRL_REG1_OST_MASK
Definition: mpl3115.h:849
#define MPL3115_PT_DATA_CFG_DREM_ENABLED
Definition: mpl3115.h:570
#define MPL3115_CTRL_REG1_OS_OSR_2
Definition: mpl3115.h:875
#define MPL3115_CTRL_REG1_OS_MASK
Definition: mpl3115.h:855
#define MPL3115_PT_DATA_CFG_PDEFE_MASK
Definition: mpl3115.h:553
#define MPL3115_PT_DATA_CFG_TDEFE_ENABLED
Definition: mpl3115.h:564
#define MPL3115_CTRL_REG3_IPOL1_LOW
Definition: mpl3115.h:989
#define MPL3115_CTRL_REG4_INT_EN_DRDY_INTENABLED
Definition: mpl3115.h:1070
#define MPL3115_CTRL_REG1_ALT_BAR
Definition: mpl3115.h:889
#define MPL3115_CTRL_REG1_SBYB_STANDBY
Definition: mpl3115.h:868
#define MPL3115_CTRL_REG4_INT_EN_DRDY_MASK
Definition: mpl3115.h:1048
#define MPL3115_PT_DATA_CFG_DREM_MASK
Definition: mpl3115.h:556
#define MPL3115_CTRL_REG5_INT_CFG_DRDY_MASK
Definition: mpl3115.h:1128
#define MPL3115_PT_DATA_CFG_TDEFE_MASK
Definition: mpl3115.h:550
#define MPL3115_CTRL_REG5_INT_CFG_DRDY_INT1
Definition: mpl3115.h:1150
#define MPL3115_CTRL_REG3_IPOL1_HIGH
Definition: mpl3115.h:990

Register settings for Interrupt (non buffered) Enablement with ONe-Shot Mode.

Definition at line 81 of file mpl3115_demo.c.

◆ cMpl3115OutputNormal

const registerreadlist_t cMpl3115OutputNormal[]
Initial value:
= {{.readFrom = MPL3115_OUT_P_MSB, .numBytes = MPL3115_DATA_SIZE},
#define __END_READ_DATA__
Definition: sensor_drv.h:77
#define MPL3115_DATA_SIZE
Definition: mpl3115_demo.c:68

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

Definition at line 107 of file mpl3115_demo.c.

◆ cMpl3115SetOST

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

Register settings for Triggring One-Shot Sampling.

Definition at line 101 of file mpl3115_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 114 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ gStreamID

uint8_t gStreamID

Definition at line 116 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 117 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 118 of file mpl3115_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 113 of file mpl3115_demo.c.

Referenced by main(), and process_host_command().