rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
tone_link.h
Go to the documentation of this file.
1
63
64#pragma once
65
66#include <stdbool.h>
67#include <stdint.h>
68
69#include "link_pages.h"
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
76#define TONE_LINK_MINOR 8u
77
83#define TONE_LINK_SETTLE_MS 500u
84
89#define TONE_LINK_READ_MS 40u
90
95#define TONE_LINK_RETRY_MS 5000u
96
98#define TONE_LINK_STALE_MS 500u
99
109#define TONE_LINK_WINDOW_STALE_MS 1500u
110
115#define TONE_LINK_EVENT_GAP_MS 5000u
116
118#define TONE_LINK_HISTORY 8u
120#define TONE_LINK_SHOWN 4u
121
123#define TONE_LINK_STATUS_COUNT \
124 ((unsigned)LINK_TN_COUNT - (unsigned)LINK_TN_FLAGS)
125
126#define TONE_LINK_BEEP_COUNT \
127 ((unsigned)LINK_TN_EVT_FLAGS - (unsigned)LINK_TN_EVT_SEQ + 1u)
128
130#define TONE_LINK_NO_ANSWER (-1)
131#define TONE_LINK_ACK 0
132
134typedef struct {
135 bool enable;
136 uint8_t pin;
137 uint16_t f_min_hz;
138 uint16_t f_max_hz;
139 uint8_t split_pct;
140 uint8_t gap_ms;
141 uint8_t min_periods;
143
145enum {
159};
160
165#define TONE_LINK_EV_SETUP ((uint16_t)(TONE_LINK_EV_PIN_REFUSED \
166 | TONE_LINK_EV_SETUP_REFUSED \
167 | TONE_LINK_EV_PIN_BUSY))
168
179
183typedef struct {
185 bool write;
186 uint8_t page;
187 uint8_t off,
189 uint16_t regs[4];
191
193typedef struct {
194 uint16_t seq;
195 uint32_t start_ms;
196 uint16_t len_dms;
197 uint16_t freq_dhz;
198 uint16_t bursts;
199 uint16_t carrier_hhz;
200 uint8_t flags;
202
212
217typedef struct {
218 tone_state_t state;
229 bool read;
230 bool overrun;
231 bool tone;
232 bool beep;
233 uint16_t win_freq_dhz;
234 uint16_t win_periods;
235 uint16_t lost;
236 uint16_t glitches;
237 uint32_t missed;
238 uint8_t n;
241
245typedef struct {
246 bool up;
247 bool page;
248
249 /* What is asked, as the page is to hold it. */
250 bool want_set;
251 uint16_t want[LINK_TN_CONFIG_COUNT];
252 uint32_t want_ms;
253
254 /* What the page holds, as read or written since the link came up. */
255 bool known;
256 uint16_t held[LINK_TN_CONFIG_COUNT];
257 bool refused0, refused1;
258 bool retry0;
260 uint8_t told;
261 uint32_t refused0_ms;
262 uint32_t retry_ms;
263
264 /* The exchange in flight. */
265 tone_link_op_kind_t pending;
266 uint16_t out[4];
267
268 /* The status read. */
269 bool asked_status;
270 uint32_t status_asked_ms;
271 bool have_status;
272 uint16_t status[TONE_LINK_STATUS_COUNT];
273 uint32_t status_ms;
274 uint16_t was_flags;
275 bool win_seen;
276 uint16_t win_last;
277 uint32_t win_moved_ms;
279
280 /* The beeps. */
281 bool synced;
283 uint8_t quiet;
284 uint16_t last;
285 uint32_t missed;
286 bool sel_ok;
287 uint16_t sel_num;
289 uint8_t hist_n;
290 uint8_t hist_at;
291 uint32_t beeps_read;
292
293 /* What has been said. */
294 uint16_t events;
295 bool event_given;
296 uint32_t event_ms;
298
305
315
326void tone_link_came_up(tone_link_t *t, uint16_t minor, uint32_t now_ms);
327
340void tone_link_want(tone_link_t *t, const tone_setup_t *w, uint32_t now_ms);
341
352bool tone_link_next(tone_link_t *t, uint32_t now_ms, tone_link_op_t *op);
353
365void tone_link_done(tone_link_t *t, int result, const uint16_t *regs,
366 uint32_t now_ms);
367
379uint16_t tone_link_event(tone_link_t *t, uint32_t now_ms);
380
400bool tone_link_event_stands(const tone_link_t *t, uint16_t ev);
401
412void tone_link_event_back(tone_link_t *t, uint16_t ev);
413
421bool tone_link_settled(const tone_link_t *t);
422
428enum {
429 TONE_LINK_ROWS_TAP = 0x01,
430 TONE_LINK_ROWS_BEEP = 0x02,
431};
432
444uint8_t tone_link_unheld(const tone_link_t *t);
445
454unsigned tone_link_beeps(const tone_link_t *t, tone_beep_t *out,
455 unsigned max);
456
464uint32_t tone_link_read_count(const tone_link_t *t);
471uint32_t tone_link_missed(const tone_link_t *t);
472
479uint16_t tone_link_flags(const tone_link_t *t);
480
492void tone_link_readout(const tone_link_t *t, uint32_t now_ms,
493 tone_readout_t *r);
494
501unsigned tone_link_pin(const tone_link_t *t);
508unsigned tone_link_f_min(const tone_link_t *t);
515unsigned tone_link_f_max(const tone_link_t *t);
516
530bool tone_link_held_pin(const tone_link_t *t, int *pin);
531
532#ifdef __cplusplus
533}
534#endif
One beep as the page reported it.
Definition tone_link.h:193
uint8_t flags
Definition tone_link.h:200
uint16_t bursts
Definition tone_link.h:198
uint16_t carrier_hhz
Definition tone_link.h:199
uint16_t freq_dhz
Definition tone_link.h:197
uint32_t start_ms
Definition tone_link.h:195
uint16_t len_dms
Definition tone_link.h:196
uint16_t seq
Definition tone_link.h:194
The screen's copy: a plain value the control task fills and the renderer reads.
Definition tone_link.h:217
uint16_t win_periods
Definition tone_link.h:234
bool read
The state and the seven values below come from a status read younger than TONE_LINK_STALE_MS; false,...
Definition tone_link.h:229
bool overrun
Definition tone_link.h:230
uint16_t win_freq_dhz
Definition tone_link.h:233
bool beep
Definition tone_link.h:232
uint16_t glitches
Definition tone_link.h:236
uint32_t missed
Definition tone_link.h:237
uint8_t n
Definition tone_link.h:238
tone_beep_t beeps[TONE_LINK_SHOWN]
Definition tone_link.h:239
uint16_t lost
Definition tone_link.h:235
bool tone
Definition tone_link.h:231
The set-up as SETUP INTERFACES has it.
Definition tone_link.h:134
uint8_t pin
Definition tone_link.h:136
bool enable
Definition tone_link.h:135
uint8_t min_periods
Definition tone_link.h:141
uint8_t split_pct
Definition tone_link.h:139
uint16_t f_min_hz
Definition tone_link.h:137
uint16_t f_max_hz
Definition tone_link.h:138
uint8_t gap_ms
Definition tone_link.h:140