Acquire DMA-capable buffer for zero-copy transmission.
- Parameters
-
| size | Number 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 {
259 return DMABuffer(SPIError::NOT_INITIALIZED);
260 }
261
262
263 if (!
pImpl->hw_backend) {
264 FL_WARN(
"SPI Device: No hardware controller available");
265 return DMABuffer(SPIError::NOT_INITIALIZED);
266 }
267
268
269 SpiHwBase* hw =
pImpl->hw_backend.get();
270
271
272
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
#define FL_LOG_SPI(...)
Serial Peripheral Interface (SPI) logging Logs SPI configuration, initialization, and transfers.
References FL_LOG_SPI, fl::FL_NO_EXCEPT, FL_WARN, isReady(), and pImpl.
Referenced by writeAsync().