TMC9660 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
tmc9660_uart_interface.hpp
Go to the documentation of this file.
1
27#ifndef TMC9660_UART_INTERFACE_HPP
28#define TMC9660_UART_INTERFACE_HPP
29
30#include <concepts>
31#include <cstddef>
32#include <cstdint>
33
34#include "tmc9660_detail.hpp"
35#include "tmc9660_types.hpp"
36
37namespace tmc9660 {
38
44inline constexpr uint8_t kUartDataBits = 8;
46inline constexpr uint32_t kMaxBaudRate = 5'000'000;
50inline constexpr uint32_t kTurnaroundUs = 1'000;
52inline constexpr uint32_t kMinAutobaudRate = 9'600;
54inline constexpr uint32_t kMaxAutobaudRate = 250'000;
61template <typename Derived>
63public:
65 UartInterface(const UartInterface&) = delete;
68
69protected:
71 UartInterface() noexcept = default;
73 ~UartInterface() noexcept = default;
74};
75
81template <typename Port>
82concept UartPort = std::derived_from<Port, UartInterface<Port>> && requires {
83 detail::ExactHook<Port, bool() noexcept>::Take(&Port::EnsureInitialized);
84 detail::ExactHook<Port, BusStatus(const uint8_t*, std::size_t, uint8_t*, std::size_t,
85 uint32_t) noexcept>::Take(&Port::Exchange);
86};
87
88} // namespace tmc9660
89
90#endif // TMC9660_UART_INTERFACE_HPP
CRTP base of the platform UART port.
Definition tmc9660_uart_interface.hpp:62
UartInterface() noexcept=default
Only the derived port is constructed.
UartInterface & operator=(const UartInterface &)=delete
Ports are not copied: the driver holds a reference.
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 tmc9660_uart_interface.hpp:82
BusStatus
What a UART port reports for one exchange.
Definition tmc9660_types.hpp:180
The TMC9660 driver: everything it declares lives here; internals in detail.
Definition tmc9660.hpp:37
constexpr uint32_t kMinAutobaudRate
Lowest standard baud rate the chip detects automatically.
Definition tmc9660_uart_interface.hpp:52
constexpr uint32_t kMaxBaudRate
Highest baud rate.
Definition tmc9660_uart_interface.hpp:46
constexpr uint8_t kUartDataBits
Data bits of a frame: 8N1, one start bit and one stop bit.
Definition tmc9660_uart_interface.hpp:44
constexpr uint32_t kMaxAutobaudRate
Highest standard baud rate the chip detects automatically at a 40 MHz system clock.
Definition tmc9660_uart_interface.hpp:54
constexpr uint32_t kTurnaroundUs
Definition tmc9660_uart_interface.hpp:50
Compile-time helpers of the TMC9660 driver: byte copy, exact hook matching, typed register fields and...
Public types of the TMC9660 driver: errors, Result<T>, the protocol enumerations, Config and its mode...