rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
heartbeat.h
Go to the documentation of this file.
1
32
33
#pragma once
34
35
#include <stdbool.h>
36
#include <stdint.h>
37
46
#define HEARTBEAT_PERIOD_MS 20u
47
57
#define HEARTBEAT_MIN_GAP_MS 4u
58
#define HEARTBEAT_MAX_GAP_MS 150u
59
67
#define HEARTBEAT_GOOD_RUN 4u
68
79
#define HEARTBEAT_SETTLE_MS \
80
(HEARTBEAT_GOOD_RUN * HEARTBEAT_PERIOD_MS + HEARTBEAT_PERIOD_MS)
81
82
/* ------------------------------------------------------- the panel's end */
83
84
typedef
struct
{
85
uint32_t
last_ms
;
86
bool
level
;
87
bool
started
;
88
}
heartbeat_gen_t
;
89
96
void
heartbeat_gen_init
(
heartbeat_gen_t
*g);
97
114
bool
heartbeat_gen_step
(
heartbeat_gen_t
*g, uint32_t now_ms,
bool
alive);
115
116
/* ------------------------------------------------ the IOmcu's end */
117
118
typedef
struct
{
119
uint32_t last_edge_ms;
120
uint32_t
good_run
;
121
bool
have_edge
;
122
bool
alive;
123
/* Kept for the status page: a line that is rejected is worth being able
124
* to ask about, and "how" narrows a fault far faster than "not alive". */
125
uint32_t
rejected_fast
;
126
uint32_t
rejected_slow
;
127
}
heartbeat_mon_t
;
128
134
void
heartbeat_mon_init
(
heartbeat_mon_t
*m);
135
146
void
heartbeat_mon_edge
(
heartbeat_mon_t
*m, uint32_t now_ms);
147
159
bool
heartbeat_mon_alive
(
heartbeat_mon_t
*m, uint32_t now_ms);
heartbeat_mon_edge
void heartbeat_mon_edge(heartbeat_mon_t *m, uint32_t now_ms)
Record an edge on the safety line.
Definition
heartbeat.c:74
heartbeat_mon_alive
bool heartbeat_mon_alive(heartbeat_mon_t *m, uint32_t now_ms)
Whether the line may be believed now.
Definition
heartbeat.c:121
heartbeat_mon_init
void heartbeat_mon_init(heartbeat_mon_t *m)
Start not alive, with no edge seen.
Definition
heartbeat.c:67
heartbeat_gen_init
void heartbeat_gen_init(heartbeat_gen_t *g)
Start held low: nothing downstream may run until this loop asks for it.
Definition
heartbeat.c:25
heartbeat_gen_step
bool heartbeat_gen_step(heartbeat_gen_t *g, uint32_t now_ms, bool alive)
Advance the generator; returns the level the pin should be driven to.
Definition
heartbeat.c:32
heartbeat_gen_t
Definition
heartbeat.h:84
heartbeat_gen_t::level
bool level
Definition
heartbeat.h:86
heartbeat_gen_t::started
bool started
Definition
heartbeat.h:87
heartbeat_gen_t::last_ms
uint32_t last_ms
Definition
heartbeat.h:85
heartbeat_mon_t
Definition
heartbeat.h:118
heartbeat_mon_t::rejected_slow
uint32_t rejected_slow
Definition
heartbeat.h:126
heartbeat_mon_t::rejected_fast
uint32_t rejected_fast
Definition
heartbeat.h:125
heartbeat_mon_t::have_edge
bool have_edge
Definition
heartbeat.h:121
heartbeat_mon_t::good_run
uint32_t good_run
Definition
heartbeat.h:120
shared
safety
include
heartbeat.h
Generated by
1.18.0