rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
prog_link.h
Go to the documentation of this file.
1
45#ifndef RCBENCH_PROG_LINK_H
46#define RCBENCH_PROG_LINK_H
47
48#include <stdbool.h>
49#include <stdint.h>
50
51#include "link_pages.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
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
74
83
85#define PROG_LINK_SEEN_NONE 0xFFu
86
88typedef enum {
89 PROG_LINK_ASK_PIN = 0,
90 PROG_LINK_ASK_FUNC,
92
104
108typedef struct {
109 bool up;
110 bool page;
113 uint8_t seen;
115 uint8_t rate;
116 bool known;
118 uint32_t read_ms;
119 uint16_t regs[LINK_PG_REGS];
120 uint8_t want_target;
121 bool want_pwm;
122 bool held;
123 bool func;
124 bool dshot;
125 uint8_t ask_state;
126 uint8_t ask_port;
127 uint8_t ask_kind;
128 uint16_t ask_value;
129 bool reread;
131 bool hitec;
132 uint8_t hitec_held;
134
136typedef struct {
137 uint8_t off;
138 uint16_t value;
140
147
157void prog_link_came_up(prog_link_t *p, uint16_t minor);
158
165
177void prog_link_want(prog_link_t *p, uint8_t target, bool pwm);
178
191void prog_link_hold(prog_link_t *p, bool held);
198bool prog_link_held(const prog_link_t *p);
199
207uint8_t prog_link_regs(const prog_link_t *p);
208
215bool prog_link_has_func(const prog_link_t *p);
216
224bool prog_link_has_dshot(const prog_link_t *p);
225
241bool prog_link_ask(prog_link_t *p, uint8_t port, prog_link_ask_kind_t kind,
242 uint16_t value);
243
255 uint8_t *port, uint8_t *kind,
256 uint16_t *value);
257
266bool prog_link_read_due(const prog_link_t *p, uint32_t now_ms);
267
278bool prog_link_hitec_due(const prog_link_t *p);
279
289void prog_link_hitec_read(prog_link_t *p, const uint16_t *state);
290
298uint8_t prog_link_hitec_held(const prog_link_t *p);
299
311void prog_link_read(prog_link_t *p, const uint16_t *regs, uint32_t now_ms);
312
319
336bool prog_link_next(const prog_link_t *p, bool quiet, prog_link_write_t *w);
337
352uint8_t prog_link_pulse_on(const prog_link_t *p, const prog_link_write_t *w);
353
362void prog_link_written(prog_link_t *p, const prog_link_write_t *w, bool ack);
363
375uint8_t prog_link_wanted(const prog_link_t *p);
376
387bool prog_link_ready(const prog_link_t *p);
388
395uint8_t prog_link_target(const prog_link_t *p);
396
404bool prog_link_pending(const prog_link_t *p);
405
415bool prog_link_settled(const prog_link_t *p);
416
429bool prog_link_command(const prog_link_t *p, bool release);
430
446
456bool prog_link_pwm(const prog_link_t *p);
457
459#define PROG_LINK_COUNT_UNKNOWN 0xFFu
460
471uint8_t prog_link_count(const prog_link_t *p);
472
481uint8_t prog_link_pin(const prog_link_t *p, uint8_t port);
482
484typedef struct {
485 uint8_t pin;
486 uint8_t func;
487 bool refused;
489
501bool prog_link_port(const prog_link_t *p, uint8_t port, prog_link_port_t *out);
502
506typedef struct {
507 uint8_t target;
510 uint8_t pin;
512 bool pwm;
514
528bool prog_link_no_drive(const prog_link_t *p);
529
560
569void prog_link_cfg(const uint16_t *cc, uint16_t *out);
570
571#ifdef __cplusplus
572}
573#endif
574
575#endif /* RCBENCH_PROG_LINK_H */