SPI Bus

API Reference

class SPIComponent : public Component

Public Functions

SPIComponent(GPIOPin *clk, GPIOPin *miso, GPIOPin *mosi)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

void dump_config()
uint8_t ICACHE_RAM_ATTR HOT SPIComponent::read_byte()
void ICACHE_RAM_ATTR HOT SPIComponent::read_array(uint8_t * data, size_t length)
void ICACHE_RAM_ATTR HOT SPIComponent::write_byte(uint8_t data)
void ICACHE_RAM_ATTR HOT SPIComponent::write_array(uint8_t * data, size_t length)
void ICACHE_RAM_ATTR HOT SPIComponent::enable(GPIOPin * cs, bool msb_first, bool high_speed)
void ICACHE_RAM_ATTR HOT SPIComponent::disable()
float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

void set_miso(const GPIOInputPin &miso)
void set_mosi(const GPIOOutputPin &mosi)

Protected Attributes

GPIOPin *clk_
GPIOPin *miso_
GPIOPin *mosi_
GPIOPin *active_cs_ = {nullptr}
bool msb_first_ = {true}
bool high_speed_ = {false}
class SPIDevice

Subclassed by binary_sensor::PN532Component, display::MAX7219Component, display::SPISSD1306, display::WaveshareEPaper, sensor::MAX6675Sensor

Public Functions

SPIDevice(SPIComponent *parent, GPIOPin *cs)
void spi_setup()
void HOT SPIDevice::enable()
void HOT SPIDevice::disable()
uint8_t HOT SPIDevice::read_byte()
void HOT SPIDevice::read_array(uint8_t * data, size_t length)
void HOT SPIDevice::write_byte(uint8_t data)
void HOT SPIDevice::write_array(uint8_t * data, size_t length)

Protected Functions

virtual bool msb_first() = 0
bool HOT SPIDevice::high_speed()

Protected Attributes

SPIComponent *parent_
GPIOPin *cs_