FastLED 3.9.15
Loading...
Searching...
No Matches
impl.h
Go to the documentation of this file.
1#pragma once
2
6
7// IWYU pragma: begin_keep
8#include "platforms/shared/spi_manager.h" // ok platform headers
9#include "platforms/shared/spi_types.h" // ok platform headers
10#include "platforms/shared/spi_hw_base.h" // ok platform headers
11#include "fl/log/log.h"
12#include "fl/stl/noexcept.h"
13// IWYU pragma: end_keep
14
15namespace fl {
16namespace spi {
17
21 SPIBusHandle bus_handle;
23
32
37
40
42 explicit Impl(const Config& cfg)
43 : config(cfg)
44 , bus_handle()
45 , initialized(false)
46 , async_state{false, nullptr, nullptr, 0, 0}
47 , hw_backend(nullptr)
48 , owns_backend(false) {}
49
52 FL_LOG_SPI("Device::Impl: Destructor called");
53 // Members will be destroyed in reverse order of declaration:
54 // 1. owns_backend (bool) - trivial
55 // 2. hw_backend (void*) - trivial (pointer not owned here)
56 // 3. async_state (struct) - trivial
57 // 4. initialized (bool) - trivial
58 // 5. bus_handle (struct) - trivial
59 // 6. config (Config) - contains fl::vector which might cause issues
60 FL_LOG_SPI("Device::Impl: Destructor complete");
61 }
62};
63
67 bool completed;
68 bool cancelled;
71
72 // Platform-specific completion tracking
73#ifdef FL_IS_ESP32
74 void* notify_task;
75#endif
76
78 explicit Impl(Device* dev)
79 : device(dev)
80 , completed(false)
81 , cancelled(false)
82 , result(fl::nullopt) // nullopt = success
83 , timeout_ms((fl::numeric_limits<u32>::max)())
84#ifdef FL_IS_ESP32
85 , notify_task(nullptr)
86#endif
87 {}
88};
89
90} // namespace spi
91} // namespace fl
friend class Device
Definition transaction.h:72
#define FL_LOG_SPI(X)
Serial Peripheral Interface (SPI) logging Logs SPI configuration, initialization, and transfers.
Definition log.h:474
Centralized logging categories for FastLED hardware interfaces and subsystems.
fl::SpiConfig Config
Definition config.h:82
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
constexpr nullopt_t nullopt
Definition optional.h:13
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
bool owns_backend
True if this Device owns the hw_backend (SINGLE_SPI mode)
Definition impl.h:39
struct fl::spi::Device::Impl::AsyncState async_state
SPIBusHandle bus_handle
Handle from SPIBusManager.
Definition impl.h:21
fl::shared_ptr< SpiHwBase > hw_backend
Platform-specific backend pointer (for single-lane SPI)
Definition impl.h:36
Impl(const Config &cfg)
Constructor.
Definition impl.h:42
~Impl() FL_NOEXCEPT
Destructor.
Definition impl.h:51
Config config
Device configuration.
Definition impl.h:20
bool initialized
Whether hardware is initialized.
Definition impl.h:22
Private implementation data for Device class.
Definition impl.h:19
u32 start_time
Start time for timeout tracking.
Definition impl.h:30
size_t size
Transfer size in bytes.
Definition impl.h:29
u8 * rx_buffer
RX buffer pointer (caller-owned)
Definition impl.h:28
const u8 * tx_buffer
TX buffer pointer (caller-owned)
Definition impl.h:27
bool active
Whether an async operation is in progress.
Definition impl.h:26
State for async operations.
Definition impl.h:25
Device * device
Back-reference to device.
Definition impl.h:66
Impl(Device *dev)
Constructor.
Definition impl.h:78
bool completed
Whether transaction has completed.
Definition impl.h:67
bool cancelled
Whether transaction was cancelled.
Definition impl.h:68
fl::optional< fl::task::Error > result
Result of the transaction (nullopt = success)
Definition impl.h:69
u32 timeout_ms
Timeout value in milliseconds.
Definition impl.h:70
Private implementation data for Transaction class.
Definition impl.h:65