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
SfeBMI330ArdSPI Class Reference

Arduino SPI implementation for the SparkFun Qwiic BMI330 breakout. More...

#include <SparkFun_BMI330.h>

Inheritance diagram for SfeBMI330ArdSPI:
sfDevBMI330

Public Member Functions

 SfeBMI330ArdSPI ()
 
bool begin (uint8_t csPin, uint32_t clockFrequency=SFE_BMI330_SPI_CLOCK_DEFAULT, SPIClass &spiPort=SPI)
 Initialize the board over SPI. More...
 
uint8_t getCSPin (void)
 Get the chip select pin this object is using. More...
 
- Public Member Functions inherited from sfDevBMI330
 sfDevBMI330 ()
 Default constructor. More...
 
virtual ~sfDevBMI330 ()
 
sfTkError_t begin (sfTkIBus *theBus=nullptr)
 Adopt a bus, verify the device, and bring the feature engine up. More...
 
void setCommunicationBus (sfTkIBus *theBus)
 Set the communication bus without initializing the device. More...
 
bool isConnected (void)
 Check that a BMI330 is responding. More...
 
sfTkError_t getChipID (uint8_t &chipId, uint8_t &revId)
 Read the chip and revision IDs from CHIP_ID (0x00). More...
 
sfTkError_t softReset (void)
 Soft reset the device and restart the feature engine. More...
 
sfTkError_t enableFeatureEngine (void)
 Start the feature engine without a full reset. More...
 
bool getFeatureEngineStatus (void)
 Check whether the feature engine is running. More...
 
sfTkError_t getFeatureEngineError (uint16_t &status)
 Read the raw FEATURE_IO1 (0x11) word. More...
 
sfTkError_t setAccelConfig (sfe_bmi330_accel_mode_t mode, sfe_bmi330_odr_t odr, sfe_bmi330_accel_range_t range, sfe_bmi330_bandwidth_t bandwidth=BMI330_BW_ODR_HALF, sfe_bmi330_averaging_t averaging=BMI330_AVG_1)
 Write the whole accelerometer configuration in one register write. More...
 
sfTkError_t getAccelConfig (sfe_bmi330_accel_mode_t &mode, sfe_bmi330_odr_t &odr, sfe_bmi330_accel_range_t &range, sfe_bmi330_bandwidth_t &bandwidth, sfe_bmi330_averaging_t &averaging)
 Read the accelerometer configuration back from ACC_CONF (0x20). More...
 
sfTkError_t enableAccel (bool enable=true)
 Turn the accelerometer on in high-performance mode, or off. More...
 
sfTkError_t setAccelMode (sfe_bmi330_accel_mode_t mode)
 Set the accelerometer power mode, leaving the rest of ACC_CONF alone. More...
 
sfTkError_t setAccelODR (sfe_bmi330_odr_t odr)
 Set the accelerometer output data rate. More...
 
sfTkError_t setAccelRange (sfe_bmi330_accel_range_t range)
 Set the accelerometer full-scale range. More...
 
sfTkError_t setAccelBandwidth (sfe_bmi330_bandwidth_t bandwidth)
 Set the accelerometer filter bandwidth. More...
 
sfTkError_t setAccelAveraging (sfe_bmi330_averaging_t averaging)
 Set the accelerometer hardware averaging. More...
 
sfe_bmi330_accel_range_t getAccelRange (void)
 Get the cached accelerometer full-scale range. More...
 
sfTkError_t setGyroConfig (sfe_bmi330_gyro_mode_t mode, sfe_bmi330_odr_t odr, sfe_bmi330_gyro_range_t range, sfe_bmi330_bandwidth_t bandwidth=BMI330_BW_ODR_HALF, sfe_bmi330_averaging_t averaging=BMI330_AVG_1)
 Write the whole gyroscope configuration in one register write. More...
 
sfTkError_t getGyroConfig (sfe_bmi330_gyro_mode_t &mode, sfe_bmi330_odr_t &odr, sfe_bmi330_gyro_range_t &range, sfe_bmi330_bandwidth_t &bandwidth, sfe_bmi330_averaging_t &averaging)
 Read the gyroscope configuration back from GYR_CONF (0x21). More...
 
sfTkError_t enableGyro (bool enable=true)
 Turn the gyroscope on in high-performance mode, or off. More...
 
sfTkError_t setGyroMode (sfe_bmi330_gyro_mode_t mode)
 Set the gyroscope power mode, leaving the rest of GYR_CONF alone. More...
 
