![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
BattTask: owns the battery ADC and the battery monitor (battery.c). More...
Go to the source code of this file.
Data Structures | |
| struct | batt_task_cfg_t |
| struct | batt_flight_t |
| last flight summary (AppTask persists it for the BATTERY calibration) More... | |
Macros | |
| #define | BATT_TASK_PERIOD_MS 20u |
Functions | |
| void | batt_task_init (const batt_task_cfg_t *cfg) |
| void | batt_task_step (uint32_t now_ms) |
| int | batt_task_post_scales (float scale_v, float scale_i) |
| AppTask -> BattTask: new calibration scales; 0 = queued. | |
| void | batt_task_last_flight (batt_flight_t *out) |
| last flight (any task, seqlock) | |
| void | batt_task_start (const batt_task_cfg_t *cfg) |
BattTask: owns the battery ADC and the battery monitor (battery.c).
A task of its own, so the battery logic stays out of the flight loop:
The flight core keeps the decisions (land, RTH, events), because it owns the flight state. batt_task_step() is plain C and runs on the host; the RTOS loop is at the end of batt_task.c.
Definition in file batt_task.h.
| #define BATT_TASK_PERIOD_MS 20u |
Definition at line 26 of file batt_task.h.
| void batt_task_init | ( | const batt_task_cfg_t * | cfg | ) |
Definition at line 27 of file batt_task.c.
References batt_task_cfg_t::batt, batt_init(), s_cfg, s_fl, s_fl_seq, s_have_last, s_sig_level, s_sig_present, s_used_at_arm, s_was_armed, and spsc_reset().
Referenced by batt_task_start().
| void batt_task_step | ( | uint32_t | now_ms | ) |
Definition at line 58 of file batt_task.c.
References batt_task_cfg_t::adc_read, fc_state_t::armed, b, batt_get_cfg(), batt_set_scales(), batt_state(), batt_step(), BATT_TASK_PERIOD_MS, batt_flight_t::count, fc_batt_heartbeat(), fc_batt_signal(), fc_snapshot(), L, logf_power(), P_BATT_CAPACITY, P_BATT_CELLS, P_BATT_CRIT, P_BATT_EMERG, P_BATT_WARN, PARAM, fc_batt_sig_t::present, s_cfg, s_fl, s_fl_seq, s_have_last, s_last, s_log_div, s_sig_level, s_sig_present, s_used_at_arm, s_was_armed, scales_t::scale_i, batt_flight_t::scale_i, batt_cfg_t::scale_i, scales_t::scale_v, SPSC_BARRIER, spsc_pop(), and batt_flight_t::used_mah.
Referenced by BattTask().
| int batt_task_post_scales | ( | float | scale_v, |
| float | scale_i | ||
| ) |
AppTask -> BattTask: new calibration scales; 0 = queued.
Definition at line 40 of file batt_task.c.
References s, and spsc_push().
Referenced by cal_apply().
| void batt_task_last_flight | ( | batt_flight_t * | out | ) |
last flight (any task, seqlock)
Definition at line 46 of file batt_task.c.
References s_fl, s_fl_seq, and SPSC_BARRIER.
Referenced by battery_flight().
| void batt_task_start | ( | const batt_task_cfg_t * | cfg | ) |
Definition at line 124 of file batt_task.c.
References batt_task_init(), and BattTask().
Referenced by app_start().