馃 meltybrain avocado
951 B
28 lines
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6/*
7 * RC signal health monitor. Belt-and-suspenders safety layer on top of
8 * the receiver's own failsafe. Computes a checksum of all channel values;
9 * if the checksum hasn't changed for longer than the timeout, the link
10 * is considered stale even if the receiver reports "alive."
11 *
12 * Call rc_health_update() every time new CRSF data arrives. Check
13 * rc_health_ok() before trusting stick inputs.
14 */
15
16/* Timeout in ms. If no channel change is detected for this long, the
17 * link is considered stale. PotatoMelt uses 3000ms. */
18#define RC_STALE_TIMEOUT_MS 3000
19
20/* Initialize the health monitor. */
21void rc_health_init(void);
22
23/* Call with the current CRSF channel array whenever a frame arrives. */
24void rc_health_update(const uint16_t channels[16]);
25
26/* Returns true if the RC link appears healthy (channels changing or
27 * recently changed within the timeout). */
28bool rc_health_ok(void);