Reference
BMI323 API Description
/**
* @fn DFRobot_BMI323
* @brief Constructor
* @details Constructor - I2C interface
* @param wire TwoWire object pointer, default &Wire
* @param i2cAddr I2C address, default 0x69
* @return None
*/
DFRobot_BMI323(TwoWire *wire = &Wire, uint8_t i2cAddr = 0x69);
/**
* @fn begin
* @brief Initialization function
* @details Initialize I2C interface, chip registers and feature context
* @param None
* @return bool type, indicates the initialization status
* @retval true Initialization successful
* @retval false Initialization failed
*/
bool begin(void);
/**
* @fn configAccel
* @brief Configure accelerometer
* @param odr Output data rate selection (see: eAccelODR_t)
* @n Available rates:
* @n - eAccelODR0_78125Hz: 0.78125 Hz
* @n - eAccelODR1_5625Hz: 1.5625 Hz
* @n - eAccelODR3_125Hz: 3.125 Hz
* @n - eAccelODR6_25Hz: 6.25 Hz
* @n - eAccelODR12_5Hz: 12.5 Hz
* @n - eAccelODR25Hz: 25 Hz
* @n - eAccelODR50Hz: 50 Hz
* @n - eAccelODR100Hz: 100 Hz
* @n - eAccelODR200Hz: 200 Hz
* @n - eAccelODR400Hz: 400 Hz
* @n - eAccelODR800Hz: 800 Hz
* @n - eAccelODR1600Hz: 1600 Hz
* @n - eAccelODR3200Hz: 3200 Hz
* @n - eAccelODR6400Hz: 6400 Hz
* @n @note ODR range limitations (based on operating mode):
* @n - Low power mode: 0.78Hz ~ 400Hz
* @n - Normal mode: 12.5Hz ~ 6400Hz
* @n - High performance mode: 12.5Hz ~ 6400Hz
* @param range Range selection (see: eAccelRange_t)
* @n Available ranges:
* @n - eAccelRange2G: ±2g
* @n - eAccelRange4G: ±4g
* @n - eAccelRange8G: ±8g
* @n - eAccelRange16G: ±16g
* @param mode Operating mode selection (see: eAccelMode_t), default eAccelModeNormal
* @n Available modes:
* @n - eAccelModeLowPower: Low power mode
* @n - eAccelModeNormal: Normal mode (default)
* @n - eAccelModeHighPerf: High performance mode
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool configAccel(eAccelODR_t odr, eAccelRange_t range, eAccelMode_t mode = eAccelModeNormal);
/**
* @fn configGyro
* @brief Configure gyroscope
* @param odr Output data rate selection (see: eGyroODR_t)
* @n Available rates:
* @n - eGyroODR0_78125Hz: 0.78125 Hz
* @n - eGyroODR1_5625Hz: 1.5625 Hz
* @n - eGyroODR3_125Hz: 3.125 Hz
* @n - eGyroODR6_25Hz: 6.25 Hz
* @n - eGyroODR12_5Hz: 12.5 Hz
* @n - eGyroODR25Hz: 25 Hz
* @n - eGyroODR50Hz: 50 Hz
* @n - eGyroODR100Hz: 100 Hz
* @n - eGyroODR200Hz: 200 Hz
* @n - eGyroODR400Hz: 400 Hz
* @n - eGyroODR800Hz: 800 Hz
* @n - eGyroODR1600Hz: 1600 Hz
* @n - eGyroODR3200Hz: 3200 Hz
* @n - eGyroODR6400Hz: 6400 Hz
* @n @note ODR range limitations (based on operating mode):
* @n - Low power mode: 0.78Hz ~ 400Hz
* @n - Normal mode: 12.5Hz ~ 6400Hz
* @n - High performance mode: 12.5Hz ~ 6400Hz
* @param range Range selection (see: eGyroRange_t)
* @n Available ranges:
* @n - eGyroRange125DPS: ±125dps
* @n - eGyroRange250DPS: ±250dps
* @n - eGyroRange500DPS: ±500dps
* @n - eGyroRange1000DPS: ±1000dps
* @n - eGyroRange2000DPS: ±2000dps
* @param mode Operating mode selection (see: eGyroMode_t), default eGyroModeNormal
* @n Available modes:
* @n - eGyroModeLowPower: Low power mode
* @n - eGyroModeNormal: Normal mode (default)
* @n - eGyroModeHighPerf: High performance mode
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool configGyro(eGyroODR_t odr, eGyroRange_t range, eGyroMode_t mode = eGyroModeNormal);
/**
* @fn getAccelGyroData
* @brief Read accelerometer and gyroscope simultaneously and return physical units
* @details Read accelerometer and gyroscope raw data at once, convert to g/dps and return
* @param accel Accelerometer output
* @param gyro Gyroscope output
* @return bool type, indicates the read status
* @retval true Read successful
* @retval false Read failed
*/
bool getAccelGyroData(sSensorData *accel, sSensorData *gyro);
/**
* @fn enableStepCounterInt
* @brief Enable step counter interrupt function
* @details Configure step counter function and map to specified interrupt pin, interrupt will be triggered when step count changes
* @param pin Bound interrupt pin (eINT1 or eINT2)
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableStepCounterInt(eInt_t pin);
/**
* @fn readStepCounter
* @brief Read step counter data
* @param stepVal Step count output pointer, the read step count will be written to the memory pointed by this pointer
* @return int8_t BMI3_OK indicates success, other values indicate failure
*/
int8_t readStepCounter(uint16_t *stepVal);
/**
* @fn getIntStatus
* @brief Get interrupt status
* @details Read and combine interrupt status from both INT1 and INT2 pins. The return value is the OR combination of INT1 and INT2 status registers.
* @return uint16_t Combined interrupt status register value (INT1 | INT2). Each bit represents a different interrupt type:
* @n - BMI3_INT_STATUS_ANY_MOTION: Any motion detected
* @n - BMI3_INT_STATUS_NO_MOTION: No motion detected
* @n - BMI3_INT_STATUS_FLAT: Flat detection
* @n - BMI3_INT_STATUS_ORIENTATION: Orientation change
* @n - BMI3_INT_STATUS_STEP_DETECTOR: Step detected
* @n - BMI3_INT_STATUS_SIG_MOTION: Significant motion detected
* @n - BMI3_INT_STATUS_TILT: Tilt detected
* @n - BMI3_INT_STATUS_TAP: Tap detected
*/
uint16_t getIntStatus(void);
/**
* @fn enableAnyMotionInt
* @brief Configure any-motion threshold interrupt (using official structure parameters)
* @param config Any-motion configuration structure (see bmi3_any_motion_config)
* @n Parameter description:
* @n - slope_thres: Acceleration slope threshold, range
* 0-4095, unit 1.953mg/LSB (official example: 9 ≈ 17.6mg)
* @n - hysteresis: Hysteresis value, range 0-1023, unit 1.953mg/LSB (official example: 5 ≈ 9.8mg)
* @n - duration: Duration, range 0-8191, unit 20ms (official example: 9 = 180ms)
* @n - acc_ref_up: Acceleration reference update mode, 0=OnEvent, 1=Always (official example: 1)
* @n - wait_time: Wait time, range 0-7, unit 20ms (official example: 4-5 = 80-100ms)
* @param pin Bound interrupt pin
* @param axisMask Axis selection mask (default: eAxisXYZ)
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableAnyMotionInt(const struct bmi3_any_motion_config &config,
eInt_t pin, uint8_t axisMask = eAxisXYZ);
/**
* @fn enableNoMotionInt
* @brief Configure no-motion threshold interrupt (using official structure parameters)
* @param config No-motion detection configuration structure (see bmi3_no_motion_config)
* @n Parameter description:
* @n - slope_thres: Acceleration slope threshold, range
* 0-4095, unit 1.953mg/LSB (official example: 9 ≈ 17.6mg)
* @n - hysteresis: Hysteresis value, range 0-1023, unit 1.953mg/LSB (official example: 5 ≈ 9.8mg)
* @n - duration: Duration, range 0-8191, unit 20ms (official example: 9 = 180ms)
* @n - acc_ref_up: Acceleration reference update mode, 0=OnEvent, 1=Always (official example: 1)
* @n - wait_time: Wait time, range 0-7, unit 20ms (official example: 5 = 100ms)
* @param pin Bound interrupt pin
* @param axisMask Axis selection mask (default: eAxisXYZ)
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableNoMotionInt(const struct bmi3_no_motion_config &config, eInt_t pin,
uint8_t axisMask = eAxisXYZ);
/**
* @fn enableSigMotionInt
* @brief Configure significant motion detection interrupt (using official structure parameters)
* @param config Significant motion configuration structure (see bmi3_sig_motion_config)
* @n Parameter description:
* @n - block_size: Detection segment size, range 0-65535 (official example: 200)
* @n - peak_2_peak_min: Peak-to-peak acceleration minimum, range 0-1023 (official example: 30)
* @n - peak_2_peak_max: Peak-to-peak acceleration maximum, range 0-1023 (official example: 30)
* @n - mcr_min: Mean crossing rate per second minimum, range 0-62 (official example: 0x10 = 16)
* @n - mcr_max: Mean crossing rate per second maximum, range 0-62 (official example: 0x10 = 16)
* @param pin Bound interrupt pin
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableSigMotionInt(const struct bmi3_sig_motion_config &config,
eInt_t pin);
/**
* @fn enableFlatInt
* @brief Configure flat detection interrupt (using official structure parameters)
* @param config Flat detection configuration structure (see bmi3_flat_config)
* @n Parameter description:
* @n - theta: Maximum allowed tilt angle, range 0-63, angle calculated as 64 *
* (tan(angle)^2) (official example: 9)
* @n - blocking: Blocking mode, 0=MODE_0(disabled), 1=MODE_1(>1.5g),
* 2=MODE_2(>1.5g or slope>half threshold), 3=MODE_3(>1.5g or slope>threshold) (official example: 3)
* @n - hold_time: Minimum duration for device to maintain flat state, range 0-255, unit 20ms (official example: 50 = 1000ms)
* @n - hysteresis: Hysteresis angle for flat detection, range 0-255 (official example: 9)
* @n - slope_thres: Minimum slope between consecutive acceleration samples, range 0-255 (official example: 0xCD = 205)
* @param pin Bound interrupt pin
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableFlatInt(const struct bmi3_flat_config &config, eInt_t pin);
/**
* @fn enableOrientationInt
* @brief Configure orientation detection interrupt (using official structure parameters)
* @param config Orientation detection configuration structure (see bmi3_orientation_config)
* @n Parameter description:
* @n - ud_en: Whether to detect flip (face up/down), 0=disabled, 1=enabled (official example: 1)
* @n - hold_time: Required duration for orientation change detection, range 0-255, unit 20ms (official example: 4 = 80ms)
* @n - hysteresis: Hysteresis for orientation detection, range 0-255 (official example: 5)
* @n - theta: Maximum allowed tilt angle, range 0-63, angle=64*(tan(angle)^2) (official example: 16)
* @n - mode: Orientation detection mode, 0/3=symmetric, 1=high asymmetric, 2=low asymmetric (official example: 1)
* @n - slope_thres: Slope threshold to prevent false detection due to violent motion, range 0-255 (official example: 30)
* @n - blocking: Blocking mode, 0-3 (official example: 3)
* @param pin Bound interrupt pin
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableOrientationInt(const struct bmi3_orientation_config &config,
eInt_t pin);
/**
* @fn readOrientation
* @brief Read orientation detection output
* @param portraitLandscape Portrait/Landscape status output pointer, can be NULL
* @param faceUpDown Face up/down status output pointer, can be NULL
* @return bool type, indicates the read status
* @retval true Read successful
* @retval false Read failed or feature not enabled
*/
bool readOrientation(uint8_t *portraitLandscape, uint8_t *faceUpDown);
/**
* @fn enableTapInt
* @brief Configure tap detection interrupt (using official structure parameters)
* @param config Tap detection configuration structure (see bmi3_tap_detector_config)
* @n Key parameters (refer to tap.c):
* @n - axis_sel: Select axis for tap detection (0=X, 1=Y, 2=Z)
* @n - mode: Detection mode (0=sensitive, 1=normal, 2=robust)
* @n - tap_peak_thres / tap_shock_settling_dur etc. for timing/amplitude thresholds to determine tap
* @param pin Bound interrupt pin
* @param enableSingle Whether to enable single tap detection (default true)
* @param enableDouble Whether to enable double tap detection (default true)
* @param enableTriple Whether to enable triple tap detection (default true)
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableTapInt(const struct bmi3_tap_detector_config &config, eInt_t pin,
bool enableSingle = true, bool enableDouble = true,
bool enableTriple = true);
/**
* @fn readTapStatus
* @brief Read tap detection status (single/double/triple tap)
* @param tapMask Output mask (can combine BMI3_TAP_DET_STATUS_SINGLE/DOUBLE/TRIPLE)
* @return bool type, indicates the read status
* @retval true Read successful
* @retval false Read failed
*/
bool readTapStatus(uint8_t *tapMask);
/**
* @fn enableTiltInt
* @brief Configure tilt detection interrupt (using official structure parameters)
* @param config Tilt detection configuration structure (see bmi3_tilt_config)
* @n Key parameters (refer to tilt.c):
* @n - segment_size: Time window for averaging reference vector, range 0-255
* @n - min_tilt_angle: Minimum tilt angle to exceed, range 0-255, angle=256*cos(angle)
* @n - beta_acc_mean: Low-pass averaging coefficient, range 0-65535
* @param pin Bound interrupt pin
* @return bool type, indicates the configuration status
* @retval true Configuration successful
* @retval false Configuration failed
*/
bool enableTiltInt(const struct bmi3_tilt_config &config, eInt_t pin);
BMM350 API Description
/**
* @fn softReset
* @brief Soft reset, restore to suspended mode after soft reset.
*/
void softReset(void);
/**
* @fn setOperationMode
* @brief Set sensor operation mode
* @param powermode
* @n eBmm350SuspendMode suspend mode: Suspend mode is the default power mode of BMM350 after the chip is powered, Current consumption in suspend mode is minimal,
* so, this mode is useful for periods when data conversion is not needed. Read and write of all registers is possible.
* @n eBmm350NormalMode normal mode: Get geomagnetic data normally.
* @n eBmm350ForcedMode forced mode: Single measurement, the sensor restores to suspend mode when the measurement is done.
* @n eBmm350ForcedModeFast To reach ODR = 200Hz is only possible by using FM_ FAST.
*/
void setOperationMode(enum eBmm350PowerModes_t powermode);
/**
* @fn getOperationMode
* @brief Get sensor operation mode
* @return result Return sensor operation mode as a character string
*/
String getOperationMode(void);
/**
* @fn setPresetMode
* @brief Set preset mode, make it easier for users to configure sensor to get geomagnetic data (The default collection rate is 12.5Hz)
* @param presetMode
* @n BMM350_PRESETMODE_LOWPOWER Low power mode, get a fraction of data and take the mean value.
* @n BMM350_PRESETMODE_REGULAR Regular mode, get a number of data and take the mean value.
* @n BMM350_PRESETMODE_ENHANCED Enhanced mode, get a plenty of data and take the mean value.
* @n BMM350_PRESETMODE_HIGHACCURACY High accuracy mode, get a huge number of data and take the mean value.
*/
void setPresetMode(uint8_t presetMode, uint8_t rate = BMM350_DATA_RATE_12_5HZ);
/**
* @fn setRate
* @brief Set the rate of obtaining geomagnetic data, the higher, the faster (without delay function)
* @param rate
* @n BMM350_DATA_RATE_1_5625HZ
* @n BMM350_DATA_RATE_3_125HZ
* @n BMM350_DATA_RATE_6_25HZ
* @n BMM350_DATA_RATE_12_5HZ (default rate)
* @n BMM350_DATA_RATE_25HZ
* @n BMM350_DATA_RATE_50HZ
* @n BMM350_DATA_RATE_100HZ
* @n BMM350_DATA_RATE_200HZ
* @n BMM350_DATA_RATE_400HZ
*/
void setRate(uint8_t rate);
/**
* @fn getRate
* @brief Get the config data rate, unit: HZ
* @return rate
*/
float getRate(void);
/**
* @fn selfTest
* @brief The sensor self test, the returned value indicate the self test result.
* @param testMode:
* @n eBmm350SelfTestNormal Normal self test, test whether x-axis, y-axis and z-axis are connected or short-circuited
* @return result The returned character string is the self test result
*/
String selfTest(eBmm350SelfTest_t testMode = eBmm350SelfTestNormal);
/**
* @fn setMeasurementXYZ
* @brief Enable the measurement at x-axis, y-axis and z-axis, default to be enabled. After disabling, the geomagnetic data at x, y, and z axis are wrong.
* @param en_x
* @n BMM350_X_EN Enable the measurement at x-axis
* @n BMM350_X_DIS Disable the measurement at x-axis
* @param en_y
* @n BMM350_Y_EN Enable the measurement at y-axis
* @n BMM350_Y_DIS Disable the measurement at y-axis
* @param en_z
* @n BMM350_Z_EN Enable the measurement at z-axis
* @n BMM350_Z_DIS Disable the measurement at z-axis
*/
void setMeasurementXYZ(enum eBmm350XAxisEnDis_t enX = BMM350_X_EN, enum eBmm350YAxisEnDis_t enY = BMM350_Y_EN, enum eBmm350ZAxisEnDis_t enZ = BMM350_Z_EN);
/**
* @fn getMeasurementStateXYZ
* @brief Get the enabling status at x-axis, y-axis and z-axis
* @return result Return enabling status as a character string
*/
String getMeasurementStateXYZ(void);
/**
* @fn getGeomagneticData
* @brief Get the geomagnetic data of 3 axis (x, y, z)
* @return Geomagnetic data structure, unit: (uT)
*/
sBmm350MagData_t getGeomagneticData(void);
/**
* @fn getCompassDegree
* @brief Get compass degree
* @return Compass degree (0° - 360°)
* @n 0° = North, 90° = East, 180° = South, 270° = West.
*/
float getCompassDegree(void);
/**
* @fn setDataReadyPin
* @brief Enable or disable data ready interrupt pin
* @n After enabling, the DRDY pin jump when there's data coming.
* @n After disabling, the DRDY pin will not jump when there's data coming.
* @n High polarity: active on high, the default is low level, which turns to high level when the interrupt is triggered.
* @n Low polarity: active on low, default is high level, which turns to low level when the interrupt is triggered.
* @param modes
* @n BMM350_ENABLE_INTERRUPT Enable DRDY
* @n BMM350_DISABLE_INTERRUPT Disable DRDY
* @param polarity
* @n BMM350_ACTIVE_HIGH High polarity
* @n BMM350_ACTIVE_LOW Low polarity
*/
void setDataReadyPin(enum eBmm350InterruptEnableDisable_t modes, enum eBmm350IntrPolarity_t polarity=BMM350_ACTIVE_HIGH);
/**
* @fn getDataReadyState
* @brief Get the data ready status, determine whether the data is ready
* @return status
* @n true Data ready
* @n false Data is not ready
*/
bool getDataReadyState(void);
/**
* @fn setThresholdInterrupt(uint8_t modes, int8_t threshold, uint8_t polarity)
* @brief Set threshold interrupt, an interrupt is triggered when the geomagnetic value of a channel is beyond/below the threshold
* @n High polarity: active on high level, the default is low level, which turns to high level when the interrupt is triggered.
* @n Low polarity: active on low level, the default is high level, which turns to low level when the interrupt is triggered.
* @param modes
* @n LOW_THRESHOLD_INTERRUPT Low threshold interrupt mode
* @n HIGH_THRESHOLD_INTERRUPT High threshold interrupt mode
* @param threshold
* @n Threshold, default to expand 16 times, for example: under low threshold mode, if the threshold is set to be 1, actually the geomagnetic data below 16 will trigger an interrupt
* @param polarity
* @n POLARITY_HIGH High polarity
* @n POLARITY_LOW Low polarity
*/
void setThresholdInterrupt(uint8_t modes, int8_t threshold, enum eBmm350IntrPolarity_t polarity);
/**
* @fn getThresholdData
* @brief Get the data with threshold interrupt occurred
* @return Returns the structure for storing geomagnetic data, the structure stores the data of 3 axis and interrupt status,
* @n The interrupt is not triggered when the data at x-axis, y-axis and z-axis are NO_DATA
* @n mag_x、mag_y、mag_z store geomagnetic data
* @n interrupt_x、interrupt_y、interrupt_z store the xyz axis interrupt state
*/
sBmm350ThresholdData_t getThresholdData(void);
BMP581 API Description
/**
* @fn begin
* @brief Initializes the sensor hardware interface
* @return true if initialization succeeds, false on failure
*/
bool begin(void);
/**
* @fn setODR
* @brief Configures sensor output data rate (ODR)
* @param odr Output data rate selection (see: eOdr_t)
* @n Available rates:
* @n - eOdr240Hz: Indicates an output rate of 240 Hz
* @n - eOdr218_5Hz: Indicates an output rate of 218.5 Hz
* @n - eOdr199_1Hz: Indicates an output rate of 199.1 Hz
* @n - eOdr179_2Hz: Indicates an output rate of 179.2 Hz
* @n - eOdr160Hz: Indicates an output rate of 160 Hz
* @n - eOdr149_3Hz: Indicates an output rate of 149.3 Hz
* @n - eOdr140Hz: Indicates an output rate of 140 Hz
* @n - eOdr129_8Hz: Indicates an output rate of 129.8 Hz
* @n - eOdr120Hz: Indicates an output rate of 120 Hz
* @n - eOdr110_1Hz: Indicates an output rate of 110.1 Hz
* @n - eOdr100_2Hz: Indicates an output rate of 100.2 Hz
* @n - eOdr89_6Hz: Indicates an output rate of 89.6 Hz
* @n - eOdr80Hz: Indicates an output rate of 80 Hz
* @n - eOdr70Hz: Indicates an output rate of 70 Hz
* @n - eOdr60Hz: Indicates an output rate of 60 Hz
* @n - eOdr50Hz: Indicates an output rate of 50 Hz
* @n - eOdr45Hz: Indicates an output rate of 45 Hz
* @n - eOdr40Hz: Indicates an output rate of 40 Hz
* @n - eOdr35Hz: Indicates an output rate of 35 Hz
* @n - eOdr30Hz: Indicates an output rate of 30 Hz
* @n - eOdr25Hz: Indicates an output rate of 25 Hz
* @n - eOdr20Hz: Indicates an output rate of 20 Hz
* @n - eOdr15Hz: Indicates an output rate of 15 Hz
* @n - eOdr10Hz: Indicates an output rate of 10 Hz
* @n - eOdr5Hz: Indicates an output rate of 5 Hz
* @n - eOdr4Hz: Indicates an output rate of 4 Hz
* @n - eOdr3Hz: Indicates an output rate of 3 Hz
* @n - eOdr2Hz: Indicates an output rate of 2 Hz
* @n - eOdr1Hz: Indicates an output rate of 1 Hz
* @n - eOdr0_5Hz: Indicates an output rate of 0.5 Hz
* @n - eOdr0_250Hz: Indicates an output rate of 0.250 Hz
* @n - eOdr0_125Hz: Indicates an output rate of 0.125 Hz
* @return uint8_t 0 on success, 1 on error
*/
uint8_t setODR(eODR_t odr);
/**
* @fn setOSR
* @brief Sets oversampling ratios for temperature and pressure
* @param osrTemp Temperature oversampling (see: eOverSampling_t)
* @param osrPress Pressure oversampling (see: eOverSampling_t)
* @n Supported values:
* @n - eOverSampling1: 1x oversampling
* @n - eOverSampling2: 2x oversampling
* @n - eOverSampling4: 4x oversampling
* @n - eOverSampling8: 8x oversampling
* @n - eOverSampling16: 16x oversampling
* @n - eOverSampling32: 32x oversampling
* @n - eOverSampling64: 64x oversampling
* @n - eOverSampling128: 128x oversampling
* @return uint8_t 0 on success, 1 on error
*/
uint8_t setOSR(eOverSampling_t osrTemp, eOverSampling_t osrPress);
/**
* @fn setMeasureMode
* @brief Configures sensor power/measurement mode
* @param mode Operation mode (see: eMeasureMode_t)
* @n Available modes:
* @n - eSleep: Sleep mode
* @n - eNormal: Normal measurement mode
* @n - eSingleShot: Single-shot measurement
* @n - eContinuous: Continuous measurement
* @n - eDeepSleep: Deep Sleep mode
* @return uint8_t 0 on success, 1 on error
*/
uint8_t setMeasureMode(eMeasureMode_t mode);
/**
* @fn reset
* @brief Performs software reset of the sensor
* @return uint8_t 0 on success, 1 on error
*/
uint8_t reset(void);
/**
* @fn readTempC
* @brief Reads calibrated temperature data
* @return float Temperature in degrees Celsius
*/
float readTempC(void);
/**
* @fn readPressPa
* @brief Reads calibrated pressure data
* @return float Pressure in Pascals (Pa)
*/
float readPressPa(void);
/**
* @fn readAltitudeM
* @brief Calculates altitude based on pressure reading
* @note Uses formula:
* @n altitude = (1 - (P/101325)^0.190284) * 44307.7
* @n where P = current pressure in Pa
* @return float Altitude in meters
*/
float readAltitudeM(void);
/**
* @fn configIIR
* @brief Configures IIR filter coefficients
* @param iirTemp Temperature IIR filter (see: eIIRFilter_t)
* @param iirPress Pressure IIR filter (see: eIIRFilter_t)
* @n Available coefficients:
* @n - eFilterBypass: Bypass filter
* @n - eFilter1: 1st order filter
* @n - eFilter3: 3rd order filter
* @n - eFilter7: 7th order filter
* @n - eFilter15: 15th order filter
* @n - eFilter31: 31st order filter
* @n - eFilter63: 63rd order filter
* @n - eFilter127: 127th order filter
* @return uint8_t 0 on success, 1 on error
*/
uint8_t configIIR(eIIRFilter_t iirTemp, eIIRFilter_t iirPress);
/**
* @fn configFIFO
* @brief Configures FIFO operation parameters
* @param dataSel Data frame type (see: eFIFODataSel_t)
* @n Available types:
* @n - eFIFODisable: FIFO disabled
* @n - eFIFOTempData: Temperature data only
* @n - eFIFOPressData: Pressure data only
* @n - eFIFOPressAndTempData: Pressure and temperature data
*
* @param downSampling Downsampling ratio (see: eFIFODownSampling_t)
* @n Available ratios:
* @n - eNoDownSampling: No downsampling
* @n - eDownSampling2: 2x downsampling
* @n - eDownSampling4: 4x downsampling
* @n - eDownSampling8: 8x downsampling
* @n - eDownSampling16: 16x downsampling
* @n - eDownSampling32: 32x downsampling
* @n - eDownSampling64: 64x downsampling
* @n - eDownSampling128: 128x downsampling
*
* @param mode FIFO operation mode (see: eFIFOWorkMode_t)
* @n Available modes:
* @n - eFIFOOverwriteMode: Stream data continuously
* @n - eFIFOFullStopMode: Stop when FIFO full
*
* @param threshold FIFO trigger threshold (0=disable, 1-31=frames)]
* @n - 0x0F: 15 frames. This is the maximum setting in PT-mode. The most
* significant bit is ignored.
* @n - 0x1F: 31 frames. This is the maximum setting in P- or T-mode.
* @return uint8_t 0 on success, 1 on error
*/
uint8_t configFIFO(eFIFODataSel_t dataSel, eFIFODownSampling_t downSampling, eFIFOWorkMode_t mode, uint8_t threshold);
/**
* @fn getFIFOCount
* @brief Gets current number of frames in FIFO
* @return uint8_t Number of stored data frames (0-31)
*/
uint8_t getFIFOCount(void);
/**
* @fn getFIFOData
* @brief Reads all data from FIFO
* @return sFIFOData_t Struct containing pressure and temperature data
* @n - len: Number of stored data frames (0-31)
* @n - pressure: Array of pressure values
* @n - temperature: Array of temperature values
*/
sFIFOData_t getFIFOData(void);
/**
* @fn configInterrupt
* @brief Configures interrupt behavior
* @param intMode Trigger mode (see: eIntMode_t)
* @n Available modes:
* @n - eIntModePulsed: Pulsed mode
* @n - eIntModeLatched: Latched mode
*
* @param intPol Signal polarity (see: eIntPolarity_t)
* @n Available polarities:
* @n - eIntLowActive: Active low
* @n - eIntHighActive: Active high
*
* @param intOd Output driver type (see: eIntOutputMode_t)
* @n Available types:
* @n - eIntPushPull: Push-pull output
* @n - eIntOpenDrain: Open-drain output
*
* @return uint8_t 0 on success, 1 on error
*/
uint8_t configInterrupt(eIntMode_t mode, eIntPolarity_t pol, eIntOutputMode_t outputMode);
/**
* @fn setIntSource
* @brief Enables specific interrupt sources
* @param source Bitmask of triggers (see: eIntSource_t)
* @n Available sources:
* @n - eIntDataReady: Data ready interrupt
* @n - eIntFIFOFull: FIFO full interrupt
* @n - eIntFIFOThres: FIFO threshold interrupt
* @n - eIntPressureOOR: Pressure out-of-range interrupt
* @details You can combine multiple interrupt sources using bitwise OR (|).
* Example: Enable both data ready and FIFO full interrupts:
* @code
* setIntSource(bmp58x.eIntDataReady | bmp58x.eIntFIFOFull);
* @endcode
* @return uint8_t 0 on success, 1 on error
*/
uint8_t setIntSource(uint8_t source);
/**
* @fn getIntStatus
* @brief Reads current interrupt status flags
* @return uint16_t Bitmask of active interrupts
* @n Possible flags:
* @n - eIntStatusDataReady: Data ready (0x01)
* @n - eIntStatusFIFOFull: FIFO full (0x02)
* @n - eIntStatusFIFOThres: FIFO threshold reached (0x04)
* @n - eIntStatusPressureOOR: Pressure out-of-range (0x08)
* @n - eIntStatusResetComplete: Reset complete (0x10)
*/
uint16_t getIntStatus(void);
/**
* @fn setPressOOR
* @brief Configures pressure out-of-range detection
* @param oor Threshold pressure value (0x00000-0x1FFFF)
* @param range Hysteresis range (0-255)
* @n oor - range < Pressure < oor + range
* @param cntLimit Trigger persistence count
* @n Available persistence settings:
* @n - eOORCountLimit1: 1 count
* @n - eOORCountLimit3: 3 counts
* @n - eOORCountLimit7: 7 counts
* @n - eOORCountLimit15: 15 counts
* @return uint8_t 0 on success, 1 on error
*/
uint8_t setPressOOR(uint32_t oor, uint8_t range, eOORCountLimit_t cntLimit);
/**
* @fn calibratedAbsoluteDifference
* @brief use the given current altitude as a reference value, eliminate the absolute difference of subsequent
* pressure and altitude data
* @param altitude current altitude
* @return boolean, indicates whether the reference value is set successfully
* @retval True indicates the reference value is set successfully
* @retval False indicates fail to set the reference value
*/
bool calibratedAbsoluteDifference(float altitude);
/**
* @fn setBaud
* @brief Set the UART communication baud rate.
* @details Configures the serial communication speed using the specified baud rate enum.
* This function initializes the necessary hardware registers to achieve the desired
* data transfer rate.
* @param baud An eBaud enum value specifying the desired baud rate.
* Defaults to e9600 if not explicitly set.
* @note Actual hardware configuration may vary depending on the microcontroller model.
* The function assumes a standard clock frequency; adjust clock settings
* if using non-default system clock configurations.
* @warning Changing the baud rate during communication may cause data loss
* or communication errors if both devices are not synchronized.
* @see eBaud for available baud rate options:
* - e2400: 2400 bits per second
* - e4800: 4800 bits per second
* - e9600: 9600 bits per second (default)
* - e14400: 14400 bits per second
* - e19200: 19200 bits per second
* - e38400: 38400 bits per second
* - e57600: 57600 bits per second
* - e115200: 115200 bits per second
*/
void setBaud(eBaud baud);
Was this article helpful?
