![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
Flight-log store: ring of sectors on a NOR flash (format in log_format.h). More...
Go to the source code of this file.
Data Structures | |
| struct | log_flash_t |
| flash backend; addresses in bytes from the start of the log area More... | |
| struct | log_entry_t |
Macros | |
| #define | LOG_LIST_MAX 64u |
Functions | |
| int | log_mount (const log_flash_t *f) |
| 0 = ok (empty flash is ok) | |
| uint8_t | log_count (void) |
| const log_entry_t * | log_entry (uint8_t index) |
| oldest first | |
| const log_entry_t * | log_find (uint16_t id) |
| uint8_t | log_used_pct (void) |
| int | log_open (uint32_t t0_ms) |
| 0 = ok | |
| int | log_append (uint8_t type, const void *payload, uint8_t len) |
| int | log_close (void) |
| uint8_t | log_is_open (void) |
| int | log_read (uint16_t id, uint32_t offset, void *buf, uint32_t n) |
| bytes of a closed log 'id' from 'offset' (sectors concatenated, headers included) | |
| uint32_t | log_size (uint16_t id) |
| nsect × LOG_SECTOR, 0 unknown | |
| int | log_erase_all (void) |
| erases every sector that holds data; logs restart from id 1 | |
Flight-log store: ring of sectors on a NOR flash (format in log_format.h).
The store works on any flash described by log_flash_t: the W25Q128JV of the ACwing FC (drivers/w25q) or a RAM area on the bench (bsp/log_flash_ram.c). It is used by one task only (the LogTask), so it has no locks. Host-testable.
Definition in file log_store.h.
| #define LOG_LIST_MAX 64u |
Definition at line 25 of file log_store.h.
| int log_mount | ( | const log_flash_t * | f | ) |
0 = ok (empty flash is ok)
Definition at line 82 of file log_store.c.
References F, log_entry_t::first, log_entry_t::id, is_used(), log_sector_hdr_t::log_id, LOG_LIST_MAX, LOG_SECTOR, next(), log_entry_t::nsect, read_hdr(), s, s_last_id, s_list, s_n, s_nsect, s_open, s_serial, s_used, s_wp, log_sector_hdr_t::seq, log_sector_hdr_t::serial, set_used(), log_flash_t::size, log_sector_hdr_t::t0_ms, log_entry_t::t0_ms, and log_entry_t::truncated.
Referenced by cmd(), and log_task_init().
| uint8_t log_count | ( | void | ) |
Definition at line 120 of file log_store.c.
References s_n.
Referenced by cmd(), cmd_list(), and last_log().
| const log_entry_t * log_entry | ( | uint8_t | index | ) |
oldest first
Definition at line 121 of file log_store.c.
Referenced by cmd_list(), and last_log().
| const log_entry_t * log_find | ( | uint16_t | id | ) |
Definition at line 124 of file log_store.c.
Referenced by log_read(), and log_size().
| uint8_t log_used_pct | ( | void | ) |
Definition at line 130 of file log_store.c.
References is_used(), n, s, and s_nsect.
Referenced by log_task_init(), and log_task_step().
| int log_open | ( | uint32_t | t0_ms | ) |
0 = ok
Definition at line 182 of file log_store.c.
References F, s_last_id, s_open, s_seq, s_t0, and start_sector().
Referenced by open_log().
| int log_append | ( | uint8_t | type, |
| const void * | payload, | ||
| uint8_t | len | ||
| ) |
Definition at line 193 of file log_store.c.
References log_entry_t::active, flush_page(), log_crc8(), LOG_PAGE, LOG_REC_MAX, LOG_REC_OVERHEAD, LOG_SECTOR, n, s_list, s_n, s_open, s_page, s_page_base, s_pos, and start_sector().
Referenced by append_time(), drain(), and open_log().
| int log_close | ( | void | ) |
Definition at line 214 of file log_store.c.
References log_entry_t::active, flush_page(), s_list, s_n, and s_open.
Referenced by close_log().
| uint8_t log_is_open | ( | void | ) |
Definition at line 122 of file log_store.c.
References s_open.
Referenced by append_time(), close_log(), drain(), and recording().
| int log_read | ( | uint16_t | id, |
| uint32_t | offset, | ||
| void * | buf, | ||
| uint32_t | n | ||
| ) |
bytes of a closed log 'id' from 'offset' (sectors concatenated, headers included)
Definition at line 230 of file log_store.c.
References log_entry_t::active, addr(), b, log_flash_t::ctx, F, log_entry_t::first, log_find(), LOG_SECTOR, n, log_entry_t::nsect, off, log_flash_t::read, and s_nsect.
Referenced by read_stream().
| uint32_t log_size | ( | uint16_t | id | ) |
nsect × LOG_SECTOR, 0 unknown
Definition at line 224 of file log_store.c.
References log_find(), LOG_SECTOR, and log_entry_t::nsect.
Referenced by cmd().
| int log_erase_all | ( | void | ) |
erases every sector that holds data; logs restart from id 1
Definition at line 246 of file log_store.c.
References addr(), log_flash_t::ctx, log_flash_t::erase, F, is_used(), s, s_last_id, s_n, s_nsect, s_open, s_wp, and set_used().
Referenced by cmd().