MCPcopy Create free account
hub / github.com/FastLED/FastLED / registerDevice

Method registerDevice

src/platforms/shared/spi_manager.cpp.hpp:49–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49SPIBusHandle SPIBusManager::registerDevice(u8 clock_pin, u8 data_pin, u32 requested_speed_hz, void* controller) FL_NOEXCEPT {
50 if (!controller) {
51 FL_WARN("SPIBusManager: nullptr controller pointer");
52 return SPIBusHandle();
53 }
54
55 // Find or create bus for this clock pin
56 SPIBusInfo* bus = getOrCreateBus(clock_pin);
57 if (!bus) {
58 FL_WARN_FMT("SPIBusManager: Too many different clock pins (max " << MAX_BUSES << ")");
59 return SPIBusHandle();
60 }
61
62 // Check if we can add another device to this bus
63 if (bus->num_devices >= 16) {
64 FL_WARN_FMT("SPIBusManager: Too many devices on clock pin " << clock_pin << " (max 16)");
65 return SPIBusHandle();
66 }
67
68 // Add device to bus
69 u8 device_idx = bus->num_devices;
70 bus->devices[device_idx].clock_pin = clock_pin;
71 bus->devices[device_idx].data_pin = data_pin;
72 bus->devices[device_idx].controller = controller;
73 bus->devices[device_idx].lane_id = device_idx; // Tentative assignment
74 bus->devices[device_idx].requested_speed_hz = requested_speed_hz;
75 bus->devices[device_idx].is_enabled = true; // Enabled by default
76 bus->devices[device_idx].is_allocated = true; // Mark as allocated
77 bus->num_devices++;
78
79 // Return handle
80 u8 bus_id = static_cast<u8>(bus - mBuses);
81 return SPIBusHandle(bus_id, device_idx);
82}
83
84bool SPIBusManager::unregisterDevice(SPIBusHandle handle) FL_NOEXCEPT {
85 if (!handle.is_valid || handle.bus_id >= mNumBuses) {

Callers 7

beginMethod · 0.80
SPIDeviceProxyClass · 0.80
SPIDeviceProxyClass · 0.80
SPIDeviceProxyClass · 0.80
SPIDeviceProxyClass · 0.80
SPIDeviceProxyClass · 0.80
spi_manager.cppFile · 0.80

Calls 1

SPIBusHandleClass · 0.85

Tested by

no test coverage detected