![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
Receive side of the ACwing Pilot link (HANDOVER_FW.md §2 and §6). More...
#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | appl_cmd_t |
| struct | appl_rc_t |
Macros | |
| #define | APPL_CMD_MAX 20u |
| #define | APPL_QUEUE_LEN 16u |
| power of 2, >= 8 required by the handover | |
Functions | |
| void | appl_reset (void) |
| void | appl_on_cmd_write (const uint8_t *data, uint16_t len, uint32_t now_ms) |
| void | appl_on_connect (void) |
| void | appl_on_disconnect (void) |
| int | appl_pop (appl_cmd_t *out) |
| 1 if a command was taken | |
| uint32_t | appl_queue_dropped (void) |
| uint8_t | appl_ever (void) |
| 1 once any CMD frame arrived | |
| uint32_t | appl_last_ms (void) |
| time of the last CMD frame | |
| uint8_t | appl_link_down (void) |
| GAP disconnected since then | |
| uint32_t | appl_silence_ms (uint32_t now_ms, uint32_t down_floor_ms) |
| Silence seen by the failsafe: now - last CMD frame, at least 'down_floor_ms' while the link is reported down; UINT32_MAX if nothing ever arrived. | |
| int | appl_rc_read (appl_rc_t *out, uint32_t *t_ms) |
| Latest RC values and their arrival time. | |
Receive side of the ACwing Pilot link (HANDOVER_FW.md §2 and §6).
The BLE CMD write callback (HCI user-event thread of the stack) calls appl_on_cmd_write() and NOTHING else happens in that context:
Only CMD frames refresh the app-link time: connection events, CCCD writes, notifications sent or link-layer keep-alives do not (they never call this). A GAP disconnection only marks the link down, which can make the failsafe start earlier, never later (appl_silence_ms()).
Host-testable: no HAL, no RTOS.
Definition in file app_link.h.
| #define APPL_CMD_MAX 20u |
Definition at line 29 of file app_link.h.
| #define APPL_QUEUE_LEN 16u |
power of 2, >= 8 required by the handover
Definition at line 30 of file app_link.h.
| void appl_reset | ( | void | ) |
| void appl_on_cmd_write | ( | const uint8_t * | data, |
| uint16_t | len, | ||
| uint32_t | now_ms | ||
| ) |
Definition at line 41 of file app_link.c.
References APPL_BARRIER, APPL_CMD_MAX, APPL_QUEUE_LEN, appl_cmd_t::b, appl_rc_t::buttons, appl_cmd_t::len, appl_rc_t::pitch, PV2_OP_HEARTBEAT, PV2_OP_RC, pv2_rd_i16(), QMASK, appl_rc_t::roll, s_down, s_ever, s_head, s_last_ms, s_q, s_qdrop, s_rc, s_rc_ever, s_rc_ms, s_rc_seq, s_tail, appl_rc_t::thr, and appl_rc_t::yaw.
| void appl_on_connect | ( | void | ) |
Definition at line 81 of file app_link.c.
| void appl_on_disconnect | ( | void | ) |
Definition at line 82 of file app_link.c.
References s_down.
| int appl_pop | ( | appl_cmd_t * | out | ) |
1 if a command was taken
Definition at line 85 of file app_link.c.
References APPL_BARRIER, QMASK, s_head, s_q, and s_tail.
Referenced by commands().
| uint32_t appl_queue_dropped | ( | void | ) |
Definition at line 96 of file app_link.c.
References s_qdrop.
| uint8_t appl_ever | ( | void | ) |
| uint32_t appl_last_ms | ( | void | ) |
| uint8_t appl_link_down | ( | void | ) |
| uint32_t appl_silence_ms | ( | uint32_t | now_ms, |
| uint32_t | down_floor_ms | ||
| ) |
Silence seen by the failsafe: now - last CMD frame, at least 'down_floor_ms' while the link is reported down; UINT32_MAX if nothing ever arrived.
Definition at line 103 of file app_link.c.
References s, s_down, s_ever, and s_last_ms.
Referenced by app_link_failsafe(), and calibration().
| int appl_rc_read | ( | appl_rc_t * | out, |
| uint32_t * | t_ms | ||
| ) |
Latest RC values and their arrival time.
Returns 1 with a consistent copy, 0 if no RC ever arrived (out untouched).
Definition at line 112 of file app_link.c.
References APPL_BARRIER, s_rc, s_rc_ever, s_rc_ms, and s_rc_seq.
Referenced by build_checks(), and update_sticks().