30template <
size_t MaxPayload = 32>
37 std::array<uint8_t, MaxPayload>
data{};
39 [[nodiscard]] std::span<const uint8_t>
payload() const noexcept {
40 return {
data.data(),
static_cast<size_t>(
length > MaxPayload ? MaxPayload :
length)};
47template <
typename EventVariant>
59 template <
typename TargetEvent = I2cFrame<32>,
size_t MaxPayload = 32>
61 if constexpr (std::is_same_v<TargetEvent, I2cFrame<MaxPayload>>) {
62 m_sink.post(EventVariant{frame}, priority);
64 m_sink.post(EventVariant{TargetEvent{frame}}, priority);
75 template <
typename TargetEvent = I2cFrame<32>>
79 std::span<const uint8_t> readBytes,
85 frame.registerAddress = regAddr;
87 frame.status = status;
88 frame.length =
static_cast<uint8_t
>(readBytes.size() > 32 ? 32 : readBytes.size());
89 std::memcpy(frame.data.data(), readBytes.data(), frame.length);
91 if constexpr (std::is_same_v<TargetEvent, I2cFrame<32>>) {
92 m_sink.post(EventVariant{frame}, priority);
94 m_sink.post(EventVariant{TargetEvent{frame}}, priority);
Non-allocating type-erased fat pointer handle for lock-free event posting.
Bounded and multi-tier priority MPSC queueing policies.
Non-blocking hardware ISR adapter for I2C master/slave controllers. Dispatches completed I2C read/wri...
Definition I2cAdapter.hpp:48
void postReadFromIsr(uint16_t devAddr, uint8_t regAddr, std::span< const uint8_t > readBytes, uint8_t status=0, EventPriority priority=EventPriority::Normal) noexcept
Construct and post an I2C read result frame from ISR context.
Definition I2cAdapter.hpp:76
void postFromIsr(const I2cFrame< MaxPayload > &frame, EventPriority priority=EventPriority::Normal) noexcept
Post an I2C frame from ISR context into the event sink.
Definition I2cAdapter.hpp:60
I2cIsrAdapter(EventSinkT< EventVariant > sink) noexcept
Definition I2cAdapter.hpp:50
Definition CanAdapter.hpp:16
I2cOpType
I2C transaction direction/operation type.
Definition I2cAdapter.hpp:22
EventPriority
Event priority levels for multi-priority queue policies.
Definition QueuePolicies.hpp:32
Zero-heap I2C transaction result frame.
Definition I2cAdapter.hpp:31
I2cOpType opType
Read, Write, or WriteRead.
Definition I2cAdapter.hpp:34
uint16_t deviceAddress
7-bit or 10-bit I2C target slave address
Definition I2cAdapter.hpp:32
uint8_t status
Hardware status (0: ACK/Success, 1: NACK, 2: Bus Error)
Definition I2cAdapter.hpp:35
std::span< const uint8_t > payload() const noexcept
Definition I2cAdapter.hpp:39
uint8_t registerAddress
Internal register address (if applicable)
Definition I2cAdapter.hpp:33
std::array< uint8_t, MaxPayload > data
Payload buffer.
Definition I2cAdapter.hpp:37
uint8_t length
Number of valid data bytes.
Definition I2cAdapter.hpp:36