TMC5160 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
tmc5160_uart_interface.hpp
Go to the documentation of this file.
1// clang-format off: the table below must keep one row per line.
18// clang-format on
19#ifndef TMC5160_UART_INTERFACE_HPP
20#define TMC5160_UART_INTERFACE_HPP
21
22#include <concepts>
23#include <cstddef>
24#include <cstdint>
25
26#include "tmc5160_detail.hpp"
27#include "tmc5160_types.hpp"
28
29namespace tmc5160 {
30
36inline constexpr uint8_t kUartDataBits = 8;
38inline constexpr uint32_t kUartGapResetBits = 63;
41inline constexpr uint32_t kUartReplyMarginBits = 64;
43inline constexpr uint32_t kMaxBaudRate = 750'000;
46inline constexpr uint32_t kTurnaroundUs = 12'500;
53template <typename Derived>
55public:
57 UartInterface(const UartInterface&) = delete;
60
61protected:
63 UartInterface() noexcept = default;
65 ~UartInterface() noexcept = default;
66};
67
73template <typename Port>
74concept UartPort = std::derived_from<Port, UartInterface<Port>> && requires {
75 detail::ExactHook<Port, bool() noexcept>::Take(&Port::EnsureInitialized);
76 detail::ExactHook<Port, BusStatus(const uint8_t*, std::size_t, uint8_t*, std::size_t,
77 uint32_t) noexcept>::Take(&Port::Exchange);
78};
79
80} // namespace tmc5160
81
82#endif // TMC5160_UART_INTERFACE_HPP
CRTP base of the platform UART port.
Definition tmc5160_uart_interface.hpp:54
UartInterface & operator=(const UartInterface &)=delete
Ports are not copied: the driver holds a reference.
UartInterface() noexcept=default
Only the derived port is constructed.
UartInterface(const UartInterface &)=delete
Ports are not copied: the driver holds a reference.
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exa...
Definition tmc5160_uart_interface.hpp:74
BusStatus
Result of one UART exchange as the port reports it.
Definition tmc5160_types.hpp:199
The TMC5160 driver: everything it declares lives here; internals in detail.
Definition tmc5160.hpp:34
constexpr uint32_t kUartGapResetBits
A gap of more than this many bit times between start bits resets the chip's receiver (page 26).
Definition tmc5160_uart_interface.hpp:38
constexpr uint32_t kTurnaroundUs
Definition tmc5160_uart_interface.hpp:46
constexpr uint32_t kUartReplyMarginBits
Definition tmc5160_uart_interface.hpp:41
constexpr uint32_t kMaxBaudRate
Highest baud rate: fCLK / 16 (page 26); 750 kBaud with the internal 12 MHz clock.
Definition tmc5160_uart_interface.hpp:43
constexpr uint8_t kUartDataBits
Data bits of a frame: 8N1, one start bit and one stop bit.
Definition tmc5160_uart_interface.hpp:36
Compile-time helpers of the TMC5160 driver: typed integer literals, exact hook matching,...
Public types of the TMC5160 driver: errors, Result<T>, configuration, validation and advice.