|
M5Unit-IMU 0.0.2 git rev:e5b00aa
|
3-axis magnetometer unit. No standalone GROVE unit exists; it is the magnetometer embedded in the MPU9250 found on early classic M5Stack Core/Fire boards, reachable at 0x0C once the MPU9250's I2C bypass is enabled (see m5::unit::imu::enableAuxBypass) More...
#include <unit_ak8963.hpp>
Classes | |
| struct | config_t |
| Settings for begin() More... | |
Public Member Functions | |
| UnitAK8963 (const uint8_t addr=DEFAULT_ADDRESS) | |
| Construct with the I2C address the chip will answer on. | |
| virtual | ~UnitAK8963 () |
| 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 (REG_CNTL2 SRST), leaving the chip initialized but unconfigured and stopped. | |
Measurement setting (stop periodic measurement first) | |
| bool | writeMeasurementMode (const ak8963::MeasurementMode mode, const ak8963::OutputBit bit) |
| Write the continuous measurement rate and output bit width. | |
| bool | readMeasurementMode (ak8963::MeasurementMode &mode, ak8963::OutputBit &bit) const |
| Read the continuous measurement rate and output bit width. | |
Periodic measurement | |
| bool | startPeriodicMeasurement (const ak8963::MeasurementMode mode, const ak8963::OutputBit bit) |
| Start periodic measurement. | |
| bool | startPeriodicMeasurement () |
| Start periodic measurement in the current settings. | |
| bool | stopPeriodicMeasurement () |
| Mark periodic measurement as stopped (bookkeeping only; the chip stays in its current mode – call sleep() to power-down for actual quiescence) | |
Power | |
| bool | sleep () override |
| Enter power-down mode (REG_CNTL1 mode 0) | |
| bool | wakeup () override |
| Leave power-down. | |
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 ak8963::MeasurementMode mode, const ak8963::OutputBit bit) |
| bool | start_periodic_measurement () |
| bool | stop_periodic_measurement () |
| bool | read_measurement (ak8963::Data &d) |
| bool | read_sensitivity (std::array< uint8_t, 3 > &asa) |
| M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitAK8963, ak8963::Data) | |
3-axis magnetometer unit. No standalone GROVE unit exists; it is the magnetometer embedded in the MPU9250 found on early classic M5Stack Core/Fire boards, reachable at 0x0C once the MPU9250's I2C bypass is enabled (see m5::unit::imu::enableAuxBypass)
|
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.
|
overridevirtual |
Read the latest raw IMU data.
| [out] | out | Destination buffer filled with the most recent sample |
Implements m5::imu::IMUDataSource.
| bool m5::unit::UnitAK8963::readMeasurementMode | ( | ak8963::MeasurementMode & | mode, |
| ak8963::OutputBit & | bit ) const |
Read the continuous measurement rate and output bit width.
| [out] | mode | Continuous measurement rate |
| [out] | bit | Output bit width |
|
overridevirtual |
Enter power-down mode (REG_CNTL1 mode 0)
Works while periodic measurement is running: it is stopped first, since a powered-down chip must not be polled. Power-down is the AK8963's only low-power state.
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitAK8963::softReset | ( | ) |
Soft reset (REG_CNTL2 SRST), leaving the chip initialized but unconfigured and stopped.
| bool m5::unit::UnitAK8963::startPeriodicMeasurement | ( | ) |
Start periodic measurement in the current settings.
| bool m5::unit::UnitAK8963::startPeriodicMeasurement | ( | const ak8963::MeasurementMode | mode, |
| const ak8963::OutputBit | bit ) |
Start periodic measurement.
| [in] | mode | Continuous measurement rate |
| [in] | bit | Output bit width |
| bool m5::unit::UnitAK8963::stopPeriodicMeasurement | ( | ) |
Mark periodic measurement as stopped (bookkeeping only; the chip stays in its current mode – call sleep() to power-down for actual quiescence)
|
overridevirtual |
Update the unit.
| [in] | force | Forces an update if true, even if not time for periodic measurement |
|
overridevirtual |
Leave power-down.
No-op by design: on the AK8963 power-down is also the state every mode change has to pass through, so there is nothing to undo here. Call startPeriodicMeasurement() to re-enter continuous measurement.
Reimplemented from m5::imu::IMUDataSource.
| bool m5::unit::UnitAK8963::writeMeasurementMode | ( | const ak8963::MeasurementMode | mode, |
| const ak8963::OutputBit | bit ) |
Write the continuous measurement rate and output bit width.
| [in] | mode | Continuous measurement rate |
| [in] | bit | Output bit width |
Applied to the chip by the next startPeriodicMeasurement(), along with the periodic measurement interval. Entering a continuous mode is measuring on this chip, so there is no way to park the setting in REG_CNTL1 while stopped – what this does write is the power-down every mode transition has to pass through