rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
kst_link.h
Go to the documentation of this file.
1
66
67#pragma once
68
69#include <stdbool.h>
70#include <stdint.h>
71
72#include "kst_reg.h"
73#include "kst_session.h"
74#include "link_pages.h"
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
81#define KST_LINK_MINOR LINK_MINOR_PROG
82
87#define KST_LINK_POLL_MS 50u
89#define KST_LINK_IDLE_MS 500u
90
95#define KST_LINK_RETRIES 3u
96
98#define KST_LINK_NO_ANSWER (-1)
99#define KST_LINK_ACK 0
100
114
128
151
167
171typedef struct {
173 link_kst_op_t op;
174 uint32_t id;
177 uint8_t nack;
178 bool taken;
180 uint8_t result;
186 uint8_t fail_reg;
187 uint8_t steps_done;
188 uint16_t frames;
189 uint32_t diff_regs;
190 uint32_t bad_regs;
192
197typedef struct {
198 kst_link_phase_t phase;
199 bool known;
200 bool was_held;
204 uint8_t port_no;
205 uint16_t flags;
207 uint16_t frames;
211 uint16_t fp_rules;
212 uint32_t fp_regs;
213 uint16_t half_min_ns;
214 uint16_t half_max_ns;
215 uint16_t delay_min_us;
216 uint16_t delay_max_us;
218
220typedef struct {
221 bool write;
222 uint8_t page;
223 uint8_t off,
225 uint16_t regs[4];
227
231typedef struct {
232 bool up;
233 bool page;
234 uint16_t minor;
235 bool known;
236 uint8_t phase;
239 uint8_t pending;
240 uint8_t tries;
241 bool was_held;
243
244 uint16_t status[LINK_KS_W_CMD_FRAME];
245 bool polled;
246 bool poll_now;
247 uint32_t status_ms;
248 uint16_t seq;
249
250 /* The operation. */
251 bool active;
252 bool verdict;
254 bool taken;
255 uint8_t op;
256 uint32_t id;
257 uint8_t stage_at;
258 uint16_t staged[LINK_KS_W_STAGED];
260 uint16_t supply[2];
262 uint16_t leave_ms;
264
265 /* The command on its way, the operation's or an abort. */
266 bool cmd_live;
267 bool cmd_abort;
272 uint16_t cmd[LINK_KS_W_CMD_FRAME];
273 bool abort_wanted;
274
275 /* What was fetched. */
276 uint8_t fetch;
279 bool have_results;
280 uint16_t results[LINK_KS_IMAGE - LINK_KS_FAIL];
281 bool have_image;
282 uint16_t image_regs[LINK_KS_IMAGE_REGS];
283 bool have_backup;
284 uint16_t backup_regs[LINK_KS_IMAGE_REGS];
285
286 bool outcome_new;
287 kst_link_outcome_t outcome;
288} kst_link_t;
289
296
307
317void kst_link_came_up(kst_link_t *k, uint16_t minor);
318
325bool kst_link_has_page(const kst_link_t *k);
326
347
358
389
401bool kst_link_next(kst_link_t *k, uint32_t now_ms, kst_link_xfer_t *x);
402
413void kst_link_done(kst_link_t *k, int result, const uint16_t *regs);
414
425
434
442
450bool kst_link_image(const kst_link_t *k, kst_image_t *out);
451
459bool kst_link_backup(const kst_link_t *k, kst_image_t *out);
460
461#ifdef __cplusplus
462}
463#endif
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
KST servo programming protocol: the register image and its fields.
uint64_t kst_field_set_t
A set of fields, bit n for field n.
Definition kst_reg.h:110
KST servo programming protocol: the session with one servo.
The 32 registers, by address.
Definition kst_reg.h:47