FastLED 3.9.15
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 17 of file spi_channel_adapter.cpp.hpp.

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

References FL_DBG, FL_WARN, fl::make_shared(), and fl::vector_basic::size().

+ Here is the call graph for this function: