![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
LogTask (see log_task.h). More...
#include "log_task.h"#include "log_queue.h"#include "usb_link.h"#include "proto_v2.h"#include "fc_core.h"#include "params.h"#include "spsc.h"#include "app_link.h"#include <string.h>#include "cmsis_os2.h"Go to the source code of this file.
Macros | |
| #define | PRE_EVENTS 8u |
| #define | PRE_EVENT_MS 2000u |
Enumerations | |
| enum | { PORT_USB = 0 , PORT_BLE = 1 } |
Functions | |
| SPSC_DEFINE (s_blein, log_cmd_t, 4u) | |
| SPSC_DEFINE (s_bleout, log_msg_t, 8u) | |
| SPSC_DEFINE (s_usbapp, appl_cmd_t, 8u) | |
| void | log_task_init (const log_task_cfg_t *cfg) |
| int | log_task_ble_cmd (const log_cmd_t *c) |
| 0 = queued, -1 = full (answer BUSY) | |
| int | log_task_ble_take (log_msg_t *m) |
| 1 if a frame was taken | |
| int | log_task_usb_app_take (appl_cmd_t *c) |
| 1 if a command was taken | |
| uint8_t | log_task_pct (void) |
| flash used %, 0xFF = no log flash (SYSTEM.log); any task | |
| uint8_t | log_task_busy (void) |
| 1 while a transfer is in progress (the task runs faster) | |
| static void | pump (void) |
| static int | port_send (uint8_t port, uint8_t type, const void *p, uint8_t len) |
| static int | port_room (uint8_t port) |
| static int | port_room_ack (uint8_t port) |
| static void | ack (uint8_t port, uint8_t op, uint8_t seq, uint8_t res, uint8_t why) |
| int | log_task_wallclock (uint32_t now, uint32_t *unix_s, uint16_t *ms) |
| wall clock set by the app (PV2_OP_SET_TIME): 0 and UTC time at uptime 'now', -1 if not set since reset. | |
| static void | append_time (uint32_t now) |
| static void | close_log (void) |
| static void | open_log (uint32_t now) |
| static void | drain (uint32_t now) |
| static void | recording (uint32_t now, uint8_t armed) |
| static void | entry_of (const log_entry_t *e, uint8_t index, uint8_t count, pv2_log_entry_t *m) |
| static const log_entry_t * | last_log (void) |
| static void | cmd_list (uint8_t port, uint8_t seq) |
| static void | cmd (uint8_t port, const uint8_t *c, uint32_t n, uint8_t armed, uint32_t now) |
| static void | read_stream (uint8_t armed) |
| static int | is_log_op (uint8_t op) |
| static int | pauses (uint8_t op) |
| static void | to_app (const uint8_t *c, uint32_t n) |
| void | log_task_step (uint32_t now) |
| static void | LogTask (void *arg) |
| void | log_task_start (const log_task_cfg_t *cfg) |
Variables | ||
| static log_task_cfg_t | s_cfg | |
| static uint8_t | s_mounted | |
| static volatile uint8_t | s_pct = 0xFFu | |
| static uint8_t | s_was_armed | |
| static uint32_t | s_disarm_ms | |
| static uint32_t | s_cmd_ms | |
| static uint8_t | s_have_cmd | |
| static log_event_t | s_pre [PRE_EVENTS] | |
| static uint8_t | s_npre | |
| struct { | ||
| uint8_t set | ||
| uint32_t up_ms | ||
| uint32_t unix_s | ||
| uint16_t ms | ||
| int16_t tz_min | ||
| } | s_clk | |
| struct { | ||
| uint8_t on | ||
| uint8_t seq | ||
| uint8_t port | ||
| uint16_t id | ||
| uint32_t off | ||
| uint32_t end | ||
| } | s_rd | |
LogTask (see log_task.h).
Definition in file log_task.c.
| #define PRE_EVENTS 8u |
Definition at line 32 of file log_task.c.
| #define PRE_EVENT_MS 2000u |
Definition at line 33 of file log_task.c.
| anonymous enum |
| Enumerator | |
|---|---|
| PORT_USB | |
| PORT_BLE | |
Definition at line 16 of file log_task.c.
| SPSC_DEFINE | ( | s_blein | , |
| log_cmd_t | , | ||
| 4u | |||
| ) |
| SPSC_DEFINE | ( | s_bleout | , |
| log_msg_t | , | ||
| 8u | |||
| ) |
| SPSC_DEFINE | ( | s_usbapp | , |
| appl_cmd_t | , | ||
| 8u | |||
| ) |
| void log_task_init | ( | const log_task_cfg_t * | cfg | ) |
Definition at line 53 of file log_task.c.
References log_task_cfg_t::flash, log_mount(), log_q_reset(), log_used_pct(), s_cfg, s_clk, s_disarm_ms, s_have_cmd, s_mounted, s_npre, s_pct, s_rd, s_was_armed, spsc_reset(), and usbl_reset().
Referenced by log_task_start().
| int log_task_ble_cmd | ( | const log_cmd_t * | c | ) |
0 = queued, -1 = full (answer BUSY)
Definition at line 66 of file log_task.c.
References spsc_push().
Referenced by commands().
| int log_task_ble_take | ( | log_msg_t * | m | ) |
1 if a frame was taken
Definition at line 67 of file log_task.c.
References spsc_pop().
Referenced by log_ble_out().
| int log_task_usb_app_take | ( | appl_cmd_t * | c | ) |
1 if a command was taken
Definition at line 68 of file log_task.c.
References spsc_pop().
Referenced by usb_commands().
| uint8_t log_task_pct | ( | void | ) |
flash used %, 0xFF = no log flash (SYSTEM.log); any task
Definition at line 70 of file log_task.c.
References s_pct.
Referenced by app_start().
| uint8_t log_task_busy | ( | void | ) |
1 while a transfer is in progress (the task runs faster)
Definition at line 71 of file log_task.c.
References s_rd.
Referenced by LogTask().
|
static |
Definition at line 73 of file log_task.c.
References s_cfg, and log_task_cfg_t::usb_pump.
Referenced by ack(), cmd_list(), log_task_step(), and read_stream().
|
static |
Definition at line 75 of file log_task.c.
References log_msg_t::len, log_msg_t::p, port, PORT_USB, spsc_push(), log_msg_t::type, and usbl_send().
Referenced by ack(), cmd_list(), and read_stream().
|
static |
Definition at line 85 of file log_task.c.
References port, PORT_USB, PV2_LOG_DATA_MAX, spsc_count(), and usbl_tx_free().
Referenced by read_stream().
|
static |
Definition at line 91 of file log_task.c.
References port, PORT_USB, spsc_count(), and usbl_tx_free().
Referenced by read_stream().
|
static |
Definition at line 97 of file log_task.c.
References port, port_send(), PORT_USB, pump(), PV2_FT_ACK, and seq.
Referenced by cmd(), cmd_list(), read_stream(), and to_app().
| int log_task_wallclock | ( | uint32_t | now_ms, |
| uint32_t * | unix_s, | ||
| uint16_t * | ms | ||
| ) |
wall clock set by the app (PV2_OP_SET_TIME): 0 and UTC time at uptime 'now', -1 if not set since reset.
LogTask only.
Definition at line 105 of file log_task.c.
References ms, s_clk, and unix_s.
Referenced by append_time().
|
static |
Definition at line 114 of file log_task.c.
References log_append(), log_is_open(), log_task_wallclock(), LR_TIME, log_time_t::ms, s_clk, log_time_t::t_ms, log_time_t::tz_min, and log_time_t::unix_s.
Referenced by cmd(), and open_log().
|
static |
Definition at line 123 of file log_task.c.
References log_close(), and log_is_open().
Referenced by cmd(), last_log(), and recording().
|
static |
Definition at line 129 of file log_task.c.
References append_time(), log_info_t::format, log_task_cfg_t::fw, log_info_t::fw, log_task_cfg_t::hw_rev, log_info_t::hw_rev, log_append(), LOG_FORMAT, log_open(), LR_EVENT, LR_INFO, PRE_EVENT_MS, s_cfg, s_npre, s_pre, log_task_cfg_t::sensors, log_info_t::sensors, and log_info_t::t0_ms.
Referenced by recording().
|
static |
Definition at line 146 of file log_task.c.
References log_append(), log_is_open(), log_q_get(), log_q_take_drops(), LOG_REC_MAX, LOG_SRC_COUNT, LR_DROP, LR_EVENT, PRE_EVENTS, s_npre, and s_pre.
Referenced by recording().
|
static |
Definition at line 166 of file log_task.c.
References close_log(), drain(), log_is_open(), LOG_POSTROLL_MS, log_q_set_active(), LOG_USB_PAUSE_MS, open_log(), P_LOG_MODE, PARAM, PARAM_LOG_ALWAYS, PARAM_LOG_ARMED, PARAM_LOG_OFF, s_cmd_ms, s_disarm_ms, s_have_cmd, and s_was_armed.
Referenced by log_task_step().
|
static |
Definition at line 186 of file log_task.c.
References log_entry_t::active, pv2_log_entry_t::bytes, pv2_log_entry_t::count, pv2_log_entry_t::flags, log_entry_t::id, pv2_log_entry_t::id, pv2_log_entry_t::index, LOG_SECTOR, log_entry_t::nsect, pv2_log_entry_t::sectors, log_entry_t::t0_ms, pv2_log_entry_t::t0_ms, and log_entry_t::truncated.
Referenced by cmd_list().
|
static |
Definition at line 195 of file log_task.c.
References close_log(), log_count(), log_entry(), and n.
Referenced by cmd(), and cmd_list().
|
static |
Definition at line 202 of file log_task.c.
References ack(), entry_of(), last_log(), log_count(), log_entry(), n, port, PORT_BLE, port_send(), pump(), PV2_ACK_OK, PV2_FT_LOG_ENTRY, PV2_OP_LOG_LIST, PV2_R_NONE, seq, and usbl_send().
Referenced by cmd().
|
static |
Definition at line 222 of file log_task.c.
References ack(), append_time(), close_log(), cmd_list(), log_task_cfg_t::erase_chip, log_task_cfg_t::flash, id, log_entry_t::id, last_log(), log_count(), log_erase_all(), log_mount(), log_size(), ms, n, off, port, PORT_BLE, PV2_ACK_BUSY, PV2_ACK_IN_PROGRESS, PV2_ACK_INVALID, PV2_ACK_OK, PV2_ACK_REJECTED, PV2_ACK_UNSUPPORTED, PV2_OP_HEARTBEAT, PV2_OP_LOG_ERASE, PV2_OP_LOG_LIST, PV2_OP_LOG_READ, PV2_OP_SET_TIME, PV2_R_ARMED, PV2_R_NONE, PV2_R_OUT_OF_RANGE, PV2_R_SENSOR_MISSING, s_cfg, s_clk, s_mounted, s_rd, and seq.
Referenced by a24(), itf_control(), log_task_step(), and usbl_poll().
|
static |
Definition at line 289 of file log_task.c.
References ack(), pv2_log_data_hdr_t::id, log_read(), port, port_room(), port_room_ack(), port_send(), PORT_USB, pump(), PV2_ACK_OK, PV2_ACK_REJECTED, PV2_FT_LOG_DATA, PV2_LOG_DATA_MAX, PV2_OP_LOG_READ, PV2_R_ARMED, PV2_R_NONE, and s_rd.
Referenced by log_task_step().
|
static |
Definition at line 322 of file log_task.c.
References PV2_OP_LOG_ERASE, PV2_OP_LOG_LIST, and PV2_OP_LOG_READ.
Referenced by log_task_step(), and pauses().
|
static |
Definition at line 323 of file log_task.c.
References is_log_op().
Referenced by log_task_step().
|
static |
Definition at line 326 of file log_task.c.
References ack(), APPL_CMD_MAX, appl_cmd_t::b, appl_cmd_t::len, n, PORT_USB, PV2_ACK_BUSY, PV2_R_NONE, and spsc_push().
Referenced by log_task_step().
| void log_task_step | ( | uint32_t | now | ) |
Definition at line 334 of file log_task.c.
References fc_state_t::armed, b, cmd(), fc_snapshot(), is_log_op(), log_cmd_t::len, log_q_get(), log_q_take_drops(), LOG_REC_MAX, LOG_SRC_COUNT, log_used_pct(), n, log_cmd_t::op, log_cmd_t::p, pauses(), PORT_BLE, PORT_USB, pump(), PV2_OP_HEARTBEAT, PV2_OP_SET_TIME, read_stream(), recording(), s_cmd_ms, s_have_cmd, s_mounted, s_pct, log_cmd_t::seq, spsc_pop(), to_app(), USBL_CMD_MAX, and usbl_poll().
Referenced by LogTask().
|
static |
Definition at line 376 of file log_task.c.
References log_task_busy(), log_task_step(), and usbl_open().
Referenced by log_task_start().
| void log_task_start | ( | const log_task_cfg_t * | cfg | ) |
Definition at line 385 of file log_task.c.
References log_task_init(), and LogTask().
Referenced by app_start().
|
static |
Definition at line 24 of file log_task.c.
Referenced by cmd(), log_task_init(), open_log(), and pump().
|
static |
Definition at line 25 of file log_task.c.
Referenced by cmd(), log_task_init(), and log_task_step().
|
static |
Definition at line 26 of file log_task.c.
Referenced by log_task_init(), log_task_pct(), and log_task_step().
|
static |
Definition at line 27 of file log_task.c.
Referenced by log_task_init(), and recording().
|
static |
Definition at line 28 of file log_task.c.
Referenced by log_task_init(), and recording().
|
static |
Definition at line 28 of file log_task.c.
Referenced by log_task_step(), and recording().
|
static |
Definition at line 29 of file log_task.c.
Referenced by log_task_init(), log_task_step(), and recording().
|
static |
Definition at line 34 of file log_task.c.
Referenced by drain(), and open_log().
|
static |
Definition at line 35 of file log_task.c.
Referenced by drain(), log_task_init(), and open_log().
| uint8_t set |
Definition at line 39 of file log_task.c.
Referenced by apply(), cal_apply(), and fsh_apply_post().
| uint32_t up_ms |
Definition at line 40 of file log_task.c.
| uint32_t unix_s |
Definition at line 41 of file log_task.c.
Referenced by log_task_wallclock().
| uint16_t ms |
Definition at line 42 of file log_task.c.
Referenced by cmd(), dly(), dly(), dly(), dly(), exec(), log_task_wallclock(), on_state(), sh_run_once(), and USBD_LL_Delay().
| int16_t tz_min |
Definition at line 43 of file log_task.c.
| struct { ... } s_clk |
Referenced by append_time(), cmd(), log_task_init(), and log_task_wallclock().
| uint8_t on |
Definition at line 48 of file log_task.c.
Referenced by log_q_set_active(), set_used(), usbl_set_configured(), and usbl_set_dtr().
| uint8_t seq |
Definition at line 48 of file log_task.c.
Referenced by ack(), ack(), ack_link(), ackc_begin(), ackc_finish(), cfg_save(), cmd(), cmd_list(), commands(), find(), latest_page(), local_cmd(), pv2_ack(), tlm_ble_want_state(), tx_frame(), and usb_commands().
| uint8_t port |
Definition at line 48 of file log_task.c.
Referenced by ack(), analog_pin(), cmd(), cmd_list(), port_room(), port_room_ack(), port_send(), and read_stream().
| uint16_t id |
Definition at line 49 of file log_task.c.
Referenced by cmd(), mat3_inv(), put(), and pv2_param().
| uint32_t off |
Definition at line 50 of file log_task.c.
Referenced by accel_fit(), cfg_flash_write(), cmd(), and log_read().
| uint32_t end |
Definition at line 50 of file log_task.c.
| struct { ... } s_rd |
Referenced by cmd(), log_task_busy(), log_task_init(), and read_stream().