SE050 Driver
API reference
Loading...
Searching...
No Matches
se050_i2c_transport_interface.hpp
Go to the documentation of this file.
1
14#pragma once
15
16#include "se050_types.hpp"
17
18#include <cstddef>
19#include <cstdint>
20
21namespace se050 {
22
37template <typename Derived>
39public:
40 I2cTransceiveInterface() noexcept = default;
43
45 [[nodiscard]] Error Write(const std::uint8_t* tx, std::size_t tx_len,
46 std::uint32_t timeout_ms) noexcept {
47 return static_cast<Derived*>(this)->I2cWrite(tx, tx_len, timeout_ms);
48 }
49
51 [[nodiscard]] Error Read(std::uint8_t* rx, std::size_t rx_len, std::uint32_t timeout_ms) noexcept {
52 return static_cast<Derived*>(this)->I2cRead(rx, rx_len, timeout_ms);
53 }
54
55 [[nodiscard]] bool EnsureInitialized() noexcept {
56 return static_cast<Derived*>(this)->EnsureInitialized();
57 }
58
59 [[nodiscard]] Error Transceive(const std::uint8_t* tx, std::size_t tx_len, std::uint8_t* rx,
60 std::size_t rx_cap, std::size_t* rx_len_out,
61 std::uint32_t timeout_ms) noexcept {
62 return static_cast<Derived*>(this)->Transceive(tx, tx_len, rx, rx_cap, rx_len_out, timeout_ms);
63 }
64
65 [[nodiscard]] Error HardwareReset() noexcept { return static_cast<Derived*>(this)->HardwareReset(); }
66
67 void delay_ms(std::uint32_t ms) noexcept { static_cast<Derived*>(this)->delay_ms_impl(ms); }
68
69protected:
70 ~I2cTransceiveInterface() noexcept = default;
72 I2cTransceiveInterface& operator=(I2cTransceiveInterface&&) noexcept = default;
73};
74
75} // namespace se050
Curiously recurring transport interface for SE050 I²C masters.
Definition se050_i2c_transport_interface.hpp:38
I2cTransceiveInterface() noexcept=default
bool EnsureInitialized() noexcept
Definition se050_i2c_transport_interface.hpp:55
~I2cTransceiveInterface() noexcept=default
Error Write(const std::uint8_t *tx, std::size_t tx_len, std::uint32_t timeout_ms) noexcept
One-shot write of tx_len bytes to the SE050 I²C target address.
Definition se050_i2c_transport_interface.hpp:45
Error Read(std::uint8_t *rx, std::size_t rx_len, std::uint32_t timeout_ms) noexcept
Read exactly rx_len bytes from the SE050 (blocking until complete or error).
Definition se050_i2c_transport_interface.hpp:51
Error Transceive(const std::uint8_t *tx, std::size_t tx_len, std::uint8_t *rx, std::size_t rx_cap, std::size_t *rx_len_out, std::uint32_t timeout_ms) noexcept
Definition se050_i2c_transport_interface.hpp:59
Error HardwareReset() noexcept
Definition se050_i2c_transport_interface.hpp:65
void delay_ms(std::uint32_t ms) noexcept
Definition se050_i2c_transport_interface.hpp:67
Definition se050_apdu.hpp:15
Error
Definition se050_types.hpp:14
Shared types, limits, and error codes for the HF-SE050 driver.