BNO08X Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Enumerations | Functions | Variables
bno08x Namespace Reference

The BNO08x driver: everything it declares lives here; internals in detail. More...

Namespaces

namespace  reg
 The BNO08x protocol constants.
 

Classes

struct  ArvrStabilization
 AR/VR stabilisation records 0x3E2D and 0x3E2E (RM S4.2). More...
 
class  Bno08x
 Driver for one BNO080, BNO085 or BNO086. More...
 
class  CalibrationHelper
 A state object that turns the calibration procedure into steps. It sends nothing: it follows what you tell it (Advance(), Observe()) and says what to do next. More...
 
struct  Config
 The configuration of a session. Config{} is the recommended setup for a BNO085. More...
 
struct  DefaultLimits
 The sizes of the driver's fixed buffers; pass your own as the second template argument. More...
 
struct  EnvCalibration
 Environmental sensor calibration records 0x39AF, 0x4D20, 0x1AC9, 0x39B1, 0x4DA2. More...
 
struct  EulerCentiDeg
 Yaw, pitch and roll in centidegrees. More...
 
struct  Event
 One thing the driver reports, taken with Bno08x::PopEvent(). More...
 
struct  FeatureConfig
 The common feature report of one sensor (RM S6.5.2). More...
 
struct  FrsBuffer
 A caller-owned buffer for ReadFrs(); it must outlive the operation. More...
 
struct  GyroRvConfig
 Gyro-integrated rotation vector configuration record 0xA1A2 (RM S4.3.12). More...
 
class  HubInterface
 CRTP base of the platform port. More...
 
struct  KconfigLimits
 The buffer sizes menuconfig selected; pass it as the second template argument of Bno08x. More...
 
struct  MeCal
 The motion engine's calibration enables (RM S6.4.6). More...
 
struct  Metadata
 Sensor metadata record (RM Figures 28 and 29, record IDs 0xE301 to 0xE325). More...
 
struct  PowerManagement
 MotionEngine power management and stability classifier record 0xD3E2 (RM S4.3.1). More...
 
struct  ProductId
 Product ID response (RM S6.3.2). More...
 
struct  Quat14
 A quaternion in Q14 (RM S6.4.3.3): the set-reorientation argument. More...
 
struct  Quat30
 A unit quaternion in Q30 (the orientation records, RM S4.1). More...
 
struct  Result
 The value of a call, or why there is none. More...
 
struct  Result< void >
 The result of a call that returns no value. More...
 
struct  RvcFrame
 A decoded UART-RVC frame (DS p21). More...
 
struct  ShakeConfig
 Shake detector configuration record 0x7D7D. More...
 
struct  SignificantMotionConfig
 Significant motion detector configuration record 0xC274. More...
 
struct  Stats
 Counters of everything the driver dropped, repaired or noticed. Never reset by the driver. More...
 
struct  WheelSample
 One wheel measurement for dead reckoning (RM S6.4.13). More...
 

Concepts

concept  LimitsLike
 What a limits type must provide.
 
concept  HubPort
 Satisfied by a class that derives from HubInterface<Port>, names its transport and implements that transport's hooks with exactly the types in the table above.
 

Typedefs

using OpId = uint16_t
 An operation number returned by every call that completes later with an OpDone event.
 

Enumerations

enum class  CalStep : uint8_t {
  EnableSensors = 0 , MovePoses = 1 , SetDown = 2 , RotateAxes = 3 ,
  WaitAccuracy = 4 , Save = 5 , Done = 6
}
 Steps of the calibration procedure (CAL 1000-4044, DS S3.1). More...
 
