![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
Persistent configuration: parameters, drone name, calibrations and one backup per calibration type (HANDOVER_FW.md §8, §10). More...
Go to the source code of this file.
Data Structures | |
| struct | cfg_param_t |
| one parameter: stored by id, so the table can grow without a migration More... | |
| struct | cfg_image_t |
| Version 2. More... | |
Macros | |
| #define | CFG_MAGIC 0x43574341u |
| "ACWC" | |
| #define | CFG_VERSION 2u |
| #define | CFG_PARAM_SLOTS 48u |
| room for parameters added later | |
| #define | CFG_PAGES 2 |
Functions | |
| void | cfg_params_put (cfg_image_t *img, const float values[PARAM_COUNT]) |
| parameters <-> slots (unknown ids ignored, missing ids -> default) | |
| void | cfg_params_get (const cfg_image_t *img, float values[PARAM_COUNT]) |
| 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 | |
| uint32_t | cfg_crc32 (const void *data, uint32_t len) |
| int | cfg_load (cfg_image_t *out) |
| latest valid image (version 1 converted); returns 0 if found, -1 if none (out left untouched) | |
| int | cfg_save (cfg_image_t *img) |
| writes img (seq and crc filled here) to the other page; 0 = ok | |
Persistent configuration: parameters, drone name, calibrations and one backup per calibration type (HANDOVER_FW.md §8, §10).
Two flash pages used alternately (A/B). Each save writes the whole image, with a sequence number and a CRC, to the page NOT holding the latest valid image: a reset or power loss during a save leaves the previous image valid. On a bad CRC everywhere the defaults are used.
The flash access is a small backend (cfg_flash_*), implemented for the STM32WB55 in bsp/cfg_flash_wb.c (CPU2-safe) and in RAM by the host test.
Definition in file cfg_store.h.
| #define CFG_MAGIC 0x43574341u |
"ACWC"
Definition at line 21 of file cfg_store.h.
| #define CFG_VERSION 2u |
Definition at line 22 of file cfg_store.h.
| #define CFG_PARAM_SLOTS 48u |
room for parameters added later
Definition at line 23 of file cfg_store.h.
| #define CFG_PAGES 2 |
Definition at line 55 of file cfg_store.h.
| void cfg_params_put | ( | cfg_image_t * | img, |
| const float | values[PARAM_COUNT] | ||
| ) |
parameters <-> slots (unknown ids ignored, missing ids -> default)
Definition at line 76 of file cfg_store.c.
References CFG_PARAM_SLOTS, g_param_def, cfg_param_t::id, param_def_t::id, PARAM_COUNT, cfg_image_t::params, and cfg_param_t::value.
Referenced by cfg_load(), and save_image().
| void cfg_params_get | ( | const cfg_image_t * | img, |
| float | values[PARAM_COUNT] | ||
| ) |
Definition at line 85 of file cfg_store.c.
References CFG_PARAM_SLOTS, g_param_def, cfg_param_t::id, PARAM_COUNT, cfg_image_t::params, params_index(), and cfg_param_t::value.
Referenced by app_task_boot().
| const void * cfg_flash_page | ( | int | page | ) |
memory-mapped page
Definition at line 41 of file cfg_flash_wb.c.
References CFG_PAGE0_ADDR, CFG_PAGE_SIZE, and CFG_PAGES.
Referenced by cfg_flash_write(), cfg_load(), cfg_save(), and latest_page().
| int cfg_flash_write | ( | int | page, |
| const void * | data, | ||
| uint32_t | len | ||
| ) |
erase + program; 0 = ok
Definition at line 79 of file cfg_flash_wb.c.
References cfg_flash_page(), CFG_PAGE_SIZE, CFG_PAGES, g_cpu2_ready, off, OP_ERASE, OP_PROGRAM, and single_op().
Referenced by cfg_save().
| uint32_t cfg_crc32 | ( | const void * | data, |
| uint32_t | len | ||
| ) |
Definition at line 9 of file cfg_store.c.
Referenced by cfg_save(), and valid_version().
| int cfg_load | ( | cfg_image_t * | out | ) |
latest valid image (version 1 converted); returns 0 if found, -1 if none (out left untouched)
Definition at line 95 of file cfg_store.c.
References cfg_image_v1_t::bak, cfg_image_t::bak, cfg_image_v1_t::bak_mask, cfg_image_t::bak_mask, cfg_image_t::batt_used_scale_i, cfg_image_v1_t::cal, cfg_image_t::cal, cal_from_v1(), cfg_flash_page(), CFG_MAGIC, cfg_params_put(), CFG_VERSION, param_def_t::def, g_param_def, latest_page(), cfg_image_t::magic, cfg_image_v1_t::name, cfg_image_t::name, PARAM_COUNT, cfg_image_v1_t::params, pg(), cfg_image_v1_t::seq, cfg_image_t::seq, cfg_image_t::size, V1_PARAMS, valid_version(), and cfg_image_t::version.
Referenced by app_task_boot().
| int cfg_save | ( | cfg_image_t * | img | ) |
writes img (seq and crc filled here) to the other page; 0 = ok
Definition at line 117 of file cfg_store.c.
References cfg_crc32(), cfg_flash_page(), cfg_flash_write(), CFG_MAGIC, CFG_PAGES, CFG_VERSION, cfg_image_t::crc, latest_page(), cfg_image_t::magic, cfg_image_t::seq, seq, cfg_image_t::size, valid(), and cfg_image_t::version.
Referenced by save_image(), and save_image_keep_params().