rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_update_dev.h
Go to the documentation of this file.
1
15#ifndef RCBENCH_LINK_UPDATE_DEV_H
16#define RCBENCH_LINK_UPDATE_DEV_H
17
18#include <stdbool.h>
19#include <stdint.h>
20
21#include "link_pages.h"
22#include "link_sha256.h"
23#include "link_update_image.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33#define LINK_UPD_HASH_STEP 1024u
34
44#define LINK_UPD_SILENCE_MS 5000u
45
50#define LINK_UPD_SWEEP_MS 1000u
51
56#define LINK_UPD_RESTART_MS 20u
57
61typedef struct {
65 bool (*erase)(void *ctx, uint32_t off);
67 bool (*program)(void *ctx, uint32_t off, const uint8_t *data);
72 bool (*gate)(void *ctx);
74 bool (*buy)(void *ctx);
76 void (*restart)(void *ctx);
77 void *ctx;
79
83typedef struct {
84 const link_update_io_t *io;
85 const uint8_t *running;
86 const uint8_t *target;
87 uint32_t slot_bytes;
88 uint16_t slot;
89
90 uint8_t state;
91 uint8_t error;
92 uint16_t regs_cmd[4];
93 uint32_t size;
94 uint16_t next;
95 uint16_t blocks;
96
97 uint16_t data[LINK_UPD_DATA_COUNT];
98
99 uint8_t digest_of;
103
104 bool restart_due;
105 bool restart_timed;
106 uint32_t restart_at_ms;
107
108 bool heard;
110 uint32_t heard_ms;
111 bool sweep;
114 uint32_t sweep_ms;
115
119
137 const uint8_t *running, const uint8_t *target,
138 uint32_t slot_bytes, uint16_t slot);
139
148void link_update_dev_read_ctl(link_update_dev_t *u, uint8_t offset,
149 uint8_t count, uint16_t *out);
159uint8_t link_update_dev_write_ctl(link_update_dev_t *u, uint8_t offset,
160 uint8_t count, const uint16_t *in);
169void link_update_dev_read_data(link_update_dev_t *u, uint8_t offset,
170 uint8_t count, uint16_t *out);
181uint8_t link_update_dev_write_data(link_update_dev_t *u, uint8_t offset,
182 uint8_t count, const uint16_t *in);
183
195void link_update_dev_poll(link_update_dev_t *u, uint32_t now_ms);
196
205
219bool link_update_dev_refuses_arm(const link_update_dev_t *u, uint8_t off,
220 uint8_t n, const uint16_t *in);
221
222#ifdef __cplusplus
223}
224#endif
225
226#endif /* RCBENCH_LINK_UPDATE_DEV_H */