rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_source.h
Go to the documentation of this file.
1
49#pragma once
50
51#include <stdbool.h>
52#include <stdint.h>
53
54#include "sense_link.h"
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
61#define SERVO_SOURCE_FRESH_MS 200u
63#define SERVO_SOURCE_SETTLE_MS 1000u
67#define SERVO_SOURCE_EVENT_GAP_MS 5000u
68
70typedef enum {
71 SERVO_SOURCE_PDMINI = 0,
72 SERVO_SOURCE_INA3221 = 1,
75
89
91enum {
99};
100
104typedef struct {
107 uint32_t changes;
110 uint32_t dropped_at;
111 bool up;
112 bool good;
113 uint32_t good_ms;
116 uint8_t resets;
117 uint16_t setups;
118 bool old_told;
119 uint32_t events;
121 uint32_t event_ms;
123
130
146 bool link_up, uint16_t minor,
147 const sense_link_meter_t *m);
148
156
167uint32_t servo_source_changes(const servo_source_t *s);
168
176
192 uint32_t *at);
193
203uint32_t servo_source_event(servo_source_t *s, uint32_t now_ms);
204
214void servo_source_event_back(servo_source_t *s, uint32_t ev);
215
216#ifdef __cplusplus
217}
218#endif
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
servo_source_id_t servo_source_id(const servo_source_t *s)
The meter as of the last step.
Definition servo_source.c:176
uint32_t servo_source_event(servo_source_t *s, uint32_t now_ms)
One event for the alert band, the older IOmcu before the reset, cleared; 0 while none waits or while ...
Definition servo_source.c:186
uint32_t servo_source_changes(const servo_source_t *s)
How many times the meter has changed since servo_source_init(), modulo 2^32.
Definition servo_source.c:171
servo_source_why_t servo_source_dropped(const servo_source_t *s, uint32_t *at)
Why the INA3221 last stopped being the meter: SERVO_SOURCE_WHY_RESET when its reset count moved in th...
Definition servo_source.c:160
@ SERVO_SOURCE_EV_OLD
The INA3221 is on with CH1 and the IOmcu is older than 4.11: the PD mini is the meter.
Definition servo_source.h:96
@ SERVO_SOURCE_EV_RESET
The INA3221 reset itself: its reset count moved.
Definition servo_source.h:98
servo_source_id_t
The servo rail's meter.
Definition servo_source.h:70
@ SERVO_SOURCE_MODEL
Definition servo_source.h:73
void servo_source_event_back(servo_source_t *s, uint32_t ev)
Put back an event servo_source_event() handed out that never reached the band, so it is handed out ag...
Definition servo_source.c:208
void servo_source_init(servo_source_t *s)
The meter is the model until a step says otherwise.
Definition servo_source.c:15
servo_source_why_t servo_source_why(const servo_source_t *s)
Why the INA3221 is not the meter, as of the last step.
Definition servo_source.c:181
servo_source_why_t
Why the INA3221 is not the meter: the first condition that fails.
Definition servo_source.h:77
@ SERVO_SOURCE_WHY_NO_LINK
Definition servo_source.h:79
@ SERVO_SOURCE_WHY_OFF
Definition servo_source.h:80
@ SERVO_SOURCE_WHY_RESET
Definition servo_source.h:86
@ SERVO_SOURCE_WHY_SETTLING
Definition servo_source.h:87
@ SERVO_SOURCE_WHY_NOT_HELD
Definition servo_source.h:82
@ SERVO_SOURCE_WHY_SILENT
Definition servo_source.h:83
@ SERVO_SOURCE_WHY_OLD
Definition servo_source.h:81
@ SERVO_SOURCE_WHY_NO_WINDOW
Definition servo_source.h:85
@ SERVO_SOURCE_WHY_NONE
Definition servo_source.h:78
servo_source_id_t servo_source_step(servo_source_t *s, uint32_t now_ms, bool link_up, uint16_t minor, const sense_link_meter_t *m)
One poll: the conditions judged at now_ms from link_up, the IOmcu's protocol minor minor and m,...
Definition servo_source.c:142
The state of which meter measures the servo rail.
Definition servo_source.h:104
servo_source_why_t dropped
Definition servo_source.h:108
uint32_t good_ms
Definition servo_source.h:113
uint32_t changes
Definition servo_source.h:107
uint16_t setups
Definition servo_source.h:117
bool event_given
Definition servo_source.h:120
uint32_t dropped_at
Definition servo_source.h:110
bool good
Definition servo_source.h:112
bool old_told
Definition servo_source.h:118
uint32_t events
Definition servo_source.h:119
uint8_t resets
Definition servo_source.h:116
bool up
Definition servo_source.h:111
bool resets_known
Definition servo_source.h:114
bool reset_step
Definition servo_source.h:115
uint32_t event_ms
Definition servo_source.h:121