7 static const char *
const TAG =
"as5600";
10 static const uint8_t REGISTER_ZMCO = 0x00;
11 static const uint8_t REGISTER_ZPOS = 0x01;
12 static const uint8_t REGISTER_MPOS = 0x03;
13 static const uint8_t REGISTER_MANG = 0x05;
14 static const uint8_t REGISTER_CONF = 0x07;
17 static const uint8_t REGISTER_ANGLE_RAW = 0x0C;
18 static const uint8_t REGISTER_ANGLE = 0x0E;
21 static const uint8_t REGISTER_STATUS = 0x0B;
22 static const uint8_t REGISTER_AGC = 0x1A;
23 static 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 digital_write(bool value)=0
InternalGPIOPin * dir_pin_
EndPositionMode end_mode_
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
bool read_byte_16(uint8_t a_register, uint16_t *data)
void dump_config() override
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
uint8_t get() const
returns the register value
AS5600MagnetStatus read_magnet_status()
virtual void pin_mode(gpio::Flags flags)=0
void setup() override
Set up the internal sensor array.
optional< uint16_t > read_position()
optional< uint16_t > read_raw_position()
bool in_range(uint16_t raw_position)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
bool write_byte_16(uint8_t a_register, uint16_t data)