BNO08X Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
Driver types

Errors, results, configuration, events and unit helpers. More...

Classes

struct  bno08x::Result< T >
 The value of a call, or why there is none. More...
 
struct  bno08x::Result< void >
 The result of a call that returns no value. More...
 
struct  bno08x::Event
 One thing the driver reports, taken with Bno08x::PopEvent(). More...
 
struct  bno08x::Stats
 Counters of everything the driver dropped, repaired or noticed. Never reset by the driver. More...
 
struct  bno08x::FeatureConfig
 The common feature report of one sensor (RM S6.5.2). More...
 
struct  bno08x::ProductId
 Product ID response (RM S6.3.2). More...
 
struct  bno08x::Metadata
 Sensor metadata record (RM Figures 28 and 29, record IDs 0xE301 to 0xE325). More...
 
struct  bno08x::FrsBuffer
 A caller-owned buffer for ReadFrs(); it must outlive the operation. More...
 
struct  bno08x::MeCal
 The motion engine's calibration enables (RM S6.4.6). More...
 
struct  bno08x::Quat14
 A quaternion in Q14 (RM S6.4.3.3): the set-reorientation argument. More...
 
struct  bno08x::WheelSample
 One wheel measurement for dead reckoning (RM S6.4.13). More...
 
struct  bno08x::RvcFrame
 A decoded UART-RVC frame (DS p21). More...
 
struct  bno08x::Config
 The configuration of a session. Config{} is the recommended setup for a BNO085. More...
 

Typedefs

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

Enumerations

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

Functions

constexpr const char * bno08x::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr bool bno08x::ToSensorId (uint8_t raw, SensorId &out) noexcept
 Whether raw is one of the sensor IDs of SensorId, and if so which.
 

Variables

constexpr std::size_t bno08x::kSensorSlots = 0x2F
 Number of slots of the per-sensor tables: sensor IDs 0x01 to 0x2E.
 
constexpr std::size_t bno08x::kEventValues = 16
 Number of values an Event carries.
 
constexpr std::size_t bno08x::kFrsMaxWords = 128
 Largest FRS record the driver reads or writes, in 32-bit words (Kconfig-free constant).
 

Detailed Description

Errors, results, configuration, events and unit helpers.

Enumeration Type Documentation

◆ Accuracy

enum class bno08x::Accuracy : uint8_t
strong

Accuracy of a sensor sample (status bits 1:0 of every input report, RM S6.5.1).

Enumerator
Unreliable 

Unreliable.

Low 

Low accuracy.

Medium 

Medium accuracy.

High 

High accuracy.

◆ AxisMask

enum class bno08x::AxisMask : uint8_t
strong

Axes of a tare (RM S6.4.3.1): 0x07 all axes, 0x04 Z only.

Enumerator
All 

X, Y and Z: reorients every motion output.

ZOnly 

Z only: changes the heading, not the tilt.

X 

X only; refused unless Config::tare_any_mask is set.

Y 

Y only; refused unless Config::tare_any_mask is set.

XY 

X and Y; refused unless Config::tare_any_mask is set.

XZ 

X and Z; refused unless Config::tare_any_mask is set.

YZ 

Y and Z; refused unless Config::tare_any_mask is set.

◆ Error

enum class bno08x::Error : uint8_t
strong

Why a call failed. Every call of the driver returns one of these in its Result.

Values 0 to 9 are the shared base set; chip-specific values start at 16. DeviceIdMismatch and Crc exist for the shared base set only: this chip has no ID register to check and its links carry no CRC, so the driver never returns them.

Enumerator
Ok 

The call succeeded.

NotInitialized 

Begin() has not been called, or the session faulted.

InvalidArgument 

An argument or a Config field is out of range; nothing was sent.

Bus 

A port hook returned false.

Timeout 

The hub did not answer in the allowed time.

DeviceIdMismatch 

Base value; never returned (the BNO08x has no ID register).

Crc 

Base value; never returned (no link of this chip carries a CRC).

Busy 

The operation queue is full, or a transmit is still pending.

DeviceFault 

The hub reported a failure inside a response (a status or error code).

Unsupported 

The hook or silicon feature this call needs is absent.

Framing 

A frame rule was broken and the engine resynchronised.

HubReset 

