101#define SENSE_LINK_MINOR 7u
103#define SENSE_LINK_ENC_MINOR 9u
105#define SENSE_LINK_WIN_MINOR LINK_MINOR_SERVO_WIN
112#define SENSE_LINK_SETTLE_MS 500u
121#define SENSE_LINK_READ_MS 40u
128#define SENSE_LINK_TOTALS_MS 100u
136#define SENSE_LINK_SERVO_MS 40u
143#define SENSE_LINK_WIN_MS 40u
146#define SENSE_LINK_WIN_HEAD ((unsigned)LINK_SW_ENTRY(2, 0))
147#define SENSE_LINK_WIN_HEAD_WINDOWS 2u
154#define SENSE_LINK_WIN_ALL_MS 100u
161#define SENSE_LINK_GRACE_MS 2500u
167#define SENSE_LINK_BUS_RETRY_MS 5000u
170#define SENSE_LINK_STALE_MS 500u
176#define SENSE_LINK_STATUS_COUNT ((unsigned)LINK_SN_COUNT - (unsigned)LINK_SN_FLAGS)
177#define SENSE_LINK_STATUS_COUNT_V48 \
178 ((unsigned)LINK_SN_COUNT_V48 - (unsigned)LINK_SN_FLAGS)
183#define SENSE_LINK_SERVO_COUNT ((unsigned)LINK_SS_CH_FLAGS + 1u)
186#define SENSE_LINK_NO_ANSWER (-1)
187#define SENSE_LINK_ACK 0
191 SENSE_LINK_INA228 = 0,
192 SENSE_LINK_INA3221 = 1,
243 SENSE_LINK_EV_I3221_SILENT = 0x0080,
248 SENSE_LINK_EV_I3221_WRONG = 0x0200,
286#define SENSE_LINK_EV_SETUP ((uint32_t)(SENSE_LINK_EV_PINS_UNSET \
287 | SENSE_LINK_EV_SAME_ADDR \
288 | SENSE_LINK_EV_BUS_REFUSED \
289 | SENSE_LINK_EV_I228_REFUSED \
290 | SENSE_LINK_EV_I3221_REFUSED))
294 SENSE_LINK_OP_NONE = 0,
320#define SENSE_LINK_WINDOW_MS 50u
418 bool refused_bus, refused_i228, refused_i3221;
421 uint32_t bus_refused_ms;
429 bool asked_status, asked_servo;
430 uint32_t status_asked_ms, servo_asked_ms;
431 bool have_status, have_servo;
441 uint32_t win_asked_ms;
466 bool enc_silent_told, enc_online_seen;
571#define SENSE_LINK_EVENT_GAP_MS 5000u
637 SENSE_LINK_ROW_I228_ADDR = 0x0010,
638 SENSE_LINK_ROW_I228_SHUNT = 0x0020,
639 SENSE_LINK_ROW_I228_MAX = 0x0040,
640 SENSE_LINK_ROW_I3221_ADDR = 0x0080,
641 SENSE_LINK_ROW_I3221_SHUNT = 0x0100,
642 SENSE_LINK_ROW_I3221_CH = 0x0200,
814 float *volts,
bool *i_ok,
float *amps);
830 int32_t *charge_cmah, uint32_t *energy_cwh);
The bench readings, in the units a person reads: V, A, W, rpm (revolutions per minute),...
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
The page map: what the panel can ask the IOmcu for, and set.
#define LINK_SN_CONFIG_COUNT
The set-up, ENABLE to register 11: what a write may change, and what flash keeps.
Definition link_pages.h:691
#define LINK_SW_RING
The windows the page carries.
Definition link_pages.h:964
uint32_t sense_link_events(sense_link_t *s)
The events since the last call, SENSE_LINK_EV_*, and cleared.
Definition sense_link.c:953
uint16_t sense_link_id(const sense_link_t *s, sense_link_part_t part)
The ID part gave, as last read (DEVICE_ID, the die ID).
Definition sense_link_view.c:322
unsigned sense_link_windows(const sense_link_t *s)
How many windows sense_link_take_window() hands over now: the ring's waiting ones,...
Definition sense_link_view.c:54
void sense_link_came_up(sense_link_t *s, uint16_t minor, uint32_t now_ms)
An IOmcu answered with protocol minor minor.
Definition sense_link.c:90
void sense_link_lost(sense_link_t *s)
The link went: nothing on the page is known, and nothing is read or written until it comes up again.
Definition sense_link.c:61
void sense_link_meter(const sense_link_t *s, sense_link_meter_t *out)
What the servo rail's meter is chosen from, into out.
Definition sense_link_view.c:166
uint32_t sense_link_event(sense_link_t *s, uint32_t now_ms)
One event for the alert band, which shows one line and replaces it with the next: the most pressing w...
Definition sense_link.c:998
bool sense_link_held_pins(const sense_link_t *s, int *sda, int *scl)
The sensor bus's pins the page holds by its last read or write, as the IOmcu reserves them (sense_pag...
Definition sense_link_view.c:492
bool sense_link_enc(const sense_link_t *s, uint32_t now_ms, sense_link_enc_t *out)
The encoder's last angle into out: true when the page enables it, the last SENSE read is younger than...
Definition sense_link_view.c:283
bool sense_link_enc_no_magnet(const sense_link_t *s, uint32_t now_ms)
Whether sense_link_enc() gives no angle at now_ms because the part answers and sees no magnet: every ...
Definition sense_link_view.c:302
void sense_link_init(sense_link_t *s)
Sets up the SENSE link state.
Definition sense_link.c:16
bool sense_link_win_on(const sense_link_t *s)
Whether the INA3221's windows come from SERVO_WIN: the IOmcu has the page and its SENSE page enables ...
Definition sense_link.c:367
uint8_t sense_link_clipped_channel(const sense_link_t *s)
The INA3221 channel SENSE_LINK_EV_I3221_CLIPPED names, 1 to 3: the one sense_link_event() last handed...
Definition sense_link_view.c:368
uint16_t sense_link_enc_magnet(const sense_link_t *s)
The magnet bits SENSE_LINK_EV_ENC_MAGNET was raised with: LINK_SN_ENC_MD, _ML and _MH,...
Definition sense_link_view.c:308
#define SENSE_LINK_SERVO_COUNT
And from SERVO_SENSE: the three channels' windows, WINDOW and CH_FLAGS.
Definition sense_link.h:183
void sense_link_set_map(sense_link_t *s, bool map)
Whether the INA3221 parts go by SENSE_MAP (sense_map_link_page()): then ENABLE bit 1 and the INA3221'...
Definition sense_link_view.c:444
bool sense_link_settled(const sense_link_t *s)
Whether nothing is owed: the page holds the set-up asked, less the frames it refused.
Definition sense_link.c:1074
void sense_link_win_bench(const sense_link_t *s, const sense_link_win_t *w, bench_state_t *b)
A ring window into b's log fields: servo_new set, its number, CH1's mean and highest current and lowe...
Definition sense_link_view.c:80
@ SENSE_LINK_ROW_PINS
Definition sense_link.h:636
@ SENSE_LINK_ROW_I228
Definition sense_link.h:633
@ SENSE_LINK_ROW_I3221
Definition sense_link.h:634
@ SENSE_LINK_ROW_ENC
Definition sense_link.h:635
bool sense_link_take_window(sense_link_t *s, bench_state_t *b)
The INA3221's next window into b for the log, once per window; true and servo_new set,...
Definition sense_link_view.c:113
void sense_link_done(sense_link_t *s, int result, const uint16_t *regs, uint32_t now_ms)
How the exchange sense_link_next() gave went: SENSE_LINK_ACK with the registers read (regs,...
Definition sense_link.c:861
bool sense_link_next(sense_link_t *s, uint32_t now_ms, bool idle, sense_link_op_t *op)
The next exchange owed at now_ms, into op; false for none.
Definition sense_link.c:391
sense_link_part_t
The two parts, for the accessors.
Definition sense_link.h:190
bool sense_link_take_win(sense_link_t *s, sense_link_win_t *out)
The next CH1 window of the ring into out, oldest first, each number once: false when none waits,...
Definition sense_link_view.c:476
void sense_link_want(sense_link_t *s, const sense_setup_t *w, uint32_t now_ms)
The set-up SETUP names now.
Definition sense_link.c:153
uint8_t sense_link_found(const sense_link_t *s, sense_link_part_t part)
Another address that answered the last scan where part could be: an INA228 at 0x40 to 0x4F,...
Definition sense_link_view.c:331
uint8_t sense_link_addr(const sense_link_t *s, sense_link_part_t part)
The address part is set up at on the page, 0 while not known.
Definition sense_link_view.c:313
void sense_link_faults(sense_link_t *s, uint16_t faults)
STATUS's faults word, as the caller last read it.
Definition sense_link.c:941
uint16_t sense_link_flags(const sense_link_t *s)
FLAGS as last read, 0 before any read.
Definition sense_link_view.c:204
@ SENSE_LINK_EV_I228_CLIPPED
The INA228's current read at the end of its range.
Definition sense_link.h:252
@ SENSE_LINK_EV_I228_REFUSED
The page refused the INA228's frame: its shunt and range.
Definition sense_link.h:238
@ SENSE_LINK_EV_PINS_UNSET
A part is enabled with SDA or SCL unset: none is enabled.
Definition sense_link.h:232
@ SENSE_LINK_EV_BUS_REFUSED
The page refused the bus frame: the pins, as a rule.
Definition sense_link.h:236
@ SENSE_LINK_EV_SAME_ADDR
Both parts enabled on one address: neither is.
Definition sense_link.h:234
@ SENSE_LINK_EV_ENC_MAGNET
The encoder answers and its magnet is missing, too weak or too strong; see sense_link_enc_magnet().
Definition sense_link.h:279
@ SENSE_LINK_EV_I228_WRONG
Something answers at the INA228's address with another identity.
Definition sense_link.h:247
@ SENSE_LINK_EV_STUCK
SDA held low; the IOmcu clocks it free.
Definition sense_link.h:250
@ SENSE_LINK_EV_I3221_REFUSED
The page refused the INA3221's frame.
Definition sense_link.h:240
@ SENSE_LINK_EV_NO_PAGE
A part is enabled and the IOmcu has no SENSE page.
Definition sense_link.h:230
@ SENSE_LINK_EV_STORE_OFF
STATUS fault bit 6: the IOmcu saves nothing this boot.
Definition sense_link.h:259
@ SENSE_LINK_EV_ENC_SILENT
The encoder is enabled and does not answer at 0x36, or something answers there that is not an AS5600.
Definition sense_link.h:266
@ SENSE_LINK_EV_I3221_CLIPPED
An INA3221 channel read 163.8mV across its shunt; see sense_link_clipped_channel().
Definition sense_link.h:257
@ SENSE_LINK_EV_I228_SILENT
The INA228 is enabled and does not answer at its address.
Definition sense_link.h:242
@ SENSE_LINK_EV_ENC_OLD
The encoder is enabled and the IOmcu is older than 4.9.
Definition sense_link.h:261
bool sense_link_enc_on(const sense_link_t *s)
Whether the encoder is set up on the page: enabled there, and read.
Definition sense_link_view.c:253
bool sense_link_take_caps(sense_link_t *s, uint16_t *caps)
The capability bits an identity read since the last call brought, into caps; false if none did.
Definition sense_link_view.c:466
uint16_t sense_link_event_id(const sense_link_t *s, sense_link_part_t part)
What an event was raised with, kept for when the band shows it: the ID part gave for SENSE_LINK_EV_*_...
Definition sense_link_view.c:358
bool sense_link_esc(const sense_link_t *s, uint32_t now_ms, bool *v_ok, float *volts, bool *i_ok, float *amps)
The ESC's own telemetry voltage and current, from the last SENSE read if it is younger than SENSE_LIN...
Definition sense_link_view.c:214
bool sense_link_totals(const sense_link_t *s, uint32_t now_ms, int32_t *charge_cmah, uint32_t *energy_cwh)
The INA228's charge in 0.01mAh and energy in 0.01Wh as last read, 0 while they are not the run's tota...
Definition sense_link_view.c:236
int sense_link_scl(const sense_link_t *s)
The SCL pin asked, -1 for unset.
Definition sense_link_view.c:389
uint32_t sense_link_reads(const sense_link_t *s)
SENSE reads answered since init: a caller that compares two counts can tell a read made in between.
Definition sense_link_view.c:209
void sense_link_reread(sense_link_t *s)
Read SENSE's set-up again, and the identity after it: a SENSE_MAP write was taken,...
Definition sense_link_view.c:458
void sense_link_event_back(sense_link_t *s, uint32_t ev)
Put back an event sense_link_event() handed out that never reached the band – another alert replaced ...
Definition sense_link.c:1055
uint16_t sense_link_i3221_dmohm(const sense_link_t *s)
The INA3221's shunt on the page, 0.1mOhm.
Definition sense_link_view.c:373
uint16_t sense_link_unheld(const sense_link_t *s)
The rows whose value as asked is not the one the page holds, SENSE_LINK_ROW_*: a set-up not written y...
Definition sense_link_view.c:396
uint8_t sense_link_i3221_addr(const sense_link_t *s)
The INA3221's address on the page, the part SERVO_SENSE reads: 0x40 to 0x43; 0 before the page is rea...
Definition sense_link_view.c:378
uint32_t sense_link_win_lost(const sense_link_t *s)
Window numbers that left the ring before a read took them, since init, modulo 2^32: the windows lost,...
Definition sense_link_view.c:487
sense_link_op_kind_t
The exchange sense_link_next() asks for.
Definition sense_link.h:293
@ SENSE_LINK_OP_BUS
Definition sense_link.h:299
@ SENSE_LINK_OP_IDENTITY
Definition sense_link.h:300
@ SENSE_LINK_OP_SERVO
Definition sense_link.h:302
@ SENSE_LINK_OP_READ_SETUP
Definition sense_link.h:295
@ SENSE_LINK_OP_STATUS
Definition sense_link.h:301
@ SENSE_LINK_OP_I228
Definition sense_link.h:297
@ SENSE_LINK_OP_WIN
Definition sense_link.h:303
@ SENSE_LINK_OP_I3221
Definition sense_link.h:298
@ SENSE_LINK_OP_OFF
Definition sense_link.h:296
@ SENSE_LINK_OP_WIN_ALL
Definition sense_link.h:304
uint8_t sense_link_event_found(const sense_link_t *s, sense_link_part_t part)
The address a scan found for the event's part, or 0 for none.
Definition sense_link_view.c:363
void sense_link_set_map_held(sense_link_t *s, bool held)
Whether SENSE_MAP holds the map SETUP asks (sense_map_link_held()): with the map in force the meter i...
Definition sense_link_view.c:451
bool sense_link_event_stands(const sense_link_t *s, uint32_t ev)
Whether what ev, one SENSE_LINK_EV_* bit, says still holds now.
Definition sense_link.c:964
int sense_link_sda(const sense_link_t *s)
The pins asked, -1 for unset: what SENSE_LINK_EV_BUS_REFUSED names.
Definition sense_link_view.c:384
#define SENSE_LINK_STATUS_COUNT
The registers read from SENSE: FLAGS to the last, AS5600_STILL_MS's neighbour; and without the encode...
Definition sense_link.h:176
The bench readings in the units a person reads: V, A, W and rpm, with their peaks.
Definition bench_state.h:54
The output encoder's angle as last read.
Definition sense_link.h:833
uint16_t still_ms
Definition sense_link.h:836
bool weak
Definition sense_link.h:838
bool strong
Definition sense_link.h:839
uint16_t raw
Definition sense_link.h:834
uint32_t taken_ms
Definition sense_link.h:837
uint16_t samples
Definition sense_link.h:835
What the servo rail's meter is chosen from (servo_source.h), as of the last exchange.
Definition sense_link.h:355
bool status
Definition sense_link.h:369
uint8_t resets
Definition sense_link.h:373
uint16_t flags
Definition sense_link.h:371
bool held
SENSE's registers 0 to 11 are the set-up asked, with the INA3221 enabled on CH1: no write owed and no...
Definition sense_link.h:366
uint32_t win_ms
Definition sense_link.h:380
bool wanted
SETUP has the INA3221 on and a channel watching the tester's target: with the map in force,...
Definition sense_link.h:361
bool win_valid
Definition sense_link.h:379
uint16_t setups
Definition sense_link.h:367
bool page
Definition sense_link.h:356
bool resets_read
Definition sense_link.h:372
bool win
SERVO_WIN showed a window under this set-up, and no read has found its number standing for SENSE_LINK...
Definition sense_link.h:378
uint32_t status_ms
Definition sense_link.h:370
One exchange the SENSE link asks the caller to make.
Definition sense_link.h:310
uint16_t regs[4]
Definition sense_link.h:316
uint8_t n
Definition sense_link.h:315
bool write
Definition sense_link.h:312
uint8_t off
Definition sense_link.h:314
uint8_t page
Definition sense_link.h:313
The panel's state of the SENSE link page.
Definition sense_link.h:386
uint32_t status_reads
Definition sense_link.h:435
bool want_i3221
Definition sense_link.h:405
bool win_all
Definition sense_link.h:442
bool win_synced
Definition sense_link.h:443
uint8_t ev_found[2]
Definition sense_link.h:474
bool win_restart
Definition sense_link.h:444
uint32_t event_ms
Definition sense_link.h:477
uint16_t ev_id[2]
Definition sense_link.h:473
bool window_taken
Definition sense_link.h:436
uint32_t setup_ms
Definition sense_link.h:417
uint8_t clip_pending
Definition sense_link.h:471
bool bus_retry
Definition sense_link.h:420
uint32_t win_sync_ms
Definition sense_link.h:447
uint16_t enc_magnet
Definition sense_link.h:468
uint8_t want_parts
Definition sense_link.h:408
bool event_given
Definition sense_link.h:476
uint8_t winq_n
Definition sense_link.h:455
bool up
Definition sense_link.h:387
bool enc_magnet_told
Definition sense_link.h:467
bool page
Definition sense_link.h:388
uint32_t want_ms
Definition sense_link.h:412
uint16_t setups
Definition sense_link.h:457
bool caps_owed
Definition sense_link.h:422
bool win_stands
Definition sense_link.h:453
uint32_t win_lost
Definition sense_link.h:448
bool map
The INA3221 parts go by SENSE_MAP (4.25, sense_map_link.h): SENSE's ENABLE bit 1 and registers 8 to 1...
Definition sense_link.h:396
bool bus_told
Definition sense_link.h:419
bool want_off_ch1
Definition sense_link.h:410
bool win_have
Definition sense_link.h:449
bool map_held
With the map in force: SENSE_MAP holds the map asked, so FAST and its shunt are the ones SETUP names ...
Definition sense_link.h:401
bool enc_page
Definition sense_link.h:389
uint16_t was_clipped
Definition sense_link.h:463
bool win_page
Definition sense_link.h:390
bool want_unwatched
Definition sense_link.h:409
bool want_enc
Definition sense_link.h:406
int8_t want_scl
Definition sense_link.h:407
uint32_t win_moved_ms
Definition sense_link.h:452
uint16_t was_flags
Definition sense_link.h:462
uint16_t window_last
Definition sense_link.h:437
bool win_valid
Definition sense_link.h:450
One 50ms window of INA3221 CH1, as SERVO_WIN carries it.
Definition sense_link.h:328
bool current
Definition sense_link.h:330
bool voltage
Definition sense_link.h:331
uint16_t number
Definition sense_link.h:329
uint32_t taken_ms
The latest the window can have closed, on the panel's tick: when the panel had the read that brought ...
Definition sense_link.h:347
bool clip_hi
Definition sense_link.h:332
int16_t mean_ma
Definition sense_link.h:335
bool clip_lo
Definition sense_link.h:333
uint8_t clipped
Definition sense_link.h:334
uint16_t mean_mv
Definition sense_link.h:338
bool stamped
Definition sense_link.h:348
uint16_t min_mv
Definition sense_link.h:339
int16_t min_ma
Definition sense_link.h:337
int16_t max_ma
Definition sense_link.h:336
The set-up as SETUP INTERFACES has it.
Definition sense_link.h:196
uint8_t i3221_parts
Bit a: the INA3221 at 0x40 + a is fitted (SETUP > SENSORS); the INA228 on any of them is one address.
Definition sense_link.h:213
uint8_t i228_addr
Definition sense_link.h:201
uint16_t i228_max_da
Definition sense_link.h:203
bool i3221_unwatched
No fitted channel watches the servo tester's target (SENSORS' FAST is none): the INA3221 is not the s...
Definition sense_link.h:218
uint16_t i228_uohm
Definition sense_link.h:202
int8_t scl
Definition sense_link.h:200
bool as5600
Definition sense_link.h:198
bool i3221_fast_off_ch1
FAST is CH2 or CH3 of its part: without the map the INA3221 is not the servo rail's meter then,...
Definition sense_link.h:224
uint8_t i3221_ch
Definition sense_link.h:206
int8_t sda
Definition sense_link.h:199
bool i3221
Definition sense_link.h:197
uint16_t i3221_dmohm
Definition sense_link.h:205
uint8_t i3221_addr
Definition sense_link.h:204