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

◆ setClockSpeed()

fl::optional< fl::task::Error > fl::spi::Device::setClockSpeed ( u32 speed_hz)

Update clock speed.

Parameters
speed_hzNew clock speed in Hz
Returns
Result indicating success or error
Note
Runtime updates not yet supported - new speed takes effect on next begin()
To apply immediately: call end() then begin()

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

358 {
359 if (!pImpl) {
360 return fl::task::Error("Device not initialized");
361 }
362
363 // Update the configuration
364 pImpl->config.clock_speed_hz = speed_hz;
365
366 // Note: Runtime clock speed updates are not currently supported by the hardware layer.
367 // The new speed will take effect on the next begin() call.
368 // To apply immediately, call end() followed by begin().
369
370 if (pImpl->initialized) {
371 FL_LOG_SPI("SPI Device: Clock speed updated to " << speed_hz
372 << " Hz (will take effect on next begin())");
373 } else {
374 FL_LOG_SPI("SPI Device: Clock speed set to " << speed_hz << " Hz");
375 }
376
377 return fl::nullopt;
378}
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
constexpr nullopt_t nullopt
Definition optional.h:13

References FL_LOG_SPI, fl::nullopt, and pImpl.