rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
port_view.h
1/*
2 * The programming ports as the screens see them, and the operator's asks
3 * that change one (protocol 4.26).
4 *
5 * The control task reads the IOmcu's PROG page (prog_link.h) and hands
6 * the UI task what each port holds: its PIN register, whether the IOmcu
7 * refused that pin, and its FUNC. OUTPUTS and PICK A PIN draw from this
8 * view. A port's PIN and FUNC are the IOmcu's, kept in its flash; a
9 * screen changes one only by asking (port_view_ask()), which the control
10 * task carries to prog_link_ask() and writes on a bench at rest. The
11 * outcome comes back here and the screens say it in words
12 * (port_view_ask_line()).
13 *
14 * Until the page is read after a link-up the ports are not known: count
15 * PORT_VIEW_UNKNOWN, no pin and no function. A screen shows them as not
16 * read, never as free.
17 *
18 * Pure state, no I/O.
19 *
20 * SPDX-License-Identifier: MIT
21 */
22#pragma once
23
24#include <stdbool.h>
25#include <stddef.h>
26#include <stdint.h>
27
28#include "link_pages.h"
29#include "prog_link.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#define PORT_VIEW_UNKNOWN 0xFFu
38#define PORT_VIEW_NO_PIN 0xFFu
40#define PORT_VIEW_FN_UNKNOWN 0xFFu
41
42typedef struct {
43 uint8_t count;
45 bool has_func;
46 bool has_dshot;
49 uint8_t refused;
51
53void port_view_unknown(port_view_t *v);
54
57void port_view_set(const port_view_t *v);
58const port_view_t *port_view_get(void);
59uint32_t port_view_revision(void);
60
62bool port_view_has(uint8_t port);
63
65uint8_t port_view_func(uint8_t port);
66
69bool port_view_pwm(uint8_t port);
70
72bool port_view_dshot(uint8_t port);
73
77const char *port_view_fn_name(uint8_t fn);
78
80typedef bool (*port_view_ask_fn)(uint8_t seq, uint8_t port,
81 prog_link_ask_kind_t kind, uint16_t value);
82void port_view_set_ask(port_view_ask_fn fn);
83
90bool port_view_ask(uint8_t port, prog_link_ask_kind_t kind, uint16_t value);
91
94void port_view_set_ask_state(uint8_t seq, prog_link_ask_state_t st);
95
97prog_link_ask_state_t port_view_ask_state(uint8_t *port, uint8_t *kind);
98
100uint8_t port_view_ask_seq(void);
101
108bool port_view_ask_line(uint8_t port, char *buf, size_t cap);
109
110#ifdef __cplusplus
111}
112#endif
Definition port_view.h:42
uint8_t refused
Definition port_view.h:49
uint8_t count
Definition port_view.h:43
uint8_t pin[LINK_PG_PORTS_MAX]
Definition port_view.h:47
uint8_t func[LINK_PG_PORTS_MAX]
Definition port_view.h:48
bool has_dshot
Definition port_view.h:46
bool has_func
Definition port_view.h:45