HF-BNO08x  0.1.0-dev
Loading...
Searching...
No Matches
bno08x::CommInterface< Derived > Class Template Reference

CRTP base class for BNO08x communication interfaces. More...

#include <bno08x_comm_interface.hpp>

Public Member Functions

Interface Identification
BNO085Interface GetInterfaceType () noexcept
 Report the transport type this implementation provides.
 
Bus I/O – Required Methods
bool Open () noexcept
 Open and initialise the communication bus.
 
void Close () noexcept
 Close the communication bus and release resources.
 
int Write (const uint8_t *data, uint32_t length) noexcept
 Write raw bytes to the sensor.
 
int Read (uint8_t *data, uint32_t length) noexcept
 Read raw bytes from the sensor.
 
bool DataAvailable () noexcept
 Check whether the sensor has data ready.
 
void Delay (uint32_t ms) noexcept
 Block for a specified duration.
 
uint32_t GetTimeUs () noexcept
 Return the current monotonic time in microseconds.
 
GPIO Pin Control

Unified interface for controlling BNO08x hardware control pins. The platform bus implementation maps GpioSignal::ACTIVE/INACTIVE to the correct physical level for each pin based on its polarity.

void GpioSet (CtrlPin pin, GpioSignal signal) noexcept
 Set a control pin to the specified signal state.
 
void GpioSetActive (CtrlPin pin) noexcept
 Assert a control pin (set to ACTIVE).
 
void GpioSetInactive (CtrlPin pin) noexcept
 Deassert a control pin (set to INACTIVE).
 

Protected Member Functions

 CommInterface ()=default
 Protected constructor – prevents direct instantiation.
 
 ~CommInterface ()=default
 Protected destructor – prevent polymorphic deletion through base.
 
 CommInterface (const CommInterface &)=delete
 Non-copyable.
 
CommInterfaceoperator= (const CommInterface &)=delete
 Non-copyable.
 
 CommInterface (CommInterface &&) noexcept=default
 Movable.
 
CommInterfaceoperator= (CommInterface &&) noexcept=default
 Movable.
 

Detailed Description

template<typename Derived>
class bno08x::CommInterface< Derived >

CRTP base class for BNO08x communication interfaces.

Platform-specific implementations inherit from this template with themselves as the template parameter. All method calls are resolved at compile time via static_cast<Derived*>(this)->Method() – no vtable, no indirection.

Template Parameters
DerivedThe concrete implementation class (CRTP pattern).
Note
Implementations must provide all listed methods. The GpioSet() method may be a no-op for pins that are not wired on the board.

Constructor & Destructor Documentation

◆ CommInterface() [1/3]

template<typename Derived >
bno08x::CommInterface< Derived >::CommInterface ( )
protecteddefault

Protected constructor – prevents direct instantiation.

◆ ~CommInterface()

template<typename Derived >
bno08x::CommInterface< Derived >::~CommInterface ( )
protecteddefault

Protected destructor – prevent polymorphic deletion through base.

◆ CommInterface() [2/3]

template<typename Derived >
bno08x::CommInterface< Derived >::CommInterface ( const CommInterface< Derived > & )
protecteddelete

Non-copyable.

◆ CommInterface() [3/3]

template<typename Derived >
bno08x::CommInterface< Derived >::CommInterface ( CommInterface< Derived > && )
protecteddefaultnoexcept

Movable.

Member Function Documentation

◆ Close()

template<typename Derived >
void bno08x::CommInterface< Derived >::Close ( )
inlinenoexcept

Close the communication bus and release resources.

Called during driver shutdown. Implementations should de-initialise the peripheral and release any allocated resources.

◆ DataAvailable()

template<typename Derived >
bool bno08x::CommInterface< Derived >::DataAvailable ( )
inlinenoexcept

Check whether the sensor has data ready.

Typically checks the interrupt (INT) pin level. For transports without an interrupt pin, return true unconditionally to allow polling.

Returns
true if data is available (or if unknown), false otherwise.

