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

◆ transmit()

fl::optional< fl::task::Error > fl::spi::Device::transmit ( DMABuffer & buffer,
bool async = true )

Transmit from previously acquired DMA buffer.

Parameters
bufferBuffer acquired via acquireBuffer()
asyncIf true, returns immediately; if false, waits for completion
Returns
Result indicating success or error
Note
Zero-copy: buffer is transmitted directly via DMA

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

286 {
287 if (!isReady()) {
288 return fl::task::Error("Device not initialized");
289 }
290
291 if (!buffer.ok()) {
292 return fl::task::Error("Invalid buffer");
293 }
294
295 // Get hardware controller
296 if (!pImpl->hw_backend) {
297 FL_WARN("SPI Device: No hardware controller available");
298 return fl::task::Error("No hardware controller");
299 }
300
301 // Use polymorphic interface (works for SpiHw1/2/4/8)
302 SpiHwBase* hw = pImpl->hw_backend.get();
303
304 // Start transmission
305 TransmitMode mode = async ? TransmitMode::ASYNC : TransmitMode::SYNC;
306 bool success = hw->transmit(mode);
307
308 if (!success) {
309 FL_WARN("SPI Device: Transmission failed");
310 return fl::task::Error("Transmission failed");
311 }
312
313 // If blocking mode, wait for completion
314 if (!async) {
315 if (!hw->waitComplete()) {
316 FL_WARN("SPI Device: Wait for completion failed");
317 return fl::task::Error("Wait for completion failed");
318 }
319 }
320
321 FL_LOG_SPI("SPI Device: Transmission started (" << (async ? "async" : "blocking") << ")");
322 return fl::nullopt;
323}
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
constexpr nullopt_t nullopt
Definition optional.h:13

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

Referenced by writeAsync().

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