84template <
typename Port>
86 decltype(std::declval<Port&>().GpioSet(std::declval<CtrlPin>(), std::declval<GpioSignal>()));
89template <
typename Port>
91 std::is_same_v<std::remove_cv_t<std::remove_reference_t<GpioSetResult<Port>>>,
bool>;
101template <
typename Port>
105 "bno08x: the port's GpioSet(pin, signal) must return bool (true = pin driven, "
106 "false = GPIO error), or void for a port that never reports errors");
107 if constexpr (std::is_void_v<Result>) {
116template <
typename Port,
typename =
void>
119template <
typename Port>
121 Port,
std::
void_t<decltype(std::declval<Port&>().GetI2cAddress()),
122 decltype(std::declval<Port&>().SetI2cAddress(std::declval<uint8_t>()))>>
135template <
typename Port>
161template <
typename Derived>
196 return static_cast<Derived*
>(
this)->
Open();
209 static_cast<Derived*
>(
this)->
Close();
222 int Write(
const uint8_t* data, uint32_t length)
noexcept {
223 return static_cast<Derived*
>(
this)->
Write(data, length);
238 int Read(uint8_t* data, uint32_t length)
noexcept {
239 return static_cast<Derived*
>(
this)->
Read(data, length);
263 static_cast<Derived*
>(
this)->
Delay(ms);
276 return static_cast<Derived*
>(
this)->
GetTimeUs();
BNO085Interface
Identifies the host interface type that a CommInterface provides.
Definition bno08x_comm_interface.hpp:27
@ UARTRVC
UART in RVC mode (PS1=0, PS0=1). RVC frames only.
@ SPI
SPI bus (PS1=1, PS0=1). Supports SH-2 and DFU.
@ UART
UART in SH-2 mode (PS1=1, PS0=0). Supports SH-2 and DFU.
@ I2C
I2C bus (PS1=0, PS0=0). Supports SH-2 and DFU.
CRTP base class for BNO08x communication interfaces.
Definition bno08x_comm_interface.hpp:162
CommInterface()=default
Protected constructor – prevents direct instantiation.
bool DataAvailable() noexcept
Check whether the sensor has data ready.
Definition bno08x_comm_interface.hpp:250
CommInterface(CommInterface &&) noexcept=default
Movable.
CommInterface & operator=(const CommInterface &)=delete
Non-copyable.
void Close() noexcept
Close the communication bus and release resources.
Definition bno08x_comm_interface.hpp:208
CommInterface(const CommInterface &)=delete
Non-copyable.
uint32_t GetTimeUs() noexcept
Return the current monotonic time in microseconds.
Definition bno08x_comm_interface.hpp:275
bool GpioSet(CtrlPin pin, GpioSignal signal) noexcept
Set a control pin to the specified signal state.
Definition bno08x_comm_interface.hpp:304
int Write(const uint8_t *data, uint32_t length) noexcept
Write raw bytes to the sensor.
Definition bno08x_comm_interface.hpp:222
bool Open() noexcept
Open and initialise the communication bus.
Definition bno08x_comm_interface.hpp:195
~CommInterface()=default
Protected destructor – prevent polymorphic deletion through base.
void Delay(uint32_t ms) noexcept
Block for a specified duration.
Definition bno08x_comm_interface.hpp:262
int Read(uint8_t *data, uint32_t length) noexcept
Read raw bytes from the sensor.
Definition bno08x_comm_interface.hpp:238
bool GpioSetInactive(CtrlPin pin) noexcept
Deassert a control pin (set to INACTIVE).
Definition bno08x_comm_interface.hpp:328
bool GpioSetActive(CtrlPin pin) noexcept
Assert a control pin (set to ACTIVE).
Definition bno08x_comm_interface.hpp:316
BNO085Interface GetInterfaceType() noexcept
Report the transport type this implementation provides.
Definition bno08x_comm_interface.hpp:176
constexpr bool kGpioSetReportsStatus
True when the port's GpioSet() reports a status (returns bool).
Definition bno08x_comm_interface.hpp:90
constexpr bool kHasI2cAddressHooks
True when the port provides the optional I2C address hooks.
Definition bno08x_comm_interface.hpp:136
decltype(std::declval< Port & >().GpioSet(std::declval< CtrlPin >(), std::declval< GpioSignal >())) GpioSetResult
Return type of Port::GpioSet(CtrlPin, GpioSignal).
Definition bno08x_comm_interface.hpp:86
bool GpioSet(Port &port, CtrlPin pin, GpioSignal signal) noexcept
Call the port's GpioSet() and return its status.
Definition bno08x_comm_interface.hpp:102
CtrlPin
Identifies the hardware control pins of the BNO08x.
Definition bno08x_comm_interface.hpp:60
@ PS0
Protocol select bit 0 (active-high on the physical pin)
@ BOOTN
Bootloader entry (active-low on the physical pin)
@ RSTN
Hardware reset (active-low on the physical pin)
@ PS1
Protocol select bit 1 (active-high on the physical pin)
@ WAKE
Wake from suspend, SPI mode only (active-low on the physical pin)
GpioSignal
Abstract signal level for control pins.
Definition bno08x_comm_interface.hpp:76
@ ACTIVE
Pin function is asserted.
@ INACTIVE
Pin function is deasserted.