@@ -71,10 +71,29 @@ pub const AS5600 = struct {
7171 WD : enum (u1 ) { off = 0 , on = 1 } = .off ,
7272 };
7373
74- pub const Status = enum (u8 ) {
75- MD = 1 << 5 ,
76- ML = 1 << 4 ,
77- MH = 1 << 3 ,
74+ // TODO: Enum is not correct. Can be multiple
75+ // Could enumerate all the combos?
76+ // pub const Status = enum {
77+ // // Magnet too close.
78+ // MagnetHigh = 0x8,
79+ // // Magnet too far.
80+ // MagnetLow = 0x10,
81+ // // Magnet detected.
82+ // MagnetDetected = 0x20,
83+ // // Magnet detected, but close.
84+ // MagnetDetectedHigh = 0x28,
85+ // // Magnet detected, but low.
86+ // MagnetDetectedLow = 0x30,
87+ // };
88+ pub const Status = packed struct (u8 ) {
89+ reserved0 : u3 = 0 ,
90+ // Magnet too strong
91+ MH : u1 = 0 ,
92+ // Magnet too weak
93+ ML : u1 = 0 ,
94+ // Magnet detected
95+ MD : u1 = 0 ,
96+ reserved6 : u2 = 0 ,
7897 };
7998
8099 pub fn init (dev : mdf.base.I2C_Device , address : mdf.base.I2C_Device.Address ) Self {
@@ -104,7 +123,7 @@ pub const AS5600 = struct {
104123 );
105124 }
106125
107- // TODO: Write method
126+ // TODO: Write method. read-modify-write? Suggested by datasheet because extra bits might be config
108127 pub fn read_zero_position (self : * const Self ) ! u16 {
109128 const zpos = self .read2_raw (register .ZPOS );
110129 return zpos & 0xFFF ;
@@ -154,4 +173,6 @@ pub const AS5600 = struct {
154173 // max position (MPOS) or the maximiium angle (MANG)
155174 return ;
156175 }
176+
177+ // TODO: Write burn functions. Scary.
157178};
0 commit comments