@brief SPI device configuration Encapsulates device-specific parameters (clock speed, mode, queue depth). Maps directly to ESP-IDF's spi_device_interface_config_t structure.
| 97 | /// Encapsulates device-specific parameters (clock speed, mode, queue depth). |
| 98 | /// Maps directly to ESP-IDF's spi_device_interface_config_t structure. |
| 99 | struct SpiDeviceConfig { |
| 100 | u8 mode; ///< SPI mode (0-3), typically 0 for WS2812 |
| 101 | int clock_speed_hz; ///< Clock frequency in Hz (e.g., 2500000 for WS2812) |
| 102 | int queue_size; ///< Transaction queue depth (typically 2-4) |
| 103 | u32 flags; ///< Device flags (e.g., SPI_DEVICE_NO_DUMMY) |
| 104 | int spics_io_num; ///< Chip select pin (-1 if unused) |
| 105 | |
| 106 | /// @brief Default constructor |
| 107 | SpiDeviceConfig() |
| 108 | FL_NOEXCEPT : mode(0) |
| 109 | , clock_speed_hz(0) |
| 110 | , queue_size(0) |
| 111 | , flags(0) |
| 112 | , spics_io_num(-1) |
| 113 | {} |
| 114 | |
| 115 | /// @brief Constructor with common parameters |
| 116 | /// @param clock_hz Clock frequency in Hz |
| 117 | /// @param queue_depth Transaction queue size |
| 118 | /// @param spi_mode SPI mode (0-3) |
| 119 | SpiDeviceConfig(int clock_hz, int queue_depth, u8 spi_mode = 0) |
| 120 | FL_NOEXCEPT : mode(spi_mode) |
| 121 | , clock_speed_hz(clock_hz) |
| 122 | , queue_size(queue_depth) |
| 123 | , flags(0) |
| 124 | , spics_io_num(-1) |
| 125 | {} |
| 126 | }; |
| 127 | |
| 128 | /// @brief SPI transaction descriptor |
| 129 | /// |