◆ Delay()

template<typename Derived >
void bno08x::CommInterface< Derived >::Delay ( uint32_t ms)
inlinenoexcept

Block for a specified duration.

Used by the driver for reset timing and post-DFU delays.

Parameters
[in]msDelay duration in milliseconds.

◆ GetInterfaceType()

template<typename Derived >
BNO085Interface bno08x::CommInterface< Derived >::GetInterfaceType ( )
inlinenoexcept

Report the transport type this implementation provides.

The BNO085 driver calls this once during Begin() or BeginRvc() to determine which operations to allow.

Returns
BNO085Interface enum identifying the bus protocol.

◆ GetTimeUs()

template<typename Derived >
uint32_t bno08x::CommInterface< Derived >::GetTimeUs ( )
inlinenoexcept

Return the current monotonic time in microseconds.

The vendor SH-2 library requires a microsecond time source for timestamping sensor events. The value does not need to represent wall-clock time – only monotonicity matters.

Returns
Current time in microseconds.

◆ GpioSet()

template<typename Derived >
void bno08x::CommInterface< Derived >::GpioSet ( CtrlPin pin,
GpioSignal signal )
inlinenoexcept

Set a control pin to the specified signal state.

The bus implementation is responsible for mapping ACTIVE/INACTIVE to the correct physical level based on the pin's active-level design.

Parameters
[in]pinWhich control pin to drive.
[in]signalACTIVE to assert the pin function, INACTIVE to deassert.

◆ GpioSetActive()

template<typename Derived >
void bno08x::CommInterface< Derived >::GpioSetActive ( CtrlPin pin)
inlinenoexcept

Assert a control pin (set to ACTIVE).

Convenience wrapper for GpioSet(pin, GpioSignal::ACTIVE).

Parameters
[in]pinWhich control pin to assert.

◆ GpioSetInactive()

template<typename Derived >
void bno08x::CommInterface< Derived >::GpioSetInactive ( CtrlPin pin)
inlinenoexcept

Deassert a control pin (set to INACTIVE).

Convenience wrapper for GpioSet(pin, GpioSignal::INACTIVE).

Parameters
[in]pinWhich control pin to deassert.

◆ Open()

template<typename Derived >
bool bno08x::CommInterface< Derived >::Open ( )
inlinenoexcept

Open and initialise the communication bus.

Called by BNO085::Begin() (SH-2 mode) or BNO085::BeginRvc() (RVC mode). Implementations should configure the peripheral, set up GPIO pins, and prepare for data transfer.

Returns
true on success, false on failure.

◆ operator=() [1/2]

template<typename Derived >
CommInterface & bno08x::CommInterface< Derived >::operator= ( CommInterface< Derived > && )
protecteddefaultnoexcept

Movable.

◆ operator=() [2/2]

template<typename Derived >
CommInterface & bno08x::CommInterface< Derived >::operator= ( const CommInterface< Derived > & )
protecteddelete

Non-copyable.

◆ Read()

template<typename Derived >
int bno08x::CommInterface< Derived >::Read ( uint8_t * data,
uint32_t length )
inlinenoexcept

Read raw bytes from the sensor.

For SH-2 mode, the vendor SHTP library calls this to receive packets. For RVC mode, the driver calls Read(&byte, 1) repeatedly to feed the internal 19-byte frame parser.

Parameters
[out]dataBuffer to fill with received bytes.
[in]lengthMaximum number of bytes to read.
Returns
Number of bytes actually read, 0 if no data available, or negative on error.

◆ Write()

template<typename Derived >
int bno08x::CommInterface< Derived >::Write ( const uint8_t * data,
uint32_t length )
inlinenoexcept

Write raw bytes to the sensor.

For I2C/SPI this sends data on the bus. For UART-RVC this is typically unused (RVC mode is read-only).

Parameters
[in]dataPointer to the buffer to transmit.
[in]lengthNumber of bytes to write.
Returns
Number of bytes written, or negative on error.

The documentation for this class was generated from the following file: