empty spi component

master
HB 5 years ago
parent ae2bff7380
commit 33bff3a1e8

@ -15,7 +15,7 @@ void EmptyI2CComponent::loop() {
} }
void EmptyI2CComponent::dump_config(){ void EmptyI2CComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty i2c component"); ESP_LOGCONFIG(TAG, "Empty I2C component");
} }

@ -0,0 +1,18 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import spi
from esphome.const import CONF_ID
DEPENDENCIES = ['spi']
empty_spi_component_ns = cg.esphome_ns.namespace('empty_spi_component')
EmptySPIComponent = empty_spi_component_ns.class_('EmptySPIComponent', cg.Component, spi.SPIDevice)
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(EmptySPIComponent)
}).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema(cs_pin_required=True))
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield spi.register_spi_device(var, config)

@ -0,0 +1,22 @@
#include "esphome/core/log.h"
#include "empty_spi_component.h"
namespace esphome {
namespace empty_spi_component {
static const char *TAG = "empty_spi_component.component";
void EmptySPIComponent::setup() {
}
void EmptySPIComponent::loop() {
}
void EmptySPIComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty SPI component");
}
} // namespace empty_spi_component
} // namespace esphome

@ -0,0 +1,20 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/spi/spi.h"
namespace esphome {
namespace empty_spi_component {
class EmptySPIComponent : public Component,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST,spi::CLOCK_POLARITY_LOW,
spi::CLOCK_PHASE_LEADING,spi::DATA_RATE_1KHZ> {
public:
void setup() override;
void loop() override;
void dump_config() override;
};
} // namespace empty_spi_component
} // namespace esphome

@ -15,7 +15,7 @@ void EmptyUARTComponent::loop() {
} }
void EmptyUARTComponent::dump_config(){ void EmptyUARTComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty i2c component"); ESP_LOGCONFIG(TAG, "Empty UART component");
} }
} // namespace empty_uart_component } // namespace empty_uart_component

@ -56,3 +56,11 @@ uart:
empty_uart_component: empty_uart_component:
id: empty_uart_component_1 id: empty_uart_component_1
spi:
clk_pin: D5
miso_pin: D6
empty_spi_component:
id: empty_spi_component_1
cs_pin: D8
Loading…
Cancel
Save