34#ifndef BNO08X_INTERFACE_HPP
35#define BNO08X_INTERFACE_HPP
59template <
typename Derived>
77template <
typename Port>
78concept CommonHooks =
requires {
79 ExactHook<Port, bool()
noexcept>::Take(&Port::EnsureInitialized);
80 ExactHook<Port, uint32_t()
noexcept>::Take(&Port::NowUs);
84template <
typename Port>
85concept I2cHooks =
requires {
86 ExactHook<Port, bool(uint8_t,
const uint8_t*, std::size_t)
noexcept>::Take(&Port::I2cWrite);
87 ExactHook<Port, bool(uint8_t, uint8_t*, std::size_t)
noexcept>::Take(&Port::I2cRead);
88 ExactHook<Port, bool()
noexcept>::Take(&Port::IntAsserted);
92template <
typename Port>
93concept SpiHooks =
requires {
94 ExactHook<Port, bool(
const uint8_t*, uint8_t*, std::size_t)
noexcept>::Take(&Port::SpiTransfer);
95 ExactHook<Port, bool(
bool)
noexcept>::Take(&Port::SetWake);
96 ExactHook<Port, bool()
noexcept>::Take(&Port::IntAsserted);
100template <
typename Port>
101concept UartRxHooks =
requires {
102 ExactHook<Port, std::size_t(uint8_t*, std::size_t)
noexcept>::Take(&Port::UartRead);
106template <
typename Port>
107concept DeclaresUartWriteByte =
requires(Port& port) { port.UartWriteByte(uint8_t{0}); };
110template <
typename Port>
111concept HasUartWriteByte =
112 requires { ExactHook<Port, bool(uint8_t)
noexcept>::Take(&Port::UartWriteByte); };
115template <
typename Port>
116concept DeclaresUartWrite =
117 requires(Port& port,
const uint8_t* p) { port.UartWrite(p, std::size_t{0}); };
120template <
typename Port>
121concept HasUartWrite =
requires {
122 ExactHook<Port, bool(
const uint8_t*, std::size_t)
noexcept>::Take(&Port::UartWrite);
126template <
typename Port>
127concept UartShtpHooks = UartRxHooks<Port> && (HasUartWriteByte<Port> || HasUartWrite<Port>);
130template <
typename Port>
131concept DeclaresTransport =
requires {
132 { Port::kTransport } -> std::convertible_to<Transport>;
136template <
typename Port, Transport T>
137concept IsTransport = DeclaresTransport<Port> && (Port::kTransport == T);
146template <
typename Port>
148 std::derived_from<Port, HubInterface<Port>> && detail::CommonHooks<Port> &&
149 ((detail::IsTransport<Port, Transport::I2c> && detail::I2cHooks<Port>) ||
150 (detail::IsTransport<Port, Transport::Spi> && detail::SpiHooks<Port>) ||
151 (detail::IsTransport<Port, Transport::UartShtp> && detail::UartShtpHooks<Port>) ||
152 (detail::IsTransport<Port, Transport::UartRvc> && detail::UartRxHooks<Port>));
Compile-time helpers of the BNO08X driver: typed integer literals, exact hook matching,...
What the BNO08x needs from the I2C bus (handbook KB-CPP-123); the port itself is in bno08x_interface....
What the BNO08x needs from the SPI bus (handbook KB-CPP-123); the port itself is in bno08x_interface....
Public types of the BNO08x driver: errors, Result<T>, configuration, events and the integer unit help...
What the BNO08x needs from the UART link (handbook KB-CPP-123); the port itself is in bno08x_interfac...
CRTP base of the platform port.
Definition bno08x_interface.hpp:60
HubInterface & operator=(const HubInterface &)=delete
Ports are not copied: the driver holds a reference.
HubInterface() noexcept=default
Only the derived port is constructed.
HubInterface(const HubInterface &)=delete
Ports are not copied: the driver holds a reference.
Satisfied by a class that derives from HubInterface<Port>, names its transport and implements that tr...
Definition bno08x_interface.hpp:147
The BNO08x driver: everything it declares lives here; internals in detail.
Definition bno08x.hpp:36