SparkFun BMI330 Arduino Library  v1.0.0-2-gdbddb99
Arduino Library for the SparkFun Qwiic BMI330 6-DoF IMU (Bosch BMI330)
Loading...
Searching...
No Matches
sfDevBMI330.h File Reference

Header file for the SparkFun Bosch BMI330 6-DoF IMU Driver. More...

#include <stddef.h>
#include <stdint.h>
#include <sfTk/sfTkIBus.h>
#include <sfTk/sfTkII2C.h>
#include <sfTk/sfTkISPI.h>
#include <sfTk/sfToolkit.h>

Go to the source code of this file.

Classes

struct  sfe_bmi330_int_pin_config_t
 Electrical configuration of an interrupt pin. More...
 
struct  sfe_bmi330_raw_data_t
 One triaxial reading in raw 16-bit signed counts, as the registers hold it. More...
 
struct  sfe_bmi330_data_t
 One triaxial reading converted to physical units - g for the accelerometer, dps for the gyroscope. More...
 
struct  sfe_bmi330_sensor_data_t
 Everything one burst read of the data block produces. More...
 
struct  sfe_bmi330_saturation_t
 Per-axis saturation flags from SAT_FLAGS (0x0C). More...
 
struct  sfe_bmi330_error_status_t
 Decoded contents of ERR_REG (0x01). More...
 
struct  sfe_bmi330_fifo_frame_t
 One decoded FIFO frame. More...
 
struct  sfe_bmi330_motion_config_t
 Any-motion and no-motion detector settings. More...
 
struct  sfe_bmi330_sig_motion_config_t
 Significant motion detector settings. More...
 
struct  sfe_bmi330_tilt_config_t
 Tilt detector settings. More...
 
struct  sfe_bmi330_orientation_config_t
 Orientation detector settings. More...
 
struct  sfe_bmi330_flat_config_t
 Flat detector settings. More...
 
struct  sfe_bmi330_tap_config_t
 Tap detector settings. More...
 
struct  sfe_bmi330_tap_event_t
 Which tap gesture the device just reported. More...
 
struct  sfe_bmi330_axis_remap_t
 A complete axis remapping: one permutation plus three sign flips. More...
 
struct  sfe_bmi330_self_test_result_t
 Outcome of a self-test. More...
 
struct  sfe_bmi330_self_calib_result_t
 Outcome of a gyroscope self-calibration. More...
 
class  sfDevBMI330
 Platform-independent driver for the Bosch BMI330 6-DoF IMU. More...
 

Macros

#define SFE_BMI330_DEFAULT_ADDRESS   0x68
 Factory-default 7-bit I2C address (SDO / ADR pin low). More...
 
#define SFE_BMI330_ALT_ADDRESS   0x69
 Alternate 7-bit I2C address, selected by the board's ADR jumper (SDO / ADR pin high). More...
 
#define SFE_BMI330_CHIP_ID   0x48
 Value in the low byte of CHIP_ID (0x00) for a BMI330. More...
 

Typedefs

typedef enum sfe_bmi330_odr_t sfe_bmi330_odr_t
 Output data rate settings, shared by the accelerometer and the gyroscope. More...
 
typedef enum sfe_bmi330_accel_range_t sfe_bmi330_accel_range_t
 Accelerometer full-scale range. More...
 
typedef enum sfe_bmi330_gyro_range_t sfe_bmi330_gyro_range_t
 Gyroscope full-scale range. More...
 
typedef enum sfe_bmi330_bandwidth_t sfe_bmi330_bandwidth_t
 3 dB cutoff of the sensor's low-pass filter, expressed as a fraction of the ODR. More...
 
typedef enum sfe_bmi330_averaging_t sfe_bmi330_averaging_t
 Number of samples averaged before a result is published. More...
 
typedef enum sfe_bmi330_accel_mode_t sfe_bmi330_accel_mode_t
 Accelerometer power mode. More...
 
typedef enum sfe_bmi330_gyro_mode_t sfe_bmi330_gyro_mode_t
 Gyroscope power mode. More...
 
typedef enum sfe_bmi330_int_pin_t sfe_bmi330_int_pin_t
 Interrupt routing target. More...
 
typedef enum sfe_bmi330_int_source_t sfe_bmi330_int_source_t
 Interrupt sources that can be routed to a pin. More...
 
typedef enum sfe_bmi330_int_status_t sfe_bmi330_int_status_t
 Bit masks for the INT_STATUS_INT1 (0x0D) and INT_STATUS_INT2 (0x0E) registers. More...
 
typedef enum sfe_bmi330_fifo_source_t sfe_bmi330_fifo_source_t
 Which data sources the FIFO records, as bits of FIFO_CONF (0x36). More...
 
typedef enum sfe_bmi330_feature_addr_t sfe_bmi330_feature_addr_t
 Base addresses inside the feature engine's extended memory. More...
 
typedef enum sfe_bmi330_feature_t sfe_bmi330_feature_t
 Feature enable bits in FEATURE_IO0 (0x10). More...
 
typedef enum sfe_bmi330_tap_axis_t sfe_bmi330_tap_axis_t
 Which axis the tap detector watches. More...
 
typedef enum sfe_bmi330_orientation_t sfe_bmi330_orientation_t
 Device orientation as classified by the orientation feature. More...
 
