ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
cfg_store.h
Go to the documentation of this file.
1
14#ifndef CFG_STORE_H
15#define CFG_STORE_H
16
17#include <stdint.h>
18#include "params.h"
19#include "calib_mgr.h"
20
21#define CFG_MAGIC 0x43574341u
22#define CFG_VERSION 2u
23#define CFG_PARAM_SLOTS 48u
26typedef struct {
27 uint16_t id;
28 uint16_t rsv;
29 float value;
31
34typedef struct {
35 uint32_t magic;
36 uint16_t version;
37 uint16_t size;
38 uint32_t seq;
40 char name[16];
43 uint32_t bak_mask;
46 uint8_t reserved[56];
47 uint32_t crc;
49
51void cfg_params_put(cfg_image_t *img, const float values[PARAM_COUNT]);
52void cfg_params_get(const cfg_image_t *img, float values[PARAM_COUNT]);
53
54/* ---- backend ---- */
55#define CFG_PAGES 2
56const void *cfg_flash_page(int page);
57int cfg_flash_write(int page, const void *data, uint32_t len);
59/* ---- store ---- */
60uint32_t cfg_crc32(const void *data, uint32_t len);
63int cfg_load(cfg_image_t *out);
65int cfg_save(cfg_image_t *img);
66
67#endif /* CFG_STORE_H */
Sensor calibrations of protocol v2 (HANDOVER_FW.md §10).
int cfg_save(cfg_image_t *img)
writes img (seq and crc filled here) to the other page; 0 = ok
Definition cfg_store.c:117
#define CFG_PARAM_SLOTS
room for parameters added later
Definition cfg_store.h:23
const void * cfg_flash_page(int page)
memory-mapped page
int cfg_flash_write(int page, const void *data, uint32_t len)
erase + program; 0 = ok
void cfg_params_put(cfg_image_t *img, const float values[PARAM_COUNT])
parameters <-> slots (unknown ids ignored, missing ids -> default)
Definition cfg_store.c:76
void cfg_params_get(const cfg_image_t *img, float values[PARAM_COUNT])
Definition cfg_store.c:85
uint32_t cfg_crc32(const void *data, uint32_t len)
Definition cfg_store.c:9
int cfg_load(cfg_image_t *out)
latest valid image (version 1 converted); returns 0 if found, -1 if none (out left untouched)
Definition cfg_store.c:95
Drone parameters of protocol v2 (HANDOVER_FW.md §8, ids.ts PARAMS).
@ PARAM_COUNT
Definition params.h:29
Version 2.
Definition cfg_store.h:34
uint32_t crc
CRC-32 of everything above
Definition cfg_store.h:47
cal_set_t bak
previous set, per type (CAL_RESTORE)
Definition cfg_store.h:42
float batt_used_scale_i
current scale it was counted with
Definition cfg_store.h:45
float batt_used_mah
charge used in the last flight
Definition cfg_store.h:44
uint16_t version
Definition cfg_store.h:36
uint16_t size
Definition cfg_store.h:37
uint32_t magic
Definition cfg_store.h:35
uint32_t seq
Definition cfg_store.h:38
cal_set_t cal
saved calibrations
Definition cfg_store.h:41
uint32_t bak_mask
bit (type-1): bak holds a set for it
Definition cfg_store.h:43
one parameter: stored by id, so the table can grow without a migration
Definition cfg_store.h:26
uint16_t rsv
Definition cfg_store.h:28
uint16_t id
0 = empty slot
Definition cfg_store.h:27
float value
Definition cfg_store.h:29