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

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

References FL_LOG_SPI, fl::FL_NO_EXCEPT, fl::nullopt, and pImpl.