typedef enum sfe_bmi330_axis_map_t sfe_bmi330_axis_map_t
 Which physical axis feeds which reported axis. More...
 
typedef enum sfe_bmi330_self_test_t sfe_bmi330_self_test_t
 Which sensors a self-test exercises. More...
 
typedef enum sfe_bmi330_self_calib_t sfe_bmi330_self_calib_t
 What a gyroscope self-calibration corrects. More...
 

Enumerations

enum  sfe_bmi330_odr_t : uint8_t {
  BMI330_ODR_0_78_HZ = 0x01 , BMI330_ODR_1_56_HZ = 0x02 , BMI330_ODR_3_12_HZ = 0x03 , BMI330_ODR_6_25_HZ = 0x04 ,
  BMI330_ODR_12_5_HZ = 0x05 , BMI330_ODR_25_HZ = 0x06 , BMI330_ODR_50_HZ = 0x07 , BMI330_ODR_100_HZ = 0x08 ,
  BMI330_ODR_200_HZ = 0x09 , BMI330_ODR_400_HZ = 0x0A , BMI330_ODR_800_HZ = 0x0B , BMI330_ODR_1600_HZ = 0x0C ,
  BMI330_ODR_3200_HZ = 0x0D , BMI330_ODR_6400_HZ = 0x0E
}
 Output data rate settings, shared by the accelerometer and the gyroscope. More...
 
enum  sfe_bmi330_accel_range_t : uint8_t { BMI330_ACCEL_RANGE_2G = 0x00 , BMI330_ACCEL_RANGE_4G = 0x01 , BMI330_ACCEL_RANGE_8G = 0x02 , BMI330_ACCEL_RANGE_16G = 0x03 }
 Accelerometer full-scale range. More...
 
enum  sfe_bmi330_gyro_range_t : uint8_t {
  BMI330_GYRO_RANGE_125DPS = 0x00 , BMI330_GYRO_RANGE_250DPS = 0x01 , BMI330_GYRO_RANGE_500DPS = 0x02 , BMI330_GYRO_RANGE_1000DPS = 0x03 ,
  BMI330_GYRO_RANGE_2000DPS = 0x04
}
 Gyroscope full-scale range. More...
 
enum  sfe_bmi330_bandwidth_t : uint8_t { BMI330_BW_ODR_HALF = 0x00 , BMI330_BW_ODR_QUARTER = 0x01 }
 3 dB cutoff of the sensor's low-pass filter, expressed as a fraction of the ODR. More...
 
enum  sfe_bmi330_averaging_t : uint8_t {
  BMI330_AVG_1 = 0x00 , BMI330_AVG_2 = 0x01 , BMI330_AVG_4 = 0x02 , BMI330_AVG_8 = 0x03 ,
  BMI330_AVG_16 = 0x04 , BMI330_AVG_32 = 0x05 , BMI330_AVG_64 = 0x06
}
 Number of samples averaged before a result is published. More...
 
enum  sfe_bmi330_accel_mode_t : uint8_t { BMI330_ACCEL_MODE_DISABLE = 0x00 , BMI330_ACCEL_MODE_LOW_POWER = 0x03 , BMI330_ACCEL_MODE_NORMAL = 0x04 , BMI330_ACCEL_MODE_HIGH_PERF = 0x07 }
 Accelerometer power mode. More...
 
enum  sfe_bmi330_gyro_mode_t : uint8_t {
  BMI330_GYRO_MODE_DISABLE = 0x00 , BMI330_GYRO_MODE_SUSPEND = 0x01 , BMI330_GYRO_MODE_LOW_POWER = 0x03 , BMI330_GYRO_MODE_NORMAL = 0x04 ,
  BMI330_GYRO_MODE_HIGH_PERF = 0x07
}
 Gyroscope power mode. More...
 
enum  sfe_bmi330_int_pin_t : uint8_t { BMI330_INT_NONE = 0x00 , BMI330_INT1 = 0x01 , BMI330_INT2 = 0x02 }
 Interrupt routing target. More...
 
enum  sfe_bmi330_int_source_t : uint8_t {
  BMI330_INT_SRC_NO_MOTION = 0 , BMI330_INT_SRC_ANY_MOTION , BMI330_INT_SRC_FLAT , BMI330_INT_SRC_ORIENTATION ,
  BMI330_INT_SRC_STEP_DETECTOR , BMI330_INT_SRC_STEP_COUNTER , BMI330_INT_SRC_SIG_MOTION , BMI330_INT_SRC_TILT ,
  BMI330_INT_SRC_TAP , BMI330_INT_SRC_I3C , BMI330_INT_SRC_ERR_STATUS , BMI330_INT_SRC_TEMP_DRDY ,
  BMI330_INT_SRC_GYRO_DRDY , BMI330_INT_SRC_ACCEL_DRDY , BMI330_INT_SRC_FIFO_WATERMARK , BMI330_INT_SRC_FIFO_FULL ,
  BMI330_INT_SRC_COUNT
}
 Interrupt sources that can be routed to a pin. More...
 
