|
M5Unit-IMU 0.0.2 git rev:e5b00aa
|
NXP/Freescale MAG3110 3-axis magnetometer. No standalone GROVE unit exists; it is the magnetometer on the original (2017) classic M5Stack Gray (paired with an MPU6050). It sits directly on the host I2C bus at 0x0E (no aux bypass needed, unlike the MPU9250's AK8963). More...
#include <unit_mag3110.hpp>
Classes | |
| struct | config_t |
| Settings for begin() More... | |
Public Member Functions | |
| UnitMAG3110 (const uint8_t addr=DEFAULT_ADDRESS) | |
| Construct with the I2C address the chip will answer on. | |
| virtual | ~UnitMAG3110 () |
| 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. | |
Reset | |
| bool | softReset () |
| Soft reset (the MAG3110 has no reset command; returns to STANDBY via REG_CTRL_REG1), leaving the chip initialized but unconfigured and stopped. | |
Measurement setting (stop periodic measurement first) | |
| bool | writeDataRate (const mag3110::DataRate rate, const mag3110::OverSampling os) |
| Write the output data rate and over sampling ratio. | |
| bool | readDataRate (mag3110::DataRate &rate, mag3110::OverSampling &os) |
| Read the output data rate and over sampling ratio. | |
Periodic measurement | |
| bool | startPeriodicMeasurement (const mag3110::DataRate rate, const mag3110::OverSampling os) |
| Start periodic measurement (auto magnetic reset + continuous ACTIVE) | |
| bool | startPeriodicMeasurement () |
| Start periodic measurement in the current settings. | |
| bool | stopPeriodicMeasurement () |
| Mark periodic measurement as stopped (bookkeeping only; the chip stays in ACTIVE – call sleep() to drop to STANDBY for actual quiescence) | |
Power | |
| bool | sleep () override |
| Enter STANDBY mode (REG_CTRL_REG1 AC cleared) | |
| bool | wakeup () override |
| Leave STANDBY. | |
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 mag3110::DataRate rate, const mag3110::OverSampling os) |
| bool | start_periodic_measurement () |
| bool | stop_periodic_measurement () |
| bool | read_measurement (mag3110::Data &d) |
| M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitMAG3110, mag3110::Data) | |
NXP/Freescale MAG3110 3-axis magnetometer. No standalone GROVE unit exists; it is the magnetometer on the original (2017) classic M5Stack Gray (paired with an MPU6050). It sits directly on the host I2C bus at 0x0E (no aux bypass needed, unlike the MPU9250's AK8963).
|
explicit |
Construct with the I2C address the chip will answer on.
| [in] | addr | I2C address (defaults to the chip's factory address) |
|
overridevirtual |
Gets the conversion parameters for raw IMU data.
| [out] | out | Destination for the scale factors this driver applies |
Implements m5::imu::IMUDataSource.
|
inlineoverridevirtual |
Capability of this unit.
Implements m5::imu::IMUDataSource.
| bool m5::unit::UnitMAG3110::readDataRate | ( | mag3110::DataRate & | rate, |
| mag3110::OverSampling & | os ) |
Read the output data rate and over sampling ratio.
| [out] | rate | Output data rate |
| [out] | os | Over sampling ratio |
|
overridevirtual |
Read the latest raw IMU data.
| [out] | out | Destination buffer filled with the most recent sample |
Implements m5::imu::IMUDataSource.
|
overridevirtual |
Enter STANDBY mode (REG_CTRL_REG1 AC cleared)
Works while periodic measurement is running: it is stopped first, since a standby chip produces no data. STANDBY is the MAG3110's low-power state.
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitMAG3110::softReset | ( | ) |
Soft reset (the MAG3110 has no reset command; returns to STANDBY via REG_CTRL_REG1), leaving the chip initialized but unconfigured and stopped.
| bool m5::unit::UnitMAG3110::startPeriodicMeasurement | ( | ) |
Start periodic measurement in the current settings.
| bool m5::unit::UnitMAG3110::startPeriodicMeasurement | ( | const mag3110::DataRate | rate, |
| const mag3110::OverSampling | os ) |
Start periodic measurement (auto magnetic reset + continuous ACTIVE)
| [in] | rate | Output data rate |
| [in] | os | Over sampling ratio |
| bool m5::unit::UnitMAG3110::stopPeriodicMeasurement | ( | ) |
Mark periodic measurement as stopped (bookkeeping only; the chip stays in ACTIVE – call sleep() to drop to STANDBY for actual quiescence)
|
overridevirtual |
Update the unit.
| [in] | force | Forces an update if true, even if not time for periodic measurement |
|
overridevirtual |
Leave STANDBY.
No-op by design: on the MAG3110 STANDBY is also the state the chip has to be in to be configured, so there is nothing to undo here. Call startPeriodicMeasurement() to enter ACTIVE continuous measurement.
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitMAG3110::writeDataRate | ( | const mag3110::DataRate | rate, |
| const mag3110::OverSampling | os ) |
Write the output data rate and over sampling ratio.
| [in] | rate | Output data rate |
| [in] | os | Over sampling ratio |
Applied to the chip immediately, and to the periodic measurement interval