rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
sense_page.h
Go to the documentation of this file.
1
35
36#pragma once
37
38#include <stdbool.h>
39#include <stdint.h>
40
41#include "bench_state.h"
42#include "link_pages.h"
43#include "outputs.h"
44#include "sense_svc.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
57#define SENSE_DEFAULT_SDA 16u
58#define SENSE_DEFAULT_SCL 17u
59#define SENSE_DEFAULT_KHZ LINK_SN_KHZ_BUS
60#define SENSE_DEFAULT_I228_ADDR 0x45u
61#define SENSE_DEFAULT_I228_UOHM 200u
62#define SENSE_DEFAULT_I228_DA 2048u
63#define SENSE_DEFAULT_I3221_ADDR 0x40u
64#define SENSE_DEFAULT_I3221_DMOHM 1000u
65#define SENSE_DEFAULT_I3221_CH 0x01u
66
71#define SENSE_DEFAULT_MOVE_MA 100u
72#define SENSE_DEFAULT_BAND_MA 50u
73
78typedef struct {
79 uint16_t sense[LINK_SN_COUNT];
80 uint16_t servo[LINK_SS_COUNT];
81 uint16_t win[LINK_SW_COUNT];
84 uint16_t cfg_gen;
85 uint16_t cap_gen;
87 bool sensed;
88 uint8_t bound;
90 uint8_t ports;
92 uint64_t held;
94 uint16_t map[LINK_SM_COUNT];
97 bool map_set;
99 uint16_t xwin[2][LINK_SX_COUNT];
101 uint16_t limit[LINK_SL_COUNT];
105
112
119void sense_page_defaults(uint16_t *cfg);
120
128uint32_t sense_i3221_full_scale_ma(uint16_t shunt_dmohm);
129
167uint8_t sense_page_write(sense_page_t *p, uint8_t off, uint8_t n,
168 const uint16_t *in, const outputs_t *o,
169 uint64_t taken);
170
180void sense_page_read(const sense_page_t *p, uint8_t off, uint8_t n,
181 uint16_t *out);
182
206uint8_t sense_servo_write(sense_page_t *p, uint8_t off, uint8_t n,
207 const uint16_t *in, const outputs_t *o);
208
218void sense_page_bound(sense_page_t *p, uint8_t slots);
219
230void sense_page_ports(sense_page_t *p, uint8_t ports);
231
244
254void sense_servo_read(const sense_page_t *p, uint8_t off, uint8_t n,
255 uint16_t *out);
256
266void sense_win_read(const sense_page_t *p, uint8_t off, uint8_t n,
267 uint16_t *out);
268
280bool sense_page_step(sense_page_t *p, bool driving);
281
293void sense_page_cmd(const sense_page_t *p, sense_cmd_t *cmd);
294
315 uint16_t run_gen);
316
326void sense_page_esc(sense_page_t *p, bool v_ok, float volts, bool i_ok,
327 float amps);
328
351 uint16_t run_gen, bool driving, bench_state_t *b);
352
367uint16_t sense_page_caps(const sense_page_t *p);
368
375bool sense_page_enabled(const sense_page_t *p);
376
385uint8_t sense_page_sda(const sense_page_t *p);
392uint8_t sense_page_scl(const sense_page_t *p);
399uint32_t sense_page_hz(const sense_page_t *p);
400
409uint64_t sense_page_pins(const sense_page_t *p);
410
421uint64_t sense_page_held(const sense_page_t *p);
422
436uint8_t sense_page_slots_check(const sense_page_t *p, const uint16_t *slots);
437
438#ifdef __cplusplus
439}
440#endif
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 intermediary every output goes through: one set of rules for arming, clamping,...
void sense_page_cmd(const sense_page_t *p, sense_cmd_t *cmd)
The order for core 1 from the page: the set-up and its generation, and the capture's.
Definition sense_page.c:561
void sense_page_ports(sense_page_t *p, uint8_t ports)
Which programming ports render a pulse while the bank drives (bit n port n): bound to the PWM generat...
Definition sense_page.c:365
uint8_t sense_page_scl(const sense_page_t *p)
The SCL pin of the bus.
Definition sense_page.c:95
uint64_t sense_page_held(const sense_page_t *p)
Those and the pins core 1 has not let go of yet (sense_page_t.held): a bus moved or closed keeps its ...
Definition sense_page.c:114
bool sense_page_port_gone(const sense_page_t *p)
Whether the capture in CAP_ARM names a programming port that renders no pulse now: its PWM switched o...
Definition sense_page.c:372
void sense_page_bound(sense_page_t *p, uint8_t slots)
Which output slots the silicon bound (bit n slot n): a capture arms only on a PWM slot that renders f...
Definition sense_page.c:358
bool sense_page_enabled(const sense_page_t *p)
Whether either part is enabled, and so the bus runs.
Definition sense_page.c:84
void sense_win_read(const sense_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
A SERVO_WIN read: CH1's ring as last published, and the capture's state, count and clipped bit as SER...
Definition sense_page.c:502
void sense_page_bench(sense_page_t *p, const sense_snap_t *s, uint16_t run_gen, bool driving, bench_state_t *b)
The BENCH page's numbers from the INA228, over what the ESC's telemetry put in b, once the peaks of b...
Definition sense_page.c:939
void sense_servo_read(const sense_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
Read SERVO_SENSE registers into out.
Definition sense_page.c:490
uint8_t sense_page_slots_check(const sense_page_t *p, const uint16_t *slots)
LINK_NACK_BAD_VALUE for an OUTPUTS page (slots, LINK_OS_COUNT registers) that binds a slot to a pin s...
Definition sense_page.c:543
void sense_page_publish(sense_page_t *p, const sense_snap_t *s, uint16_t run_gen)
What core 1 read into the read-only registers of both pages, when s was taken under the set-up in for...
Definition sense_page.c:886
void sense_page_init(sense_page_t *p)
Set a SENSE page to its start-up state.
Definition sense_page.c:50
uint32_t sense_page_hz(const sense_page_t *p)
The bus clock in Hz.
Definition sense_page.c:100
uint16_t sense_page_caps(const sense_page_t *p)
The capability bits the set-up makes true: LINK_CAP_PACK_SENSE while the INA228 is enabled,...
Definition sense_page.c:993
uint8_t sense_servo_write(sense_page_t *p, uint8_t off, uint8_t n, const uint16_t *in, const outputs_t *o)
A SERVO_SENSE write.
Definition sense_page.c:445
void sense_page_read(const sense_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
Read SENSE registers into out.
Definition sense_page.c:319
uint8_t sense_page_sda(const sense_page_t *p)
The bus's pins and clock.
Definition sense_page.c:90
uint32_t sense_i3221_full_scale_ma(uint16_t shunt_dmohm)
The INA3221's full scale in mA for a shunt of shunt_dmohm tenths of a milliohm: 163....
Definition sense_page.c:75
uint8_t sense_page_write(sense_page_t *p, uint8_t off, uint8_t n, const uint16_t *in, const outputs_t *o, uint64_t taken)
A SENSE write, validated whole before any of it is stored.
Definition sense_page.c:275
bool sense_page_step(sense_page_t *p, bool driving)
One pass: a bank that is not driving ends a capture that has not finished – CAP_ARM 0,...
Definition sense_page.c:527
void sense_page_defaults(uint16_t *cfg)
The set-up as a page starts, into cfg (LINK_SN_CONFIG_COUNT registers): what a store record from befo...
Definition sense_page.c:33
uint64_t sense_page_pins(const sense_page_t *p)
The pins the set-up holds, as a reservation mask; 0 while neither part is enabled.
Definition sense_page.c:105
void sense_page_esc(sense_page_t *p, bool v_ok, float volts, bool i_ok, float amps)
The ESC's own telemetry voltage and current, each with its valid bit, into SENSE registers 23 to 25.
Definition sense_page.c:926
The IOmcu's sensor service: what core 1 does each 1ms tick with the orders core 0 gives it,...
The bench readings in the units a person reads: V, A, W and rpm, with their peaks.
Definition bench_state.h:54
The state of a bank of channels and slots.
Definition outputs.h:143
What core 0 asks for.
Definition sense_svc.h:82
The state of the SENSE page: its three register images, the generations, the pins and the map and lim...
Definition sense_page.h:78
uint16_t win[LINK_SW_COUNT]
Definition sense_page.h:81
uint16_t map[LINK_SM_COUNT]
Definition sense_page.h:94
uint8_t bound
Definition sense_page.h:88
uint16_t lim_seen[LINK_SL_KEPT]
Definition sense_page.h:103
uint16_t sense[LINK_SN_COUNT]
Definition sense_page.h:79
uint16_t cfg_gen
Definition sense_page.h:84
uint16_t cap_gen
Definition sense_page.h:85
bool sensed
Definition sense_page.h:87
uint8_t ports
Definition sense_page.h:90
uint64_t held
Definition sense_page.h:92
uint16_t servo[LINK_SS_COUNT]
Definition sense_page.h:80
uint16_t limit[LINK_SL_COUNT]
Definition sense_page.h:101
uint16_t xwin[2][LINK_SX_COUNT]
Definition sense_page.h:99
bool map_set
Definition sense_page.h:97
What core 1 hands back after each step.
Definition sense_svc.h:100