sfTkError_t setGyroODR (sfe_bmi330_odr_t odr)
 Set the gyroscope output data rate. More...
 
sfTkError_t setGyroRange (sfe_bmi330_gyro_range_t range)
 Set the gyroscope full-scale range. More...
 
sfTkError_t setGyroBandwidth (sfe_bmi330_bandwidth_t bandwidth)
 Set the gyroscope filter bandwidth. More...
 
sfTkError_t setGyroAveraging (sfe_bmi330_averaging_t averaging)
 Set the gyroscope hardware averaging. More...
 
sfe_bmi330_gyro_range_t getGyroRange (void)
 Get the cached gyroscope full-scale range. More...
 
sfTkError_t getSensorData (sfe_bmi330_sensor_data_t &data)
 Read accelerometer, gyroscope, temperature and timestamp in one transaction. More...
 
sfTkError_t getAccelData (sfe_bmi330_data_t &data)
 Read just the accelerometer, converted to g. More...
 
sfTkError_t getAccelDataRaw (sfe_bmi330_raw_data_t &data)
 Read just the accelerometer, in raw counts. More...
 
sfTkError_t getGyroData (sfe_bmi330_data_t &data)
 Read just the gyroscope, converted to degrees per second. More...
 
sfTkError_t getGyroDataRaw (sfe_bmi330_raw_data_t &data)
 Read just the gyroscope, in raw counts. More...
 
sfTkError_t getTemperature (float &celsius)
 Read the die temperature in degrees Celsius. More...
 
sfTkError_t getSensorTime (uint32_t &sensorTime)
 Read the 32-bit sensor timestamp, in ticks of 39.0625 us. More...
 
sfTkError_t getDataReady (bool &accelReady, bool &gyroReady, bool &tempReady)
 Read the STATUS register (0x02) data-ready flags. More...
 
sfTkError_t getErrorStatus (sfe_bmi330_error_status_t &status)
 Read and decode ERR_REG (0x01). More...
 
sfTkError_t getSaturationFlags (sfe_bmi330_saturation_t &flags)
 Read and decode the per-axis saturation flags in SAT_FLAGS (0x0C). More...
 
float accelRawToG (int16_t raw)
 Convert a raw accelerometer count to g using the cached range. More...
 
float gyroRawToDps (int16_t raw)
 Convert a raw gyroscope count to degrees per second using the cached range. More...
 
sfTkError_t setInterruptPinConfig (sfe_bmi330_int_pin_t pin, const sfe_bmi330_int_pin_config_t &config)
 Configure the electrical behavior of one interrupt pin. More...
 
sfTkError_t setInterruptLatch (bool latched)
 Choose between latched and pulsed interrupts. More...
 
sfTkError_t mapInterrupt (sfe_bmi330_int_source_t source, sfe_bmi330_int_pin_t pin)
 Route one interrupt source to a pin, or disconnect it. More...
 
sfTkError_t getInterruptStatus (sfe_bmi330_int_pin_t pin, uint16_t &status)
 Read and clear a pin's interrupt status word. More...
 
sfTkError_t setFifoConfig (uint16_t sources, bool stopOnFull=false)
 Choose what the FIFO records, and what it does when full. More...
 
sfTkError_t getFifoConfig (uint16_t &sources, bool &stopOnFull)
 Read back the configured FIFO sources and full behavior. More...
 
sfTkError_t setFifoWatermark (uint16_t words)
 Set the FIFO watermark, in 16-bit words. More...
 
sfTkError_t getFifoWatermark (uint16_t &words)
 Read the FIFO watermark, in words. More...
 
sfTkError_t getFifoFillLevel (uint16_t &words)
 Read how many words the FIFO currently holds. More...
 
sfTkError_t flushFifo (void)
 Discard everything in the FIFO. More...
 
sfTkError_t readFifoRaw (uint16_t *words, uint16_t count)
 Read raw words out of FIFO_DATA (0x16) without interpreting them. More...
 
sfTkError_t readFifoData (sfe_bmi330_fifo_frame_t *frames, uint8_t maxFrames, uint8_t &numFrames, uint16_t sources)
 Read and decode complete frames from the FIFO. More...
 
sfTkError_t enableFeature (uint16_t features, bool enable=true)
 Enable or disable feature-engine features. More...
 
sfTkError_t getEnabledFeatures (uint16_t &features)
 Read which features are currently enabled. More...
 