enum  sfe_bmi330_int_status_t : uint16_t {
  BMI330_INT_STATUS_NO_MOTION = 0x0001 , BMI330_INT_STATUS_ANY_MOTION = 0x0002 , BMI330_INT_STATUS_FLAT = 0x0004 , BMI330_INT_STATUS_ORIENTATION = 0x0008 ,
  BMI330_INT_STATUS_STEP_DETECTOR = 0x0010 , BMI330_INT_STATUS_STEP_COUNTER = 0x0020 , BMI330_INT_STATUS_SIG_MOTION = 0x0040 , BMI330_INT_STATUS_TILT = 0x0080 ,
  BMI330_INT_STATUS_TAP = 0x0100 , BMI330_INT_STATUS_I3C = 0x0200 , BMI330_INT_STATUS_ERROR = 0x0400 , BMI330_INT_STATUS_TEMP_DRDY = 0x0800 ,
  BMI330_INT_STATUS_GYRO_DRDY = 0x1000 , BMI330_INT_STATUS_ACCEL_DRDY = 0x2000 , BMI330_INT_STATUS_FIFO_WATERMARK = 0x4000 , BMI330_INT_STATUS_FIFO_FULL = 0x8000
}
 Bit masks for the INT_STATUS_INT1 (0x0D) and INT_STATUS_INT2 (0x0E) registers. More...
 
enum  sfe_bmi330_fifo_source_t : uint16_t {
  BMI330_FIFO_TIME = 0x0100 , BMI330_FIFO_ACCEL = 0x0200 , BMI330_FIFO_GYRO = 0x0400 , BMI330_FIFO_TEMP = 0x0800 ,
  BMI330_FIFO_ALL = 0x0F00
}
 Which data sources the FIFO records, as bits of FIFO_CONF (0x36). More...
 
enum  sfe_bmi330_feature_addr_t : uint8_t {
  BMI330_FEAT_ADDR_CONFIG_VERSION = 0x00 , BMI330_FEAT_ADDR_AXIS_REMAP = 0x03 , BMI330_FEAT_ADDR_ANY_MOTION = 0x05 , BMI330_FEAT_ADDR_NO_MOTION = 0x08 ,
  BMI330_FEAT_ADDR_FLAT = 0x0B , BMI330_FEAT_ADDR_SIG_MOTION = 0x0D , BMI330_FEAT_ADDR_STEP_COUNTER = 0x10 , BMI330_FEAT_ADDR_ORIENTATION = 0x1C ,
  BMI330_FEAT_ADDR_TAP = 0x1E , BMI330_FEAT_ADDR_TILT = 0x21 , BMI330_FEAT_ADDR_ST_RESULT = 0x24 , BMI330_FEAT_ADDR_ST_SELECT = 0x25 ,
  BMI330_FEAT_ADDR_SC_SELECT = 0x26 , BMI330_FEAT_ADDR_SC_ST_CONF = 0x27 , BMI330_FEAT_ADDR_SC_ST_COEFF = 0x28
}
 Base addresses inside the feature engine's extended memory. More...
 
enum  sfe_bmi330_feature_t : uint16_t {
  BMI330_FEAT_NO_MOTION_X = 0x0001 , BMI330_FEAT_NO_MOTION_Y = 0x0002 , BMI330_FEAT_NO_MOTION_Z = 0x0004 , BMI330_FEAT_NO_MOTION = 0x0007 ,
  BMI330_FEAT_ANY_MOTION_X = 0x0008 , BMI330_FEAT_ANY_MOTION_Y = 0x0010 , BMI330_FEAT_ANY_MOTION_Z = 0x0020 , BMI330_FEAT_ANY_MOTION = 0x0038 ,
  BMI330_FEAT_FLAT = 0x0040 , BMI330_FEAT_ORIENTATION = 0x0080 , BMI330_FEAT_STEP_DETECTOR = 0x0100 , BMI330_FEAT_STEP_COUNTER = 0x0200 ,
  BMI330_FEAT_SIG_MOTION = 0x0400 , BMI330_FEAT_TILT = 0x0800 , BMI330_FEAT_SINGLE_TAP = 0x1000 , BMI330_FEAT_DOUBLE_TAP = 0x2000 ,
  BMI330_FEAT_TRIPLE_TAP = 0x4000
}
 Feature enable bits in FEATURE_IO0 (0x10). More...
 
enum  sfe_bmi330_tap_axis_t : uint8_t { BMI330_TAP_AXIS_X = 0x00 , BMI330_TAP_AXIS_Y = 0x01 , BMI330_TAP_AXIS_Z = 0x02 }
 Which axis the tap detector watches. More...
 
enum  sfe_bmi330_orientation_t : uint8_t { BMI330_ORIENT_PORTRAIT_UPRIGHT = 0x00 , BMI330_ORIENT_LANDSCAPE_LEFT = 0x01 , BMI330_ORIENT_PORTRAIT_UPSIDE_DOWN = 0x02 , BMI330_ORIENT_LANDSCAPE_RIGHT = 0x03 }
 Device orientation as classified by the orientation feature. More...
 
enum  sfe_bmi330_axis_map_t : uint8_t {
  BMI330_AXIS_MAP_XYZ = 0x00 , BMI330_AXIS_MAP_YXZ = 0x01 , BMI330_AXIS_MAP_XZY = 0x02 , BMI330_AXIS_MAP_ZXY = 0x03 ,
  BMI330_AXIS_MAP_YZX = 0x04 , BMI330_AXIS_MAP_ZYX = 0x05
}
 Which physical axis feeds which reported axis. More...
 
