ESPHome  2022.1.2
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::spi::SPIComponent Class Reference

#include <spi.h>

Inheritance diagram for esphome::spi::SPIComponent:
esphome::Component

Public Member Functions

void set_clk (GPIOPin *clk)
 
void set_miso (GPIOPin *miso)
 
void set_mosi (GPIOPin *mosi)
 
void setup () override
 
void dump_config () override
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
uint8_t read_byte ()
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void read_array (uint8_t *data, size_t length)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void write_byte (uint8_t data)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void write_byte16 (const uint16_t data)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void write_array16 (const uint16_t *data, size_t length)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void write_array (const uint8_t *data, size_t length)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
uint8_t transfer_byte (uint8_t data)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void transfer_array (uint8_t *data, size_t length)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, uint32_t DATA_RATE>
void enable (GPIOPin *cs)
 
void disable ()
 
float get_setup_priority () const override
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, bool READ, bool WRITE>
uint8_t HOT transfer_ (uint8_t data)
 
- Public Member Functions inherited from esphome::Component
virtual void loop ()
 This method will be called repeatedly. More...
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed ()
 
virtual bool can_proceed ()
 
bool status_has_warning ()
 
bool status_has_error ()
 
void status_set_warning ()
 
void status_set_error ()
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 

Protected Member Functions

void cycle_clock_ (bool value)
 
template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, bool READ, bool WRITE>
uint8_t transfer_ (uint8_t data)
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_setup ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult()> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult()> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

GPIOPinclk_
 
GPIOPinmiso_ {nullptr}
 
GPIOPinmosi_ {nullptr}
 
GPIOPinactive_cs_ {nullptr}
 
SPIClass * hw_spi_ {nullptr}
 
uint32_t wait_cycle_
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ = nullptr
 

Detailed Description

Definition at line 72 of file spi.h.

Member Function Documentation

◆ cycle_clock_()

void esphome::spi::SPIComponent::cycle_clock_ ( bool  value)
inlineprotected

Definition at line 107 of file spi.cpp.

◆ disable()

void IRAM_ATTR HOT esphome::spi::SPIComponent::disable ( )

Definition at line 11 of file spi.cpp.

◆ dump_config()

void esphome::spi::SPIComponent::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 96 of file spi.cpp.

◆ enable()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, uint32_t DATA_RATE>
void esphome::spi::SPIComponent::enable ( GPIOPin cs)
inline

Definition at line 195 of file spi.h.

◆ get_setup_priority()

float esphome::spi::SPIComponent::get_setup_priority ( ) const
overridevirtual

Reimplemented from esphome::Component.

Definition at line 105 of file spi.cpp.

◆ read_array()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::read_array ( uint8_t *  data,
size_t  length 
)
inline

Definition at line 92 of file spi.h.

◆ read_byte()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
uint8_t esphome::spi::SPIComponent::read_byte ( )
inline

Definition at line 82 of file spi.h.

◆ set_clk()

void esphome::spi::SPIComponent::set_clk ( GPIOPin clk)
inline

Definition at line 74 of file spi.h.

◆ set_miso()

void esphome::spi::SPIComponent::set_miso ( GPIOPin miso)
inline

Definition at line 75 of file spi.h.

◆ set_mosi()

void esphome::spi::SPIComponent::set_mosi ( GPIOPin mosi)
inline

Definition at line 76 of file spi.h.

◆ setup()

void esphome::spi::SPIComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 22 of file spi.cpp.

◆ transfer_() [1/2]

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, bool READ, bool WRITE>
template uint8_t esphome::spi::SPIComponent::transfer_< BIT_ORDER_MSB_FIRST, CLOCK_POLARITY_HIGH, CLOCK_PHASE_TRAILING, true, true > ( uint8_t  data)

Definition at line 125 of file spi.cpp.

◆ transfer_() [2/2]

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE, bool READ, bool WRITE>
uint8_t esphome::spi::SPIComponent::transfer_ ( uint8_t  data)
protected

◆ transfer_array()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::transfer_array ( uint8_t *  data,
size_t  length 
)
inline

Definition at line 173 of file spi.h.

◆ transfer_byte()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
uint8_t esphome::spi::SPIComponent::transfer_byte ( uint8_t  data)
inline

Definition at line 158 of file spi.h.

◆ write_array()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::write_array ( const uint8_t *  data,
size_t  length 
)
inline

Definition at line 144 of file spi.h.

◆ write_array16()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::write_array16 ( const uint16_t *  data,
size_t  length 
)
inline

Definition at line 129 of file spi.h.

◆ write_byte()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::write_byte ( uint8_t  data)
inline

Definition at line 105 of file spi.h.

◆ write_byte16()

template<SPIBitOrder BIT_ORDER, SPIClockPolarity CLOCK_POLARITY, SPIClockPhase CLOCK_PHASE>
void esphome::spi::SPIComponent::write_byte16 ( const uint16_t  data)
inline

Definition at line 116 of file spi.h.

Field Documentation

◆ active_cs_

GPIOPin* esphome::spi::SPIComponent::active_cs_ {nullptr}
protected

Definition at line 236 of file spi.h.

◆ clk_

GPIOPin* esphome::spi::SPIComponent::clk_
protected

Definition at line 233 of file spi.h.

◆ hw_spi_

SPIClass* esphome::spi::SPIComponent::hw_spi_ {nullptr}
protected

Definition at line 238 of file spi.h.

◆ miso_

GPIOPin* esphome::spi::SPIComponent::miso_ {nullptr}
protected

Definition at line 234 of file spi.h.

◆ mosi_

GPIOPin* esphome::spi::SPIComponent::mosi_ {nullptr}
protected

Definition at line 235 of file spi.h.

◆ wait_cycle_

uint32_t esphome::spi::SPIComponent::wait_cycle_
protected

Definition at line 240 of file spi.h.


The documentation for this class was generated from the following files: