8const char *
const TAG =
"spi";
20 if (this->
devices_.count(device) != 0) {
21 ESP_LOGE(
TAG,
"SPI device already registered");
30 if (this->
devices_.count(device) == 0) {
31 esph_log_e(
TAG,
"SPI device not registered");
39 ESP_LOGD(
TAG,
"Setting up SPI bus...");
46 ESP_LOGE(
TAG,
"No clock pin for SPI");
55 ESP_LOGE(
TAG,
"Unable to allocate SPI interface");
68 ESP_LOGCONFIG(
TAG,
"SPI bus:");
69 LOG_PIN(
" CLK Pin: ", this->
clk_pin_)
70 LOG_PIN(
" SDI Pin: ", this->
sdi_pin_)
71 LOG_PIN(
" SDO Pin: ", this->
sdo_pin_)
72 for (
size_t i = 0; i != this->
data_pins_.size(); i++) {
73 ESP_LOGCONFIG(
TAG,
" Data pin %u: GPIO%d", i, this->
data_pins_[i]);
78 ESP_LOGCONFIG(
TAG,
" Using software SPI");
91 uint16_t out_data = 0;
93 for (uint8_t i = 0; i != num_bits; i++) {
96 shift = num_bits - 1 - i;
BedjetMode mode
BedJet operating mode.
void feed_wdt(uint32_t time=0)
virtual 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)
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_
SPIDelegate * register_device(SPIClient *device, SPIMode mode, SPIBitOrder bit_order, uint32_t data_rate, GPIOPin *cs_pin)
void dump_config() override
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
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.
@ CLOCK_PHASE_LEADING
The data is sampled on a leading clock edge. (CPHA=0)
Providing packet encoding functions for exchanging data with a remote host.
Application App
Global storage of Application pointer - only one Application can exist.