enum  sfe_bmi330_self_test_t : uint8_t { BMI330_SELF_TEST_ACCEL = 0x01 , BMI330_SELF_TEST_GYRO = 0x02 , BMI330_SELF_TEST_BOTH = 0x03 }
 Which sensors a self-test exercises. More...
 
enum  sfe_bmi330_self_calib_t : uint8_t { BMI330_SELF_CALIB_SENSITIVITY = 0x01 , BMI330_SELF_CALIB_OFFSET = 0x02 , BMI330_SELF_CALIB_BOTH = 0x03 }
 What a gyroscope self-calibration corrects. More...
 

Detailed Description

Header file for the SparkFun Bosch BMI330 6-DoF IMU Driver.

sfDevBMI330 is a comms-agnostic driver for the Bosch BMI330 inertial measurement unit, built on the SparkFun Toolkit. The BMI330 pairs a 16-bit triaxial accelerometer with a 16-bit triaxial gyroscope, a temperature sensor, a 2 kB FIFO, two interrupt pins, and an on-chip feature engine that detects motion events without host involvement.

Note
NO CONFIGURATION FILE. Unlike the BMI270 - which will not report a single sample until the host uploads an 8 kB firmware blob and waits for it to boot - every BMI330 feature lives in ROM. begin() is a chip ID check and a feature-engine enable, nothing more, and the library carries no vendor binary. That is why this driver talks to the register map directly rather than wrapping Bosch's SensorAPI: there is nothing the vendor code is uniquely required for, and going native buys I2C and SPI from one code path through sfTkIBus.
SIXTEEN-BIT REGISTERS, AND DUMMY BYTES. Every BMI330 register is a 16-bit word, little-endian, and the register address auto-increments by one WORD per two bytes transferred. A read burst is therefore always an even number of bytes. More surprising: the device prepends DUMMY BYTES to the payload of every read - two on I2C, one on SPI - so a driver that forgets them reads garbage shifted by one byte. The count is settled once, in begin(), from sfTkIBus::type(), and readRegisters() skips them. See kDummyBytesI2C / kDummyBytesSPI.
THE FEATURE ENGINE IS A SEPARATE ADDRESS SPACE. Any-motion, tap, step counting, self-test and the rest are not configured through the main register map. They live in extended memory reached through a two-register window: write a base address to FEATURE_DATA_ADDR (0x41), then read or write consecutive words at FEATURE_DATA_TX (0x42), which auto-increments. Enabling a feature is a third step again - a bit in FEATURE_IO0 (0x10), committed by writing 1 to FEATURE_IO_STATUS (0x14). readFeatureWords() / writeFeatureWords() / enableFeature() wrap all of this; the sfe_bmi330_feature_addr_t values are the window's base addresses.
The feature engine must be running before any feature - including self-test and self-calibration - will respond. It starts during softReset(), which begin() calls, and getFeatureEngineStatus() reports whether it came up.
Author
SparkFun Electronics
Date
September 2026

SPDX-License-Identifier: MIT

See also
https://github.com/sparkfun/SparkFun_BMI330_Arduino_Library

Macro Definition Documentation

◆ SFE_BMI330_ALT_ADDRESS

#define SFE_BMI330_ALT_ADDRESS   0x69

Alternate 7-bit I2C address, selected by the board's ADR jumper (SDO / ADR pin high).

◆ SFE_BMI330_CHIP_ID

#define SFE_BMI330_CHIP_ID   0x48

Value in the low byte of CHIP_ID (0x00) for a BMI330.

The BMI323 reads 0x43 here.

◆ SFE_BMI330_DEFAULT_ADDRESS

#define SFE_BMI330_DEFAULT_ADDRESS   0x68

Factory-default 7-bit I2C address (SDO / ADR pin low).

SparkFun ships the Qwiic board this way.

Typedef Documentation

◆ sfe_bmi330_accel_mode_t

Accelerometer power mode.

Both sensors are DISABLED at power-on - a fresh BMI330 produces no data until a mode is set. enableAccel() picks high-performance mode, which is what most sketches want.

◆ sfe_bmi330_accel_range_t

Accelerometer full-scale range.

The output is always 16-bit signed across the selected range, so sensitivity halves each time the range doubles: 16384 LSB/g at +/-2 g down to 2048 LSB/g at +/-16 g. Picking the smallest range the application can survive is free resolution.

◆ sfe_bmi330_averaging_t

Number of samples averaged before a result is published.

Hardware averaging trades bandwidth and current for noise: averaging N samples drops broadband noise by sqrt(N). It does NOT change the output data rate - the device oversamples internally - so it is free bandwidth from the host's point of view, but it does raise the sensor's own sample rate and therefore its current draw.

◆ sfe_bmi330_axis_map_t

Which physical axis feeds which reported axis.

Read the name as "reported X, Y, Z come from physical ...". BMI330_AXIS_MAP_YXZ means reported X is the physical Y axis, reported Y is the physical X axis, and Z is unchanged.

◆ sfe_bmi330_bandwidth_t

3 dB cutoff of the sensor's low-pass filter, expressed as a fraction of the ODR.

