22 GPIOPin *cs_pin,
bool release_device,
bool write_only) {
23 if (this->
devices_.contains(device)) {
24 ESP_LOGE(TAG,
"Device already registered");
40 if (!this->
devices_.contains(device)) {
41 esph_log_e(TAG,
"Device not registered");
54 ESP_LOGE(TAG,
"No clock pin");
63 ESP_LOGE(TAG,
"Unable to allocate SPI interface");
76 ESP_LOGCONFIG(TAG,
"SPI bus:");
77 LOG_PIN(
" CLK Pin: ", this->
clk_pin_);
78 LOG_PIN(
" SDI Pin: ", this->
sdi_pin_);
79 LOG_PIN(
" SDO Pin: ", this->
sdo_pin_);
80 for (
size_t i = 0; i != this->
data_pins_.size(); i++) {
81 ESP_LOGCONFIG(TAG,
" Data pin %zu: GPIO%d", i, this->
data_pins_[i]);
89 ESP_LOGCONFIG(TAG,
" Using software SPI");
102 uint16_t out_data = 0;
104 for (uint8_t i = 0; i != num_bits; i++) {
107 shift = num_bits - 1 - i;
134#if defined(USE_ZEPHYR)
137 const std::vector<uint8_t> &data_pins) {
138 if (!device_is_ready(interface)) {
139 ESP_LOGE(TAG,
"SPI device is not ready");
145#elif !defined(USE_ESP32) && !defined(USE_ARDUINO)
148 const std::vector<uint8_t> &data_pins) {
BedjetMode mode
BedJet operating mode.
void feed_wdt()
Feed the task watchdog.
void mark_failed()
Mark this component as failed.
virtual void digital_write(bool value)=0
virtual bool digital_read()=0
A pin to replace those that don't exist.
static GPIOPin *const NULL_PIN
virtual SPIDelegate * get_delegate(uint32_t data_rate, SPIBitOrder bit_order, SPIMode mode, GPIOPin *cs_pin, bool release_device, bool write_only)
Base class for SPIDevice, un-templated.
void unregister_device(SPIClient *device)
static SPIBus * get_bus(SPIInterface interface, GPIOPin *clk, GPIOPin *sdo, GPIOPin *sdi, const std::vector< uint8_t > &data_pins)
std::map< SPIClient *, SPIDelegate * > devices_
void dump_config() override
SPIDelegate * register_device(SPIClient *device, SPIMode mode, SPIBitOrder bit_order, uint32_t data_rate, GPIOPin *cs_pin, bool release_device, bool write_only)
const char * interface_name_
std::vector< uint8_t > data_pins_
uint8_t transfer(uint8_t data) override
SPIClockPolarity clock_polarity_
void write(uint16_t data, size_t num_bits) override
SPIClockPhase clock_phase_
uint16_t transfer_(uint16_t data, size_t num_bits)
A dummy SPIDelegate that complains if it's used.
void begin_transaction() override
static SPIDelegate *const NULL_DELEGATE
Implementation of SPI Controller mode.
SPIMode
Modes mapping to clock phase and polarity.
SPIBitOrder
The bit-order for SPI devices. This defines how the data read from and written to the device is inter...
@ BIT_ORDER_MSB_FIRST
The most significant bit is transmitted/received first.
ESPHOME_LOG_TAG(TAG, "spi")
@ CLOCK_PHASE_LEADING
The data is sampled on a leading clock edge. (CPHA=0)
Application App
Global storage of Application pointer - only one Application can exist.
spi_host_device_t SPIInterface