API Reference

group group_board_libs

Basic set of APIs for interacting with the BME680 atmospheric sensor.

This provides basic initialization and access to to the basic accelerometer & gyroscope data. It also provides access to the base BME680 driver for full control. For more information about the motion sensor, see: https://github.com/BoschSensortec/BME680_driver.git

note

Currently, this library only supports being used for a single instance of this device.

note

BME680 support requires delays. If the RTOS_AWARE component is set or CY_RTOS_AWARE is defined, the HAL driver will defer to the RTOS for delays. Because of this, it is not safe to call any functions other than mtb_bme680_init_i2c or mtb_bme680_init_spi until after the RTOS scheduler has started.

Enums

enum mtb_bme680_address_t

mtb_bme680_address_t: Enumeration used for selecting I2C address.

Values:

enumerator MTB_BME680_DEFAULT_ADRESS
enumerator MTB_BME680_SECONDARY_ADRESS

Functions

cy_rslt_t mtb_bme680_init_i2c(mtb_bme680_t *obj, cyhal_i2c_t *inst, mtb_bme680_address_t address)

Initialize the atmospheric sensor for I2C communication.

Then applies the default configuration settings for both the accelerometer & gyroscope. Known maximum I2C frequency of 3.4MHz; refer to manufacturer’s datasheet for confirmation. See: mtb_bme680_config_default()

Return

CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.

Parameters
  • [in] obj: Pointer to a BME680 object. The caller must allocate the memory for this object but the init function will initialize its contents.

  • [in] inst: I2C instance to use for communicating with the BME680 sensor.

  • [in] address: BME680 I2C address, set by hardware implemntation.

cy_rslt_t mtb_bme680_init_spi(mtb_bme680_t *obj, cyhal_spi_t *inst, cyhal_gpio_t pin)

Initialize the atmospheric sensor for SPI communication.

Then applies the default configuration settings for both the accelerometer & gyroscope. See: mtb_bme680_config_default()

Return

CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.

Parameters
  • [in] obj: Pointer to a BME680 object. The caller must allocate the memory for this object but the init function will initialize its contents.

  • [in] inst: I2C instance to use for communicating with the BME680 sensor.

  • [in] pin: GPIO pin connected to BME680 Chip Select.

cy_rslt_t mtb_bme680_config_default(mtb_bme680_t *obj)

Configure the motion sensor to a default mode with both accelerometer & gyroscope enabled with a nominal output data rate.

Return

CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.

Parameters
  • [in] obj: Pointer to a BME680 object.

cy_rslt_t mtb_bme680_read(mtb_bme680_t *obj, mtb_bme680_data_t *sensor_data)

Reads the current accelerometer & gyroscope data from the motion sensor.

Return

CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.

Parameters
  • [in] obj: Pointer to a BME680 object.

  • [out] sensor_data: The accelerometer & gyroscope data read from the motion sensor

struct bme680_dev *mtb_bme680_get(mtb_bme680_t *obj)

Gets access to the base motion sensor data.

This allows for direct manipulation of the sensor for any desired behavior. See https://github.com/BoschSensortec/BME680_driver for more details on the sensor.

Return

pointer to the BME680 configuration structure.

Parameters
  • [in] obj: Pointer to a BME680 object.

void mtb_bme680_free(mtb_bme680_t *obj)

Frees up any resources allocated by the motion_sensor as part of mtb_bme680_init_i2c or mtb_bme680_init_spi.

Parameters
  • [in] obj: Pointer to a BME680 object.

struct mtb_bme680_t
#include <mtb_bme680.h>

Structure holding the IMU instance specific information.

struct mtb_bme680_data_t
#include <mtb_bme680.h>

Structure holding the atmospheric data read from the device.