| 125 | } |
| 126 | |
| 127 | void Device::end() { |
| 128 | if (!pImpl || !pImpl->initialized) { |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | // Wait for any pending operations |
| 133 | waitComplete(); |
| 134 | |
| 135 | // Note: Do NOT call hw->end() here! |
| 136 | // The SPIBusManager will call releaseBusHardware() (which calls hw->end()) |
| 137 | // when the last device on this bus is unregistered below. |
| 138 | // Calling hw->end() here would result in calling end() twice on the same hardware. |
| 139 | pImpl->hw_backend = nullptr; |
| 140 | |
| 141 | // Unregister from bus manager |
| 142 | if (pImpl->bus_handle.is_valid) { |
| 143 | SPIBusManager& mgr = getSPIBusManager(); |
| 144 | mgr.unregisterDevice(pImpl->bus_handle); |
| 145 | pImpl->bus_handle = SPIBusHandle(); |
| 146 | } |
| 147 | |
| 148 | pImpl->initialized = false; |
| 149 | FL_LOG_SPI("SPI Device: Shutdown complete"); |
| 150 | } |
| 151 | |
| 152 | bool Device::isReady() const { |
| 153 | return pImpl && pImpl->initialized; |
no test coverage detected