45#ifndef RCBENCH_PROG_LINK_H
46#define RCBENCH_PROG_LINK_H
60#define PROG_LINK_POLL_MS 500u
62#define PROG_LINK_NO_PIN 0xFFu
67#define PROG_LINK_TARGET_UNKNOWN 0xFEu
69#define PROG_LINK_TARGET_NO_LINK 0xFFu
73#define PROG_LINK_CFG_REGS 3u
85#define PROG_LINK_SEEN_NONE 0xFFu
89 PROG_LINK_ASK_PIN = 0,
255 uint8_t *port, uint8_t *kind,
459#define PROG_LINK_COUNT_UNKNOWN 0xFFu
The page map: what the panel can ask the IOmcu for, and set.
bool prog_link_hitec_due(const prog_link_t *p)
The HITEC page beside the PROG page (protocol 4.23): a session the bench console opens holds a port t...
Definition prog_link.c:66
bool prog_link_next(const prog_link_t *p, bool quiet, prog_link_write_t *w)
The write that is due, into w.
Definition prog_link.c:356
uint8_t prog_link_pin(const prog_link_t *p, uint8_t port)
The GPIO port port is bound to, or PROG_LINK_NO_PIN: no page, no read, no such port,...
Definition prog_link.c:457
bool prog_link_settled(const prog_link_t *p)
Whether the tester may command: there is no page, or the page is known and its target is the one want...
Definition prog_link.c:323
void prog_link_read(prog_link_t *p, const uint16_t *regs, uint32_t now_ms)
The page as read, prog_link_regs() registers, or NULL for a read that was not answered: the page is u...
Definition prog_link.c:166
prog_link_rate_t prog_link_rate(prog_link_t *p)
What the reads and writes since the last call did to the SERVO rate, and forgets it.
Definition prog_link.c:106
void prog_link_init(prog_link_t *p)
No link, no page, nothing wanted.
Definition prog_link.c:14
bool prog_link_ready(const prog_link_t *p)
Whether prog_link_target() is the IOmcu's: there is no page, or the page is read.
Definition prog_link.c:304
uint8_t prog_link_target(const prog_link_t *p)
The target as the IOmcu holds it; 0 without a page or a read.
Definition prog_link.c:309
void prog_link_came_up(prog_link_t *p, uint16_t minor)
An IOmcu answered with protocol minor minor.
Definition prog_link.c:22
uint8_t prog_link_count(const prog_link_t *p)
The ports the IOmcu's page reports (register COUNT), at most LINK_PG_PORTS_MAX: 0 for an IOmcu withou...
Definition prog_link.c:442
prog_link_ask_kind_t
What a prog_link_ask() asks: a port's PIN or its FUNC.
Definition prog_link.h:88
void prog_link_written(prog_link_t *p, const prog_link_write_t *w, bool ack)
What became of w: acknowledged, or not (refused or unanswered), which makes the page unknown.
Definition prog_link.c:409
bool prog_link_no_drive(const prog_link_t *p)
Whether the screen wants a port the page cannot make the target: one the IOmcu does not have,...
Definition prog_link.c:137
uint8_t prog_link_wanted(const prog_link_t *p)
The target the screen can have: what is wanted, or 0 when the page has no such port,...
Definition prog_link.c:291
bool prog_link_pwm(const prog_link_t *p)
Whether the target port renders its pulse, as the page holds it.
Definition prog_link.c:331
bool prog_link_ask(prog_link_t *p, uint8_t port, prog_link_ask_kind_t kind, uint16_t value)
Ask for port port's PIN (value a GPIO, or LINK_PG_PIN_NONE) or FUNC (a link_pg_func_t) to be written.
Definition prog_link.c:236
bool prog_link_has_func(const prog_link_t *p)
Whether the IOmcu takes a FUNC: protocol 4.26 or later.
Definition prog_link.c:226
bool prog_link_pending(const prog_link_t *p)
Whether a target change waits: the page is known and its target is not the one prog_link_wanted() nam...
Definition prog_link.c:317
bool prog_link_read_due(const prog_link_t *p, uint32_t now_ms)
Whether the page is to be read now: it is unknown, or PROG_LINK_POLL_MS have passed.
Definition prog_link.c:157
prog_link_rate_t
What became of the SERVO rate the panel last wrote (prog_link_rate()).
Definition prog_link.h:78
@ PROG_LINK_RATE_RESET
Definition prog_link.h:80
@ PROG_LINK_RATE_UNKNOWN
Definition prog_link.h:81
@ PROG_LINK_RATE_KEPT
Definition prog_link.h:79
uint8_t prog_link_hitec_held(const prog_link_t *p)
Bit n: the HITEC page holds port n, as last read; 0 with no link, no page or nothing read since the l...
Definition prog_link.c:82
void prog_link_stale(prog_link_t *p)
The page is unknown until it is read again.
Definition prog_link.c:189
bool prog_link_command(const prog_link_t *p, bool release)
Whether the tester sends a command now, a release for release.
Definition prog_link.c:143
prog_link_ask_state_t
Where the last prog_link_ask() stands.
Definition prog_link.h:94
@ PROG_LINK_ASK_WAITING
Definition prog_link.h:96
@ PROG_LINK_ASK_IDLE
Definition prog_link.h:95
@ PROG_LINK_ASK_LOST
Definition prog_link.h:102
@ PROG_LINK_ASK_DONE
Definition prog_link.h:99
@ PROG_LINK_ASK_REFUSED
Definition prog_link.h:100
uint8_t prog_link_regs(const prog_link_t *p)
The registers a read of the page asks for: LINK_PG_REGS from 4.26, LINK_PG_REGS_V424 before.
Definition prog_link.c:220
void prog_link_cfg(const uint16_t *cc, uint16_t *out)
A channel's configuration as the CHAN_CFG page takes it (LINK_CC_STRIDE registers) as a port takes it...
Definition prog_link.c:513
void prog_link_lost(prog_link_t *p)
The link is down: no page, no link.
Definition prog_link.c:45
void prog_link_hold(prog_link_t *p, bool held)
Whether the servo programmer has a port (kst_prog_port_taken()).
Definition prog_link.c:125
bool prog_link_port(const prog_link_t *p, uint8_t port, prog_link_port_t *out)
Port port as the page holds it into out.
Definition prog_link.c:470
prog_link_drive_t prog_link_drive(const prog_link_t *p)
Where the tester's commands go now, for the SERVO screen's TARGET row.
Definition prog_link.c:486
bool prog_link_has_dshot(const prog_link_t *p)
Whether the IOmcu takes FUNC DSHOT150 to DSHOT600: protocol 4.28 or later.
Definition prog_link.c:231
uint8_t prog_link_pulse_on(const prog_link_t *p, const prog_link_write_t *w)
The port w switches its pulse on for, as 1 + n, or 0 for a write that switches none on.
Definition prog_link.c:395
prog_link_ask_state_t prog_link_ask_state(const prog_link_t *p, uint8_t *port, uint8_t *kind, uint16_t *value)
Where the last ask stands, and what it was (port, kind, value may be NULL).
Definition prog_link.c:259
bool prog_link_held(const prog_link_t *p)
Whether the servo programmer holds a port.
Definition prog_link.c:132
void prog_link_hitec_read(prog_link_t *p, const uint16_t *state)
The HITEC STATE register as read, state NULL for a read nobody answered: the port it names is held fr...
Definition prog_link.c:71
void prog_link_want(prog_link_t *p, uint8_t target, bool pwm)
What the screen wants: target 0 for the standard outputs or 1 + n for port n, and whether that port r...
Definition prog_link.c:116
What the tester drives: the target, and with a port its pin and pulse.
Definition prog_link.h:506
uint8_t pin
Definition prog_link.h:510
bool pwm
Definition prog_link.h:512
uint8_t target
Definition prog_link.h:507
A port as the page holds it, for the OUTPUTS entry and PICK A PIN.
Definition prog_link.h:484
uint8_t func
Definition prog_link.h:486
bool refused
Definition prog_link.h:487
uint8_t pin
Definition prog_link.h:485
The panel's side of the programming ports' page.
Definition prog_link.h:108
bool read_once
Definition prog_link.h:117
bool target_rate
Definition prog_link.h:111
uint16_t ask_value
Definition prog_link.h:128
uint8_t hitec_held
Definition prog_link.h:132
bool page
Definition prog_link.h:110
bool dshot
Definition prog_link.h:124
uint8_t ask_port
Definition prog_link.h:126
bool held
Definition prog_link.h:122
uint8_t want_target
Definition prog_link.h:120
uint8_t rate
Definition prog_link.h:115
bool want_pwm
Definition prog_link.h:121
uint32_t read_ms
Definition prog_link.h:118
uint8_t ask_state
Definition prog_link.h:125
uint8_t seen
Definition prog_link.h:113
uint16_t regs[LINK_PG_REGS]
Definition prog_link.h:119
uint8_t ask_kind
Definition prog_link.h:127
bool reread
Definition prog_link.h:129
bool up
Definition prog_link.h:109
bool func
Definition prog_link.h:123
bool hitec
Definition prog_link.h:131
bool known
Definition prog_link.h:116
One register to write.
Definition prog_link.h:136