1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
uint8_t init_flag; // Flag to check f AS5600 is initialized, Call
uint8_t zmco; // Prog Counter that shows nr of time MPOS and ZPOS has been written prog cmd=0x40, max value 0x02 (3x)
uint16_t zpos; // Zero postion angle
uint16_t mpos; // Max postion angle
uint16_t mang; // Max Angle range 18...360 degree.
struct conf {
uint8_t pm : 2; // Power Mode : 00 = NOM, 01 = LPM1, 10 = LPM2, 11 = LPM3
uint8_t hyst : 2; // Hysteresis : 00 = OFF, 01 = 1 LSB, 10 = 2 LSBs, 11 = 3 LSBs
uint8_t outs : 2; // Ouput Stage Mode : 00 = analog (range 0%..100%), 01 = analog range 10%..90%, (Range GND..VDD), 10 = digital PWM
uint8_t pwmf : 2; // PWM Frequency: 00 = 115 Hz; 01 = 230 Hz; 10 = 460 Hz; 11 = 920 Hz
uint8_t sf : 2; // Slow Filter : 00 = 16x (1); 01 = 8x; 10 = 4x; 11 = 2x
uint8_t fth : 3; // Fast Filter trhreshold : 000 = slow filter only, 001 = 6 LSBs, 010 = 7 LSBs, 011 = 9 LSBs,100 = 18 LSBs, 101 = 21 LSBs, 110 = 24 LSBs, 111 = 10 LSBs
uint8_t wd : 1; // Watch Dog : 0 = OFF, 1 = ON
uint8_t dummy0 : 2; // dummy bits
}conf;
uint16_t raw_angle; // Unscale un modified angle value
uint16_t angle; // Scale modified angle value
struct stat {
uint8_t dummy1 : 3; // dummy bits
uint8_t mh : 1; // Magnetic field to high Flag
uint8_t ml : 1; // Magnetic field to low Flag
uint8_t md : 1; // Magnetic field available flag
uint8_t dummy2 : 2; // dummy bits
} stat;
uint8_t agc; // Value of the AGC feedback amplifier
uint16_t magnitude; // Magnetic field value
uint8_t burn; // Command register to burn settings cmd=0x40 or burn angle values cmd=0x80
// MANG can only be programmed when ZMCO=0x00, max time programmable 1x
} __attribute__((packed, aligned(1))) AS5600_reg = { false, 0,0x00A,0x0FEC,0x0000, {0,2,0,2, 0,0x01,0,0}, 0,0, {0,0,0,0,0} ,0,0,0 };
| |