◆ sfe_bmi330_feature_addr_t

Base addresses inside the feature engine's extended memory.

These index the FEATURE_DATA_ADDR (0x41) / FEATURE_DATA_TX (0x42) window, not the main register map - readFeatureWords() and writeFeatureWords() take one of these. The spacing between consecutive entries is each feature's size in words.

◆ sfe_bmi330_feature_t

Feature enable bits in FEATURE_IO0 (0x10).

Combine with bitwise OR and pass to enableFeature(). Note that any-motion and no-motion are enabled PER AXIS - the feature runs when at least one of its axis bits is set - while the others are a single bit each.

◆ sfe_bmi330_fifo_source_t

Which data sources the FIFO records, as bits of FIFO_CONF (0x36).

Combine with bitwise OR. The BMI330 FIFO is HEADERLESS: frames carry no tag, and the order inside a frame is fixed by the hardware - accelerometer (3 words), gyroscope (3 words), temperature (1 word), sensor time (1 word) - with disabled sources simply absent. The parser has to be told the same enable set that was programmed, which is why readFifoData() takes it as an argument rather than guessing.

◆ sfe_bmi330_gyro_mode_t

Gyroscope power mode.

Note
SUSPEND versus DISABLE. In DISABLE the drive circuit is off and the gyro needs its full start-up time (tens of milliseconds) to produce valid data again. SUSPEND keeps the drive running and the ADC off, so waking is fast, at the cost of standing current. Choose SUSPEND for something that must respond to an interrupt promptly; choose DISABLE for something that sleeps for seconds.

◆ sfe_bmi330_gyro_range_t

Gyroscope full-scale range.

As with the accelerometer, the 16-bit output spans the selected range: 262.144 LSB/dps at +/-125 dps down to 16.384 LSB/dps at +/-2000 dps.

◆ sfe_bmi330_int_pin_t

Interrupt routing target.

Every interrupt source is routed independently. The SparkFun Qwiic BMI330 breakout brings both pins out, so a sketch can (for example) put data-ready on INT1 and motion events on INT2 and tell them apart without reading a status register.

◆ sfe_bmi330_int_source_t

Interrupt sources that can be routed to a pin.

These are the routable sources, as laid out across INT_MAP1 (0x3A) and INT_MAP2 (0x3B). mapInterrupt() hides which map register a source lives in.

◆ sfe_bmi330_int_status_t

Bit masks for the INT_STATUS_INT1 (0x0D) and INT_STATUS_INT2 (0x0E) registers.

Both status registers are CLEAR-ON-READ, and getInterruptStatus() reads the whole word, so a sketch must read once and test every bit it cares about in the returned value. Reading twice loses the first read's events.

◆ sfe_bmi330_odr_t

Output data rate settings, shared by the accelerometer and the gyroscope.

Each sensor keeps its own ODR field, so the two may run at different rates. Not every rate is legal in every power mode: low-power mode tops out at 400 Hz, and rates below 12.5 Hz are only available in low-power mode. An illegal pairing is not rejected by the write - it raises acc_conf_err / gyr_conf_err in ERR_REG, which getErrorStatus() reports.

See also
setAccelODR(), setGyroODR(), getErrorStatus()

◆ sfe_bmi330_orientation_t

Device orientation as classified by the orientation feature.

◆ sfe_bmi330_self_calib_t

What a gyroscope self-calibration corrects.

◆ sfe_bmi330_self_test_t

Which sensors a self-test exercises.

◆ sfe_bmi330_tap_axis_t

Which axis the tap detector watches.

Enumeration Type Documentation

◆ sfe_bmi330_accel_mode_t

enum sfe_bmi330_accel_mode_t : uint8_t

Accelerometer power mode.

Both sensors are DISABLED at power-on - a fresh BMI330 produces no data until a mode is set. enableAccel() picks high-performance mode, which is what most sketches want.

Enumerator
BMI330_ACCEL_MODE_DISABLE 

Accelerometer off. Power-on default.

BMI330_ACCEL_MODE_LOW_POWER 

Duty-cycled. ODR limited to 400 Hz and below.

BMI330_ACCEL_MODE_NORMAL 

Continuous, reduced current. ODR up to 1600 Hz.

BMI330_ACCEL_MODE_HIGH_PERF 

Continuous, lowest noise. All ODRs available.

◆ sfe_bmi330_accel_range_t

enum sfe_bmi330_accel_range_t : uint8_t

Accelerometer full-scale range.

The output is always 16-bit signed across the selected range, so sensitivity halves each time the range doubles: 16384 LSB/g at +/-2 g down to 2048 LSB/g at +/-16 g. Picking the smallest range the application can survive is free resolution.

Enumerator
BMI330_ACCEL_RANGE_2G 

+/-2 g, 16384 LSB/g.

BMI330_ACCEL_RANGE_4G 

+/-4 g, 8192 LSB/g.

BMI330_ACCEL_RANGE_8G 

+/-8 g, 4096 LSB/g. Required for gyro self-calibration.

BMI330_ACCEL_RANGE_16G 

+/-16 g, 2048 LSB/g.

◆ sfe_bmi330_averaging_t

enum sfe_bmi330_averaging_t : uint8_t

Number of samples averaged before a result is published.

