ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
mt6701_spi.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::mt6701_spi {
7
9bool decode_frame(const uint8_t frame[3], uint16_t &count, uint8_t &status);
10
11// Noise passes the 6-bit CRC 1 time in 64, so setup wants several good frames
12static constexpr uint8_t PROBE_FRAMES = 10;
13static constexpr uint8_t PROBE_MIN_VALID = 3;
14
15enum class ProbeResult : uint8_t {
17 PROBE_RESULT_ALL_ZERO, // a stuck-low data line, or an encoder at rest
19};
20ProbeResult probe_result(uint8_t valid_frames, bool any_nonzero);
21
26 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
27 spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_1MHZ> {
28 public:
29 void setup() override;
30 void dump_config() override;
31
33 uint8_t get_status() const { return this->status_; }
34
35 protected:
36 bool read_count(uint16_t &count) override;
37
38 uint8_t status_{0};
39};
40
41} // namespace esphome::mt6701_spi
Bus-independent core; the I2C and SSI hubs provide read_count(), the entities poll it.
Definition mt6701.h:13
MT6701 over SSI: read-only, but each frame carries the field, push button and track-loss flags.
Definition mt6701_spi.h:27
bool read_count(uint16_t &count) override
uint8_t get_status() const
The 4-bit status of the last good frame: bit3 track loss, bit2 push button, bits1:0 field strength.
Definition mt6701_spi.h:33
The SPIDevice is what components using the SPI will create.
Definition spi.h:456
unsigned count
Definition gif.cpp:51
bool decode_frame(const uint8_t frame[3], uint16_t &count, uint8_t &status)
Decode a 24-bit SSI frame (14-bit angle, 4 status bits, 6-bit CRC); false when the CRC fails.
ProbeResult probe_result(uint8_t valid_frames, bool any_nonzero)