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

AK8963 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::ak8963::Data
 One AK8963 sample: an 8-byte burst from ST1 (0x02) plus the device ASA trim. More...
 

Namespaces

namespace  m5
 Top level namespace of M5Stack.
 

Enumerations

enum class  m5::unit::ak8963::Mode : uint8_t {
  PowerDown = 0x00 , Single = 0x01 , Cont8Hz = 0x02 , Cont100Hz = 0x06 ,
  SelfTest = 0x08 , FuseRom = 0x0F
}
 CNTL1 (0x0A) low-nibble operating mode. More...
 
enum class  m5::unit::ak8963::MeasurementMode : uint8_t { Cont8Hz = 0x02 , Cont100Hz = 0x06 }
 Continuous measurement rate, the subset of Mode this driver measures in. More...
 
enum class  m5::unit::ak8963::OutputBit : uint8_t { Bit14 = 0x00 , Bit16 = 0x10 }
 Output bit width (CNTL1 bit4 BIT) More...
 

Functions

constexpr uint32_t m5::unit::ak8963::interval_ms (const MeasurementMode mode)
 Sampling interval (ms) for a continuous measurement rate.
 
constexpr uint8_t m5::unit::ak8963::cntl1_value (const MeasurementMode mode, const OutputBit bit)
 REG_CNTL1 value entering a continuous measurement mode.
 

Variables

constexpr float m5::unit::ak8963::RAW_UT_PER_LSB {4912.0f / 32760.0f}
 16bit-mode sensitivity (µT per raw LSB) = 4912/32760
 
constexpr float m5::unit::ak8963::RAW_UT_PER_LSB_14BIT {4912.0f / 8190.0f}
 14bit-mode sensitivity (µT per raw LSB) = 4912/8190
 
constexpr float m5::unit::ak8963::OUTPUT_LSB_PER_UT {16.0f}
 Library-wide magnetometer output scale (raw LSB per µT); see imu_convert_param_t.
 

Detailed Description

AK8963 setting enums and measurement data (framework independent)

Enumeration Type Documentation

◆ MeasurementMode

enum class m5::unit::ak8963::MeasurementMode : uint8_t
strong

Continuous measurement rate, the subset of Mode this driver measures in.

Mode itself is the raw CNTL1 nibble and includes states the driver owns (FuseRom backs the ASA read, PowerDown backs every mode transition), so only the two continuous rates are offered here. The difference is almost entirely power: a measurement draws 5mA for 7.2ms, so Cont100Hz (10ms period) is on nearly all the time while Cont8Hz (125ms) has a ~6% duty cycle

Enumerator
Cont8Hz 

Continuous measurement, 8Hz.

Cont100Hz 

Continuous measurement, 100Hz.

◆ Mode

enum class m5::unit::ak8963::Mode : uint8_t
strong

CNTL1 (0x0A) low-nibble operating mode.

Enumerator
PowerDown 

Power-down.

Single 

Single measurement.

Cont8Hz 

Continuous measurement, 8Hz.

Cont100Hz 

Continuous measurement, 100Hz.

SelfTest 

Self test.

FuseRom 

FUSE-ROM access (ASA readable only here)

◆ OutputBit

enum class m5::unit::ak8963::OutputBit : uint8_t
strong

Output bit width (CNTL1 bit4 BIT)

Full scale is +/-4912µT either way; only the resolution changes. 14bit output is sign-extended and right-aligned, so it needs no shifting – just the coarser sensitivity below

Enumerator
Bit14 

14bit (0.6µT/LSB)

Bit16 

16bit (0.15µT/LSB)