| 277 | } |
| 278 | |
| 279 | void SPISingleESP32::cleanup() FL_NOEXCEPT { |
| 280 | if (mInitialized) { |
| 281 | // Wait for any pending transmission |
| 282 | if (mTransactionActive) { |
| 283 | waitComplete(); |
| 284 | } |
| 285 | |
| 286 | // Release DMA buffer |
| 287 | mDMABuffer.reset(); |
| 288 | mBufferAcquired = false; |
| 289 | |
| 290 | // Remove device and free bus |
| 291 | if (mSPIHandle) { |
| 292 | spi_bus_remove_device(mSPIHandle); |
| 293 | mSPIHandle = nullptr; |
| 294 | } |
| 295 | |
| 296 | if (mBusInitializedByUs) { |
| 297 | spi_bus_free(mHost); |
| 298 | mBusInitializedByUs = false; |
| 299 | } |
| 300 | mInitialized = false; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // ============================================================================ |
| 305 | // Instance Management (accessed by spi_esp32_init.cpp) |