MCPcopy Create free account
hub / github.com/FastLED/FastLED / ESP32SPIOutput

Class ESP32SPIOutput

src/platforms/esp/32/core/fastspi_esp32_idf.h:46–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45template <u8 DATA_PIN, u8 CLOCK_PIN, u32 SPI_SPEED>
46class ESP32SPIOutput {
47 spi_device_handle_t mSPIHandle;
48 spi_host_device_t mHost;
49 Selectable* mPSelect;
50 bool mInitialized;
51 bool mInTransaction;
52 spi_transaction_t mTransaction;
53
54public:
55 // Verify that the pins are valid
56 FL_STATIC_ASSERT(FastPin<DATA_PIN>::validpin(), "Invalid data pin specified");
57 FL_STATIC_ASSERT(FastPin<CLOCK_PIN>::validpin(), "Invalid clock pin specified");
58
59 ESP32SPIOutput()
60 : mSPIHandle(nullptr)
61 , mHost(FASTLED_ESP32_DEFAULT_SPI_HOST)
62 , mPSelect(nullptr)
63 , mInitialized(false)
64 , mInTransaction(false)
65 {
66 fl::memset(&mTransaction, 0, sizeof(mTransaction));
67 }
68
69 ESP32SPIOutput(Selectable* pSelect)
70 : mSPIHandle(nullptr)
71 , mHost(FASTLED_ESP32_DEFAULT_SPI_HOST)
72 , mPSelect(pSelect)
73 , mInitialized(false)
74 , mInTransaction(false)
75 {
76 fl::memset(&mTransaction, 0, sizeof(mTransaction));
77 }
78
79 ~ESP32SPIOutput() {
80 if (mInitialized) {
81 if (mSPIHandle) {
82 spi_bus_remove_device(mSPIHandle);
83 mSPIHandle = nullptr;
84 }
85 spi_bus_free(mHost);
86 mInitialized = false;
87 }
88 }
89
90 void setSelect(Selectable* pSelect) FL_NOEXCEPT {
91 mPSelect = pSelect;
92 }
93
94 void init() FL_NOEXCEPT {
95 if (mInitialized) {
96 return;
97 }
98
99 // Configure SPI bus
100 spi_bus_config_t bus_config = {};
101 bus_config.mosi_io_num = DATA_PIN;
102 bus_config.miso_io_num = -1; // Not used for LED strips
103 bus_config.sclk_io_num = CLOCK_PIN;

Callers

nothing calls this directly

Calls 2

selectMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected