|
M5Unit-IMU 0.0.2 git rev:e5b00aa
|
3-axis magnetometer unit (U231, GROVE) More...
#include <unit_bmm350.hpp>
Classes | |
| struct | config_t |
| Settings for begin() More... | |
Public Member Functions | |
| UnitBMM350 (const uint8_t addr=DEFAULT_ADDRESS) | |
| Construct with the I2C address the chip will answer on. | |
| virtual | ~UnitBMM350 () |
| Destructor. | |
| virtual bool | begin () override |
| Begin the unit. | |
| virtual void | update (const bool force=false) override |
| Update the unit. | |
Settings | |
| config_t | config () const |
| Gets the configuration. | |
| void | config (const config_t &cfg) |
| Set the configuration. | |
Setting (applies immediately) | |
| bool | writeDataRate (const bmm350::DataRate rate) |
| Write the output data rate (averaging is re-clamped to the new rate) | |
| bool | writeAveraging (const bmm350::Averaging avg) |
| Write the averaging factor (clamped to what the current rate accepts) | |
| bool | readDataRate (bmm350::DataRate &rate) |
| Read the output data rate from the device (REG_PMU_CMD_AGGR_SET bits[3:0]) | |
| bool | readAveraging (bmm350::Averaging &avg) |
| Read the averaging factor from the device (REG_PMU_CMD_AGGR_SET bits[5:4]) | |
Reset | |
| bool | softReset () |
| Soft reset (REG_CMD CMD_SOFTRESET), then re-run the mandatory post-reset initialization (OTP download and magnetic reset (BR/FGR)), leaving the chip initialized but unconfigured and stopped. | |
Periodic measurement | |
| bool | startPeriodicMeasurement (const bmm350::DataRate rate, const bmm350::Averaging avg) |
| Start periodic measurement. | |
| bool | startPeriodicMeasurement () |
| Start periodic measurement in the current settings. | |
| bool | stopPeriodicMeasurement () |
| Stop periodic measurement. | |
Power | |
| bool | sleep () override |
| Put the chip into suspend mode (REG_PMU_CMD suspend) | |
| bool | wakeup () override |
| Return the chip to normal mode. | |
IMUDataSource | |
| virtual m5::imu::Capability | imuSpec () const override |
| Capability of this unit. | |
| virtual m5::imu::Capability | readImuRaw (m5::imu::imu_raw_data_t &out) override |
| Read the latest raw IMU data. | |
| virtual void | imuConvertParam (m5::imu::imu_convert_param_t &out) const override |
| Gets the conversion parameters for raw IMU data. | |
Protected Member Functions | |
| bool | start_periodic_measurement (const bmm350::DataRate rate, const bmm350::Averaging avg) |
| bool | start_periodic_measurement () |
| bool | stop_periodic_measurement () |
| bool | read_measurement (bmm350::Data &d) |
| bool | write_register8_verified (const uint8_t reg, const uint8_t val) |
| bool | read_registers (const uint8_t reg, uint8_t *out, const uint32_t len) |
| bool | read_register8 (const uint8_t reg, uint8_t &out) |
| bool | download_otp (bmm350::otp_compensation_t &comp) |
| bool | commit_odr_avg (const bmm350::DataRate rate, const bmm350::Averaging avg) |
| M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitBMM350, bmm350::Data) | |
3-axis magnetometer unit (U231, GROVE)
|
explicit |
Construct with the I2C address the chip will answer on.
| [in] | addr | I2C address (defaults to the chip's factory address) |
|
inline |
Gets the configuration.
|
inline |
Set the configuration.
| [in] | cfg | Configuration |
|
overridevirtual |
Gets the conversion parameters for raw IMU data.
| [out] | out | Conversion parameters |
Implements m5::imu::IMUDataSource.
|
inlineoverridevirtual |
| bool m5::unit::UnitBMM350::readAveraging | ( | bmm350::Averaging & | avg | ) |
Read the averaging factor from the device (REG_PMU_CMD_AGGR_SET bits[5:4])
| [out] | avg | Averaging factor |
| bool m5::unit::UnitBMM350::readDataRate | ( | bmm350::DataRate & | rate | ) |
Read the output data rate from the device (REG_PMU_CMD_AGGR_SET bits[3:0])
| [out] | rate | Data rate |
|
overridevirtual |
Read the latest raw IMU data.
| [out] | out | Raw IMU data |
Implements m5::imu::IMUDataSource.
|
overridevirtual |
Put the chip into suspend mode (REG_PMU_CMD suspend)
Works while periodic measurement is running: it is stopped first, since a suspended chip must not be polled. Suspend is the BMM350's lowest power state and preserves the register map, so the OTP compensation data and the configured ODR/averaging survive it.
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitBMM350::softReset | ( | ) |
Soft reset (REG_CMD CMD_SOFTRESET), then re-run the mandatory post-reset initialization (OTP download and magnetic reset (BR/FGR)), leaving the chip initialized but unconfigured and stopped.
| bool m5::unit::UnitBMM350::startPeriodicMeasurement | ( | ) |
Start periodic measurement in the current settings.
| bool m5::unit::UnitBMM350::startPeriodicMeasurement | ( | const bmm350::DataRate | rate, |
| const bmm350::Averaging | avg ) |
Start periodic measurement.
| rate | Output data rate |
| avg | Averaging factor (clamped to what the rate accepts, see clamp_averaging()) |
| bool m5::unit::UnitBMM350::stopPeriodicMeasurement | ( | ) |
Stop periodic measurement.
|
overridevirtual |
Update the unit.
| [in] | force | Forces an update if true, even if not time for periodic measurement |
|
overridevirtual |
Return the chip to normal mode.
Issues the normal-mode PMU command and verifies that the power mode actually switched – measurement stays stopped. Call startPeriodicMeasurement() to resume sampling. Harmless without a preceding sleep().
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitBMM350::writeAveraging | ( | const bmm350::Averaging | avg | ) |
Write the averaging factor (clamped to what the current rate accepts)
| [in] | avg | Averaging factor |
| bool m5::unit::UnitBMM350::writeDataRate | ( | const bmm350::DataRate | rate | ) |
Write the output data rate (averaging is re-clamped to the new rate)
| [in] | rate | Data rate |