BNO08x Driver
API reference
Loading...
Searching...
No Matches
Classes | Functions | Variables
bno08x::shtp_uart Namespace Reference

Classes

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

Functions

constexpr std::size_t MaxEncodedSize (std::size_t payloadLen) noexcept
 Largest frame EncodeFrame() can produce for payloadLen bytes (every byte escaped).
 
std::size_t EncodeFrame (const uint8_t *shtp, std::size_t len, uint8_t *out, std::size_t cap) noexcept
 Wrap one SHTP transfer (header included) in a UART-SHTP frame.
 

Variables

constexpr uint32_t BAUD_RATE = 3000000
 UART-SHTP line rate: 3 Mbit/s, 8 data bits, no parity, 1 stop bit (datasheet 1.2.3.1).
 
constexpr uint32_t HOST_BYTE_GAP_US = 100
 Minimum spacing between bytes sent from the host to the hub, in µs (datasheet 1.2.3.1).
 
constexpr uint8_t FLAG = 0x7E
 Frame delimiter.
 
constexpr uint8_t ESCAPE = 0x7D
 Escape: the next byte is XOR ESCAPE_XOR.
 
constexpr uint8_t ESCAPE_XOR = 0x20
 Value XORed into an escaped byte.
 
constexpr uint8_t PROTOCOL_CONTROL = 0x00
 Protocol ID of control frames (BSQ / BSN).
 
constexpr uint8_t PROTOCOL_SHTP = 0x01
 Protocol ID of SHTP transfers.
 
constexpr uint8_t BUFFER_STATUS_QUERY [3] = {FLAG, PROTOCOL_CONTROL, FLAG}
 Buffer Status Query, ready to send.
 

Function Documentation

◆ EncodeFrame()

std::size_t bno08x::shtp_uart::EncodeFrame ( const uint8_t *  shtp,
std::size_t  len,
uint8_t *  out,
std::size_t  cap 
)
inlinenoexcept

Wrap one SHTP transfer (header included) in a UART-SHTP frame.

Parameters
[in]shtpThe transfer, as the SH-2 library passes it to Write().
[in]lenIts length in bytes.
[out]outDestination buffer.
[in]capSize of out; MaxEncodedSize(len) always fits.
Returns
Number of bytes written to out, or 0 if they do not fit.

◆ MaxEncodedSize()

constexpr std::size_t bno08x::shtp_uart::MaxEncodedSize ( std::size_t  payloadLen)
constexprnoexcept

Largest frame EncodeFrame() can produce for payloadLen bytes (every byte escaped).

Variable Documentation

◆ BAUD_RATE

constexpr uint32_t bno08x::shtp_uart::BAUD_RATE = 3000000
inlineconstexpr

UART-SHTP line rate: 3 Mbit/s, 8 data bits, no parity, 1 stop bit (datasheet 1.2.3.1).

◆ BUFFER_STATUS_QUERY

constexpr uint8_t bno08x::shtp_uart::BUFFER_STATUS_QUERY[3] = {FLAG, PROTOCOL_CONTROL, FLAG}
inlineconstexpr

Buffer Status Query, ready to send.

◆ ESCAPE

constexpr uint8_t bno08x::shtp_uart::ESCAPE = 0x7D
inlineconstexpr

Escape: the next byte is XOR ESCAPE_XOR.

◆ ESCAPE_XOR

constexpr uint8_t bno08x::shtp_uart::ESCAPE_XOR = 0x20
inlineconstexpr

Value XORed into an escaped byte.

◆ FLAG

constexpr uint8_t bno08x::shtp_uart::FLAG = 0x7E
inlineconstexpr

Frame delimiter.

◆ HOST_BYTE_GAP_US

constexpr uint32_t bno08x::shtp_uart::HOST_BYTE_GAP_US = 100
inlineconstexpr

Minimum spacing between bytes sent from the host to the hub, in µs (datasheet 1.2.3.1).

◆ PROTOCOL_CONTROL

constexpr uint8_t bno08x::shtp_uart::PROTOCOL_CONTROL = 0x00
inlineconstexpr

Protocol ID of control frames (BSQ / BSN).

◆ PROTOCOL_SHTP

constexpr uint8_t bno08x::shtp_uart::PROTOCOL_SHTP = 0x01
inlineconstexpr

Protocol ID of SHTP transfers.