BNO08x Driver
API reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
bno08x::shtp_uart::FrameDecoder< Capacity > Class Template Reference

Byte-at-a-time decoder for frames received from the hub. More...

#include <bno08x_shtp_uart.hpp>

Public Types

enum class  Event : uint8_t { None , ShtpFrame , BufferStatus , Dropped }
 What the last byte completed. More...
 

Public Member Functions

Event Push (uint8_t c) noexcept
 Feed one received byte.
 
const uint8_t * Data () const noexcept
 SHTP transfer of the last Event::ShtpFrame (header first).
 
std::size_t Size () const noexcept
 Length of the last SHTP transfer.
 
uint16_t BufferSpace () const noexcept
 Free space the hub reported in its last Buffer Status Notification.
 
void ClearBufferSpace () noexcept
 Forget the reported buffer space (the next frame needs a new query).
 
void Reset () noexcept
 Drop any partial frame and wait for the next flag.
 

Detailed Description

template<std::size_t Capacity>
class bno08x::shtp_uart::FrameDecoder< Capacity >

Byte-at-a-time decoder for frames received from the hub.

Push() every received byte. When it returns Event::ShtpFrame, Data() and Size() hold the SHTP transfer (protocol ID removed) until the next Push(). Event::BufferStatus updates BufferSpace(). Bytes outside a frame are ignored, and a frame that overflows Capacity or has an unknown protocol ID is reported as Event::Dropped.

Template Parameters
CapacityLargest frame payload kept, protocol ID included.

Member Enumeration Documentation

◆ Event

template<std::size_t Capacity>
enum class bno08x::shtp_uart::FrameDecoder::Event : uint8_t
strong

What the last byte completed.

Enumerator
None 

Nothing complete yet.

ShtpFrame 

An SHTP transfer is in Data() / Size().

BufferStatus 

A Buffer Status Notification updated BufferSpace().

Dropped 

A frame was discarded (overflow or unknown protocol ID).

Member Function Documentation

◆ BufferSpace()

template<std::size_t Capacity>
uint16_t bno08x::shtp_uart::FrameDecoder< Capacity >::BufferSpace ( ) const
inlinenoexcept

Free space the hub reported in its last Buffer Status Notification.

◆ ClearBufferSpace()

template<std::size_t Capacity>
void bno08x::shtp_uart::FrameDecoder< Capacity >::ClearBufferSpace ( )
inlinenoexcept

Forget the reported buffer space (the next frame needs a new query).

◆ Data()

template<std::size_t Capacity>
const uint8_t * bno08x::shtp_uart::FrameDecoder< Capacity >::Data ( ) const
inlinenoexcept

SHTP transfer of the last Event::ShtpFrame (header first).

◆ Push()

template<std::size_t Capacity>
Event bno08x::shtp_uart::FrameDecoder< Capacity >::Push ( uint8_t  c)
inlinenoexcept

Feed one received byte.

◆ Reset()

template<std::size_t Capacity>
void bno08x::shtp_uart::FrameDecoder< Capacity >::Reset ( )
inlinenoexcept

Drop any partial frame and wait for the next flag.

◆ Size()

template<std::size_t Capacity>
std::size_t bno08x::shtp_uart::FrameDecoder< Capacity >::Size ( ) const
inlinenoexcept

Length of the last SHTP transfer.


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