sfTkError_t readFeatureWords (uint8_t baseAddr, uint16_t *words, uint8_t count)
 Read consecutive words from feature engine extended memory. More...
 
sfTkError_t writeFeatureWords (uint8_t baseAddr, const uint16_t *words, uint8_t count)
 Write consecutive words to feature engine extended memory. More...
 
sfTkError_t setAnyMotionConfig (const sfe_bmi330_motion_config_t &config)
 Write the any-motion detector configuration. More...
 
sfTkError_t getAnyMotionConfig (sfe_bmi330_motion_config_t &config)
 Read the any-motion detector configuration. More...
 
sfTkError_t setNoMotionConfig (const sfe_bmi330_motion_config_t &config)
 Write the no-motion detector configuration. More...
 
sfTkError_t getNoMotionConfig (sfe_bmi330_motion_config_t &config)
 Read the no-motion detector configuration. More...
 
sfTkError_t setSigMotionConfig (const sfe_bmi330_sig_motion_config_t &config)
 Write the significant motion detector configuration. More...
 
sfTkError_t getSigMotionConfig (sfe_bmi330_sig_motion_config_t &config)
 Read the significant motion detector configuration. More...
 
sfTkError_t setTiltConfig (const sfe_bmi330_tilt_config_t &config)
 Write the tilt detector configuration. More...
 
sfTkError_t getTiltConfig (sfe_bmi330_tilt_config_t &config)
 Read the tilt detector configuration. More...
 
sfTkError_t setOrientationConfig (const sfe_bmi330_orientation_config_t &config)
 Write the orientation detector configuration. More...
 
sfTkError_t getOrientationConfig (sfe_bmi330_orientation_config_t &config)
 Read the orientation detector configuration. More...
 
sfTkError_t getOrientation (sfe_bmi330_orientation_t &orientation, bool &faceDown)
 Read the current orientation classification. More...
 
sfTkError_t setFlatConfig (const sfe_bmi330_flat_config_t &config)
 Write the flat detector configuration. More...
 
sfTkError_t getFlatConfig (sfe_bmi330_flat_config_t &config)
 Read the flat detector configuration. More...
 
sfTkError_t setTapConfig (const sfe_bmi330_tap_config_t &config)
 Write the tap detector configuration. More...
 
sfTkError_t getTapConfig (sfe_bmi330_tap_config_t &config)
 Read the tap detector configuration. More...
 
sfTkError_t getTapEvent (sfe_bmi330_tap_event_t &event)
 Read which tap gesture was last detected. More...
 
sfTkError_t getStepCount (uint32_t &steps)
 Read the step count. More...
 
sfTkError_t resetStepCount (void)
 Reset the step count to zero. More...
 
sfTkError_t setStepCounterWatermark (uint16_t watermark)
 Set how many steps trigger the step counter interrupt. More...
 
sfTkError_t getStepCounterWatermark (uint16_t &watermark)
 Read the step counter watermark. More...
 
sfTkError_t setAxisRemap (const sfe_bmi330_axis_remap_t &remap)
 Apply an axis remapping inside the device. More...
 
sfTkError_t getAxisRemap (sfe_bmi330_axis_remap_t &remap)
 Read the current axis remapping. More...
 
sfTkError_t performSelfTest (sfe_bmi330_self_test_t selection, sfe_bmi330_self_test_result_t &result)
 Run the built-in self-test. More...
 
sfTkError_t performGyroSelfCalibration (sfe_bmi330_self_calib_t selection, bool applyCorrection, sfe_bmi330_self_calib_result_t &result)
 Run the gyroscope self-calibration. More...
 
sfTkError_t setAccelOffset (int16_t x, int16_t y, int16_t z)
 Write the accelerometer user offsets. More...
 
sfTkError_t getAccelOffset (int16_t &x, int16_t &y, int16_t &z)
 Read the accelerometer user offsets. More...
 
sfTkError_t setGyroOffset (int16_t x, int16_t y, int16_t z)
 Write the gyroscope user offsets. More...
 
sfTkError_t getGyroOffset (int16_t &x, int16_t &y, int16_t &z)
 Read the gyroscope user offsets. More...
 
sfTkError_t readRegister (uint8_t reg, uint16_t &value)
 Read one 16-bit register, dummy bytes handled. More...
 
sfTkError_t writeRegister (uint8_t reg, uint16_t value)
 Write one 16-bit register. More...
 
