7static const char *
const TAG =
"as5600";
10static const uint8_t REGISTER_ZMCO = 0x00;
11static const uint8_t REGISTER_ZPOS = 0x01;
12static const uint8_t REGISTER_MPOS = 0x03;
13static const uint8_t REGISTER_MANG = 0x05;
14static const uint8_t REGISTER_CONF = 0x07;
17static const uint8_t REGISTER_ANGLE_RAW = 0x0C;
18static const uint8_t REGISTER_ANGLE = 0x0E;
21static const uint8_t REGISTER_STATUS = 0x0B;
22static const uint8_t REGISTER_AGC = 0x1A;
23static const uint8_t REGISTER_MAGNITUDE = 0x1B;
26 ESP_LOGCONFIG(TAG,
"Setting up AS5600...");
28 if (!this->
read_byte(REGISTER_STATUS).has_value()) {
49 config |= (this->
watchdog_ << 13) & 0b0010000000000000;
50 config |= (this->
fast_filter_ << 10) & 0b0001110000000000;
51 config |= (this->
slow_filter_ << 8) & 0b0000001100000000;
53 config |= (this->
output_mode_ << 4) & 0b0000000000110000;
54 config |= (this->
hysteresis_ << 2) & 0b0000000000001100;
55 config |= (this->
power_mode_ << 0) & 0b0000000000000011;
90 ESP_LOGCONFIG(TAG,
"AS5600:");
94 ESP_LOGE(TAG,
"Communication with AS5600 failed!");
98 ESP_LOGCONFIG(TAG,
" Watchdog: %d", this->
watchdog_);
99 ESP_LOGCONFIG(TAG,
" Fast Filter: %d", this->
fast_filter_);
100 ESP_LOGCONFIG(TAG,
" Slow Filter: %d", this->
slow_filter_);
101 ESP_LOGCONFIG(TAG,
" Hysteresis: %d", this->
hysteresis_);
104 ESP_LOGCONFIG(TAG,
" End Position: %d", this->
end_position_);
117 uint8_t
status = this->
reg(REGISTER_STATUS).
get() >> 3 & 0b000111;
virtual void mark_failed()
Mark this component as failed.
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
optional< uint16_t > read_position()
AS5600MagnetStatus read_magnet_status()
void dump_config() override
optional< uint16_t > read_raw_position()
bool in_range(uint16_t raw_position)
void setup() override
Set up the internal sensor array.
EndPositionMode end_mode_
InternalGPIOPin * dir_pin_
bool read_byte_16(uint8_t a_register, uint16_t *data)
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
bool write_byte_16(uint8_t a_register, uint16_t data)
uint8_t get() const
returns the register value
Providing packet encoding functions for exchanging data with a remote host.