Hardware averaging trades bandwidth and current for noise: averaging N samples drops broadband noise by sqrt(N). It does NOT change the output data rate - the device oversamples internally - so it is free bandwidth from the host's point of view, but it does raise the sensor's own sample rate and therefore its current draw.

Enumerator
BMI330_AVG_1 

No averaging.

BMI330_AVG_2 

Average 2 samples.

BMI330_AVG_4 

Average 4 samples.

BMI330_AVG_8 

Average 8 samples.

BMI330_AVG_16 

Average 16 samples.

BMI330_AVG_32 

Average 32 samples.

BMI330_AVG_64 

Average 64 samples.

◆ sfe_bmi330_axis_map_t

enum sfe_bmi330_axis_map_t : uint8_t

Which physical axis feeds which reported axis.

Read the name as "reported X, Y, Z come from physical ...". BMI330_AXIS_MAP_YXZ means reported X is the physical Y axis, reported Y is the physical X axis, and Z is unchanged.

Enumerator
BMI330_AXIS_MAP_XYZ 

No swap. Power-on default.

BMI330_AXIS_MAP_YXZ 

Swap X and Y.

BMI330_AXIS_MAP_XZY 

Swap Y and Z.

BMI330_AXIS_MAP_ZXY 

Rotate: X<-Z, Y<-X, Z<-Y.

BMI330_AXIS_MAP_YZX 

Rotate: X<-Y, Y<-Z, Z<-X.

BMI330_AXIS_MAP_ZYX 

Swap X and Z.

◆ sfe_bmi330_bandwidth_t

enum sfe_bmi330_bandwidth_t : uint8_t

3 dB cutoff of the sensor's low-pass filter, expressed as a fraction of the ODR.

Enumerator
BMI330_BW_ODR_HALF 

Cutoff at ODR / 2.

BMI330_BW_ODR_QUARTER 

Cutoff at ODR / 4. Quieter, more group delay.

◆ sfe_bmi330_feature_addr_t

enum sfe_bmi330_feature_addr_t : uint8_t

Base addresses inside the feature engine's extended memory.

These index the FEATURE_DATA_ADDR (0x41) / FEATURE_DATA_TX (0x42) window, not the main register map - readFeatureWords() and writeFeatureWords() take one of these. The spacing between consecutive entries is each feature's size in words.

Enumerator
BMI330_FEAT_ADDR_CONFIG_VERSION 

Feature engine configuration version (1 word).

BMI330_FEAT_ADDR_AXIS_REMAP 

Axis remap (2 words).

BMI330_FEAT_ADDR_ANY_MOTION 

Any-motion configuration (3 words).

BMI330_FEAT_ADDR_NO_MOTION 

No-motion configuration (3 words).

BMI330_FEAT_ADDR_FLAT 

Flat configuration (2 words).

BMI330_FEAT_ADDR_SIG_MOTION 

Significant motion configuration (3 words).

BMI330_FEAT_ADDR_STEP_COUNTER 

Step counter configuration (12 words).

BMI330_FEAT_ADDR_ORIENTATION 

Orientation configuration (2 words).

BMI330_FEAT_ADDR_TAP 

Tap detector configuration (3 words).

BMI330_FEAT_ADDR_TILT 

Tilt configuration (2 words).

BMI330_FEAT_ADDR_ST_RESULT 

Self-test per-axis results (1 word).

BMI330_FEAT_ADDR_ST_SELECT 

Self-test selection (1 word).

BMI330_FEAT_ADDR_SC_SELECT 

Gyro self-calibration selection (1 word).

BMI330_FEAT_ADDR_SC_ST_CONF 

Self-calibration / self-test configuration (1 word).

BMI330_FEAT_ADDR_SC_ST_COEFF 

Gyro filter coefficients (9 words). See performSelfTest().

◆ sfe_bmi330_feature_t

enum sfe_bmi330_feature_t : uint16_t

Feature enable bits in FEATURE_IO0 (0x10).

Combine with bitwise OR and pass to enableFeature(). Note that any-motion and no-motion are enabled PER AXIS - the feature runs when at least one of its axis bits is set - while the others are a single bit each.

Enumerator
BMI330_FEAT_NO_MOTION_X 

No-motion on the X axis.

BMI330_FEAT_NO_MOTION_Y 

No-motion on the Y axis.

BMI330_FEAT_NO_MOTION_Z 

No-motion on the Z axis.

BMI330_FEAT_NO_MOTION 

No-motion on all three axes.

BMI330_FEAT_ANY_MOTION_X 

Any-motion on the X axis.

BMI330_FEAT_ANY_MOTION_Y 

Any-motion on the Y axis.

BMI330_FEAT_ANY_MOTION_Z 

Any-motion on the Z axis.

BMI330_FEAT_ANY_MOTION 

Any-motion on all three axes.

BMI330_FEAT_FLAT 

Flat detection.

BMI330_FEAT_ORIENTATION 

Orientation detection.

BMI330_FEAT_STEP_DETECTOR 

Step detector (one interrupt per step).

BMI330_FEAT_STEP_COUNTER 

Step counter (counts, interrupts at the watermark).

BMI330_FEAT_SIG_MOTION 

Significant motion detection.

BMI330_FEAT_TILT 

