![]() |
SparkFun BMI330 Arduino Library
v1.0.0-2-gdbddb99
Arduino Library for the SparkFun Qwiic BMI330 6-DoF IMU (Bosch BMI330)
|
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... | |
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.
SPDX-License-Identifier: MIT
| #define SFE_BMI330_ALT_ADDRESS 0x69 |
Alternate 7-bit I2C address, selected by the board's ADR jumper (SDO / ADR pin high).
| #define SFE_BMI330_CHIP_ID 0x48 |
Value in the low byte of CHIP_ID (0x00) for a BMI330.
The BMI323 reads 0x43 here.
| #define SFE_BMI330_DEFAULT_ADDRESS 0x68 |
Factory-default 7-bit I2C address (SDO / ADR pin low).
SparkFun ships the Qwiic board this way.
| typedef enum sfe_bmi330_accel_mode_t 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.
| typedef enum sfe_bmi330_accel_range_t 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.
| typedef enum sfe_bmi330_averaging_t 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.
| typedef enum sfe_bmi330_axis_map_t 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.
| 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.
| typedef enum sfe_bmi330_feature_addr_t 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.
| typedef enum sfe_bmi330_feature_t 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.
| typedef enum sfe_bmi330_fifo_source_t 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.
| typedef enum sfe_bmi330_gyro_mode_t sfe_bmi330_gyro_mode_t |
Gyroscope power mode.
| typedef enum sfe_bmi330_gyro_range_t 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.
| typedef enum sfe_bmi330_int_pin_t 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.
| typedef enum sfe_bmi330_int_source_t 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.
| 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.
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.
| typedef enum sfe_bmi330_odr_t 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.
| typedef enum sfe_bmi330_orientation_t sfe_bmi330_orientation_t |
Device orientation as classified by the orientation feature.
| typedef enum sfe_bmi330_self_calib_t sfe_bmi330_self_calib_t |
What a gyroscope self-calibration corrects.
| typedef enum sfe_bmi330_self_test_t sfe_bmi330_self_test_t |
Which sensors a self-test exercises.
| typedef enum sfe_bmi330_tap_axis_t sfe_bmi330_tap_axis_t |
Which axis the tap detector watches.
| 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.
| 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.
| 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.
| 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.
| enum sfe_bmi330_bandwidth_t : uint8_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.
| 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.
| 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.
| enum sfe_bmi330_gyro_mode_t : uint8_t |
Gyroscope power mode.
| 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.
| 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. |
| 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.
| 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.
| 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.
| enum sfe_bmi330_orientation_t : uint8_t |
| enum sfe_bmi330_self_calib_t : uint8_t |
| enum sfe_bmi330_self_test_t : uint8_t |
| enum sfe_bmi330_tap_axis_t : uint8_t |