rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_update_host.h
Go to the documentation of this file.
1
19#ifndef RCBENCH_LINK_UPDATE_HOST_H
20#define RCBENCH_LINK_UPDATE_HOST_H
21
22#include <stdbool.h>
23#include <stdint.h>
24
25#include "link_host.h"
26#include "link_pages.h"
27#include "link_port.h"
28#include "link_sha256.h"
29#include "link_update_image.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#define LINK_UPH_HASH_STEP 8192u
43#define LINK_UPH_LOST_MS 4000u
48#define LINK_UPH_RESTARTS 3u
50#define LINK_UPH_BLOCK_TRIES 3u
54#define LINK_UPH_BUSY_MS 10000u
56#define LINK_UPH_HASH_MS 10000u
61#define LINK_UPH_SETTLE_MS 500u
66#define LINK_UPH_CONFIRM_MS 12000u
67
71typedef enum {
72 LINK_UPH_IDLE = 0,
77 LINK_UPH_BEGIN,
80 LINK_UPH_FINISH,
81 LINK_UPH_VERIFY,
82 LINK_UPH_ACTIVATE,
84 LINK_UPH_BUY,
87
105
109typedef struct {
110 const uint8_t *img;
111 uint32_t len;
112 int32_t flag_at;
113
114 link_uph_phase_t phase;
115 uint8_t result;
116 uint8_t error;
117 bool missing;
118 uint8_t restarts;
119 uint8_t block_tries;
120 uint8_t after_resync;
121 bool aborted;
122
127
128 uint16_t block;
129 uint16_t blocks;
130 uint16_t slot;
131 uint16_t block_tried;
132 bool busy;
133 uint32_t busy_ms;
134 uint32_t since_ms;
135 uint32_t missing_ms;
136
137 bool have_ident;
138 uint16_t ident[LINK_ID_COUNT];
139} link_uph_t;
140
157void link_uph_check(link_uph_t *u, const uint8_t *img, uint32_t len,
158 uint32_t now_ms);
159
171void link_uph_update(link_uph_t *u, const uint8_t *img, uint32_t len,
172 uint32_t now_ms);
173
182void link_uph_confirm(link_uph_t *u, uint32_t now_ms);
183
193 const link_port_t *port);
194
201uint16_t link_uph_permille(const link_uph_t *u);
202
212typedef struct {
213 bool told;
214 bool owed;
216
229bool link_uph_mismatch_probe(link_uph_mismatch_t *m, bool mismatch);
230
238
245
246#ifdef __cplusplus
247}
248#endif
249
250#endif /* RCBENCH_LINK_UPDATE_HOST_H */