MCPcopy Create free account
hub / github.com/FastLED/FastLED / acquireBuffer

Method acquireBuffer

src/fl/channels/spi/device.cpp.hpp:259–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257// }
258
259DMABuffer Device::acquireBuffer(size_t size) {
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}
285
286fl::optional<fl::task::Error> Device::transmit(DMABuffer& buffer, bool async) {
287 if (!isReady()) {

Callers 1

FL_TEST_FILEFunction · 0.80

Calls 4

DMABufferClass · 0.50
getMethod · 0.45
acquireDMABufferMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected