Basic set of APIs for interacting with the XENSIV™ DPS3xx pressure sensors.
This provides basic initialization and access to to the pressure & temperature data. It also provides access to the configuration settings for the sensor for full control. More information about the motion sensor is available at: https://www.infineon.com/cms/en/product/sensor/pressure-sensors/pressure-sensors-for-iot/
The following snippet initializes an I2C instance and the DPS3xx.
The following snippet demonstrates how to configure the sensor.
The following snippet demonstrates how to read data from the sensor.
Data Structures | |
struct | xensiv_dps3xx_config_t |
Structure of configuration parameters for the pressure sensor. More... | |
struct | xensiv_dps3xx_i2c_comm_t |
Structure providing function pointers to I2C communication routines. More... | |
struct | xensiv_dps3xx_t |
Structure of pressure sensor context. More... | |
Functions | |
cy_rslt_t | xensiv_dps3xx_init_i2c (xensiv_dps3xx_t *obj, const xensiv_dps3xx_i2c_comm_t *functions, xensiv_dps3xx_i2c_addr_t i2c_addr) |
Initialize the DPS sensor, and configures it to use the specified I2C peripheral. More... | |
cy_rslt_t | xensiv_dps3xx_get_config (xensiv_dps3xx_t *obj, xensiv_dps3xx_config_t *config) |
Gets the current configuration parameters. More... | |
cy_rslt_t | xensiv_dps3xx_set_config (xensiv_dps3xx_t *obj, xensiv_dps3xx_config_t *config) |
Sets the current configuration parameters for the sensor. More... | |
cy_rslt_t | xensiv_dps3xx_get_revision_id (xensiv_dps3xx_t *obj, uint8_t *revision_id) |
Gets the sensor revision number. More... | |
cy_rslt_t | xensiv_dps3xx_read (xensiv_dps3xx_t *obj, float *pressure, float *temperature) |
Gets the current pressure and temperature values from the sensor. More... | |
cy_rslt_t | xensiv_dps3xx_check_ready (xensiv_dps3xx_t *obj, bool *pressure_ready, bool *temperature_ready) |
Gets whether the pressure sensor has new pressure/temperature data ready to be read. More... | |
void | xensiv_dps3xx_free (xensiv_dps3xx_t *obj) |
Frees up any resources allocated by the motion_sensor as part of xensiv_dps3xx_init_i2c(). More... | |
struct xensiv_dps3xx_config_t |
Data Fields | ||
---|---|---|
xensiv_dps3xx_mode_t | dev_mode | Operating mode of device. |
xensiv_dps3xx_rate_t | pressure_rate | Pressure sensor measurement mode. |
xensiv_dps3xx_rate_t | temperature_rate | Temperature sensor measurement mode. |
xensiv_dps3xx_oversample_t | pressure_oversample | Pressure sensor oversample rate. |
xensiv_dps3xx_oversample_t | temperature_oversample | Temperature sensor oversample rate. |
xensiv_dps3xx_interrupt_t | interrupt_triggers | Signals that trigger an interrupt. |
bool | fifo_enable | Should the FIFO buffer be enabled. |
uint16_t | data_timeout | Millisecond timeout for measurements. |
uint16_t | i2c_timeout | Millisecond timeout for I2C commands. |
struct xensiv_dps3xx_i2c_comm_t |
Data Fields | ||
---|---|---|
xensiv_dps3xx_i2c_read_t | read | Function to read sensor registers over I2C. |
xensiv_dps3xx_i2c_write_t | write | Function to write sensor registers over I2C. |
xensiv_dps3xx_delay_t | delay | Function to delay while waiting for the sensor. |
void * | context | Contextual data to provide to the read/write funcs. |
struct xensiv_dps3xx_t |
Data Fields | ||
---|---|---|
xensiv_dps3xx_i2c_comm_t | comm | sensor |
xensiv_dps3xx_config_t | user_config | User configuration settings. |
xensiv_dps3xx_i2c_addr_t | i2c_address | Sensor slave address. |
float | temp_scaled | sensor |
uint8_t | meas_cfg | sensor |
_xensiv_dps3xx_scaling_coeffs_t | tmp_osr_scale_coeff | Temperature scaling coefficient. |
_xensiv_dps3xx_scaling_coeffs_t | prs_osr_scale_coeff | Pressure scaling coefficient. |
_xensiv_dps3xx_cal_coeff_regs_t | calib_coeffs | Calibration coefficients index. |
_xensiv_dps3xx_temp_src_t | tmp_ext | Should always be set MEMS. |
enum xensiv_dps3xx_mode_t |
enum defining the different device operating modes
Enumerator | |
---|---|
XENSIV_DPS3XX_MODE_IDLE | Idle mode value. |
XENSIV_DPS3XX_MODE_COMMAND_PRESSURE | Single shot pressure only. After a single measurement the device will return to IDLE. Subsequent measurements must call xensiv_dps3xx_set_config to set the mode again. |
XENSIV_DPS3XX_MODE_COMMAND_TEMPERATURE | Single shot temperature only. After a single measurement the device will return to IDLE. Subsequent measurements must call xensiv_dps3xx_set_config to set the mode again. |
XENSIV_DPS3XX_MODE_BACKGROUND_PRESSURE | Ongoing background pressure only. |
XENSIV_DPS3XX_MODE_BACKGROUND_TEMPERATURE | Ongoing background temperature only. |
XENSIV_DPS3XX_MODE_BACKGROUND_ALL | Ongoing background pressure and temp. |
Enum to enable/disable/report interrupt cause flags.
Oversampling rates for both pressure and temperature measurements.
enum xensiv_dps3xx_rate_t |
Measurement rates for both pressure and temperature measurements.
cy_rslt_t xensiv_dps3xx_init_i2c | ( | xensiv_dps3xx_t * | obj, |
const xensiv_dps3xx_i2c_comm_t * | functions, | ||
xensiv_dps3xx_i2c_addr_t | i2c_addr | ||
) |
Initialize the DPS sensor, and configures it to use the specified I2C peripheral.
By default it is configured in command mode.
[out] | obj | Pointer to an pressure sensor object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[in] | functions | Structure containing pointers to the I2C communication functions. |
[in] | i2c_addr | I2C address to use when communicating with the sensor. |
cy_rslt_t xensiv_dps3xx_get_config | ( | xensiv_dps3xx_t * | obj, |
xensiv_dps3xx_config_t * | config | ||
) |
Gets the current configuration parameters.
[in] | obj | Pointer to a pressure sensor object. |
[out] | config | The current configuration parameters from the device |
cy_rslt_t xensiv_dps3xx_set_config | ( | xensiv_dps3xx_t * | obj, |
xensiv_dps3xx_config_t * | config | ||
) |
Sets the current configuration parameters for the sensor.
[in] | obj | Pointer to a pressure sensor object. |
[out] | config | The new configuration parameters to apply |
cy_rslt_t xensiv_dps3xx_get_revision_id | ( | xensiv_dps3xx_t * | obj, |
uint8_t * | revision_id | ||
) |
Gets the sensor revision number.
[in] | obj | Pointer to a pressure sensor object. |
[out] | revision_id | Pointer to populate with the revision id |
cy_rslt_t xensiv_dps3xx_read | ( | xensiv_dps3xx_t * | obj, |
float * | pressure, | ||
float * | temperature | ||
) |
Gets the current pressure and temperature values from the sensor.
[in] | obj | Pointer to a pressure sensor object. |
[out] | pressure | Pointer to populate with the pressure data, may be NULL |
[out] | temperature | Pointer to populate with the temperature data, may be NULL |
cy_rslt_t xensiv_dps3xx_check_ready | ( | xensiv_dps3xx_t * | obj, |
bool * | pressure_ready, | ||
bool * | temperature_ready | ||
) |
Gets whether the pressure sensor has new pressure/temperature data ready to be read.
[in] | obj | Pointer to a pressure sensor object. |
[out] | pressure_ready | Indication whether the pressure data is ready to be read |
[out] | temperature_ready | Indication whether the temperature data is ready to be read |
void xensiv_dps3xx_free | ( | xensiv_dps3xx_t * | obj | ) |
Frees up any resources allocated by the motion_sensor as part of xensiv_dps3xx_init_i2c().
[in] | obj | Pointer to the pressure sensor object to free. |