BNO08X Driver 0.1.0
API reference
Loading...
Searching...
No Matches
bno08x_types.hpp
Go to the documentation of this file.
1
13#ifndef BNO08X_TYPES_HPP
14#define BNO08X_TYPES_HPP
15
16#include <array>
17#include <cstddef>
18#include <cstdint>
19
20#include "bno08x_detail.hpp"
21#include "bno08x_registers.hpp"
22#include "bno08x_version.h"
23
25namespace bno08x {
26
40enum class [[nodiscard]] Error : uint8_t {
41 Ok = 0,
42 NotInitialized = 1,
43 InvalidArgument = 2,
44 Bus = 3,
45 Timeout = 4,
47 Crc = 6,
48 Busy = 7,
49 DeviceFault = 8,
50 Unsupported = 9,
51 Framing = 16,
52 HubReset = 17,
53 Overflow = 18,
54 Refused = 19,
55 Oversize = 20,
56 NotAdvertised = 21,
57 Variant = 22,
58};
59
60namespace detail {
61
63inline constexpr std::array<const char*, 23> kErrorNames{
64 "Ok", "NotInitialized", "InvalidArgument", "Bus", "Timeout", "DeviceIdMismatch",
65 "Crc", "Busy", "DeviceFault", "Unsupported", nullptr, nullptr,
66 nullptr, nullptr, nullptr, nullptr, "Framing", "HubReset",
67 "Overflow", "Refused", "Oversize", "NotAdvertised", "Variant"};
68
69} // namespace detail
70
76constexpr const char* ToString(Error error) noexcept {
77 const auto index = static_cast<std::size_t>(detail::ToUnderlying(error));
78 if (index < detail::kErrorNames.size()) {
79 const char* name = detail::kErrorNames[index];
80 if (name != nullptr) {
81 return name;
82 }
83 }
84 return "Unknown";
85}
86
94template <typename T>
95struct [[nodiscard]] Result {
96 T value{};
97 Error error{Error::Ok};
98
100 [[nodiscard]] constexpr bool ok() const noexcept {
101 return error == Error::Ok;
102 }
104 constexpr explicit operator bool() const noexcept {
105 return ok();
106 }
112 static constexpr Result Success(T v) noexcept {
113 return {v, Error::Ok};
114 }
120 static constexpr Result Failure(Error e) noexcept {
121 Result r{};
122 r.error = e;
123 return r;
124 }
125};
126
128template <>
129struct [[nodiscard]] Result<void> {
130 Error error{Error::Ok};
131
133 [[nodiscard]] constexpr bool ok() const noexcept {
134 return error == Error::Ok;
135 }
137 constexpr explicit operator bool() const noexcept {
138 return ok();
139 }
141 static constexpr Result Success() noexcept {
142 return {Error::Ok};
143 }
149 static constexpr Result Failure(Error e) noexcept {
150 return {e};
151 }
152};
153
155enum class LogLevel : uint8_t {
156 Error = 0,
157 Warning,
158 Info,
159 Debug,
160};
161
163enum class Transport : uint8_t {
164 I2c = 0,
165 Spi = 1,
166 UartShtp = 2,
167 UartRvc = 3,
168};
169
172enum class Variant : uint8_t {
173 Bno080 = 0,
174 Bno085 = 1,
175 Bno086 = 2,
176};
177
179enum class ReadPolicy : uint8_t {
181 0,
182 Fixed = 1,
183};
184
186enum class State : uint8_t {
187 Idle = 0,
188 Resetting = 1,
189 WaitAdvert = 2,
190 WaitReady = 3,
191 Ready = 4,
192 Faulted = 5,
193};
194
196enum class Accuracy : uint8_t {
197 Unreliable = 0,
198 Low = 1,
199 Medium = 2,
200 High = 3,
201};
202
205enum class SensorId : uint8_t {
206 Accelerometer = 0x01,
207 GyroscopeCalibrated = 0x02,
209 LinearAcceleration = 0x04,
210 RotationVector = 0x05,
211 Gravity = 0x06,
212 GyroscopeUncalibrated = 0x07,
213 GameRotationVector = 0x08,
215 Pressure = 0x0A,
216 AmbientLight = 0x0B,
217 Humidity = 0x0C,
218 Proximity = 0x0D,
219 Temperature = 0x0E,
221 TapDetector = 0x10,
222 StepCounter = 0x11,
223 SignificantMotion = 0x12,
224 StabilityClassifier = 0x13,
225 RawAccelerometer = 0x14,
226 RawGyroscope = 0x15,
227 RawMagnetometer = 0x16,
228 StepDetector = 0x18,
229 ShakeDetector = 0x19,
230 FlipDetector = 0x1A,
231 PickupDetector = 0x1B,
232 StabilityDetector = 0x1C,
234 SleepDetector = 0x1F,
235 TiltDetector = 0x20,
236 PocketDetector = 0x21,
237 CircleDetector = 0x22,
238 HeartRateMonitor = 0x23,
239 ArvrRotationVector = 0x28,
242 0x2A,
243 MotionRequest = 0x2B,
244 OpticalFlow = 0x2C,
245 DeadReckoningPose = 0x2D,
246 WheelEncoder = 0x2E,
247};
248
250inline constexpr std::size_t kSensorSlots = 0x2F;
251
258[[nodiscard]] constexpr bool ToSensorId(uint8_t raw, SensorId& out) noexcept {
259 const auto v = static_cast<uint32_t>(raw);
260 const bool known = ((v >= 0x01U) && (v <= 0x16U)) || ((v >= 0x18U) && (v <= 0x1CU)) ||
261 ((v >= 0x1EU) && (v <= 0x23U)) || ((v >= 0x28U) && (v <= 0x2EU));
262 if (known) {
263 out = static_cast<SensorId>(raw);
264 }
265 return known;
266}
267
269enum class EventKind : uint8_t {
270 Sensor = 0,
271 OpDone = 1,
272 FeatureChanged = 2,
273 Reset = 3,
274 FlushDone = 4,
275 HubError = 5,
276 Dropped = 6,
277 Rvc = 7,
279 Sh2Error = 8,
281};
282
285using OpId = uint16_t;
286
288inline constexpr std::size_t kEventValues = 16;
289
298struct Event {
302 bool wake{false};
303 uint8_t report_seq{0};
304 OpId op{0};
306 uint32_t t_us{0};
307 uint32_t hub_t_us{0};
308 uint32_t detail{0};
309 std::array<int32_t, kEventValues> v{};
310};
311
314struct Stats {
315 uint32_t short_transfer{0};
316 uint32_t length_ffff{0};
317 uint32_t null_header{0};
318 uint32_t length_short{0};
319 uint32_t oversize_cargo{0};
320 uint32_t bad_channel{0};
321 uint32_t lost_cargo{0};
322 uint32_t orphan_cont{0};
323 uint32_t bad_cont_len{0};
324 uint32_t dup_seq{0};
325 uint32_t seq_gap{0};
326 uint32_t nonzero_pad{0};
327 uint32_t unknown_report{0};
328 uint32_t short_report{0};
329 uint32_t bad_gyrorv{0};
330 uint32_t early_cargo{0};
331 uint32_t bad_advert{0};
332 uint32_t bad_protocol_id{0};
333 uint32_t bad_escape{0};
334 uint32_t oversize_frame{0};
335 uint32_t base_overflow{0};
336 uint32_t bsq_retries{0};
337 uint32_t product_id_extra{0};
338 uint32_t frs_foreign{0};
339 uint32_t report_seq_gaps{0};
341 uint32_t resyncs{0};
342 uint32_t hub_resets{0};
343 uint32_t restore_failed{0};
344 uint32_t hub_errors{0};
345 uint32_t bus_errors{0};
346 uint32_t events_dropped{0};
347 uint32_t rvc_frames{0};
348 uint32_t rvc_bad_csum{0};
349 uint32_t rvc_index_gaps{0};
351 0};
352 uint32_t rvc_out_of_range{0};
353 uint32_t rvc_csum_with_mi{0};
355};
356
359 bool relative{false};
360 bool change_enable{false};
361 bool wake{false};
362 bool always_on{false};
364 uint32_t interval_us{0};
365 uint32_t batch_us{0};
366 uint32_t sensor_config{0};
368 friend constexpr bool operator==(const FeatureConfig& lhs,
369 const FeatureConfig& rhs) noexcept = default;
370};
371
373struct ProductId {
374 uint8_t reset_cause{0};
375 uint8_t version_major{0};
376 uint8_t version_minor{0};
377 uint16_t version_patch{0};
378 uint32_t part_number{0};
379 uint32_t build{0};
380 bool valid{false};
381};
382
384struct Metadata {
385 bool valid{false};
386 uint8_t version_me{0};
387 uint8_t version_mh{0};
388 uint8_t version_sh{0};
389 uint32_t range{0};
390 uint32_t resolution{0};
391 uint16_t power_q10{0};
392 uint16_t revision{0};
393 uint32_t min_period_us{0};
394 uint32_t max_period_us{0};
395 uint16_t fifo_max{0};
396 uint16_t fifo_reserved{0};
397 uint16_t batch_bytes{0};
398 uint16_t vendor_id_len{0};
399 uint16_t q1{0};
400 uint16_t q2{0};
401 uint16_t q3{0};
402 uint16_t specific_len{0};
403 std::array<char, 32> vendor_id{};
404 uint32_t activity_classes{0};
405};
406
409inline constexpr std::size_t kFrsMaxWords = 128;
410
412struct FrsBuffer {
413 std::array<uint32_t, kFrsMaxWords> words{};
414 std::size_t length{0};
415 uint8_t last_status{0};
416};
417
419struct MeCal {
420 bool accel{false};
421 bool gyro{false};
422 bool mag{false};
423 bool planar{false};
424 bool on_table{false};
425};
426
428struct Quat14 {
429 int16_t x{0};
430 int16_t y{0};
431 int16_t z{0};
432 int16_t w{0};
433};
434
436enum class TareBasis : uint8_t {
437 RotationVector = 0,
440 GyroIntegrated = 3,
443 5,
444};
445
447enum class AxisMask : uint8_t {
448 All = 0x07,
449 ZOnly = 0x04,
450 X = 0x01,
451 Y = 0x02,
452 XY = 0x03,
453 XZ = 0x05,
454 YZ = 0x06,
455};
456
458enum class MotionIntent : uint8_t {
459 Unknown = 0,
462 InMotion = 3,
464};
465
467enum class SimpleCalStatus : uint8_t {
468 Ok = 0,
469 NoGyroOffset = 1,
470 NoStationary = 2,
473 AccelOffset = 5,
474 GyroGain = 6,
475 GyroPeriod = 7,
476 GyroSampleDrops = 8,
477};
478
481 uint8_t wheel{0};
482 uint32_t timestamp_us{0};
483 uint16_t data{0};
484 bool velocity{false};
485};
486
488struct RvcFrame {
489 uint8_t index{0};
490 int16_t yaw{0};
491 int16_t pitch{0};
492 int16_t roll{0};
493 int16_t ax{0};
494 int16_t ay{0};
495 int16_t az{0};
496 uint8_t mi{0};
497 uint8_t mr{0};
498 bool mi_mr_valid{false};
499};
500
502struct Config {
506 uint16_t fixed_read_bytes{64};
507 bool strict_variant{true};
508 bool auto_restore{true};
509 bool poll_without_int{false};
511 bool frs_verify{true};
513 bool strict_raw{false};
514 bool strict_cont_len{true};
515 bool strict_padding{false};
516 bool tare_any_mask{false};
517 bool rvc_strict{false};
519 uint16_t startup_timeout_ms{500};
520 uint16_t op_timeout_ms{1000};
521 uint16_t frs_write_timeout_ms{5000};
522 uint32_t wake_timeout_us{10000};
523 uint32_t reset_pulse_us{1000};
524 uint16_t advert_retry_ms{100};
526 1000};
527 uint16_t uart_bsq_retry_ms{20};
528 uint16_t poll_interval_ms{10};
529 uint8_t resync_limit{4};
530 uint16_t resync_window_ms{100};
532
538 [[nodiscard]] constexpr bool TimesValid() const noexcept {
539 const bool non_zero = (startup_timeout_ms > 0U) && (op_timeout_ms > 0U) &&
540 (frs_write_timeout_ms > 0U) && (wake_timeout_us > 0U) &&
541 (resync_window_ms > 0U) && (poll_interval_ms > 0U);
542 const bool pulses = (reset_pulse_us > 0U) && (uart_bsq_retry_ms > 0U);
543 const bool order = wake_timeout_us < (static_cast<uint32_t>(op_timeout_ms) * 1000U);
544 return non_zero && pulses && order;
545 }
546
551 [[nodiscard]] constexpr bool Valid() const noexcept {
552 const bool enums =
553 (detail::ToUnderlying(variant) <= detail::ToUnderlying(Variant::Bno086)) &&
554 (detail::ToUnderlying(read_policy) <= detail::ToUnderlying(ReadPolicy::Fixed));
555 const bool sizes = (fixed_read_bytes >= 4U) && (fixed_read_bytes <= 1024U);
556 const bool counts =
557 (resync_limit > 0U) && (product_id_entries >= 1U) && (product_id_entries <= 5U);
558 const bool addr = (i2c_address == reg::kI2cAddrLow) || (i2c_address == reg::kI2cAddrHigh);
559 return enums && sizes && TimesValid() && counts && addr;
560 }
561};
562
576[[nodiscard]] constexpr int32_t ToMmPerS2(int32_t q8) noexcept {
577 return static_cast<int32_t>((static_cast<int64_t>(q8) * 1000) / 256);
578}
584[[nodiscard]] constexpr int32_t ToMilliRadPerS(int32_t q9) noexcept {
585 return static_cast<int32_t>((static_cast<int64_t>(q9) * 1000) / 512);
586}
592[[nodiscard]] constexpr int32_t ToNanoTesla(int32_t q4) noexcept {
593 return static_cast<int32_t>((static_cast<int64_t>(q4) * 1000) / 16);
594}
600[[nodiscard]] constexpr int32_t ToMicroRad(int32_t q12) noexcept {
601 return static_cast<int32_t>((static_cast<int64_t>(q12) * 1'000'000) / 4096);
602}
608[[nodiscard]] constexpr int32_t ToPpm(int32_t q14) noexcept {
609 return static_cast<int32_t>((static_cast<int64_t>(q14) * 1'000'000) / 16384);
610}
611
614 int32_t yaw{0};
615 int32_t pitch{0};
616 int32_t roll{0};
617};
618
620constexpr const char* GetDriverVersion() noexcept {
621 return BNO08X_VERSION_STRING;
622}
624constexpr uint32_t GetDriverVersionMajor() noexcept {
625 return BNO08X_VERSION_MAJOR;
626}
628constexpr uint32_t GetDriverVersionMinor() noexcept {
629 return BNO08X_VERSION_MINOR;
630}
632constexpr uint32_t GetDriverVersionPatch() noexcept {
633 return BNO08X_VERSION_PATCH;
634}
635
638} // namespace bno08x
639
640#endif // BNO08X_TYPES_HPP
Compile-time helpers of the BNO08X driver: typed integer literals, exact hook matching,...
BNO08x protocol constants: SHTP channels, SH-2 report, command and record identifiers,...
constexpr uint8_t kI2cAddrLow
7-bit I2C address with SA0 low (DS p14).
Definition bno08x_registers.hpp:199
constexpr uint8_t kI2cAddrHigh
7-bit I2C address with SA0 high.
Definition bno08x_registers.hpp:200
Variant
The chip of the family the driver talks to. It selects behaviour; it is never detected.
Definition bno08x_types.hpp:172
constexpr std::size_t kFrsMaxWords
Largest FRS record the driver reads or writes, in 32-bit words (Kconfig-free constant).
Definition bno08x_types.hpp:409
ReadPolicy
How an I2C or SPI read sizes its transfers.
Definition bno08x_types.hpp:179
SensorId
Every sensor report ID any CEVA document defines (RM S6.5; matrix section 1.8 of the design).
Definition bno08x_types.hpp:205
LogLevel
Severity passed to the optional Log() hook.
Definition bno08x_types.hpp:155
TareBasis
The rotation vector a tare is based on (RM S6.4.3.1, P2).
Definition bno08x_types.hpp:436
constexpr std::size_t kEventValues
Number of values an Event carries.
Definition bno08x_types.hpp:288
constexpr bool ToSensorId(uint8_t raw, SensorId &out) noexcept
Whether raw is one of the sensor IDs of SensorId, and if so which.
Definition bno08x_types.hpp:258
SimpleCalStatus
Result of the simple calibration finish (RM S6.4.10.2, R1).
Definition bno08x_types.hpp:467
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition bno08x_types.hpp:76
Accuracy
Accuracy of a sensor sample (status bits 1:0 of every input report, RM S6.5.1).
Definition bno08x_types.hpp:196
Transport
How the host reaches the hub (strapped by PS1 and PS0 at reset, DS p9 Figure 1-5).
Definition bno08x_types.hpp:163
constexpr std::size_t kSensorSlots
Number of slots of the per-sensor tables: sensor IDs 0x01 to 0x2E.
Definition bno08x_types.hpp:250
State
State of the session.
Definition bno08x_types.hpp:186
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition bno08x_types.hpp:40
MotionIntent
The motion intent of the interactive calibration (RM S6.4.12.1; BNO086).
Definition bno08x_types.hpp:458
uint16_t OpId
An operation number returned by every call that completes later with an OpDone event.
Definition bno08x_types.hpp:285
AxisMask
Axes of a tare (RM S6.4.3.1): 0x07 all axes, 0x04 Z only.
Definition bno08x_types.hpp:447
EventKind
What an Event reports.
Definition bno08x_types.hpp:269
@ 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.
@ Fixed
Read Config::fixed_read_bytes per transfer; the hub zero-pads.
@ HeaderThenRest
Read the 4-byte header, then exactly the rest as a continuation (default).
@ HeartRateMonitor
Heart rate monitor (manual only).
@ MagneticFieldUncalibrated
Uncalibrated magnetic field with hard-iron bias, Q4 uT.
@ GyroscopeCalibrated
Calibrated gyroscope, Q9 rad/s.
@ GyroIntegratedRotationVector
Gyro-integrated rotation vector (channel 5, no report ID).
@ PersonalActivityClassifier
Personal activity classifier with 10 confidences.
@ StepDetector
Step detector latency.
@ ArvrRotationVector
AR/VR stabilised rotation vector.
@ ShakeDetector
Shake detector axis bits.
@ PickupDetector
Pickup detector (manual only).
@ CircleDetector
Circle detector (manual only).
@ GeomagneticRotationVector
Geomagnetic rotation vector, Q14, accuracy Q12 rad.
@ FlipDetector
Flip detector (manual only).
@ StepCounter
Step counter: latency and 16-bit step count.
@ MotionRequest
Motion request of the interactive calibration (BNO086).
@ Gravity
Gravity, Q8 m/s2.
@ SleepDetector
Sleep detector (manual only).
@ WheelEncoder
Wheel encoder input: named by one library only, no layout.
@ RotationVector
Rotation vector, Q14, accuracy Q12 rad.
@ SignificantMotion
Significant motion.
@ AmbientLight
Ambient light, Q8 lux (needs the environmental sensor).
@ TiltDetector
Tilt detector (manual only).
@ RawMagnetometer
Raw magnetometer ADC counts with hub timestamp.
@ TapDetector
Tap detector flags.
@ Pressure
Pressure, Q20 hPa (needs the environmental sensor).
@ StabilityClassifier
Stability classifier enumeration.
@ Accelerometer
Accelerometer, Q8 m/s2.
@ LinearAcceleration
Linear acceleration, Q8 m/s2.
@ StabilityDetector
Stability detector bits.
@ GameRotationVector
Game rotation vector, Q14.
@ GyroscopeUncalibrated
Uncalibrated gyroscope with bias, Q9 rad/s.
@ OpticalFlow
Optical flow (manual only; several fields undocumented).
@ ArvrGameRotationVector
AR/VR stabilised game rotation vector.
@ RawAccelerometer
Raw accelerometer ADC counts with hub timestamp.
@ Humidity
Relative humidity, Q8 percent (environmental sensor).
@ DeadReckoningPose
Dead reckoning pose (manual only).
@ Temperature
Temperature, Q7 degrees C (environmental sensor).
@ RawGyroscope
Raw gyroscope ADC counts, temperature and hub timestamp.
@ MagneticFieldCalibrated
Calibrated magnetic field, Q4 uT.
@ Proximity
Proximity, Q4 cm (environmental sensor).
@ PocketDetector
Pocket detector (manual only).
@ Warning
Something unexpected that the driver recovered from.
@ Info
Lifecycle events: session ready, hub reset.
@ Debug
Detail for bring-up.
@ GyroIntegrated
Gyro-integrated rotation vector (tares its underlying vector).
@ AccelOffset
Accelerometer offset out of specification.
@ GyroGain
Gyro gain out of specification.
@ NoStationary
No stationary detection.
@ GyroPeriod
Gyro period out of specification.
@ GyroOffsetOutOfSpec
Gyro offset out of specification.
@ GyroSampleDrops
Gyro sample drops.
@ NoGyroOffset
No gyro offset found.
@ RotationOutOfSpec
Rotation out of specification.
@ Low
Low accuracy.
@ High
High accuracy.
@ Medium
Medium accuracy.
@ Unreliable
Unreliable.
@ UartShtp
PS1 = 1, PS0 = 0: SHTP over UART (3 Mbit/s, framed).
@ I2c
PS1 = 0, PS0 = 0: SHTP over I2C.
@ Spi
PS1 = 1, PS0 = 1: SHTP over SPI with H_INTN and WAKE.
@ UartRvc
PS1 = 0, PS0 = 1: the stand-alone UART-RVC frames (115200 baud).
@ WaitReady
Advertisement seen; waiting for reset-complete and the initialise response.
@ Faulted
A start-up step timed out; only Begin() leaves this state.
@ WaitAdvert
Waiting for the SHTP advertisement.
@ Resetting
The reset sequence runs; the hub needs t1 + t2 (DS p47).
@ Idle
Before Begin().
@ Ready
Operations and events flow.
@ HubReset
The hub restarted; the operation was abandoned.
@ Overflow
The event queue or a cargo buffer was full.
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ Framing
A frame rule was broken and the engine resynchronised.
@ DeviceIdMismatch
Base value; never returned (the BNO08x has no ID register).
@ Crc
Base value; never returned (no link of this chip carries a CRC).
@ Oversize
A request does not fit one write transfer; nothing was sent.
@ Bus
A port hook returned false.
@ DeviceFault
The hub reported a failure inside a response (a status or error code).
@ NotInitialized
Begin() has not been called, or the session faulted.
@ Ok
The call succeeded.
@ Unsupported
The hook or silicon feature this call needs is absent.
@ Timeout
The hub did not answer in the allowed time.
@ Busy
The operation queue is full, or a transmit is still pending.
@ NotAdvertised
The channel or report was never advertised by the hub.
@ Refused
The hub answered with a failure status (for example an FRS status).
@ StationaryWithVibration
Stationary with vibration.
@ StationaryNoVibration
Stationary without vibration.
@ InMotionAccelerating
In motion and accelerating.
@ InMotion
In motion.
@ X
X only; refused unless Config::tare_any_mask is set.
@ ZOnly
Z only: changes the heading, not the tilt.
@ XZ
X and Z; 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.
@ All
X, Y and Z: reorients every motion output.
@ YZ
Y and Z; refused unless Config::tare_any_mask is set.
@ Sensor
A sensor sample: sensor, accuracy, t_us and the values v.
@ HubError
The SHTP error list: detail is the first code, v all of them.
@ FlushDone
A flush completed for sensor.
@ Reset
The hub restarted; detail is the reset cause when known.
@ Dropped
Events were lost to a full queue: detail is how many.
@ 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).
constexpr int32_t ToMicroRad(int32_t q12) noexcept
A Q12 angle (rad), such as a rotation vector's accuracy, in microradians.
Definition bno08x_types.hpp:600
constexpr int32_t ToPpm(int32_t q14) noexcept
A Q14 quaternion component in parts per million of unity.
Definition bno08x_types.hpp:608
constexpr uint32_t GetDriverVersionMinor() noexcept
Definition bno08x_types.hpp:628
constexpr int32_t ToMilliRadPerS(int32_t q9) noexcept
A Q9 angular rate (rad/s) in milliradians per second.
Definition bno08x_types.hpp:584
constexpr uint32_t GetDriverVersionPatch() noexcept
Definition bno08x_types.hpp:632
constexpr const char * GetDriverVersion() noexcept
Definition bno08x_types.hpp:620
constexpr uint32_t GetDriverVersionMajor() noexcept
Definition bno08x_types.hpp:624
constexpr int32_t ToNanoTesla(int32_t q4) noexcept
A Q4 magnetic field (uT) in nanotesla.
Definition bno08x_types.hpp:592
constexpr int32_t ToMmPerS2(int32_t q8) noexcept
A Q8 acceleration (m/s2) in millimetres per second squared.
Definition bno08x_types.hpp:576
The BNO08x driver: everything it declares lives here; internals in detail.
Definition bno08x.hpp:36
The configuration of a session. Config{} is the recommended setup for a BNO085.
Definition bno08x_types.hpp:502
bool rvc_strict
UART-RVC: also require the index to increment by one.
Definition bno08x_types.hpp:517
Variant variant
Chip of the family; selects behaviour.
Definition bno08x_types.hpp:503
uint16_t poll_interval_ms
poll_without_int: read cadence.
Definition bno08x_types.hpp:528
uint16_t uart_token_timeout_ms
UART-SHTP: BSN validity when the hub did not advertise one.
Definition bno08x_types.hpp:525
uint16_t resync_window_ms
The window of resync_limit.
Definition bno08x_types.hpp:530
uint32_t wake_timeout_us
SPI: limit for H_INTN after WAKE.
Definition bno08x_types.hpp:522
uint8_t resync_limit
Violations within the window that force a recovery.
Definition bno08x_types.hpp:529
bool strict_padding
Count non-zero padding bytes.
Definition bno08x_types.hpp:515
uint8_t product_id_entries
Product ID responses accepted (1, up to 5).
Definition bno08x_types.hpp:531
bool tare_any_mask
Allow tare axis masks other than 0x07 and 0x04.
Definition bno08x_types.hpp:516
bool strict_cont_len
Require continuation length = remaining + 4.
Definition bno08x_types.hpp:514
bool poll_without_int
Guarded: read on a cadence, ignoring H_INTN (I2C only).
Definition bno08x_types.hpp:509
uint16_t fixed_read_bytes
Bytes per read for ReadPolicy::Fixed (header included).
Definition bno08x_types.hpp:506
bool set_feature_confirm
Complete SetFeature on the hub's reply, not when written.
Definition bno08x_types.hpp:512
uint16_t startup_timeout_ms
Limit for each start-up wait (advertisement, ready).
Definition bno08x_types.hpp:519
uint32_t reset_pulse_us
NRST low time; the datasheet minimum is 10 ns.
Definition bno08x_types.hpp:523
bool require_init_response
Wait for the unsolicited initialise response at start.
Definition bno08x_types.hpp:510
uint16_t frs_write_timeout_ms
Limit for one FRS write step.
Definition bno08x_types.hpp:521
bool frs_verify
Read an FRS record back after writing it.
Definition bno08x_types.hpp:511
uint16_t op_timeout_ms
Limit for one operation.
Definition bno08x_types.hpp:520
ReadPolicy read_policy
How I2C and SPI reads are sized.
Definition bno08x_types.hpp:504
constexpr bool TimesValid() const noexcept
Whether every time limit is non-zero and the SPI WAKE wait ends before an operation's limit,...
Definition bno08x_types.hpp:538
uint8_t i2c_address
I2C: 0x4A (SA0 low) or 0x4B (SA0 high).
Definition bno08x_types.hpp:505
constexpr bool Valid() const noexcept
Whether every field is inside its documented range.
Definition bno08x_types.hpp:551
bool strict_variant
Refuse features the chip lacks with Variant.
Definition bno08x_types.hpp:507
bool rvc_inputs_experimental
Guarded: allow the unverified $MIB host inputs.
Definition bno08x_types.hpp:518
uint16_t advert_retry_ms
Without NRST: wait before asking for the advertisement.
Definition bno08x_types.hpp:524
uint16_t uart_bsq_retry_ms
UART-SHTP: wait for a BSN before the query is sent again.
Definition bno08x_types.hpp:527
bool auto_restore
Re-send enabled features after a hub restart.
Definition bno08x_types.hpp:508
bool strict_raw
Refuse a raw sensor whose base sensor is off.
Definition bno08x_types.hpp:513
Yaw, pitch and roll in centidegrees.
Definition bno08x_types.hpp:613
int32_t roll
Rotation about X, -18000 to 18000.
Definition bno08x_types.hpp:616
int32_t pitch
Rotation about Y, -9000 to 9000.
Definition bno08x_types.hpp:615
int32_t yaw
Rotation about Z, -18000 to 18000.
Definition bno08x_types.hpp:614
One thing the driver reports, taken with Bno08x::PopEvent().
Definition bno08x_types.hpp:298
Error error
The operation's outcome (OpDone).
Definition bno08x_types.hpp:305
OpId op
The operation (OpDone).
Definition bno08x_types.hpp:304
bool wake
The sample came on the wake-up channel.
Definition bno08x_types.hpp:302
uint32_t t_us
Host time of the sample, NowUs() domain, wrap-safe.
Definition bno08x_types.hpp:306
Accuracy accuracy
The sample's accuracy (Sensor).
Definition bno08x_types.hpp:301
SensorId sensor
The sensor (Sensor, FeatureChanged, FlushDone).
Definition bno08x_types.hpp:300
EventKind kind
What this event is.
Definition bno08x_types.hpp:299
uint32_t hub_t_us
Raw sensors and pose: the hub's own timestamp.
Definition bno08x_types.hpp:307
uint8_t report_seq
The report's own sequence number (Sensor).
Definition bno08x_types.hpp:303
std::array< int32_t, kEventValues > v
The values.
Definition bno08x_types.hpp:309
The common feature report of one sensor (RM S6.5.2).
Definition bno08x_types.hpp:358
bool relative
Change sensitivity is relative (flag bit 0).
Definition bno08x_types.hpp:359
int16_t change_sensitivity
Change sensitivity, in the report's Q point.
Definition bno08x_types.hpp:363
uint32_t sensor_config
Definition bno08x_types.hpp:366
friend constexpr bool operator==(const FeatureConfig &lhs, const FeatureConfig &rhs) noexcept=default
Equality of all fields, as a hidden friend.
uint32_t batch_us
Batch interval in microseconds; 0 none, 0xFFFFFFFF never.
Definition bno08x_types.hpp:365
bool change_enable
Change sensitivity is enabled (flag bit 1).
Definition bno08x_types.hpp:360
bool always_on
The sensor stays on in sleep (flag bit 3).
Definition bno08x_types.hpp:362
uint32_t interval_us
Report interval in microseconds; 0 turns the sensor off.
Definition bno08x_types.hpp:364
bool wake
The sensor wakes the host (flag bit 2).
Definition bno08x_types.hpp:361
A caller-owned buffer for ReadFrs(); it must outlive the operation.
Definition bno08x_types.hpp:412
std::size_t length
Words received so far; final at OpDone.
Definition bno08x_types.hpp:414
uint8_t last_status
The last status the hub sent.
Definition bno08x_types.hpp:415
std::array< uint32_t, kFrsMaxWords > words
The record's words.
Definition bno08x_types.hpp:413
The motion engine's calibration enables (RM S6.4.6).
Definition bno08x_types.hpp:419
bool accel
Accelerometer calibration.
Definition bno08x_types.hpp:420
bool mag
Magnetometer calibration.
Definition bno08x_types.hpp:422
bool gyro
Gyroscope calibration.
Definition bno08x_types.hpp:421
bool on_table
On-table calibration.
Definition bno08x_types.hpp:424
bool planar
Planar accelerometer calibration.
Definition bno08x_types.hpp:423
Sensor metadata record (RM Figures 28 and 29, record IDs 0xE301 to 0xE325).
Definition bno08x_types.hpp:384
uint8_t version_me
MotionEngine version byte.
Definition bno08x_types.hpp:386
uint16_t q2
Q point 2.
Definition bno08x_types.hpp:400
uint32_t range
Range, in the sensor's Q point.
Definition bno08x_types.hpp:389
uint16_t fifo_max
Most reports the hub's FIFO holds.
Definition bno08x_types.hpp:395
uint16_t vendor_id_len
Length of the vendor ID string.
Definition bno08x_types.hpp:398
std::array< char, 32 > vendor_id
The vendor ID string, NUL-terminated, truncated to 31.
Definition bno08x_types.hpp:403
uint16_t specific_len
Sensor-specific metadata length in bytes.
Definition bno08x_types.hpp:402
uint8_t version_sh
SensorHub version byte.
Definition bno08x_types.hpp:388
uint32_t activity_classes
Activity classifier: bit n set means class n is supported.
Definition bno08x_types.hpp:404
uint32_t resolution
Resolution, in the sensor's Q point.
Definition bno08x_types.hpp:390
uint32_t max_period_us
Longest report period (revision 4; 0 in revision 3).
Definition bno08x_types.hpp:394
uint8_t version_mh
MotionHub version byte.
Definition bno08x_types.hpp:387
uint16_t q3
Q point 3.
Definition bno08x_types.hpp:401
uint16_t power_q10
Power in mA, Q10.
Definition bno08x_types.hpp:391
uint16_t fifo_reserved
Reports reserved for this sensor.
Definition bno08x_types.hpp:396
uint32_t min_period_us
Shortest report period.
Definition bno08x_types.hpp:393
bool valid
The record has been read.
Definition bno08x_types.hpp:385
uint16_t revision
Record revision (3 or 4).
Definition bno08x_types.hpp:392
uint16_t q1
Q point 1.
Definition bno08x_types.hpp:399
uint16_t batch_bytes
Batch buffer size in bytes.
Definition bno08x_types.hpp:397
Product ID response (RM S6.3.2).
Definition bno08x_types.hpp:373
uint32_t build
Software build number.
Definition bno08x_types.hpp:379
uint16_t version_patch
Software version, patch.
Definition bno08x_types.hpp:377
uint8_t reset_cause
0 n/a, 1 power on, 2 internal reset, 3 watchdog, 4 external, 5 other.
Definition bno08x_types.hpp:374
uint8_t version_major
Software version, major.
Definition bno08x_types.hpp:375
uint32_t part_number
Software part number.
Definition bno08x_types.hpp:378
bool valid
A response has been received.
Definition bno08x_types.hpp:380
uint8_t version_minor
Software version, minor.
Definition bno08x_types.hpp:376
A quaternion in Q14 (RM S6.4.3.3): the set-reorientation argument.
Definition bno08x_types.hpp:428
int16_t x
X component.
Definition bno08x_types.hpp:429
int16_t z
Z component.
Definition bno08x_types.hpp:431
int16_t y
Y component.
Definition bno08x_types.hpp:430
int16_t w
W component.
Definition bno08x_types.hpp:432
static constexpr Result Success() noexcept
Definition bno08x_types.hpp:141
constexpr bool ok() const noexcept
Definition bno08x_types.hpp:133
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition bno08x_types.hpp:149
The value of a call, or why there is none.
Definition bno08x_types.hpp:95
static constexpr Result Success(T v) noexcept
A successful result.
Definition bno08x_types.hpp:112
constexpr bool ok() const noexcept
Definition bno08x_types.hpp:100
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition bno08x_types.hpp:120
Error error
Error::Ok on success.
Definition bno08x_types.hpp:97
A decoded UART-RVC frame (DS p21).
Definition bno08x_types.hpp:488
uint8_t mi
Motion intent (BNO086 only).
Definition bno08x_types.hpp:496
uint8_t index
Frame index, increments per frame.
Definition bno08x_types.hpp:489
int16_t pitch
Pitch in 0.01 degree.
Definition bno08x_types.hpp:491
int16_t ax
Acceleration x in milli-g.
Definition bno08x_types.hpp:493
uint8_t mr
Motion request (BNO086 only).
Definition bno08x_types.hpp:497
bool mi_mr_valid
mi and mr carry data (variant BNO086).
Definition bno08x_types.hpp:498
int16_t az
Acceleration z in milli-g.
Definition bno08x_types.hpp:495
int16_t ay
Acceleration y in milli-g.
Definition bno08x_types.hpp:494
int16_t roll
Roll in 0.01 degree.
Definition bno08x_types.hpp:492
int16_t yaw
Yaw in 0.01 degree.
Definition bno08x_types.hpp:490
Counters of everything the driver dropped, repaired or noticed. Never reset by the driver.
Definition bno08x_types.hpp:314
uint32_t restore_failed
Auto-restore writes given up after their retries.
Definition bno08x_types.hpp:343
uint32_t null_header
Null headers, length 0 (V3).
Definition bno08x_types.hpp:317
uint32_t orphan_cont
Continuations with no cargo open (V8).
Definition bno08x_types.hpp:322
uint32_t short_report
Reports cut short by the cargo end (V14).
Definition bno08x_types.hpp:328
uint32_t lost_cargo
Cargoes abandoned by a new header or channel (V7, V9).
Definition bno08x_types.hpp:321
uint32_t hub_errors
SHTP error lists received.
Definition bno08x_types.hpp:344
uint32_t payload_upper_nonzero
Narrow payloads whose upper byte was not zero.
Definition bno08x_types.hpp:340
uint32_t oversize_frame
UART frames longer than the receive buffer (dropped).
Definition bno08x_types.hpp:334
uint32_t oversize_cargo
Cargoes larger than the receive buffer (V5).
Definition bno08x_types.hpp:319
uint32_t frs_foreign
FRS read responses for another record type (ignored).
Definition bno08x_types.hpp:338
uint32_t resyncs
Resynchronisations of the frame engine.
Definition bno08x_types.hpp:341
uint32_t product_id_extra
Product ID responses that no request was waiting for.
Definition bno08x_types.hpp:337
uint32_t hub_resets
Hub restarts seen while ready.
Definition bno08x_types.hpp:342
uint32_t nonzero_pad
Non-zero bytes in the padding (V12).
Definition bno08x_types.hpp:326
uint32_t bad_cont_len
Continuations with the wrong length (V10).
Definition bno08x_types.hpp:323
uint32_t bsq_retries
UART-SHTP: Buffer Status Queries sent again (no BSN came).
Definition bno08x_types.hpp:336
uint32_t base_overflow
Base timestamps that were 0x7FFFFFFF.
Definition bno08x_types.hpp:335
uint32_t bad_escape
UART frames with a bad escape sequence.
Definition bno08x_types.hpp:333
uint32_t early_cargo
Cargoes before the advertisement (V16).
Definition bno08x_types.hpp:330
uint32_t report_seq_gaps
Gaps in a sensor's own sequence number.
Definition bno08x_types.hpp:339
uint32_t bad_channel
Cargoes on a channel above 5 (V6).
Definition bno08x_types.hpp:320
uint32_t length_ffff
Headers with length 0xFFFF (V2).
Definition bno08x_types.hpp:316
uint32_t bad_gyrorv
Channel 5 cargoes of the wrong length (V15).
Definition bno08x_types.hpp:329
uint32_t rvc_out_of_range
UART-RVC angles outside the documented ranges.
Definition bno08x_types.hpp:352
uint32_t seq_gap
Gaps in the SHTP sequence numbers (V11).
Definition bno08x_types.hpp:325
uint32_t rvc_bad_csum
UART-RVC frames with a wrong checksum.
Definition bno08x_types.hpp:348
uint32_t short_transfer
Transfers shorter than a header (V1).
Definition bno08x_types.hpp:315
uint32_t length_short
Headers with length 1 to 3 (V4).
Definition bno08x_types.hpp:318
uint32_t dup_seq
Duplicate SHTP sequence numbers (V11).
Definition bno08x_types.hpp:324
uint32_t rvc_frames
UART-RVC frames accepted.
Definition bno08x_types.hpp:347
uint32_t rvc_index_gaps
UART-RVC frames whose index skipped.
Definition bno08x_types.hpp:349
uint32_t bad_advert
Advertisements with a malformed TLV.
Definition bno08x_types.hpp:331
uint32_t rvc_banner_bytes
Bytes skipped before the first UART-RVC frame (the ASCII banner).
Definition bno08x_types.hpp:350
uint32_t events_dropped
Events lost to a full queue.
Definition bno08x_types.hpp:346
uint32_t bus_errors
Port hooks that returned false while reading.
Definition bno08x_types.hpp:345
uint32_t unknown_report
Reports with an ID the table does not know (V13).
Definition bno08x_types.hpp:327
uint32_t bad_protocol_id
UART frames with a protocol ID other than 0 or 1.
Definition bno08x_types.hpp:332
uint32_t rvc_csum_without_mi
UART-RVC checksums that matched only without MI and MR.
Definition bno08x_types.hpp:354
uint32_t rvc_csum_with_mi
UART-RVC checksums that matched when MI and MR are included.
Definition bno08x_types.hpp:353
One wheel measurement for dead reckoning (RM S6.4.13).
Definition bno08x_types.hpp:480
bool velocity
false: data is a position, true: a velocity.
Definition bno08x_types.hpp:484
uint32_t timestamp_us
Time of the measurement, microseconds.
Definition bno08x_types.hpp:482
uint16_t data
Position (uint16) or velocity (int16 bit pattern).
Definition bno08x_types.hpp:483
uint8_t wheel
0 left, 1 right.
Definition bno08x_types.hpp:481