FastLED 3.9.15
Loading...
Searching...
No Matches
parallel_device.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "fl/stl/stdint.h"
7#include "fl/stl/vector.h"
8#include "fl/stl/unique_ptr.h"
9#include "fl/stl/optional.h"
10#include "fl/task/promise.h" // for fl::task::Error
12// IWYU pragma: begin_keep
13#include "platforms/shared/spi_types.h" // ok platform headers
14#include "fl/stl/noexcept.h"
15// IWYU pragma: end_keep // ok platform headers
16
17// Forward declarations for backends
18namespace fl {
19 class SpiIsr1;
20 class SpiIsr2;
21 class SpiIsr4;
22 class SpiIsr8;
23 class SpiIsr16;
24 class SpiIsr32;
25 class SpiBlock1;
26 class SpiBlock2;
27 class SpiBlock4;
28 class SpiBlock8;
29 class SpiBlock16;
30 class SpiBlock32;
31}
32
33namespace fl {
34namespace spi {
35
36// ============================================================================
37// ParallelDevice - 1-32 GPIO pins (single stream → LUT → parallel output)
38// ============================================================================
39
66public:
68 struct Config {
73
74 Config() FL_NOEXCEPT; // Implemented in .cpp to avoid circular dependency
75 };
76
79 explicit ParallelDevice(const Config& config);
80
83
84 // Disable copy/move
86 ParallelDevice& operator=(const ParallelDevice&) FL_NOEXCEPT = delete;
89
90 // ========== Initialization ==========
91
96
98 void end();
99
102 bool isReady() const;
103
104 // ========== Transmission ==========
105
111 Result<Transaction> write(const u8* data, size_t size);
112
116 // Use (max)() to prevent macro expansion by Arduino.h's max macro
117 bool waitComplete(u32 timeout_ms = (fl::numeric_limits<u32>::max)());
118
121 bool isBusy() const;
122
123 // ========== Configuration ==========
124
130 void configureLUT(const u32* set_masks, const u32* clear_masks);
131
134 const Config& getConfig() const;
135
136private:
137 struct Impl;
139};
140
141} // namespace spi
142} // namespace fl
bool isReady() const
Check if device is initialized.
const Config & getConfig() const
Get current configuration.
Result< Transaction > write(const u8 *data, size_t size)
Write data (single stream drives all pins via LUT)
bool waitComplete(u32 timeout_ms=(fl::numeric_limits< u32 >::max)())
Wait for pending transmission to complete.
void configureLUT(const u32 *set_masks, const u32 *clear_masks)
Configure custom LUT (advanced)
bool isBusy() const
Check if transmission is in progress.
ParallelDevice(const Config &config)
Construct parallel device.
void end()
Shutdown hardware and release resources.
fl::optional< fl::task::Error > begin()
Initialize hardware and setup LUT.
fl::unique_ptr< Impl > pImpl
Handle for asynchronous SPI operations.
Definition transaction.h:38
fl::result< T, SPIError > Result
Definition transaction.h:29
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
Optional< T > optional
Definition optional.h:16
SpiParallelMode
Parallel device execution modes.
Definition config.h:33
Base definition for an LED controller.
Definition crgb.hpp:179
Promise-based fluent API for FastLED - standalone async primitives.
#define FL_NOEXCEPT
u32 timer_hz
Timer frequency for ISR mode.
fl::vector< u8 > gpio_pins
GPIO pins (1-32 pins)
SpiParallelMode mode
Execution mode (ISR vs bit-bang)
Configuration for parallel GPIO SPI.
Transaction class for asynchronous SPI operations.