sfTkError_t readRegisters (uint8_t reg, uint16_t *values, uint8_t count)
 Read consecutive 16-bit registers in one transaction, dummy bytes handled. More...
 
sfTkError_t writeRegisters (uint8_t reg, const uint16_t *values, uint8_t count)
 Write consecutive 16-bit registers in one transaction. More...
 
sfTkError_t sendCommand (uint16_t command)
 Send a command through the CMD register (0x7E). More...
 

Additional Inherited Members

- Static Public Member Functions inherited from sfDevBMI330
static float rawToCelsius (int16_t raw)
 Convert a raw temperature count to degrees Celsius. More...
 
static float accelSensitivity (sfe_bmi330_accel_range_t range)
 Sensitivity of a given accelerometer range, in LSB per g. More...
 
static float gyroSensitivity (sfe_bmi330_gyro_range_t range)
 Sensitivity of a given gyroscope range, in LSB per degree per second. More...
 
static uint8_t frameLengthWords (uint16_t sources)
 Words per FIFO frame for a given set of sources. More...
 
- Protected Member Functions inherited from sfDevBMI330
sfTkError_t updateRegister (uint8_t reg, uint16_t mask, uint16_t value)
 Read-modify-write a bit field of a 16-bit register. More...
 
sfTkError_t updateFeatureWord (uint8_t baseAddr, uint8_t wordIndex, uint16_t mask, uint16_t value)
 Read-modify-write a bit field of a feature engine word. More...
 
sfTkError_t setMotionConfig (uint8_t baseAddr, const sfe_bmi330_motion_config_t &config)
 Shared implementation for the any-motion and no-motion configuration writers. More...
 
sfTkError_t getMotionConfig (uint8_t baseAddr, sfe_bmi330_motion_config_t &config)
 Shared implementation for the any-motion and no-motion configuration readers. More...
 
sfTkError_t primeGyroFilterCoefficients (void)
 Seed the gyroscope filter coefficients required by BMI330 self-test and self-calibration. More...
 
sfTkError_t waitForSelfTestComplete (uint16_t &featureIO1, uint16_t stepDelayMs)
 Poll FEATURE_IO1 until the self-test / self-calibration completion bit is set. More...
 
sfTkError_t readFifoWords (uint16_t *words, uint8_t count)
 Read up to kMaxBurstWords words from the FIFO in one transaction. More...
 
- Static Protected Member Functions inherited from sfDevBMI330
static int16_t signExtend (uint16_t value, uint8_t bits)
 Sign-extend a right-aligned two's complement field to a full int16_t. More...
 
- Protected Attributes inherited from sfDevBMI330
sfTkIBus * _theBus
 The bus this driver communicates over. More...
 
uint8_t _dummyBytes
 Dummy bytes the device prepends to every read: 2 on I2C, 1 on SPI. More...
 
sfe_bmi330_accel_range_t _accelRange
 Cached accelerometer range, used by accelRawToG(). More...
 
sfe_bmi330_gyro_range_t _gyroRange
 Cached gyroscope range, used by gyroRawToDps(). More...
 
uint16_t _accelOffsetMask
 Mask for the accelerometer user offset field, set from the silicon revision. More...
 
uint16_t _pendingInt1
 INT1 status bits that setAxisRemap() had to read (and so clear) before its commit. More...
 
- Static Protected Attributes inherited from sfDevBMI330
static const uint8_t kRegChipId = 0x00
 Chip and revision ID. More...
 
static const uint8_t kRegErrReg = 0x01
 Error flags. More...
 
static const uint8_t kRegStatus = 0x02
 Data ready and POR flags. Clear-on-read. More...
 
static const uint8_t kRegAccelDataX = 0x03
 Accelerometer X. Start of the data block. More...
 
static const uint8_t kRegGyroDataX = 0x06
 Gyroscope X. More...
 
static const uint8_t kRegTempData = 0x09
 Temperature. More...
 
static const uint8_t kRegSensorTime0 = 0x0A
 Sensor time, low word. More...
 
static const uint8_t kRegSatFlags = 0x0C
 Per-axis saturation flags. More...
 
static const uint8_t kRegIntStatusInt1 = 0x0D
 INT1 status. Clear-on-read. More...
 
static const uint8_t kRegIntStatusInt2 = 0x0E
 INT2 status. Clear-on-read. More...
 
static const uint8_t kRegFeatureIO0 = 0x10
 Feature enable bits. More...
 
