rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_limrun_int.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "servo_limrun.h"
14
15#include <stdbool.h>
16#include <stddef.h>
17#include <stdint.h>
18#include <string.h>
19
28
37static inline int32_t limrun_span(const servo_limrun_servo_t *sv,
38 uint8_t side)
39{
40 const int32_t n = (int32_t)sv->pulse_dus[SERVO_LIMRUN_P_NEUTRAL];
41 return side == SERVO_LIMRUN_HI
42 ? (int32_t)sv->pulse_dus[SERVO_LIMRUN_P_UPPER] - n
43 : n - (int32_t)sv->pulse_dus[SERVO_LIMRUN_P_LOWER];
44}
45
53static inline bool limrun_restore(const servo_limrun_t *r)
54{
55 return r != NULL && r->state == SERVO_LIMRUN_DONE && r->programmed
56 && (r->verdict == SERVO_LIMRUN_FAIL
57 || r->verdict == SERVO_LIMRUN_ABORTED);
58}
59
68static inline int32_t span_now(const servo_limrun_t *r, uint8_t side)
69{
71 memset(&sv, 0, sizeof(sv));
72 memcpy(sv.pulse_dus, r->pulse_now, sizeof(sv.pulse_dus));
73 return limrun_span(&sv, side);
74}
The limit run: the limit search (servo_limit.h) run on the SERVO screen against the INA3221's windows...
static int32_t limrun_span(const servo_limrun_servo_t *sv, uint8_t side)
Distance from NEUTRAL to a side pulse limit, 0.1us, from the pulses given. servo_limrun_span() wraps ...
Definition servo_limrun_int.h:37
limrun_stage_t
Where a side stands.
Definition servo_limrun_int.h:21
@ ST_DONE
Definition servo_limrun_int.h:26
@ ST_OVERSET
Definition servo_limrun_int.h:23
@ ST_FINAL
Definition servo_limrun_int.h:25
@ ST_NONE
Definition servo_limrun_int.h:22
@ ST_OVERSET_SEARCH
Definition servo_limrun_int.h:24
static int32_t span_now(const servo_limrun_t *r, uint8_t side)
The span from the pulses in force: after SERVO PULSES at 1000-2000 those written, not those read.
Definition servo_limrun_int.h:68
static bool limrun_restore(const servo_limrun_t *r)
Whether RESTORE is offered: the run is DONE and programmed, and ended as FAIL or ABORTED....
Definition servo_limrun_int.h:53
The servo the programmer read.
Definition servo_limrun.h:247
uint16_t pulse_dus[3]
NEUTRAL, PULSE LOWER and PULSE UPPER, 0.1us.
Definition servo_limrun.h:255
Definition servo_limrun.h:364
bool programmed
Definition servo_limrun.h:418
uint16_t pulse_now[3]
Definition servo_limrun.h:395