The hub restarted; the operation was abandoned.

Overflow 

The event queue or a cargo buffer was full.

Refused 

The hub answered with a failure status (for example an FRS status).

Oversize 

A request does not fit one write transfer; nothing was sent.

NotAdvertised 

The channel or report was never advertised by the hub.

Variant 

The feature is not available on the configured chip.

◆ EventKind

enum class bno08x::EventKind : uint8_t
strong

What an Event reports.

Enumerator
Sensor 

A sensor sample: sensor, accuracy, t_us and the values v.

OpDone 

An operation finished: op, error, detail and the response bytes in v.

FeatureChanged 

The hub sent a feature response nobody asked for (a rate change).

Reset 

The hub restarted; detail is the reset cause when known.

FlushDone 

A flush completed for sensor.

HubError 

The SHTP error list: detail is the first code, v all of them.

Dropped 

Events were lost to a full queue: detail is how many.

Rvc 

A UART-RVC frame: v holds the RvcFrame fields in order (index, yaw, pitch, roll, ax, ay, az, mi, mr, mi_mr_valid).

Sh2Error 

An SH-2 error queue entry: v[0..5] severity, error sequence, source, error, module, code.

◆ LogLevel

enum class bno08x::LogLevel : uint8_t
strong

Severity passed to the optional Log() hook.

Enumerator
Error 

A call failed.

Warning 

Something unexpected that the driver recovered from.

Info 

Lifecycle events: session ready, hub reset.

Debug 

Detail for bring-up.

◆ MotionIntent

enum class bno08x::MotionIntent : uint8_t
strong

The motion intent of the interactive calibration (RM S6.4.12.1; BNO086).

Enumerator
Unknown 

Unknown.

StationaryNoVibration 

Stationary without vibration.

StationaryWithVibration 

Stationary with vibration.

InMotion 

In motion.

InMotionAccelerating 

In motion and accelerating.

◆ ReadPolicy

enum class bno08x::ReadPolicy : uint8_t
strong

How an I2C or SPI read sizes its transfers.

Enumerator
HeaderThenRest 

Read the 4-byte header, then exactly the rest as a continuation (default).

Fixed 

Read Config::fixed_read_bytes per transfer; the hub zero-pads.

◆ SensorId

enum class bno08x::SensorId : uint8_t
strong

Every sensor report ID any CEVA document defines (RM S6.5; matrix section 1.8 of the design).

Enumerator
Accelerometer 

Accelerometer, Q8 m/s2.

GyroscopeCalibrated 

Calibrated gyroscope, Q9 rad/s.

MagneticFieldCalibrated 

Calibrated magnetic field, Q4 uT.

LinearAcceleration 

Linear acceleration, Q8 m/s2.

RotationVector 

Rotation vector, Q14, accuracy Q12 rad.

Gravity 

Gravity, Q8 m/s2.

GyroscopeUncalibrated 

Uncalibrated gyroscope with bias, Q9 rad/s.

GameRotationVector 

Game rotation vector, Q14.

GeomagneticRotationVector 

Geomagnetic rotation vector, Q14, accuracy Q12 rad.

Pressure 

Pressure, Q20 hPa (needs the environmental sensor).

AmbientLight 

Ambient light, Q8 lux (needs the environmental sensor).

Humidity 

Relative humidity, Q8 percent (environmental sensor).

Proximity 

Proximity, Q4 cm (environmental sensor).

Temperature 

Temperature, Q7 degrees C (environmental sensor).

MagneticFieldUncalibrated 

Uncalibrated magnetic field with hard-iron bias, Q4 uT.

TapDetector 

Tap detector flags.

StepCounter 

Step counter: latency and 16-bit step count.

SignificantMotion 

Significant motion.

StabilityClassifier 

Stability classifier enumeration.

RawAccelerometer 

Raw accelerometer ADC counts with hub timestamp.

RawGyroscope 

Raw gyroscope ADC counts, temperature and hub timestamp.

RawMagnetometer 

Raw magnetometer ADC counts with hub timestamp.

StepDetector 

Step detector latency.

ShakeDetector 

Shake detector axis bits.

FlipDetector 

Flip detector (manual only).

PickupDetector 

Pickup detector (manual only).

StabilityDetector 

