BNO08X Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts
bno08x_interface.hpp File Reference

The port of the BNO08x driver: the CRTP base, the four transports and the HubPort concept. More...

#include <concepts>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include "bno08x_detail.hpp"
#include "bno08x_i2c_interface.hpp"
#include "bno08x_spi_interface.hpp"
#include "bno08x_types.hpp"
#include "bno08x_uart_interface.hpp"

Go to the source code of this file.

Classes

class  bno08x::HubInterface< Derived >
 CRTP base of the platform port. More...
 

Namespaces

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

Concepts

concept  bno08x::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.
 

Detailed Description

The port of the BNO08x driver: the CRTP base, the four transports and the HubPort concept.

The driver never calls an SDK. It calls hooks on a class you derive from bno08x::HubInterface<Self>. The class declares which link it is with static constexpr bno08x::Transport kTransport, and the driver is constrained to the hooks of that transport (each hook's exact signature and noexcept are checked). No hook may block longer than one bus transfer; the driver never loops waiting on a hook.

Hook Transports Contract
bool EnsureInitialized() noexcept all Bring the bus up on the first call; true at once afterwards
uint32_t NowUs() noexcept all Free-running microsecond counter; the driver compares elapsed times, so the wrap at 2^32 is harmless as long as Poll() runs at least every 35 minutes (an interval measured across one longer pause can read short)
bool I2cWrite(uint8_t addr, const uint8_t* data, std::size_t len) noexcept I2C START, addr + W, len bytes, STOP; false on a NACK or bus error
bool I2cRead(uint8_t addr, uint8_t* data, std::size_t len) noexcept I2C START, addr + R, len bytes, NAK on the last, STOP; never a repeated start; stretching by the hub is tolerated up to the port's own timeout
bool IntAsserted() noexcept I2C, SPI H_INTN level: true when low (optional for the UART transports)
bool SpiTransfer(const uint8_t* tx, uint8_t* rx, std::size_t len) noexcept SPI One chip-select assertion for the whole call, mode 3, MSB first, at most 3 MHz, full duplex
bool SetWake(bool level) noexcept SPI Drives PS0/WAKE: true = high (idle), false = low (wake request)
std::size_t UartRead(uint8_t* data, std::size_t cap) noexcept UART Bytes available now, at most cap; never waits
bool UartWriteByte(uint8_t b) noexcept UART-SHTP Queue one byte; false when the transmitter is busy. The driver paces bytes 100 us apart

Optional hooks (each detected by name, then checked for its exact signature): bool SetReset(bool level) (NRST, true = high), bool SetBootn(bool level) (BOOTN, driven high around a reset), bool TakeIntTimestamp(uint32_t& us) (the time of the latest H_INTN edge, consumed once), void Log(LogLevel, const char*), and for UART ports that pace bytes in hardware bool UartWrite(const uint8_t* data, std::size_t len) together with static constexpr bool kPortPacesUartTx = true.