static const uint8_t kRegFeatureIO1 = 0x11
 Feature engine status and errors. More...
 
static const uint8_t kRegFeatureIO2 = 0x12
 Step count low word / start-up config. More...
 
static const uint8_t kRegFeatureIO3 = 0x13
 Step count high word / start-up config. More...
 
static const uint8_t kRegFeatureIOStatus = 0x14
 Commit register for FEATURE_IO0 changes. More...
 
static const uint8_t kRegFifoFillLevel = 0x15
 FIFO fill level, in words. More...
 
static const uint8_t kRegFifoData = 0x16
 FIFO read port. Does not auto-increment. More...
 
static const uint8_t kRegAccelConf = 0x20
 Accelerometer configuration. More...
 
static const uint8_t kRegGyroConf = 0x21
 Gyroscope configuration. More...
 
static const uint8_t kRegAltAccelConf = 0x28
 Alternate accelerometer configuration. More...
 
static const uint8_t kRegAltGyroConf = 0x29
 Alternate gyroscope configuration. More...
 
static const uint8_t kRegFifoWatermark = 0x35
 FIFO watermark, in words. More...
 
static const uint8_t kRegFifoConf = 0x36
 FIFO source enables and stop-on-full. More...
 
static const uint8_t kRegFifoCtrl = 0x37
 FIFO flush. More...
 
static const uint8_t kRegIoIntCtrl = 0x38
 Interrupt pin electrical configuration. More...
 
static const uint8_t kRegIntConf = 0x39
 Interrupt latch mode. More...
 
static const uint8_t kRegIntMap1 = 0x3A
 Interrupt routing, feature sources. More...
 
static const uint8_t kRegIntMap2 = 0x3B
 Interrupt routing, data and FIFO sources. More...
 
static const uint8_t kRegFeatureCtrl = 0x40
 Feature engine enable. More...
 
static const uint8_t kRegFeatureDataAddr = 0x41
 Feature memory address window. More...
 
static const uint8_t kRegFeatureDataTx = 0x42
 Feature memory data port. Auto-increments. More...
 
static const uint8_t kRegFeatureEventExt = 0x47
 Orientation and tap event outputs. More...
 
static const uint8_t kRegAccelDpOffX = 0x60
 Accelerometer X user offset. More...
 
static const uint8_t kRegGyroDpOffX = 0x66
 Gyroscope X user offset. More...
 
static const uint8_t kRegCmd = 0x7E
 Command register. More...
 
static const uint16_t kCmdSelfTestTrigger = 0x0100
 Start a self-test. More...
 
static const uint16_t kCmdSelfCalibTrigger = 0x0101
 Start a gyroscope self-calibration. More...
 
static const uint16_t kCmdSelfCalibAbort = 0x0200
 Abort a self-calibration. More...
 
static const uint16_t kCmdAxisMapUpdate = 0x0300
 Commit an axis remap. More...
 
static const uint16_t kCmdSoftReset = 0xDEAF
 Soft reset. More...
 
static const uint16_t kConfOdrMask = 0x000F
 Output data rate, bits 3:0. More...
 
static const uint16_t kConfRangeMask = 0x0070
 Full-scale range, bits 6:4. More...
 
static const uint8_t kConfRangeShift = 4
 Range field position. More...
 
static const uint16_t kConfBwMask = 0x0080
 Bandwidth, bit 7. More...
 
static const uint8_t kConfBwShift = 7
 Bandwidth field position. More...
 
static const uint16_t kConfAvgMask = 0x0700
 Averaging, bits 10:8. More...
 
static const uint8_t kConfAvgShift = 8
 Averaging field position. More...
 
static const uint16_t kConfModeMask = 0x7000
 Power mode, bits 14:12. More...
 
static const uint8_t kConfModeShift = 12
 Power mode field position. More...
 
static const uint16_t kStatusTempDrdy = 0x0020
 Temperature data ready. More...
 
static const uint16_t kStatusGyroDrdy = 0x0040
 Gyroscope data ready. More...
 
static const uint16_t kStatusAccelDrdy = 0x0080
 Accelerometer data ready. More...
 
static const uint16_t kErrFatal = 0x0001
 Fatal error. More...
 
static const uint16_t kErrFeatEngOverload = 0x0004
 Feature engine overload. More...
 
static const uint16_t kErrFeatEngWatchdog = 0x0010
 Feature engine watchdog. More...
 
static const uint16_t kErrAccelConf = 0x0020
 Unsupported accelerometer configuration. More...
 