Tilt detection.

BMI330_FEAT_SINGLE_TAP 

Single tap detection.

BMI330_FEAT_DOUBLE_TAP 

Double tap detection.

BMI330_FEAT_TRIPLE_TAP 

Triple tap detection.

◆ sfe_bmi330_fifo_source_t

enum sfe_bmi330_fifo_source_t : uint16_t

Which data sources the FIFO records, as bits of FIFO_CONF (0x36).

Combine with bitwise OR. The BMI330 FIFO is HEADERLESS: frames carry no tag, and the order inside a frame is fixed by the hardware - accelerometer (3 words), gyroscope (3 words), temperature (1 word), sensor time (1 word) - with disabled sources simply absent. The parser has to be told the same enable set that was programmed, which is why readFifoData() takes it as an argument rather than guessing.

Enumerator
BMI330_FIFO_TIME 

Include the sensor timestamp (1 word per frame).

BMI330_FIFO_ACCEL 

Include accelerometer data (3 words per frame).

BMI330_FIFO_GYRO 

Include gyroscope data (3 words per frame).

BMI330_FIFO_TEMP 

Include temperature (1 word per frame).

BMI330_FIFO_ALL 

All four sources (8 words per frame).

◆ sfe_bmi330_gyro_mode_t

enum sfe_bmi330_gyro_mode_t : uint8_t

Gyroscope power mode.

Note
SUSPEND versus DISABLE. In DISABLE the drive circuit is off and the gyro needs its full start-up time (tens of milliseconds) to produce valid data again. SUSPEND keeps the drive running and the ADC off, so waking is fast, at the cost of standing current. Choose SUSPEND for something that must respond to an interrupt promptly; choose DISABLE for something that sleeps for seconds.
Enumerator
BMI330_GYRO_MODE_DISABLE 

Gyroscope off, drive off. Power-on default.

BMI330_GYRO_MODE_SUSPEND 

Drive running, ADC off. Fast wake, higher idle current.

BMI330_GYRO_MODE_LOW_POWER 

Duty-cycled. ODR limited to 400 Hz and below.

BMI330_GYRO_MODE_NORMAL 

Continuous, reduced current. ODR up to 1600 Hz.

BMI330_GYRO_MODE_HIGH_PERF 

Continuous, lowest noise. All ODRs available.

◆ sfe_bmi330_gyro_range_t

enum sfe_bmi330_gyro_range_t : uint8_t

Gyroscope full-scale range.

As with the accelerometer, the 16-bit output spans the selected range: 262.144 LSB/dps at +/-125 dps down to 16.384 LSB/dps at +/-2000 dps.

Enumerator
BMI330_GYRO_RANGE_125DPS 

+/-125 dps, 262.144 LSB/dps.

BMI330_GYRO_RANGE_250DPS 

+/-250 dps, 131.072 LSB/dps.

BMI330_GYRO_RANGE_500DPS 

+/-500 dps, 65.536 LSB/dps.

BMI330_GYRO_RANGE_1000DPS 

+/-1000 dps, 32.768 LSB/dps.

BMI330_GYRO_RANGE_2000DPS 

+/-2000 dps, 16.384 LSB/dps.

◆ sfe_bmi330_int_pin_t

enum sfe_bmi330_int_pin_t : uint8_t

Interrupt routing target.

Every interrupt source is routed independently. The SparkFun Qwiic BMI330 breakout brings both pins out, so a sketch can (for example) put data-ready on INT1 and motion events on INT2 and tell them apart without reading a status register.

Enumerator
BMI330_INT_NONE 

Source disabled - not routed to a pin.

BMI330_INT1 

Route to the INT1 pin.

BMI330_INT2 

Route to the INT2 pin.

◆ sfe_bmi330_int_source_t

enum sfe_bmi330_int_source_t : uint8_t

Interrupt sources that can be routed to a pin.

These are the routable sources, as laid out across INT_MAP1 (0x3A) and INT_MAP2 (0x3B). mapInterrupt() hides which map register a source lives in.

Enumerator
BMI330_INT_SRC_NO_MOTION 

No-motion detected.

BMI330_INT_SRC_ANY_MOTION 

Any-motion detected.

BMI330_INT_SRC_FLAT 

Flat position detected.

BMI330_INT_SRC_ORIENTATION 

Orientation changed.

BMI330_INT_SRC_STEP_DETECTOR 

A single step was detected.

BMI330_INT_SRC_STEP_COUNTER 

Step counter reached its watermark.

BMI330_INT_SRC_SIG_MOTION 

Significant motion detected.

BMI330_INT_SRC_TILT 

Tilt detected.

BMI330_INT_SRC_TAP 

Single, double or triple tap detected.

BMI330_INT_SRC_I3C 

I3C sync event.

BMI330_INT_SRC_ERR_STATUS 

Feature engine error or status change.

BMI330_INT_SRC_TEMP_DRDY 

Temperature data ready.

BMI330_INT_SRC_GYRO_DRDY 

Gyroscope data ready.

BMI330_INT_SRC_ACCEL_DRDY 

Accelerometer data ready.

BMI330_INT_SRC_FIFO_WATERMARK 

FIFO reached its watermark.

BMI330_INT_SRC_FIFO_FULL 

FIFO full.

