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

The diff_p_demo.c file implements the ISSDK DIFF_P sensor driver example demonstration with Interrupt 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 "diff_p_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for diff_p_demo.c:

Go to the source code of this file.

Macros

#define DIFF_P_DATA_SIZE   (3) /* 2 byte Pressure and 1 byte Temperature. */
 
#define DIFF_P_STREAM_DATA_SIZE   (7) /* 7 byte Data */
 
#define APPLICATION_NAME   "NPS300x Differential Pressure 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 diffp_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 cDiffPConfigNormal []
 Register settings for Normal (non buffered) mode. More...
 
const registerwritelist_t cDiffPClearStatusBits []
 Register settings for Clearing Pressure and Temperature Data Ready Bits. More...
 
const registerreadlist_t cDiffPStatus [] = {{.readFrom = DIFF_P_INT_STATUS_0, .numBytes = 1}, __END_READ_DATA__}
 Address of Status Register. More...
 
const registerreadlist_t cDiffPOutputNormal []
 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 bDiffPDataReady = false
 
volatile bool bDiffPReady = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The diff_p_demo.c file implements the ISSDK DIFF_P sensor driver example demonstration with Interrupt mode.

Definition in file diff_p_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "NPS300x Differential Pressure Demo"

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

Definition at line 45 of file diff_p_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 47 of file diff_p_demo.c.

Referenced by main().

◆ DIFF_P_DATA_SIZE

#define DIFF_P_DATA_SIZE   (3) /* 2 byte Pressure and 1 byte Temperature. */

Definition at line 41 of file diff_p_demo.c.

Referenced by main().

◆ DIFF_P_STREAM_DATA_SIZE

#define DIFF_P_STREAM_DATA_SIZE   (7) /* 7 byte Data */

Definition at line 42 of file diff_p_demo.c.

Referenced by main().

Function Documentation

◆ diffp_int_data_ready_callback()

void diffp_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 86 of file diff_p_demo.c.

References bDiffPDataReady.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize INT1 DIFF_P 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 DIFF_P sensor driver.

Configure the DIFF_P sensor.

Initialize streaming and assign a Stream ID.

Populate streaming header.

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

Check for both data ready bits from the DIFF_P.

If samples available, explicitly clear the Status Bits.

Read new raw sensor data from the DIFF_P.

Process the sample and convert the raw sensor data.

Definition at line 175 of file diff_p_demo.c.

References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bDiffPDataReady, bDiffPReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, DIFF_P_DATA_SIZE, DIFF_P_I2C_ADDR, DIFF_P_INT1, DIFF_P_STREAM_DATA_SIZE, diffp_int_data_ready_callback(), 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(), GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, SENSOR_ERROR_NONE, Sensor_I2C_Write(), SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, fxos8700_accelmagdata_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

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

◆ bDiffPDataReady

volatile bool bDiffPDataReady = false

Definition at line 77 of file diff_p_demo.c.

Referenced by diffp_int_data_ready_callback(), and main().

◆ bDiffPReady

volatile bool bDiffPReady = false

Definition at line 77 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 75 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 77 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ cDiffPClearStatusBits

const registerwritelist_t cDiffPClearStatusBits[]
Initial value:
= {
{DIFF_P_INT_STATUS_0, 0x00, DIFF_P_INT_STATUS_0_TDR_MASK | DIFF_P_INT_STATUS_0_PDR_MASK}, __END_WRITE_DATA__}
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45

Register settings for Clearing Pressure and Temperature Data Ready Bits.

Definition at line 62 of file diff_p_demo.c.

◆ cDiffPConfigNormal

const registerwritelist_t cDiffPConfigNormal[]
Initial value:
= {
{DIFF_P_CTRL_REG2, DIFF_P_CTRL_REG2_ODR_ODR6P25, DIFF_P_CTRL_REG2_ODR_MASK},
{DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_OSR_OSR512, DIFF_P_CTRL_REG1_OSR_MASK},
{DIFF_P_INT_MASK0, DIFF_P_INT_MASK0_TDR_INT_EN | DIFF_P_INT_MASK0_PDR_INT_EN,
DIFF_P_INT_MASK0_TDR_MASK | DIFF_P_INT_MASK0_PDR_MASK},
{DIFF_P_CTRL_REG3, DIFF_P_CTRL_REG3_IPOL1_ACTIVE_HIGH, DIFF_P_CTRL_REG3_IPOL1_MASK},
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45

Register settings for Normal (non buffered) mode.

Definition at line 53 of file diff_p_demo.c.

◆ cDiffPOutputNormal

const registerreadlist_t cDiffPOutputNormal[]
Initial value:
= {{.readFrom = DIFF_P_OUT_P_LSB, .numBytes = DIFF_P_DATA_SIZE},
#define DIFF_P_DATA_SIZE
Definition: diff_p_demo.c:41
#define __END_READ_DATA__
Definition: sensor_drv.h:51

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

Definition at line 69 of file diff_p_demo.c.

◆ cDiffPStatus

const registerreadlist_t cDiffPStatus[] = {{.readFrom = DIFF_P_INT_STATUS_0, .numBytes = 1}, __END_READ_DATA__}

Address of Status Register.

Definition at line 66 of file diff_p_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 76 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ gStreamID

uint8_t gStreamID

Definition at line 78 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 79 of file diff_p_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 80 of file diff_p_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 75 of file diff_p_demo.c.

Referenced by main(), and process_host_command().