static const uint16_t kErrGyroConf = 0x0040
 Unsupported gyroscope configuration. More...
 
static const uint16_t kSatAccelX = 0x0001
 Accelerometer X saturated. More...
 
static const uint16_t kSatAccelY = 0x0002
 Accelerometer Y saturated. More...
 
static const uint16_t kSatAccelZ = 0x0004
 Accelerometer Z saturated. More...
 
static const uint16_t kSatGyroX = 0x0008
 Gyroscope X saturated. More...
 
static const uint16_t kSatGyroY = 0x0010
 Gyroscope Y saturated. More...
 
static const uint16_t kSatGyroZ = 0x0020
 Gyroscope Z saturated. More...
 
static const uint16_t kInt1LevelMask = 0x0001
 INT1 polarity, 1 = active high. More...
 
static const uint16_t kInt1OpenDrainMask = 0x0002
 INT1 open-drain. More...
 
static const uint16_t kInt1OutputEnMask = 0x0004
 INT1 output enable. More...
 
static const uint16_t kInt2LevelMask = 0x0100
 INT2 polarity, 1 = active high. More...
 
static const uint16_t kInt2OpenDrainMask = 0x0200
 INT2 open-drain. More...
 
static const uint16_t kInt2OutputEnMask = 0x0400
 INT2 output enable. More...
 
static const uint16_t kIntLatchMask = 0x0001
 Latched interrupt mode. More...
 
static const uint16_t kFifoStopOnFullMask = 0x0001
 Stop writing when full. More...
 
static const uint16_t kFifoSourceMask = 0x0F00
 Source enable field. More...
 
static const uint16_t kFifoFlushMask = 0x0001
 Flush command bit in FIFO_CTRL. More...
 
static const uint16_t kFifoWatermarkMask = 0x03FF
 Watermark field. More...
 
static const uint16_t kFifoFillLevelMask = 0x07FF
 Fill level field. More...
 
static const uint16_t kFifoAccelInvalid = 0x7F01
 Sentinel word written into a FIFO accelerometer slot when the sensor was idle. More...
 
static const uint16_t kFifoGyroInvalid = 0x7F02
 Sentinel word written into a FIFO gyroscope slot when the sensor was idle. More...
 
static const uint16_t kFifoTempInvalid = 0x8000
 Sentinel word written into a FIFO temperature slot when the sensor was idle. More...
 
static const uint16_t kFeatureEngineEnable = 0x0001
 Engine enable / active flag. More...
 
static const uint16_t kFeatureIOStatusCommit = 0x0001
 Commit bit for FEATURE_IO0 changes. More...
 
static const uint16_t kFeatureStartupConfig = 0x012C
 Start-up value written to FEATURE_IO2. More...
 
static const uint16_t kFeatureErrorMask = 0x000F
 Error nibble in FEATURE_IO1. More...
 
static const uint16_t kFeatureNoError = 0x0005
 Error nibble value meaning "no error". More...
 
static const uint16_t kScStComplete = 0x0010
 Self-test / self-calibration complete. More...
 
static const uint16_t kScResult = 0x0020
 Gyroscope self-calibration result. More...
 
static const uint16_t kStResult = 0x0040
 Self-test result. More...
 
static const uint16_t kAxisMapComplete = 0x0400
 Axis map applied. More...
 
static const uint16_t kFeatureAddrMask = 0x07FF
 Address field of FEATURE_DATA_ADDR. More...
 
static const uint16_t kEventOrientationMask = 0x0003
 Portrait / landscape classification. More...
 
static const uint16_t kEventFaceDownMask = 0x0004
 Face down flag. More...
 
static const uint16_t kEventSingleTap = 0x0008
 Single tap detected. More...
 
static const uint16_t kEventDoubleTap = 0x0010
 Double tap detected. More...
 
static const uint16_t kEventTripleTap = 0x0020
 Triple tap detected. More...
 
static const uint16_t kMotionSlopeThresholdMask = 0x0FFF
 Any/no-motion slope threshold. More...
 
static const uint16_t kMotionAccelRefUpMask = 0x1000
 Any/no-motion reference update. More...
 
static const uint16_t kMotionHysteresisMask = 0x03FF
 Any/no-motion hysteresis. More...
 
static const uint16_t kMotionDurationMask = 0x1FFF
 Any/no-motion duration. More...
 
static const uint16_t kMotionWaitTimeMask = 0xE000
 Any/no-motion wait time. More...
 