BMI330_INT_SRC_COUNT 

Number of sources. Not a valid source.

◆ sfe_bmi330_int_status_t

enum sfe_bmi330_int_status_t : uint16_t

Bit masks for the INT_STATUS_INT1 (0x0D) and INT_STATUS_INT2 (0x0E) registers.

Both status registers are CLEAR-ON-READ, and getInterruptStatus() reads the whole word, so a sketch must read once and test every bit it cares about in the returned value. Reading twice loses the first read's events.

Enumerator
BMI330_INT_STATUS_NO_MOTION 

No-motion detected.

BMI330_INT_STATUS_ANY_MOTION 

Any-motion detected.

BMI330_INT_STATUS_FLAT 

Flat position detected.

BMI330_INT_STATUS_ORIENTATION 

Orientation changed.

BMI330_INT_STATUS_STEP_DETECTOR 

A step was detected.

BMI330_INT_STATUS_STEP_COUNTER 

Step counter watermark reached.

BMI330_INT_STATUS_SIG_MOTION 

Significant motion detected.

BMI330_INT_STATUS_TILT 

Tilt detected.

BMI330_INT_STATUS_TAP 

Tap detected - see getTapEvent() for which kind.

BMI330_INT_STATUS_I3C 

I3C sync event.

BMI330_INT_STATUS_ERROR 

Feature engine error or status change.

BMI330_INT_STATUS_TEMP_DRDY 

Temperature data ready.

BMI330_INT_STATUS_GYRO_DRDY 

Gyroscope data ready.

BMI330_INT_STATUS_ACCEL_DRDY 

Accelerometer data ready.

BMI330_INT_STATUS_FIFO_WATERMARK 

FIFO watermark reached.

BMI330_INT_STATUS_FIFO_FULL 

FIFO full.

◆ sfe_bmi330_odr_t

enum sfe_bmi330_odr_t : uint8_t

Output data rate settings, shared by the accelerometer and the gyroscope.

Each sensor keeps its own ODR field, so the two may run at different rates. Not every rate is legal in every power mode: low-power mode tops out at 400 Hz, and rates below 12.5 Hz are only available in low-power mode. An illegal pairing is not rejected by the write - it raises acc_conf_err / gyr_conf_err in ERR_REG, which getErrorStatus() reports.

See also
setAccelODR(), setGyroODR(), getErrorStatus()
Enumerator
BMI330_ODR_0_78_HZ 

0.78125 Hz. Low-power mode only.

BMI330_ODR_1_56_HZ 

1.5625 Hz. Low-power mode only.

BMI330_ODR_3_12_HZ 

3.125 Hz. Low-power mode only.

BMI330_ODR_6_25_HZ 

6.25 Hz. Low-power mode only.

BMI330_ODR_12_5_HZ 

12.5 Hz.

BMI330_ODR_25_HZ 

25 Hz.

BMI330_ODR_50_HZ 

50 Hz. Required by several feature-engine features.

BMI330_ODR_100_HZ 

100 Hz. The self-test and self-calibration rate.

BMI330_ODR_200_HZ 

200 Hz.

BMI330_ODR_400_HZ 

400 Hz. Highest rate available in low-power mode.

BMI330_ODR_800_HZ 

800 Hz. Normal or high-performance mode only.

BMI330_ODR_1600_HZ 

1600 Hz. Normal or high-performance mode only.

BMI330_ODR_3200_HZ 

3200 Hz. High-performance mode only.

BMI330_ODR_6400_HZ 

6400 Hz. High-performance mode only, accelerometer-friendly.

◆ sfe_bmi330_orientation_t

enum sfe_bmi330_orientation_t : uint8_t

Device orientation as classified by the orientation feature.

Enumerator
BMI330_ORIENT_PORTRAIT_UPRIGHT 

Portrait, upright.

BMI330_ORIENT_LANDSCAPE_LEFT 

Landscape, left.

BMI330_ORIENT_PORTRAIT_UPSIDE_DOWN 

Portrait, upside down.

BMI330_ORIENT_LANDSCAPE_RIGHT 

Landscape, right.

◆ sfe_bmi330_self_calib_t

enum sfe_bmi330_self_calib_t : uint8_t

What a gyroscope self-calibration corrects.

Enumerator
BMI330_SELF_CALIB_SENSITIVITY 

Correct gyroscope sensitivity only.

BMI330_SELF_CALIB_OFFSET 

Correct gyroscope offset only.

BMI330_SELF_CALIB_BOTH 

Correct both.

◆ sfe_bmi330_self_test_t

enum sfe_bmi330_self_test_t : uint8_t

Which sensors a self-test exercises.

Enumerator
BMI330_SELF_TEST_ACCEL 

Accelerometer only.

BMI330_SELF_TEST_GYRO 

Gyroscope only.

BMI330_SELF_TEST_BOTH 

Both sensors.

◆ sfe_bmi330_tap_axis_t

enum sfe_bmi330_tap_axis_t : uint8_t

Which axis the tap detector watches.

Enumerator
BMI330_TAP_AXIS_X 

Detect taps along X.

BMI330_TAP_AXIS_Y 

Detect taps along Y.

BMI330_TAP_AXIS_Z 

Detect taps along Z. Power-on default - the usual "tap the lid" axis.