Skip to main content

AS5600_Driver/
regs.rs

1/// Standard I2C address for the AS5600 (fixed by manufacturer).
2pub const DEFAULT_ADDR: u8 = 0x36;
3
4/// Register map for the AS5600 according to ams datasheet.
5///
6/// Registers are mostly 12-bit values spread across two 8-bit registers (HI/LO).
7pub mod regs {
8    /// Zero setting multi-cycle counter.
9    ///
10    /// Indicates how many times the `BURN_SETTINGS` command has been executed (max 3).
11    pub const ZMCO: u8 = 0x00;
12
13    /// Start position (ZPOS) - HI register.
14    /// Defines the 0 degree point.
15    pub const ZPOS_HI: u8 = 0x01;
16    /// Start position (ZPOS) - LO register.
17    pub const ZPOS_LO: u8 = 0x02;
18
19    /// Stop position (MPOS) - HI register.
20    /// Defines the end point of the measuring range.
21    pub const MPOS_HI: u8 = 0x03;
22    /// Stop position (MPOS) - LO register.
23    pub const MPOS_LO: u8 = 0x04;
24
25    /// Maximum angle (MANG) - HI register.
26    /// Defines the full range angle (if ZPOS/MPOS are not set manually).
27    pub const MANG_HI: u8 = 0x05;
28    /// Maximum angle (MANG) - LO register.
29    pub const MANG_LO: u8 = 0x06;
30
31    /// Configuration register - HI byte.
32    pub const CONF_HI: u8 = 0x07;
33    /// Configuration register - LO byte.
34    pub const CONF_LO: u8 = 0x08;
35
36    /// Status register.
37    /// Contains magnet detection flags (MH, ML, MD).
38    pub const STATUS: u8 = 0x0B;
39
40    /// Raw Angle - HI register.
41    /// The direct 12-bit value from the Hall sensors.
42    pub const RAW_ANGLE_HI: u8 = 0x0C;
43    /// Raw Angle - LO register.
44    pub const RAW_ANGLE_LO: u8 = 0x0D;
45
46    /// Angle - HI register.
47    /// The 12-bit value after applying Zero Position, Maximum Position and filters.
48    pub const ANGLE_HI: u8 = 0x0E;
49    /// Angle - LO register.
50    pub const ANGLE_LO: u8 = 0x0F;
51
52    /// Automatic Gain Control.
53    /// Returns 0..255 indicating the magnetic field stability.
54    pub const AGC: u8 = 0x1A;
55
56    /// Magnitude - HI register.
57    /// Internal representation of the magnetic field strength.
58    pub const MAGNITUDE_HI: u8 = 0x1B;
59    /// Magnitude - LO register.
60    pub const MAGNITUDE_LO: u8 = 0x1C;
61
62    /// Programming register.
63    /// Used for `BURN_SETTINGS` (0x80) and `BURN_ANGLE` (0x40).
64    pub const BURN: u8 = 0xFF;
65}