static const uint8_t kMotionWaitTimeShift = 13
 Wait time field position. More...
 
static const uint16_t kSigP2pMinMask = 0x03FF
 Significant motion minimum peak-to-peak. More...
 
static const uint16_t kSigMcrMinMask = 0xFC00
 Significant motion minimum crossing rate. More...
 
static const uint8_t kSigMcrMinShift = 10
 Minimum crossing rate field position. More...
 
static const uint16_t kSigP2pMaxMask = 0x03FF
 Significant motion maximum peak-to-peak. More...
 
static const uint16_t kSigMcrMaxMask = 0xFC00
 Significant motion maximum crossing rate. More...
 
static const uint8_t kSigMcrMaxShift = 10
 Maximum crossing rate field position. More...
 
static const uint16_t kTiltSegmentSizeMask = 0x00FF
 Tilt reference segment size. More...
 
static const uint16_t kTiltMinAngleMask = 0xFF00
 Tilt minimum angle. More...
 
static const uint8_t kTiltMinAngleShift = 8
 Minimum angle field position. More...
 
static const uint16_t kOrientUdEnMask = 0x0001
 Orientation face up / down enable. More...
 
static const uint16_t kOrientModeMask = 0x0006
 Orientation mode. More...
 
static const uint8_t kOrientModeShift = 1
 Orientation mode field position. More...
 
static const uint16_t kOrientBlockingMask = 0x0018
 Orientation blocking. More...
 
static const uint8_t kOrientBlockingShift = 3
 Blocking field position. More...
 
static const uint16_t kOrientThetaMask = 0x07E0
 Orientation theta. More...
 
static const uint8_t kOrientThetaShift = 5
 Theta field position. More...
 
static const uint16_t kOrientHoldTimeMask = 0xF800
 Orientation hold time. More...
 
static const uint8_t kOrientHoldTimeShift = 11
 Hold time field position. More...
 
static const uint16_t kOrientSlopeThresMask = 0x00FF
 Orientation slope threshold. More...
 
static const uint16_t kOrientHystMask = 0xFF00
 Orientation hysteresis. More...
 
static const uint8_t kOrientHystShift = 8
 Hysteresis field position. More...
 
static const uint16_t kFlatThetaMask = 0x003F
 Flat theta. More...
 
static const uint16_t kFlatBlockingMask = 0x00C0
 Flat blocking. More...
 
static const uint8_t kFlatBlockingShift = 6
 Blocking field position. More...
 
static const uint16_t kFlatHoldTimeMask = 0xFF00
 Flat hold time. More...
 
static const uint8_t kFlatHoldTimeShift = 8
 Hold time field position. More...
 
static const uint16_t kFlatSlopeThresMask = 0x00FF
 Flat slope threshold. More...
 
static const uint16_t kFlatHystMask = 0xFF00
 Flat hysteresis. More...
 
static const uint8_t kFlatHystShift = 8
 Hysteresis field position. More...
 
static const uint16_t kTapAxisMask = 0x0003
 Tap axis selection. More...
 
static const uint16_t kTapWaitTimeoutMask = 0x0004
 Tap wait-for-timeout. More...
 
static const uint16_t kTapMaxPeaksMask = 0x0038
 Tap maximum peaks. More...
 
static const uint8_t kTapMaxPeaksShift = 3
 Maximum peaks field position. More...
 
static const uint16_t kTapModeMask = 0x00C0
 Tap mode. More...
 
static const uint8_t kTapModeShift = 6
 Mode field position. More...
 
static const uint16_t kTapPeakThresMask = 0x03FF
 Tap peak threshold. More...
 
static const uint16_t kTapMaxGestDurMask = 0xFC00
 Tap maximum gesture duration. More...
 
static const uint8_t kTapMaxGestDurShift = 10
 Gesture duration field position. More...
 
static const uint16_t kTapMaxDurBwPeaksMask = 0x000F
 Tap maximum duration between peaks. More...
 
static const uint16_t kTapShockSettDurMask = 0x00F0
 Tap shock settling duration. More...
 
static const uint8_t kTapShockSettDurShift = 4
 Shock settling field position. More...
 
static const uint16_t kTapMinQuietDurMask = 0x0F00
 Tap minimum quiet duration. More...
 
static const uint8_t kTapMinQuietDurShift = 8
 Minimum quiet field position. More...
 
static const uint16_t kTapQuietAfterGestMask = 0xF000
 Tap quiet time after gesture. More...
 
