WS2812_RMT Driver 0.1.0
API reference
Loading...
Searching...
No Matches
ws2812_rmt_gpio_interface.hpp
Go to the documentation of this file.
1
24#ifndef WS2812_RMT_GPIO_INTERFACE_HPP
25#define WS2812_RMT_GPIO_INTERFACE_HPP
26
27#include <concepts>
28#include <cstdint>
29#include <span>
30
31#include "ws2812_rmt_detail.hpp"
32#include "ws2812_rmt_types.hpp"
33
34namespace ws2812_rmt {
35
37enum class CtrlPin : uint8_t {
38 Power =
39 0,
40};
41
43enum class GpioSignal : uint8_t {
44 INACTIVE = 0,
45 ACTIVE = 1,
46};
47
51inline constexpr uint32_t kMinResolutionHz = 20'000'000;
54inline constexpr uint32_t kRecommendedResolutionHz = 20'000'000;
57inline constexpr uint32_t kRmtHalfSymbolMaxTicks = 32'767;
58
67template <typename Derived>
69public:
71 GpioInterface(const GpioInterface&) = delete;
74
75protected:
77 GpioInterface() noexcept = default;
79 ~GpioInterface() noexcept = default;
80};
81
87template <typename Port>
88concept Ws2812RmtPort = std::derived_from<Port, GpioInterface<Port>> && requires {
89 detail::ExactHook<Port, bool() noexcept>::Take(&Port::EnsureInitialized);
90 detail::ExactHook<Port, bool(uint32_t&) noexcept>::Take(&Port::ResolutionHz);
91 detail::ExactHook<Port, bool(std::span<const uint8_t>, const Waveform&, uint32_t) noexcept>::Take(
92 &Port::Transmit);
93 detail::ExactHook<Port, void(uint32_t) noexcept>::Take(&Port::DelayUs);
94};
95
96} // namespace ws2812_rmt
97
98#endif // WS2812_RMT_GPIO_INTERFACE_HPP
CRTP base of the platform port.
Definition ws2812_rmt_gpio_interface.hpp:68
GpioInterface() noexcept=default
Only the derived port is constructed.
GpioInterface(const GpioInterface &)=delete
Ports are not copied: the driver holds a reference.
GpioInterface & operator=(const GpioInterface &)=delete
Ports are not copied: the driver holds a reference.
Satisfied by a class that derives from GpioInterface<Port> and implements the required hooks with exa...
Definition ws2812_rmt_gpio_interface.hpp:88
The WS2812_RMT driver: everything it declares lives here; internals in detail.
Definition ws2812_rmt.hpp:29
constexpr uint32_t kRmtHalfSymbolMaxTicks
Definition ws2812_rmt_gpio_interface.hpp:57
constexpr uint32_t kMinResolutionHz
Definition ws2812_rmt_gpio_interface.hpp:51
CtrlPin
Control pins the port may drive through the optional GpioSet() hook.
Definition ws2812_rmt_gpio_interface.hpp:37
@ Power
The strip supply or the level shifter's enable; ACTIVE means powered. Idle: INACTIVE.
constexpr uint32_t kRecommendedResolutionHz
Definition ws2812_rmt_gpio_interface.hpp:54
GpioSignal
Logical level of a pin; the port maps it to the physical polarity.
Definition ws2812_rmt_gpio_interface.hpp:43
@ ACTIVE
The pin function is asserted.
@ INACTIVE
The pin function is deasserted.
Compile-time helpers of the WS2812_RMT driver: exact hook matching and enumeration checks.
Public types of the WS2812_RMT driver: errors, Result<T>, colours, the timing profile of every suppor...