100#define AS5600_ADDR 0x36u
101#define AS5600_REG_STATUS 0x0Bu
102#define AS5600_REG_RAW_ANGLE 0x0Cu
103#define AS5600_REG_ANGLE 0x0Eu
104#define AS5600_REG_AGC 0x1Au
105#define AS5600_REG_MAGNITUDE 0x1Bu
107#define AS5600_STATUS_MH 0x08u
108#define AS5600_STATUS_ML 0x10u
109#define AS5600_STATUS_MD 0x20u
111#define AS5600_STATUS_MASK (AS5600_STATUS_MH | AS5600_STATUS_ML | AS5600_STATUS_MD)
114#define AS5600_COUNTS 4096u
116#define AS5600_CDEG_TURN 36000
280 uint16_t *magnitude);
bool as5600_status_possible(uint8_t status)
Whether status is one an AS5600 can give: not ML and MH together.
Definition as5600.c:17
bool as5600_ml(uint8_t status)
Read the ML bit of a STATUS value.
Definition as5600.c:28
sense_err_t as5600_read_agc(as5600_t *d, uint8_t *agc)
AGC: 1 byte from 0x1A; the same rule.
Definition as5600.c:121
uint16_t as5600_u12(const uint8_t *b)
A 12-bit register pair, most significant byte first: RAW ANGLE, ANGLE or MAGNITUDE.
Definition as5600.c:12
bool as5600_md(uint8_t status)
The magnet bits of status.
Definition as5600.c:23
sense_state_t as5600_state(const as5600_t *d)
The part's state as of the last probe.
Definition as5600.c:94
void as5600_init(as5600_t *d, sense_bus_t *bus)
A part on bus at AS5600_ADDR, not yet probed.
Definition as5600.c:62
sense_err_t as5600_read_status(as5600_t *d, uint8_t *status)
STATUS: 1 byte from 0x0B.
Definition as5600.c:99
int16_t as5600_delta(uint16_t a, uint16_t b)
a minus b on the circle, -2048 to 2047 counts: the shortest way from b to a.
Definition as5600.c:38
sense_err_t as5600_read_angle(as5600_t *d, uint8_t *status, uint16_t *raw)
STATUS, then RAW ANGLE: two transactions.
Definition as5600.c:143
bool as5600_mh(uint8_t status)
Read the MH bit of a STATUS value.
Definition as5600.c:33
sense_err_t as5600_read_raw(as5600_t *d, uint16_t *raw)
RAW ANGLE: 2 bytes from 0x0C, 0 to 4095; the same rule.
Definition as5600.c:110
int32_t as5600_cdeg(int32_t counts)
counts in hundredths of a degree, rounded to the nearest, halves away from zero.
Definition as5600.c:46
bool as5600_step(as5600_t *d, uint32_t now_ms)
Every tick: probes the part when it is due – at the first call, and SENSE_RETRY_MS after it was found...
Definition as5600.c:86
sense_err_t as5600_read_mag(as5600_t *d, uint16_t *magnitude)
MAGNITUDE: 2 bytes from 0x1B, 0 to 4095; the same rule.
Definition as5600.c:132
sense_err_t as5600_read_magnitude(as5600_t *d, uint8_t *agc, uint16_t *magnitude)
AGC, then MAGNITUDE: two transactions; the same rule.
Definition as5600.c:158
The sensor bus: one I2C (Inter-Integrated Circuit) bus with current monitors on it,...
sense_err_t
What a transaction came to.
Definition sense_bus.h:62
sense_state_t
A part on the bus, as far as it is known.
Definition sense_bus.h:175
Definition sense_bus.h:91
A part on the bus: its address, state and last probe.
Definition sense_bus.h:190