2020-12-06 12:43:55 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esphome/core/component.h"
|
2021-03-08 08:23:54 +13:00
|
|
|
#include "esphome/components/mcp23x17_base/mcp23x17_base.h"
|
2021-09-20 11:47:51 +02:00
|
|
|
#include "esphome/core/hal.h"
|
2020-12-06 12:43:55 -05:00
|
|
|
#include "esphome/components/spi/spi.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace mcp23s17 {
|
|
|
|
|
2021-03-08 08:23:54 +13:00
|
|
|
class MCP23S17 : public mcp23x17_base::MCP23X17Base,
|
2020-12-06 12:43:55 -05:00
|
|
|
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
|
|
|
|
spi::DATA_RATE_8MHZ> {
|
|
|
|
public:
|
|
|
|
MCP23S17() = default;
|
|
|
|
|
|
|
|
void setup() override;
|
|
|
|
void dump_config() override;
|
|
|
|
void set_device_address(uint8_t device_addr);
|
|
|
|
|
|
|
|
protected:
|
2021-03-08 08:23:54 +13:00
|
|
|
bool read_reg(uint8_t reg, uint8_t *value) override;
|
|
|
|
bool write_reg(uint8_t reg, uint8_t value) override;
|
2020-12-06 12:43:55 -05:00
|
|
|
|
2021-03-08 08:23:54 +13:00
|
|
|
uint8_t device_opcode_ = 0x40;
|
2020-12-06 12:43:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mcp23s17
|
|
|
|
} // namespace esphome
|