static const uint8_t kTapQuietAfterGestShift = 12
 Quiet after gesture field position. More...
 
static const uint16_t kStepWatermarkMask = 0x03FF
 Step counter watermark. More...
 
static const uint16_t kStepResetCounterMask = 0x0400
 Step counter reset bit. More...
 
static const uint16_t kRemapAxisMask = 0x0007
 Axis permutation. More...
 
static const uint16_t kRemapXSignMask = 0x0008
 Invert X. More...
 
static const uint16_t kRemapYSignMask = 0x0010
 Invert Y. More...
 
static const uint16_t kRemapZSignMask = 0x0020
 Invert Z. More...
 
static const uint16_t kAccelOffsetMask14 = 0x3FFF
 Accelerometer offset, 14-bit (rev 1+). More...
 
static const uint16_t kAccelOffsetMask13 = 0x1FFF
 Accelerometer offset, 13-bit (rev 0). More...
 
static const uint16_t kGyroOffsetMask = 0x03FF
 Gyroscope offset, 10-bit signed. More...
 
static const uint8_t kDummyBytesI2C = 2
 Dummy bytes prepended to a read on I2C. More...
 
static const uint8_t kDummyBytesSPI = 1
 Dummy bytes prepended to a read on SPI. More...
 
static const uint8_t kMaxBurstWords = 15
 Largest word count a single readRegisters() / writeRegisters() call handles. More...
 
static const uint8_t kSoftResetDelayMs = 2
 Milliseconds to wait after a soft reset before touching the device. More...
 
static const uint8_t kFeatureEngineStepMs = 10
 Milliseconds between feature engine start-up polls. More...
 
static const uint8_t kFeatureEngineRetries = 20
 Feature engine start-up polls before giving up. More...
 
static const uint8_t kSelfTestStepMs = 35
 Milliseconds between self-test completion polls. More...
 
static const uint8_t kSelfCalibStepMs = 43
 Milliseconds between self-calibration completion polls. More...
 
static const uint8_t kSelfTestRetries = 10
 Completion polls before a self-test or self-calibration is declared timed out. More...
 
static const uint8_t kAxisMapRetries = 10
 Axis-map acknowledgement polls before giving up. More...
 
static const uint8_t kAxisMapStepMs = 10
 Milliseconds between axis-map acknowledgement polls. More...
 
static const uint16_t kFifoSizeWords = 1024
 Words in the FIFO buffer (2048 bytes). More...
 

Detailed Description

Arduino SPI implementation for the SparkFun Qwiic BMI330 breakout.

Owns an sfTkArdSPI bus object and hands it to sfDevBMI330. Everything above the bus is identical to the I2C class - a sketch can be moved from one to the other by changing the object's type and its begin() arguments, and nothing else.

Note
SPI IS SELECTED BY THE FIRST CS EDGE. The BMI330 powers up undecided about its interface and commits to SPI when it first sees CSB go low and back high. That first transfer therefore returns garbage by design, which is why the driver performs and discards one read before checking the chip ID - both in begin() and after every soft reset. A driver without that throwaway read fails to identify a perfectly healthy part.
See also
sfDevBMI330
SfeBMI330ArdI2C

Constructor & Destructor Documentation

◆ SfeBMI330ArdSPI()

SfeBMI330ArdSPI::SfeBMI330ArdSPI ( )
inline

Member Function Documentation

◆ begin()

bool SfeBMI330ArdSPI::begin ( uint8_t  csPin,
uint32_t  clockFrequency = SFE_BMI330_SPI_CLOCK_DEFAULT,
SPIClass &  spiPort = SPI 
)
inline

Initialize the board over SPI.

Drives the chip select pin high before switching it to an output - the order matters, since an output that starts low would look like the beginning of a transfer to a device that has not yet decided which interface it speaks.

Note
As with the I2C class, both sensors are left disabled. See SfeBMI330ArdI2C::begin().
Parameters
csPinChip select pin.
clockFrequencySPI clock in hertz. Defaults to SFE_BMI330_SPI_CLOCK_DEFAULT; the device is specified to 10 MHz.
spiPortSPIClass instance to use (default: SPI).
Returns
true if the device was found and initialized.

◆ getCSPin()

uint8_t SfeBMI330ArdSPI::getCSPin ( void  )
inline

Get the chip select pin this object is using.

Returns
The configured chip select pin.

The documentation for this class was generated from the following file: