ESPHome  2024.8.3
weikai_spi.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <bitset>
10 #include <memory>
11 #include "esphome/core/component.h"
15 
16 namespace esphome {
17 namespace weikai_spi {
22  public:
23  WeikaiRegisterSPI(weikai::WeikaiComponent *const comp, uint8_t reg, uint8_t channel)
24  : weikai::WeikaiRegister(comp, reg, channel) {}
25 
26  uint8_t read_reg() const override;
27  void write_reg(uint8_t value) override;
28  void read_fifo(uint8_t *data, size_t length) const override;
29  void write_fifo(uint8_t *data, size_t length) override;
30 };
31 
37  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
38  spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
39  public:
40  weikai::WeikaiRegister &reg(uint8_t reg, uint8_t channel) override {
41  reg_spi_.register_ = reg;
42  reg_spi_.channel_ = channel;
43  return reg_spi_;
44  }
45 
46  void setup() override;
47  void dump_config() override;
48 
49  protected:
50  WeikaiRegisterSPI reg_spi_{this, 0, 0};
51 };
52 
53 } // namespace weikai_spi
54 } // namespace esphome
void setup()
WeikaiRegisterSPI(weikai::WeikaiComponent *const comp, uint8_t reg, uint8_t channel)
Definition: weikai_spi.h:23
void write_fifo(uint8_t *data, size_t length) override
Definition: weikai_spi.cpp:139
The WeikaiComponentSPI class stores the information to the WeiKai component connected through an SPI ...
Definition: weikai_spi.h:36
void write_reg(uint8_t value) override
Definition: weikai_spi.cpp:129
The SPIDevice is what components using the SPI will create.
Definition: spi.h:391
The WeikaiComponent class stores the information global to the WeiKai component and provides methods ...
Definition: weikai.h:197
WeikaiRegisterSPI objects acts as proxies to access remote register through an SPI Bus...
Definition: weikai_spi.h:21
WeiKai component family - classes declaration.
WeikaiRegister objects acts as proxies to access remote register independently of the bus type...
Definition: weikai.h:139
void read_fifo(uint8_t *data, size_t length) const override
Definition: weikai_spi.cpp:115
uint16_t length
Definition: tt21100.cpp:12
uint8_t register_
address of the register
Definition: weikai.h:186
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
weikai::WeikaiRegister & reg(uint8_t reg, uint8_t channel) override
Definition: weikai_spi.h:40
uint8_t read_reg() const override
Definition: weikai_spi.cpp:103