FastLED 3.10.10
Loading...
Searching...
No Matches

◆ create()

fl::shared_ptr< SpiChannelEngineAdapter > fl::SpiChannelEngineAdapter::create ( fl::vector< fl::shared_ptr< SpiHwBase > > hwControllers,
fl::vector< int > priorities,
fl::vector< const char * > names,
const char * adapterName )
static

Create unified adapter managing multiple controllers.

Parameters
hwControllersVector of hardware controllers (SpiHw1, SpiHw16, etc.)
prioritiesPer-controller priorities (must match hwControllers.size())
namesPer-controller names (must match hwControllers.size())
adapterNameUnified adapter name (e.g., "SPI_UNIFIED")
Returns
Shared pointer to adapter, or nullptr on error

Definition at line 16 of file spi_channel_adapter.cpp.hpp.

21 {
22 // Validation
23 if (hwControllers.empty()) {
24 FL_WARN("SpiChannelEngineAdapter::create: No controllers provided");
25 return nullptr;
26 }
27
28 if (hwControllers.size() != priorities.size() || hwControllers.size() != names.size()) {
29 FL_WARN("SpiChannelEngineAdapter::create: Size mismatch in arguments");
30 return nullptr;
31 }
32
33 if (!adapterName || adapterName[0] == '\0') {
34 FL_WARN("SpiChannelEngineAdapter::create: Empty adapter name");
35 return nullptr;
36 }
37
38 // Create adapter
39 auto adapter = fl::make_shared<SpiChannelEngineAdapter>(adapterName);
40
41 // Register all controllers
42 for (size_t i = 0; i < hwControllers.size(); i++) {
43 if (!hwControllers[i]) {
44 FL_WARN("SpiChannelEngineAdapter: Null controller at index " << i);
45 continue;
46 }
47
48 adapter->mControllers.emplace_back(hwControllers[i], priorities[i], names[i]);
49
50 FL_DBG("SpiChannelEngineAdapter: Registered controller '" << names[i] << "' (priority " << priorities[i] << ", lanes: " << (static_cast<int>(hwControllers[i]->getLaneCount())) << ")");
51 }
52
53 if (adapter->mControllers.empty()) {
54 FL_WARN("SpiChannelEngineAdapter: No valid controllers registered");
55 return nullptr;
56 }
57
58 for (auto& ctrl : adapter->mControllers) {
59 ctrl.controller->setStreamCompletionCallback(&streamCompletionThunk, adapter.get());
60 }
61
62 return adapter;
63}
static void streamCompletionThunk(void *context) FL_NO_EXCEPT
fl::size size() const FL_NO_EXCEPT
bool empty() const FL_NO_EXCEPT
#define FL_WARN(...)
Definition log.h:437
#define FL_DBG
Definition log.h:553
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423

References FL_DBG, fl::FL_NO_EXCEPT, FL_WARN, fl::adl_barrier::make_shared(), and streamCompletionThunk().

+ Here is the call graph for this function: