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

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

References FL_LOG_SPI, fl::FL_NO_EXCEPT, 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: