rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
hitec_link.h
Go to the documentation of this file.
1
68#ifndef RCBENCH_HITEC_LINK_H
69#define RCBENCH_HITEC_LINK_H
70
71#include <stdbool.h>
72#include <stdint.h>
73
74#include "hitec_session.h"
75#include "hitec_wire.h"
76#include "link_pages.h"
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
83#define HITEC_LINK_MINOR LINK_MINOR_HITEC
84
87#define HITEC_LINK_POLL_MS 5u
89#define HITEC_LINK_HELD_MS 100u
91#define HITEC_LINK_IDLE_MS 500u
94#define HITEC_LINK_RETRIES 3u
96#define HITEC_LINK_PASS_MAX 4u
99#define HITEC_LINK_RUN_MAX_MS 25000u
101#define HITEC_LINK_NO_PIN 0xFFFFu
102
104#define HITEC_LINK_NO_ANSWER (-1)
107#define HITEC_LINK_ACK 0
108
119
129
146
180
182typedef struct {
184 uint16_t minor;
188 bool known;
190 uint8_t port_no;
191 uint16_t flags;
193 bool held;
194 bool stopped;
195 bool ours;
199 uint16_t seq;
201 uint16_t count;
204 uint16_t pin;
205 uint16_t line;
207 uint16_t bit_ns;
209
211typedef struct {
212 bool write;
213 uint8_t page;
214 uint8_t off;
215 uint8_t n;
216 uint16_t regs[4];
218
229typedef int (*hitec_link_xchg_fn)(void *ctx, const hitec_link_xfer_t *x,
230 uint16_t *regs);
231
233#define HITEC_LINK_STAGED (LINK_HT_W_STAGED + 1u)
234
236typedef struct {
237 uint8_t up;
238 uint8_t page;
239 uint16_t minor;
240 uint8_t known;
241 uint8_t phase;
242 uint8_t pending;
243 uint8_t tries;
244 uint8_t polled;
245 uint8_t poll_now;
246 uint32_t status_ms;
247 uint32_t now_ms;
248 uint16_t seq;
250 uint8_t ours;
251 uint8_t have_line;
252 uint16_t line[3];
253
254 /* The request. */
255 uint8_t active;
256 uint8_t op;
257 uint8_t port;
258 uint32_t id;
259 uint8_t stage_at;
263 uint8_t verdict;
265 uint8_t taken;
266 uint32_t taken_ms;
267 uint8_t limit_cut;
268
269 /* The command on its way: the request's, or an abort. */
270 uint8_t cmd_live;
271 uint8_t cmd_abort;
272 uint8_t cmd_tries;
273 uint8_t cmd_doubt;
276 uint8_t doubt_abort;
278 uint8_t doubt_nack;
282 uint8_t abort_wanted;
283
284 uint16_t end[LINK_HT_DATA];
286 uint8_t outcome_new;
289
296
307
316void hitec_link_came_up(hitec_link_t *l, uint16_t minor);
317
324bool hitec_link_has_page(const hitec_link_t *l);
325
341 uint8_t family, uint8_t drive,
342 uint32_t id);
343
354 uint32_t id);
355
368 uint32_t id);
369
390 const hitec_ses_step_t *st, uint16_t mv,
391 uint16_t ma, uint32_t id);
392
408
419bool hitec_link_next(hitec_link_t *l, uint32_t now_ms, hitec_link_xfer_t *x);
420
428void hitec_link_done(hitec_link_t *l, int result, const uint16_t *regs);
429
441unsigned hitec_link_service(hitec_link_t *l, uint32_t now_ms,
442 hitec_link_xchg_fn xchg, void *ctx);
443
451
460
468
469#ifdef __cplusplus
470}
471#endif
472
473#endif /* RCBENCH_HITEC_LINK_H */
Hitec servo programming protocols: the session with one servo, as a state machine that hands out step...
Hitec servo programming protocols: frames, transactions, the reply decoders and the driver interface.
#define HITEC_RX_MAX
Definition hitec_wire.h:204
The result of a step.
Definition hitec_session.h:138
One step.
Definition hitec_session.h:117