rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
art_store.h
Go to the documentation of this file.
1
30
31#ifndef RCBENCH_ART_STORE_H
32#define RCBENCH_ART_STORE_H
33
34#include <stdbool.h>
35#include <stdint.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
42#define ART_SLOT_BYTES (16u * 1024u)
43
52typedef struct {
53 bool (*read)(void *ctx, uint32_t off, void *dst, uint32_t len);
54 bool (*erase)(void *ctx, uint32_t off, uint32_t len);
55 bool (*write)(void *ctx, uint32_t off, const void *src, uint32_t len);
56 void *ctx;
57 uint32_t size;
58 uint32_t sector;
60
65typedef struct {
66 uint16_t board;
67 uint16_t format;
68 uint16_t width;
69 uint16_t height;
70 uint16_t crc;
71 uint32_t hash;
72 uint32_t bytes;
74
85bool art_entry_same(const art_entry_t *a, const art_entry_t *b);
86
93uint32_t art_store_slots(const art_flash_t *f);
94
101uint32_t art_store_capacity(const art_flash_t *f);
102
115bool art_store_find(const art_flash_t *f, uint16_t board, art_entry_t *out);
116
131bool art_store_read(const art_flash_t *f, uint16_t board, uint8_t *dst,
132 uint32_t cap);
133
148bool art_store_read_same(const art_flash_t *f, const art_entry_t *key,
149 uint8_t *dst, uint32_t cap);
150
166bool art_store_put(const art_flash_t *f, uint16_t board,
167 const art_entry_t *entry, const uint8_t *payload);
168
178bool art_store_forget(const art_flash_t *f, uint16_t board);
179
180/* ------------------------------------------------- a keep, a sector at a time */
181
188#define ART_KEEP_READ_BYTES 256u
189
198
215typedef struct {
216 const art_flash_t *f;
217 const uint8_t *payload;
218 art_entry_t entry;
219 uint16_t board;
220 uint8_t phase;
221 uint32_t at;
222 uint32_t span;
223 uint32_t done;
224 uint16_t crc;
225 uint32_t hash;
227} art_keep_t;
228
247bool art_keep_begin(art_keep_t *k, const art_flash_t *f, uint16_t board,
248 const art_entry_t *entry, const uint8_t *payload);
249
264
271bool art_keep_busy(const art_keep_t *k);
272
273#ifdef __cplusplus
274}
275#endif
276
277#endif /* RCBENCH_ART_STORE_H */
bool art_entry_same(const art_entry_t *a, const art_entry_t *b)
Whether two entries describe the same payload: every field equal.
Definition art_store.c:137
bool art_store_find(const art_flash_t *f, uint16_t board, art_entry_t *out)
What is kept for board, without reading the drawing itself.
Definition art_store.c:114
bool art_keep_busy(const art_keep_t *k)
Whether k has a keep under way, waiting or not.
Definition art_store.c:273
bool art_store_read(const art_flash_t *f, uint16_t board, uint8_t *dst, uint32_t cap)
Read the drawing for board into dst.
Definition art_store.c:145
uint32_t art_store_capacity(const art_flash_t *f)
The most bytes a drawing may be for this partition to hold it.
Definition art_store.c:75
bool art_keep_begin(art_keep_t *k, const art_flash_t *f, uint16_t board, const art_entry_t *entry, const uint8_t *payload)
Set k up to keep payload for board.
Definition art_store.c:250
uint32_t art_store_slots(const art_flash_t *f)
How many drawings this partition has room for.
Definition art_store.c:70
bool art_store_put(const art_flash_t *f, uint16_t board, const art_entry_t *entry, const uint8_t *payload)
Keep payload for board, replacing anything kept for it already.
Definition art_store.c:211
bool art_store_read_same(const art_flash_t *f, const art_entry_t *key, uint8_t *dst, uint32_t cap)
Read the drawing key describes into dst: only when the entry kept for key->board equals key in every ...
Definition art_store.c:165
art_keep_status_t art_keep_step(art_keep_t *k, bool may_write)
One step, when may_write is true: at most one sector erased, written or read back,...
Definition art_store.c:384
bool art_store_forget(const art_flash_t *f, uint16_t board)
Forget what is kept for board.
Definition art_store.c:415
art_keep_status_t
What a step of a keep did; see art_keep_step().
Definition art_store.h:191
@ ART_KEEP_IDLE
Definition art_store.h:192
@ ART_KEEP_WAITING
Definition art_store.h:193
@ ART_KEEP_RUNNING
Definition art_store.h:194
@ ART_KEEP_FAILED
Definition art_store.h:196
@ ART_KEEP_DONE
Definition art_store.h:195
#define ART_KEEP_READ_BYTES
Bytes read back per read while a keep checks what it wrote.
Definition art_store.h:188
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
What a slot says it holds: the board and the ARTWORK page it came from.
Definition art_store.h:65
uint32_t hash
Definition art_store.h:71
uint16_t crc
Definition art_store.h:70
uint32_t bytes
Definition art_store.h:72
uint16_t height
Definition art_store.h:69
uint16_t format
Definition art_store.h:67
uint16_t width
Definition art_store.h:68
The flash a store lives in.
Definition art_store.h:52
uint32_t sector
Definition art_store.h:58
uint32_t size
Definition art_store.h:57
The write art_store_put() does, cut into steps of at most one sector each, so a caller can stop betwe...
Definition art_store.h:215
uint32_t done
Definition art_store.h:223
uint8_t buf[ART_KEEP_READ_BYTES]
Definition art_store.h:226
uint16_t crc
Definition art_store.h:224
uint8_t phase
Definition art_store.h:220
uint32_t span
Definition art_store.h:222
uint32_t at
Definition art_store.h:221
uint32_t hash
Definition art_store.h:225