7const char *
const TAG =
"spi";
18 GPIOPin *cs_pin,
bool release_device,
bool write_only) {
19 if (this->
devices_.count(device) != 0) {
20 ESP_LOGE(
TAG,
"Device already registered");
30 if (this->
devices_.count(device) == 0) {
31 esph_log_e(
TAG,
"Device not registered");
44 ESP_LOGE(
TAG,
"No clock pin");
53 ESP_LOGE(
TAG,
"Unable to allocate SPI interface");
66 ESP_LOGCONFIG(
TAG,
"SPI bus:");
67 LOG_PIN(
" CLK Pin: ", this->
clk_pin_)
68 LOG_PIN(
" SDI Pin: ", this->
sdi_pin_)
69 LOG_PIN(
" SDO Pin: ", this->
sdo_pin_)
70 for (
size_t i = 0; i != this->
data_pins_.size(); i++) {
71 ESP_LOGCONFIG(
TAG,
" Data pin %u: GPIO%d", i, this->
data_pins_[i]);
76 ESP_LOGCONFIG(
TAG,
" Using software SPI");
89 uint16_t out_data = 0;
91 for (uint8_t i = 0; i != num_bits; i++) {
94 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, 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.
@ 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.