rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_dev.h
Go to the documentation of this file.
1
12#ifndef RCBENCH_LINK_DEV_H
13#define RCBENCH_LINK_DEV_H
14
15#include <stdbool.h>
16#include <stddef.h>
17#include <stdint.h>
18
19#include "link_msg.h"
20#include "link_pages.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
34#define LINK_DEV_SILENCE_MS 200u
35
43typedef struct {
44 uint8_t page;
45 uint8_t count;
47 void (*read)(void *ctx, uint8_t offset, uint8_t count, uint16_t *out);
49 uint8_t (*write)(void *ctx, uint8_t offset, uint8_t count,
50 const uint16_t *in);
52
56typedef struct {
57 const link_page_t *pages;
58 uint8_t page_count;
59 void *ctx;
60
61 uint32_t last_request_ms;
71 bool heard;
72 bool silent;
73 bool failsafe;
86 uint32_t requests;
88
99void link_dev_init(link_dev_t *d, const link_page_t *pages, uint8_t page_count,
100 void *ctx, uint32_t now_ms);
101
119bool link_dev_dispatch(link_dev_t *d, const link_msg_t *req,
120 link_msg_t *reply, uint32_t now_ms);
121
137bool link_dev_apply(const link_dev_t *d, const link_msg_t *req,
138 link_msg_t *reply);
139
140
151bool link_dev_tick(link_dev_t *d, uint32_t now_ms);
152
163void link_dev_clear_failsafe(link_dev_t *d, uint32_t now_ms);
164
174
181bool link_dev_arm_latched(const link_dev_t *d);
182
183#ifdef __cplusplus
184}
185#endif
186
187#endif /* RCBENCH_LINK_DEV_H */