Stability detector bits.

PersonalActivityClassifier 

Personal activity classifier with 10 confidences.

SleepDetector 

Sleep detector (manual only).

TiltDetector 

Tilt detector (manual only).

PocketDetector 

Pocket detector (manual only).

CircleDetector 

Circle detector (manual only).

HeartRateMonitor 

Heart rate monitor (manual only).

ArvrRotationVector 

AR/VR stabilised rotation vector.

ArvrGameRotationVector 

AR/VR stabilised game rotation vector.

GyroIntegratedRotationVector 

Gyro-integrated rotation vector (channel 5, no report ID).

MotionRequest 

Motion request of the interactive calibration (BNO086).

OpticalFlow 

Optical flow (manual only; several fields undocumented).

DeadReckoningPose 

Dead reckoning pose (manual only).

WheelEncoder 

Wheel encoder input: named by one library only, no layout.

◆ SimpleCalStatus

enum class bno08x::SimpleCalStatus : uint8_t
strong

Result of the simple calibration finish (RM S6.4.10.2, R1).

Enumerator
Ok 

Calibration succeeded.

NoGyroOffset 

No gyro offset found.

NoStationary 

No stationary detection.

RotationOutOfSpec 

Rotation out of specification.

GyroOffsetOutOfSpec 

Gyro offset out of specification.

AccelOffset 

Accelerometer offset out of specification.

GyroGain 

Gyro gain out of specification.

GyroPeriod 

Gyro period out of specification.

GyroSampleDrops 

Gyro sample drops.

◆ State

enum class bno08x::State : uint8_t
strong

State of the session.

Enumerator
Idle 

Before Begin().

Resetting 

The reset sequence runs; the hub needs t1 + t2 (DS p47).

WaitAdvert 

Waiting for the SHTP advertisement.

WaitReady 

Advertisement seen; waiting for reset-complete and the initialise response.

Ready 

Operations and events flow.

Faulted 

A start-up step timed out; only Begin() leaves this state.

◆ TareBasis

enum class bno08x::TareBasis : uint8_t
strong

The rotation vector a tare is based on (RM S6.4.3.1, P2).

Enumerator
RotationVector 

Rotation vector: reorients every motion output.

GameRotationVector 

Game rotation vector: reorients only that vector; not persistent.

GeomagneticRotationVector 

Geomagnetic rotation vector: reorients every motion output.

GyroIntegrated 

Gyro-integrated rotation vector (tares its underlying vector).

ArvrRotationVector 

AR/VR stabilised rotation vector (tares its underlying vector).

ArvrGameRotationVector 

AR/VR stabilised game rotation vector (tares its underlying vector).

◆ Transport

enum class bno08x::Transport : uint8_t
strong

How the host reaches the hub (strapped by PS1 and PS0 at reset, DS p9 Figure 1-5).

Enumerator
I2c 

PS1 = 0, PS0 = 0: SHTP over I2C.

Spi 

PS1 = 1, PS0 = 1: SHTP over SPI with H_INTN and WAKE.

UartShtp 

PS1 = 1, PS0 = 0: SHTP over UART (3 Mbit/s, framed).

UartRvc 

PS1 = 0, PS0 = 1: the stand-alone UART-RVC frames (115200 baud).

◆ Variant

enum class bno08x::Variant : uint8_t
strong

The chip of the family the driver talks to. It selects behaviour; it is never detected.

Enumerator
Bno080 

BNO080 (end of life): the base MotionEngine.

Bno085 

BNO085: enhanced fusion; I2C polling stretches the clock.

Bno086 

BNO086: interactive calibration, RVC MI/MR bytes, zero-length I2C packets.

Function Documentation

◆ ToSensorId()

constexpr bool bno08x::ToSensorId ( uint8_t  raw,
SensorId &  out 
)
constexprnoexcept

Whether raw is one of the sensor IDs of SensorId, and if so which.

Parameters
rawA report ID.
[out]outThe sensor, set only when the function returns true.
Returns
true for an ID of SensorId.

◆ ToString()

constexpr const char * bno08x::ToString ( Error  error)
constexprnoexcept

The name of an error, for logs.

Parameters
errorThe error.
Returns
A static string such as "Timeout"; "Unknown" for a value that is not an enumerator.