enum class  Error : uint8_t {
  Error::Ok = 0 , Error::NotInitialized = 1 , Error::InvalidArgument = 2 , Error::Bus = 3 ,
  Error::Timeout = 4 , Error::DeviceIdMismatch = 5 , Error::Crc = 6 , Error::Busy = 7 ,
  Error::DeviceFault = 8 , Error::Unsupported = 9 , Error::Framing = 16 , Error::HubReset = 17 ,
  Error::Overflow = 18 , Error::Refused = 19 , Error::Oversize = 20 , Error::NotAdvertised = 21 ,
  Error::Variant = 22
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  LogLevel : uint8_t { LogLevel::Error = 0 , LogLevel::Warning , LogLevel::Info , LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  Transport : uint8_t { Transport::I2c = 0 , Transport::Spi = 1 , Transport::UartShtp = 2 , Transport::UartRvc = 3 }
 How the host reaches the hub (strapped by PS1 and PS0 at reset, DS p9 Figure 1-5). More...
 
enum class  Variant : uint8_t { Variant::Bno080 = 0 , Variant::Bno085 = 1 , Variant::Bno086 = 2 }
 The chip of the family the driver talks to. It selects behaviour; it is never detected. More...
 
enum class  ReadPolicy : uint8_t { ReadPolicy::HeaderThenRest , ReadPolicy::Fixed = 1 }
 How an I2C or SPI read sizes its transfers. More...
 
enum class  State : uint8_t {
  State::Idle = 0 , State::Resetting = 1 , State::WaitAdvert = 2 , State::WaitReady = 3 ,
  State::Ready = 4 , State::Faulted = 5
}
 State of the session. More...
 
enum class  Accuracy : uint8_t { Accuracy::Unreliable = 0 , Accuracy::Low = 1 , Accuracy::Medium = 2 , Accuracy::High = 3 }
 Accuracy of a sensor sample (status bits 1:0 of every input report, RM S6.5.1). More...
 
enum class  SensorId : uint8_t {
  SensorId::Accelerometer = 0x01 , SensorId::GyroscopeCalibrated = 0x02 , SensorId::MagneticFieldCalibrated = 0x03 , SensorId::LinearAcceleration = 0x04 ,
  SensorId::RotationVector = 0x05 , SensorId::Gravity = 0x06 , SensorId::GyroscopeUncalibrated = 0x07 , SensorId::GameRotationVector = 0x08 ,
  SensorId::GeomagneticRotationVector = 0x09 , SensorId::Pressure = 0x0A , SensorId::AmbientLight = 0x0B , SensorId::Humidity = 0x0C ,
  SensorId::Proximity = 0x0D , SensorId::Temperature = 0x0E , SensorId::MagneticFieldUncalibrated = 0x0F , SensorId::TapDetector = 0x10 ,
  SensorId::StepCounter = 0x11 , SensorId::SignificantMotion = 0x12 , SensorId::StabilityClassifier = 0x13 , SensorId::RawAccelerometer = 0x14 ,
  SensorId::RawGyroscope = 0x15 , SensorId::RawMagnetometer = 0x16 , SensorId::StepDetector = 0x18 , SensorId::ShakeDetector = 0x19 ,
  SensorId::FlipDetector = 0x1A , SensorId::PickupDetector = 0x1B , SensorId::StabilityDetector = 0x1C , SensorId::PersonalActivityClassifier = 0x1E ,
  SensorId::SleepDetector = 0x1F , SensorId::TiltDetector = 0x20 , SensorId::PocketDetector = 0x21 , SensorId::CircleDetector = 0x22 ,
  SensorId::HeartRateMonitor = 0x23 , SensorId::ArvrRotationVector = 0x28 , SensorId::ArvrGameRotationVector = 0x29 , SensorId::GyroIntegratedRotationVector ,
  SensorId::MotionRequest = 0x2B , SensorId::OpticalFlow = 0x2C , SensorId::DeadReckoningPose = 0x2D , SensorId::WheelEncoder = 0x2E
}
 Every sensor report ID any CEVA document defines (RM S6.5; matrix section 1.8 of the design). More...
 
enum class  EventKind : uint8_t {
  EventKind::Sensor = 0 , EventKind::OpDone = 1 , EventKind::FeatureChanged = 2 , EventKind::Reset = 3 ,
  EventKind::FlushDone = 4 , EventKind::HubError = 5 , EventKind::Dropped = 6 , EventKind::Rvc = 7 ,
  EventKind::Sh2Error = 8
}
 What an Event reports. More...
 
enum class  TareBasis : uint8_t {
  TareBasis::RotationVector = 0 , TareBasis::GameRotationVector = 1 , TareBasis::GeomagneticRotationVector = 2 , TareBasis::GyroIntegrated = 3 ,
  TareBasis::ArvrRotationVector = 4 , TareBasis::ArvrGameRotationVector
}
 The rotation vector a tare is based on (RM S6.4.3.1, P2). More...
 
enum class  AxisMask : uint8_t {
  AxisMask::All = 0x07 , AxisMask::ZOnly = 0x04 , AxisMask::X = 0x01 , AxisMask::Y = 0x02 ,
  AxisMask::XY = 0x03 , AxisMask::XZ = 0x05 , AxisMask::YZ = 0x06
}
 Axes of a tare (RM S6.4.3.1): 0x07 all axes, 0x04 Z only. More...
 
enum class  MotionIntent : uint8_t {
  MotionIntent::Unknown = 0 , MotionIntent::StationaryNoVibration = 1 , MotionIntent::StationaryWithVibration = 2 , MotionIntent::InMotion = 3 ,
  MotionIntent::InMotionAccelerating = 4
}
 The motion intent of the interactive calibration (RM S6.4.12.1; BNO086). More...
 
enum class  SimpleCalStatus : uint8_t {
  SimpleCalStatus::Ok = 0 , SimpleCalStatus::NoGyroOffset = 1 , SimpleCalStatus::NoStationary = 2 , SimpleCalStatus::RotationOutOfSpec = 3 ,
  SimpleCalStatus::GyroOffsetOutOfSpec = 4 , SimpleCalStatus::AccelOffset = 5 , SimpleCalStatus::GyroGain = 6 , SimpleCalStatus::GyroPeriod = 7 ,
  SimpleCalStatus::GyroSampleDrops = 8
}
 Result of the simple calibration finish (RM S6.4.10.2, R1). More...
 

Functions

constexpr EulerCentiDeg ToEulerCentiDeg (int32_t i, int32_t j, int32_t k, int32_t real) noexcept
 Euler angles from a Q14 unit quaternion, with integer arithmetic only.
 
constexpr Config KconfigDefaults () noexcept
 The configuration menuconfig selected, on top of the driver defaults.
 
constexpr std::array< uint32_t, kOrientationWords > EncodeOrientation (const Quat30 &q) noexcept
 Words of an orientation record (x, y, z, w; RM S4.1).
 
constexpr Quat30 DecodeOrientation (const std::array< uint32_t, kOrientationWords > &w) noexcept
 The quaternion of an orientation record.
 
constexpr std::array< uint32_t, kPowerMgmtWords > EncodePowerManagement (const PowerManagement &p) noexcept
 Words of record 0xD3E2.
 
constexpr PowerManagement DecodePowerManagement (const std::array< uint32_t, kPowerMgmtWords > &w) noexcept
 The record 0xD3E2 of its words.
 
constexpr std::array< uint32_t, kArvrWords > EncodeArvr (const ArvrStabilization &a) noexcept
 Words of an AR/VR stabilisation record.
 
constexpr ArvrStabilization DecodeArvr (const std::array< uint32_t, kArvrWords > &w) noexcept
 The AR/VR record of its words.
 
constexpr std::array< uint32_t, kSigMotionWords > EncodeSignificantMotion (const SignificantMotionConfig &s) noexcept
 Words of record 0xC274.
 
constexpr SignificantMotionConfig DecodeSignificantMotion (const std::array< uint32_t, kSigMotionWords > &w) noexcept
 The record 0xC274 of its words.
 
constexpr std::array< uint32_t, kShakeWords > EncodeShake (const ShakeConfig &s) noexcept
 Words of record 0x7D7D (the enable word has bit 0 X, bit 1 Y, bit 2 Z).
 
constexpr ShakeConfig DecodeShake (const std::array< uint32_t, kShakeWords > &w) noexcept
 The record 0x7D7D of its words.
 
constexpr std::array< uint32_t, kEnvCalWords > EncodeEnvCalibration (const EnvCalibration &e) noexcept
 Words of an environmental calibration record.
 
constexpr EnvCalibration DecodeEnvCalibration (const std::array< uint32_t, kEnvCalWords > &w) noexcept
 The environmental calibration of its words.
 
constexpr std::array< uint32_t, kGyroRvConfigWords > EncodeGyroRvConfig (const GyroRvConfig &g) noexcept
 Words of record 0xA1A2.
 
constexpr GyroRvConfig DecodeGyroRvConfig (const std::array< uint32_t, kGyroRvConfigWords > &w) noexcept
 The record 0xA1A2 of its words.
 
constexpr Quat30 MountingQuaternion (std::size_t row) noexcept
 The mapping quaternion of row row of DS Figure 4-3 (p41), the system orientation for a device mounted with the listed physical axes aligned to East, North, Up.
 
constexpr uint8_t QPoint (SensorId id) noexcept
 The Q point of the first value of a sensor's event (0 when not fixed point).
 
constexpr uint16_t MetadataRecord (SensorId id) noexcept
 The metadata record that describes a sensor (RM Figure 27).
 
constexpr const char * SensorName (SensorId id) noexcept
 The name of a sensor.
 
constexpr bool InDatasheet (SensorId id) noexcept
 Whether the data sheet itself describes the sensor ("D" in the coverage matrix); the others come from the reference manual only and may not exist on a given chip (ambiguity A31).
 
constexpr bool IsRawSensor (SensorId id) noexcept
 Whether the sensor delivers raw ADC data (it needs its base sensor enabled, DS p30).
 
constexpr const char * ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr bool ToSensorId (uint8_t raw, SensorId &out) noexcept
 Whether raw is one of the sensor IDs of SensorId, and if so which.
 
constexpr int32_t ToMmPerS2 (int32_t q8) noexcept
 A Q8 acceleration (m/s2) in millimetres per second squared.
 
constexpr int32_t ToMilliRadPerS (int32_t q9) noexcept
 A Q9 angular rate (rad/s) in milliradians per second.
 
constexpr int32_t ToNanoTesla (int32_t q4) noexcept
 A Q4 magnetic field (uT) in nanotesla.
 
constexpr int32_t ToMicroRad (int32_t q12) noexcept
 A Q12 angle (rad), such as a rotation vector's accuracy, in microradians.
 
constexpr int32_t ToPpm (int32_t q14) noexcept
 A Q14 quaternion component in parts per million of unity.
 
constexpr const char * GetDriverVersion () noexcept
 
constexpr uint32_t GetDriverVersionMajor () noexcept
 
constexpr uint32_t GetDriverVersionMinor () noexcept
 
constexpr uint32_t GetDriverVersionPatch () noexcept
 

Variables

template<typename Port >
constexpr Transport kTransportOf = Port::kTransport
 The transport a port names (used in constraints before the class is complete).
 
constexpr std::size_t kOrientationWords = 4
 Words of each typed record.
 
constexpr std::size_t kPowerMgmtWords = 3
 Record 0xD3E2.
 
constexpr std::size_t kArvrWords = 4
 Records 0x3E2D and 0x3E2E.
 
constexpr std::size_t kSigMotionWords = 2
 Record 0xC274.
 
constexpr std::size_t kShakeWords = 5
 Record 0x7D7D.
 
constexpr std::size_t kEnvCalWords = 2
 Environmental calibration records.
 
constexpr std::size_t kGyroRvConfigWords = 7
 Record 0xA1A2.
 
constexpr std::size_t kMountingCount = 24
 Number of mounting rows in DS Figure 4-3.
 
constexpr std::size_t kSensorSlots = 0x2F
 Number of slots of the per-sensor tables: sensor IDs 0x01 to 0x2E.
 
constexpr std::size_t kEventValues = 16
 Number of values an Event carries.
 
constexpr std::size_t kFrsMaxWords = 128
 Largest FRS record the driver reads or writes, in 32-bit words (Kconfig-free constant).
 

Detailed Description

The BNO08x driver: everything it declares lives here; internals in detail.

Enumeration Type Documentation

◆ CalStep

enum class bno08x::CalStep : uint8_t
strong

Steps of the calibration procedure (CAL 1000-4044, DS S3.1).

Enumerator
EnableSensors 

Enable accelerometer and magnetometer calibration; Game Rotation Vector and Magnetic Field at 50 Hz or faster.

MovePoses 

Move the device through 4 to 6 orientations, about 1 s each.

SetDown 

Set the device down for 2 to 3 s so the gyroscope calibrates.

RotateAxes 

Rotate about 180 degrees around each axis, about 2 s each.

WaitAccuracy 

Wait until the magnetometer accuracy reads medium or high.

Save 

Save the DCD.

Done 

The calibration is stored.

Function Documentation

◆ DecodeArvr()

constexpr ArvrStabilization bno08x::DecodeArvr ( const std::array< uint32_t, kArvrWords > &  w)
constexprnoexcept

The AR/VR record of its words.

Parameters
wThe words.
Returns
The record.

◆ DecodeEnvCalibration()

constexpr EnvCalibration bno08x::DecodeEnvCalibration ( const std::array< uint32_t, kEnvCalWords > &  w)
constexprnoexcept

The environmental calibration of its words.

Parameters
wThe words.
Returns
The record.

◆ DecodeGyroRvConfig()

constexpr GyroRvConfig bno08x::DecodeGyroRvConfig ( const std::array< uint32_t, kGyroRvConfigWords > &  w)
constexprnoexcept

The record 0xA1A2 of its words.

Parameters
wThe words.
Returns
The record.

◆ DecodeOrientation()

constexpr Quat30 bno08x::DecodeOrientation ( const std::array< uint32_t, kOrientationWords > &  w)
constexprnoexcept

The quaternion of an orientation record.

Parameters
wThe words.
Returns
The quaternion.

◆ DecodePowerManagement()

constexpr PowerManagement bno08x::DecodePowerManagement ( const std::array< uint32_t, kPowerMgmtWords > &  w)
constexprnoexcept

The record 0xD3E2 of its words.

Parameters
wThe words.
Returns
The record.

◆ DecodeShake()

constexpr ShakeConfig bno08x::DecodeShake ( const std::array< uint32_t, kShakeWords > &  w)
constexprnoexcept

The record 0x7D7D of its words.

Parameters
wThe words.
Returns
The record.

◆ DecodeSignificantMotion()

constexpr SignificantMotionConfig bno08x::DecodeSignificantMotion ( const std::array< uint32_t, kSigMotionWords > &  w)
constexprnoexcept

The record 0xC274 of its words.

Parameters
wThe words.
Returns
The record.

◆ EncodeArvr()

constexpr std::array< uint32_t, kArvrWords > bno08x::EncodeArvr ( const ArvrStabilization &  a)
constexprnoexcept

Words of an AR/VR stabilisation record.

Parameters
aThe record.
Returns
The words.

◆ EncodeEnvCalibration()

constexpr std::array< uint32_t, kEnvCalWords > bno08x::EncodeEnvCalibration ( const EnvCalibration &  e)
constexprnoexcept

Words of an environmental calibration record.

Parameters
eThe record.
Returns
The words.

◆ EncodeGyroRvConfig()

constexpr std::array< uint32_t, kGyroRvConfigWords > bno08x::EncodeGyroRvConfig ( const GyroRvConfig &  g)
constexprnoexcept

Words of record 0xA1A2.

Parameters
gThe record.
Returns
The words.

◆ EncodeOrientation()

constexpr std::array< uint32_t, kOrientationWords > bno08x::EncodeOrientation ( const Quat30 &  q)
constexprnoexcept

Words of an orientation record (x, y, z, w; RM S4.1).

Parameters
qThe quaternion.
Returns
The words.

◆ EncodePowerManagement()

constexpr std::array< uint32_t, kPowerMgmtWords > bno08x::EncodePowerManagement ( const PowerManagement &  p)
constexprnoexcept

Words of record 0xD3E2.

Parameters
pThe record.
Returns
The words.

◆ EncodeShake()

constexpr std::array< uint32_t, kShakeWords > bno08x::EncodeShake ( const ShakeConfig &  s)
constexprnoexcept

Words of record 0x7D7D (the enable word has bit 0 X, bit 1 Y, bit 2 Z).

Parameters
sThe record.
Returns
The words.

◆ EncodeSignificantMotion()

constexpr std::array< uint32_t, kSigMotionWords > bno08x::EncodeSignificantMotion ( const SignificantMotionConfig &  s)
constexprnoexcept

Words of record 0xC274.

Parameters
sThe record.
Returns
The words.

◆ InDatasheet()

constexpr bool bno08x::InDatasheet ( SensorId  id)
constexprnoexcept

Whether the data sheet itself describes the sensor ("D" in the coverage matrix); the others come from the reference manual only and may not exist on a given chip (ambiguity A31).

Parameters
idThe sensor.
Returns
true when the BNO080/085/086 data sheet lists the sensor.

◆ IsRawSensor()

constexpr bool bno08x::IsRawSensor ( SensorId  id)
constexprnoexcept

Whether the sensor delivers raw ADC data (it needs its base sensor enabled, DS p30).

Parameters
idThe sensor.
Returns
true for the raw accelerometer, gyroscope and magnetometer.

◆ KconfigDefaults()

constexpr Config bno08x::KconfigDefaults ( )
constexprnoexcept

The configuration menuconfig selected, on top of the driver defaults.

Returns
Config{} with the chip variant, the I2C address, the two timeouts and the strictness options taken from Kconfig.

◆ MetadataRecord()

constexpr uint16_t bno08x::MetadataRecord ( SensorId  id)
constexprnoexcept

The metadata record that describes a sensor (RM Figure 27).

Parameters
idThe sensor.
Returns
The FRS record ID 0xE301 to 0xE325, or 0 for a sensor that has none.

◆ MountingQuaternion()

constexpr Quat30 bno08x::MountingQuaternion ( std::size_t  row)
constexprnoexcept

The mapping quaternion of row row of DS Figure 4-3 (p41), the system orientation for a device mounted with the listed physical axes aligned to East, North, Up.

Parameters
row0 to 23: East-North-Up first, as the data sheet lists them.
Returns
The quaternion in Q30; all zero for a row out of range.

◆ QPoint()

constexpr uint8_t bno08x::QPoint ( SensorId  id)
constexprnoexcept

The Q point of the first value of a sensor's event (0 when not fixed point).

Parameters
idThe sensor.
Returns
Fractional bits of Event::v[0].

◆ SensorName()

constexpr const char * bno08x::SensorName ( SensorId  id)
constexprnoexcept

The name of a sensor.

Parameters
idThe sensor.
Returns
A static string such as "RotationVector".

◆ ToEulerCentiDeg()

constexpr EulerCentiDeg bno08x::ToEulerCentiDeg ( int32_t  i,
int32_t  j,
int32_t  k,
int32_t  real 
)
constexprnoexcept

Euler angles from a Q14 unit quaternion, with integer arithmetic only.

Parameters
iQuaternion i (x) component, Q14.
jQuaternion j (y) component, Q14.
kQuaternion k (z) component, Q14.
realQuaternion real (w) component, Q14.
Returns
Yaw, pitch and roll in centidegrees (accurate to a few centidegrees).

Variable Documentation

◆ kOrientationWords

constexpr std::size_t bno08x::kOrientationWords = 4
inlineconstexpr

Words of each typed record.

Orientation records.