M5Unit-IMU 0.0.2 git rev:e5b00aa
Loading...
Searching...
No Matches
unit_mag3110_data.hpp File Reference

MAG3110 setting enums and measurement data (framework independent) More...

#include <array>
#include <cstdint>
#include <cmath>

Go to the source code of this file.

Classes

struct  m5::unit::mag3110::Data
 One MAG3110 sample: a 7-byte burst from DR_STATUS (0x00) More...
 

Namespaces

namespace  m5
 Top level namespace of M5Stack.
 

Enumerations

enum class  m5::unit::mag3110::DataRate : uint8_t {
  Rate80Hz , Rate40Hz , Rate20Hz , Rate10Hz ,
  Rate5Hz , Rate2_5Hz , Rate1_25Hz , Rate0_63Hz
}
 Output data rate select (REG_CTRL_REG1 DR[7:5]) More...
 
enum class  m5::unit::mag3110::OverSampling : uint8_t { X16 , X32 , X64 , X128 }
 Over sampling ratio (REG_CTRL_REG1 OS[4:3]) More...
 

Functions

constexpr uint32_t m5::unit::mag3110::output_rate_mhz (const DataRate rate, const OverSampling os)
 Effective output rate in milli-Hz.
 
constexpr uint32_t m5::unit::mag3110::interval_ms (const DataRate rate, const OverSampling os)
 Sampling interval (ms) for a rate/oversampling pair, rounded up.
 
constexpr uint8_t m5::unit::mag3110::ctrl_reg1_active (const DataRate rate, const OverSampling os)
 REG_CTRL_REG1 value entering continuous ACTIVE measurement (FR and TM left at 0)
 

Variables

constexpr float m5::unit::mag3110::RAW_UT_PER_LSB {0.10f}
 Native sensitivity (µT per raw LSB); fixed, factory-calibrated.
 
constexpr float m5::unit::mag3110::OUTPUT_LSB_PER_UT {16.0f}
 Library-wide magnetometer output scale (raw LSB per µT); see imu_convert_param_t.
 

Detailed Description

MAG3110 setting enums and measurement data (framework independent)

Enumeration Type Documentation

◆ DataRate

enum class m5::unit::mag3110::DataRate : uint8_t
strong

Output data rate select (REG_CTRL_REG1 DR[7:5])

Each value is named after the output rate it gives at OverSampling::X16, which is how the datasheet labels them (Table 32); a larger oversampling ratio divides that down. DR on its own fixes the ADC rate and with it the supply current, from 900µA at Rate80Hz to 8.6µA at Rate0_63Hz

Enumerator
Rate80Hz 

80Hz at X16 (ADC 1280Hz, 900µA)

Rate40Hz 

40Hz at X16 (ADC 640Hz, 550µA)

Rate20Hz 

20Hz at X16 (ADC 320Hz, 275µA)

Rate10Hz 

10Hz at X16 (ADC 160Hz, 137.5µA)

Rate5Hz 

5Hz at X16 (ADC 80Hz, 68.8µA)

Rate2_5Hz 

2.5Hz at X16 (ADC 80Hz, 34.4µA)

Rate1_25Hz 

1.25Hz at X16 (ADC 80Hz, 17.2µA)

Rate0_63Hz 

0.63Hz at X16 (ADC 80Hz, 8.6µA)

◆ OverSampling

enum class m5::unit::mag3110::OverSampling : uint8_t
strong

Over sampling ratio (REG_CTRL_REG1 OS[4:3])

OS on its own fixes the noise floor: 0.40µT rms at X16 down to 0.25µT rms at X128. It also divides the output rate, so most output rates are reachable from several DataRate/OverSampling pairs whose current and noise differ widely – 10Hz for instance is available at 900/550/275/137.5µA with 0.25/0.30/0.35/0.40µT rms. That trade-off is why the two fields are exposed separately

Enumerator
X16 

16x (0.40µT rms)

X32 

32x (0.35µT rms)

X64 

64x (0.30µT rms)

X128 

128x (0.25µT rms)

Function Documentation

◆ interval_ms()

uint32_t m5::unit::mag3110::interval_ms ( const DataRate rate,
const OverSampling os )
constexpr

Sampling interval (ms) for a rate/oversampling pair, rounded up.

Note
Rate80Hz + X16 gives 13ms, the interval this driver used when the rate was fixed

◆ output_rate_mhz()

uint32_t m5::unit::mag3110::output_rate_mhz ( const DataRate rate,
const OverSampling os )
constexpr

Effective output rate in milli-Hz.

Oversampling divides the DataRate's rate, exactly as datasheet Table 32 tabulates it