rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
out_bind.h
Go to the documentation of this file.
1
32
33#ifndef RCBENCH_OUT_BIND_H
34#define RCBENCH_OUT_BIND_H
35
36#include <stdbool.h>
37#include <stdint.h>
38
39#include "outputs.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/* ------------------------------------------------------------ the boards */
46
66
68#define OUTBIND_PINS 26u
69
73typedef struct {
74 uint8_t gpio;
75 uint8_t pad;
76 bool reserved;
77 const char *held_by;
79
89typedef struct {
90 uint16_t width_cmm;
91 uint16_t height_cmm;
92 uint16_t pitch_cmm;
93 uint16_t inset_cmm;
94 uint8_t per_side;
95 uint8_t corner;
97
106typedef struct {
107 uint8_t pad;
108 uint8_t kind;
114 uint8_t decivolts;
116
120typedef struct {
121 uint16_t id;
122 const char *name;
124 uint8_t count;
133 bool fixed;
144 uint8_t pad_count;
146
160const outbind_board_t *outbind_board(uint16_t id);
161
162/* ------------------------------------------------ a board that describes itself */
163
173void outbind_board_to_regs(const outbind_board_t *board, uint16_t *regs);
174
197bool outbind_learn_board(uint16_t id, const uint16_t *regs);
198
206void outbind_shape_to_regs(const outbind_board_t *board, uint16_t *regs);
207
223bool outbind_learn_shape(uint16_t id, const uint16_t *regs);
224
240bool outbind_pad_xy(const outbind_shape_t *shape, uint8_t pad,
241 uint16_t *x_cmm, uint16_t *y_cmm);
242
251const outbind_pad_t *outbind_pads(uint16_t board);
252
260uint8_t outbind_pad_count(uint16_t board);
261
268void outbind_pads_to_regs(const outbind_board_t *board, uint16_t *regs);
269
285bool outbind_learn_pads(uint16_t id, const uint16_t *regs);
286
296void outbind_forget_learned(void);
297
305uint8_t outbind_board_count(void);
306
313const outbind_board_t *outbind_board_at(uint8_t index);
314
327bool outbind_pin_selectable(const outbind_board_t *board, uint8_t index);
328
339const outbind_pin_t *outbind_pins(uint16_t board);
340
348uint8_t outbind_pin_count(uint16_t board);
349
359uint8_t outbind_index_of(uint16_t board, uint8_t gpio);
360
378uint64_t outbind_reserved_mask(uint16_t board);
379
380/* ------------------------------------------------------------- protocols */
381
389typedef struct {
390 const char *name;
392 uint16_t rate;
393 uint8_t max_pins;
394 uint8_t channels;
406
408#define OUTBIND_PROTOS 8u
409
416
417/* --------------------------------------------------------- the selection */
418
423typedef struct {
424 uint16_t board;
425 uint8_t proto;
433} outbind_t;
434
441void outbind_init(outbind_t *b);
442
456uint8_t outbind_group_of(const outbind_t *b, uint8_t index);
457
466uint8_t outbind_chosen_total(const outbind_t *b);
467
474uint8_t outbind_channels_used(const outbind_t *b);
475
486void outbind_trim(outbind_t *b);
487
500void outbind_set_board(outbind_t *b, uint16_t board);
501
508uint8_t outbind_chosen(const outbind_t *b);
509
524uint8_t outbind_wire_proto(const outbind_t *b);
525
540bool outbind_toggle(outbind_t *b, uint8_t index);
541
557void outbind_set_proto(outbind_t *b, uint8_t proto);
558
572bool outbind_can_add(const outbind_t *b, uint8_t index);
573
575#define OUTBIND_NO_GPIO 0xFFu
576
580typedef enum {
581 OUTBIND_CLASH_NONE = 0,
587
613outbind_clash_t outbind_pwm_clash(const outbind_t *b, uint8_t index,
614 uint8_t prog_gpio, uint8_t *with);
615
633 const uint8_t *ports, uint8_t count,
634 uint8_t *with);
635
636/* ------------------------------------------------------------- the pages */
637
654uint8_t outbind_to_slots(const outbind_t *b, uint16_t *regs);
655
688bool outbind_from_slots(outbind_t *b, uint16_t board,
689 const uint16_t *regs, const uint16_t *chan_cfg);
690
692#define OUTBIND_PROTO_MIXED 0xFFu
693
712uint8_t outbind_role_proto(const uint16_t *regs, const uint16_t *chan_cfg,
713 out_role_t role);
714
734void outbind_to_chan_cfg(const outbind_t *b, uint16_t *regs,
735 uint16_t min_us, uint16_t max_us);
736
737#ifdef __cplusplus
738}
739#endif
740
741#endif /* RCBENCH_OUT_BIND_H */
uint8_t outbind_pin_count(uint16_t board)
How many pins the board's catalogue lists, or 0 for a board this build does not know.
Definition out_bind.c:527
const outbind_pad_t * outbind_pads(uint16_t board)
The pads that are not pins, and how many.
Definition out_bind.c:290
void outbind_init(outbind_t *b)
Empty, and belonging to no board: nothing can be chosen until one is set.
Definition out_bind.c:609
uint8_t outbind_to_slots(const outbind_t *b, uint16_t *regs)
Render the selection into the OUTPUTS page.
Definition out_bind.c:953
bool outbind_learn_pads(uint16_t id, const uint16_t *regs)
Give the learned board its grounds and rails.
Definition out_bind.c:319
uint8_t outbind_chosen(const outbind_t *b)
How many pins the protocol being edited has chosen.
Definition out_bind.c:667
bool outbind_toggle(outbind_t *b, uint8_t index)
Add or remove a pin, in the protocol being edited.
Definition out_bind.c:905
void outbind_shape_to_regs(const outbind_board_t *board, uint16_t *regs)
Render a board's shape into LINK_SH_COUNT registers, or leave them zero when it has none.
Definition out_bind.c:368
bool outbind_pad_xy(const outbind_shape_t *shape, uint8_t pad, uint16_t *x_cmm, uint16_t *y_cmm)
Where a pad's centre is, in hundredths of a millimetre from the top-left of the outline.
Definition out_bind.c:427
bool outbind_from_slots(outbind_t *b, uint16_t board, const uint16_t *regs, const uint16_t *chan_cfg)
Read a selection back out of an OUTPUTS page.
Definition out_bind.c:1058
uint8_t outbind_chosen_total(const outbind_t *b)
Pins chosen across every protocol, and the channels they render.
Definition out_bind.c:689
outbind_board_id_t
Which IOmcu is on the other end.
Definition out_bind.h:62
@ OUTBIND_BOARD_PICO_HEADER
Definition out_bind.h:64
@ OUTBIND_BOARD_UNKNOWN
Definition out_bind.h:63
void outbind_pads_to_regs(const outbind_board_t *board, uint16_t *regs)
Render them into LINK_PAD_COUNT registers, or leave them zero.
Definition out_bind.c:302
uint8_t outbind_index_of(uint16_t board, uint8_t gpio)
Index of gpio in that board's catalogue, or its count when the board does not bring that pin out.
Definition out_bind.c:533
bool outbind_learn_shape(uint16_t id, const uint16_t *regs)
Give the learned board a shape from a shape page.
Definition out_bind.c:387
void outbind_forget_learned(void)
Forget it.
Definition out_bind.c:476
uint8_t outbind_role_proto(const uint16_t *regs, const uint16_t *chan_cfg, out_role_t role)
The entry the slots of role are bound as, an index into outbind_protos(), read from an OUTPUTS page a...
Definition out_bind.c:1022
bool outbind_learn_board(uint16_t id, const uint16_t *regs)
Learn the board a catalogue page describes, replacing any previous one.
Definition out_bind.c:198
const outbind_pin_t * outbind_pins(uint16_t board)
Its catalogue and how long it is.
Definition out_bind.c:521
outbind_clash_t outbind_pwm_clash_ports(const outbind_t *b, uint8_t index, const uint8_t *ports, uint8_t count, uint8_t *with)
outbind_pwm_clash() beside every programming port's pin: count pins from ports (NULL or 0 for none),...
Definition out_bind.c:857
const outbind_board_t * outbind_board(uint16_t id)
The board with this identity, or NULL when nothing here describes it.
Definition out_bind.c:131
outbind_clash_t
Why the PWM generator cannot take a pin, as outbind_pwm_clash() says.
Definition out_bind.h:580
@ OUTBIND_CLASH_COMPARE
The pin's compare register drives a pin already bound as PWM.
Definition out_bind.h:585
@ OUTBIND_CLASH_PROG_SLICE
The pin's slice is the programming port's pin's slice.
Definition out_bind.h:583
void outbind_board_to_regs(const outbind_board_t *board, uint16_t *regs)
Render a board's catalogue into LINK_CAT_COUNT registers for the wire.
Definition out_bind.c:166
void outbind_set_proto(outbind_t *b, uint8_t proto)
Choose which protocol is being edited.
Definition out_bind.c:936
void outbind_trim(outbind_t *b)
Drop anything a selection cannot mean on its board.
Definition out_bind.c:729
uint8_t outbind_group_of(const outbind_t *b, uint8_t index)
Which protocol holds index, or 0 (OFF) when nothing does.
Definition out_bind.c:715
bool outbind_can_add(const outbind_t *b, uint8_t index)
True when this pin may still be added to the protocol being edited, for a screen drawing it.
Definition out_bind.c:811
uint8_t outbind_pad_count(uint16_t board)
How many pads that are not pins the board has, or 0 for a board nothing here describes that way.
Definition out_bind.c:296
uint64_t outbind_reserved_mask(uint16_t board)
Every pin of a board that no output and no PD mini pin may take, one bit per GPIO (0 to 63).
Definition out_bind.c:547
void outbind_to_chan_cfg(const outbind_t *b, uint16_t *regs, uint16_t min_us, uint16_t max_us)
Render the channel configuration to match.
Definition out_bind.c:1163
bool outbind_pin_selectable(const outbind_board_t *board, uint8_t index)
Whether index may be added to a selection on board.
Definition out_bind.c:510
outbind_clash_t outbind_pwm_clash(const outbind_t *b, uint8_t index, uint8_t prog_gpio, uint8_t *with)
Whether the IOmcu refuses catalogue entry index for the protocol being edited, beside prog_gpio and t...
Definition out_bind.c:851
void outbind_set_board(outbind_t *b, uint16_t board)
Say which board this binding is for.
Definition out_bind.c:621
uint8_t outbind_board_count(void)
The table itself, so a caller can walk every board rather than guess at a range of identities....
Definition out_bind.c:484
const outbind_board_t * outbind_board_at(uint8_t index)
The board at index in the table, or NULL past the end.
Definition out_bind.c:489
uint8_t outbind_channels_used(const outbind_t *b)
Channels the chosen pins render, across every protocol.
Definition out_bind.c:702
const outbind_proto_t * outbind_protos(void)
The protocol table, indexed by protocol number; entry 0 is OFF.
Definition out_bind.c:605
#define OUTBIND_PROTOS
Entries in the protocol table, OFF included.
Definition out_bind.h:408
uint8_t outbind_wire_proto(const outbind_t *b)
The protocol a page rendered from this selection reads back as: the lowest-numbered one holding a pin...
Definition out_bind.c:676
The intermediary every output goes through: one set of rules for arming, clamping,...
out_driver_t
The drivers a slot can be configured as.
Definition outputs.h:83
out_role_t
What rest means for a channel, which is the one thing a command cannot say.
Definition outputs.h:70
One board: its identity, catalogue, outline and pads.
Definition out_bind.h:120
bool fixed
Definition out_bind.h:133
const char * name
Definition out_bind.h:122
const outbind_shape_t * shape
Where the pads are, or NULL when nothing here says.
Definition out_bind.h:138
uint8_t count
Definition out_bind.h:124
const outbind_pin_t * pins
Definition out_bind.h:123
uint16_t id
Definition out_bind.h:121
const outbind_pad_t * pads
The pads that are not pins, or NULL when nothing here says.
Definition out_bind.h:143
uint8_t pad_count
Definition out_bind.h:144
A pad that is not a pin: a ground, a rail, or neither.
Definition out_bind.h:106
uint8_t pad
Definition out_bind.h:107
uint8_t decivolts
Tenths of a volt. Zero on a rail means it is not a fixed voltage – an input follows whatever feeds it...
Definition out_bind.h:114
uint8_t kind
Definition out_bind.h:108
One pin of a board's catalogue.
Definition out_bind.h:73
const char * held_by
Definition out_bind.h:77
uint8_t pad
Definition out_bind.h:75
uint8_t gpio
Definition out_bind.h:74
bool reserved
Definition out_bind.h:76
What can be bound, as an operator names it.
Definition out_bind.h:389
uint8_t max_pins
Definition out_bind.h:393
uint16_t rate
Definition out_bind.h:392
uint8_t channels
Definition out_bind.h:394
const char * name
Definition out_bind.h:390
out_driver_t driver
Definition out_bind.h:391
out_role_t role
What the channels this entry renders are for.
Definition out_bind.h:404
Where a board's pads are: two rows on one pitch, which is every 0.1-inch header board.
Definition out_bind.h:89
uint16_t inset_cmm
Definition out_bind.h:93
uint16_t pitch_cmm
Definition out_bind.h:92
uint8_t per_side
Definition out_bind.h:94
uint8_t corner
Definition out_bind.h:95
uint16_t height_cmm
Definition out_bind.h:91
uint16_t width_cmm
Definition out_bind.h:90
The selection: which board, the protocol being edited, and each protocol's pins.
Definition out_bind.h:423
uint32_t pins[OUTBIND_PROTOS]
Definition out_bind.h:432
uint16_t board
Definition out_bind.h:424
uint8_t proto
Definition out_bind.h:425