FastLED 3.9.15
Loading...
Searching...
No Matches

◆ acquireBuffer()

DMABuffer fl::spi::Device::acquireBuffer ( size_t size)

Acquire DMA-capable buffer for zero-copy transmission.

Parameters
sizeNumber of bytes needed
Returns
DMABuffer (managed buffer) or error
Note
Buffer is backed by DMA-capable memory (PSRAM on ESP32)
Buffer lifetime managed by shared_ptr

Definition at line 259 of file device.cpp.hpp.

259 {
260 if (!isReady()) {
261 return DMABuffer(SPIError::NOT_INITIALIZED);
262 }
263
264 // Get hardware controller
265 if (!pImpl->hw_backend) {
266 FL_WARN("SPI Device: No hardware controller available");
267 return DMABuffer(SPIError::NOT_INITIALIZED);
268 }
269
270 // Use polymorphic interface (works for SpiHw1/2/4/8)
271 SpiHwBase* hw = pImpl->hw_backend.get();
272
273 // Always acquire a fresh buffer from hardware
274 // Note: The hardware controller may internally cache/reuse buffers
275 DMABuffer buffer = hw->acquireDMABuffer(size);
276
277 if (!buffer.ok()) {
278 FL_WARN("SPI Device: Failed to acquire DMA buffer from hardware");
279 } else {
280 FL_LOG_SPI("SPI Device: Acquired DMA buffer (" << size << " bytes)");
281 }
282
283 return buffer;
284}
bool isReady() const
Check if device is initialized and ready for use.
fl::unique_ptr< Impl > pImpl
Definition device.h:134
#define FL_LOG_SPI(X)
Serial Peripheral Interface (SPI) logging Logs SPI configuration, initialization, and transfers.
Definition log.h:474
#define FL_WARN(X)
Definition log.h:276

References FL_LOG_SPI, FL_WARN, isReady(), and pImpl.

Referenced by writeAsync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: