FastLED 3.10.8
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 257 of file device.cpp.hpp.

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

References FL_LOG_SPI, fl::FL_NO_EXCEPT, FL_WARN, isReady(), and pImpl.

Referenced by writeAsync().

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