Create unified adapter managing multiple controllers.
22 {
23
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
41
42
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] <<
"' (priority " << priorities[i] <<
", lanes: " << (
static_cast<int>(hwControllers[i]->getLaneCount())) <<
")");
52 }
53
54 if (adapter->mControllers.empty()) {
55 FL_WARN(
"SpiChannelEngineAdapter: No valid controllers registered");
56 return nullptr;
57 }
58
59 return adapter;
60}
fl::size size() const FL_NO_EXCEPT
bool empty() const FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT