rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
kst_port.h
Go to the documentation of this file.
1
169#ifndef RCBENCH_KST_PORT_H
170#define RCBENCH_KST_PORT_H
171
172#include <stdbool.h>
173#include <stdint.h>
174
175#include "kst_session.h"
176#include "link_pages.h"
177#include "outputs.h"
178#include "supply_page.h"
179
180#ifdef __cplusplus
181extern "C" {
182#endif
183
186#define KST_PORT_STOP_MS 50u
188#define KST_PORT_LOW_MS 100u
194#define KST_PORT_RAIL_OFF_MS 2000u
198#define KST_PORT_RAIL_WAIT_MS 1000u
200#define KST_PORT_SUPPLY_MS 3000u
206#define KST_PORT_SUPPLY_MAX_MV 8400u
213#define KST_PORT_SUPPLY_MIN_MV 4800u
214
216typedef struct {
219 void *ctx;
221 uint8_t ports;
224 uint8_t (*pin)(void *ctx, uint8_t port);
228 bool (*take)(void *ctx, uint8_t port, uint8_t pin);
233 void (*give)(void *ctx);
238 void (*supply)(void *ctx, supply_port_view_t *out);
241 bool (*supply_set)(void *ctx, bool on, uint16_t mv, uint16_t ma);
248
253typedef struct {
254 kst_port_hw_t hw;
255 kst_session_t session;
260 uint32_t t0_ms;
261 uint32_t t1_ms;
262 uint16_t seq;
263 uint16_t frames;
264 uint16_t supply_mv;
265 uint16_t supply_ma;
266 uint16_t want_mv;
267 uint16_t want_ma;
268 uint16_t back_mv;
269 uint16_t back_ma;
270 uint16_t leave_ms;
271 uint16_t wait_ms;
272 uint8_t state;
273 uint8_t port;
274 uint8_t pin;
275 uint8_t op;
276 uint8_t result;
278 uint8_t refusal;
279 uint8_t fail_reg;
280 uint8_t steps_done;
281 uint8_t seen_step;
282 uint8_t busy;
283 uint8_t running;
284 uint8_t leaving;
285 uint8_t framed;
286 uint8_t must_read;
287 uint8_t view;
288 uint8_t safe;
289 uint8_t armed;
290 uint8_t other;
291 uint8_t has_pin;
292 uint8_t sup;
293 uint8_t on_here;
294 uint8_t watch;
296 uint8_t again;
297 uint8_t from_pwm;
298} kst_port_t;
299
310bool kst_port_init(kst_port_t *p, const kst_port_hw_t *hw);
311
328uint8_t kst_port_write(kst_port_t *p, uint8_t off, uint8_t n,
329 const uint16_t *in, uint32_t now_ms);
330
340void kst_port_read(const kst_port_t *p, uint8_t off, uint8_t n,
341 uint16_t *out);
342
358void kst_port_step(kst_port_t *p, bool safe, bool stop, uint32_t now_ms);
359
367
376uint8_t kst_port_quiet_mask(const kst_port_t *p);
377
387bool kst_port_frame_out(const kst_port_t *p);
388
398void kst_port_bench_armed(kst_port_t *p, bool armed);
399
409void kst_port_other_mask(kst_port_t *p, uint8_t mask);
410
421uint8_t kst_port_pin_mask(const kst_port_t *p);
422
423#ifdef __cplusplus
424}
425#endif
426
427#endif /* RCBENCH_KST_PORT_H */
uint8_t kst_port_quiet_mask(const kst_port_t *p)
Bit n: programming port n renders no PWM pulse.
Definition kst_port.c:1274
bool kst_port_frame_out(const kst_port_t *p)
An operation of the session runs: a frame may be on the wire.
Definition kst_port.c:1280
void kst_port_step(kst_port_t *p, bool safe, bool stop, uint32_t now_ms)
One pass.
Definition kst_port.c:1206
void kst_port_other_mask(kst_port_t *p, uint8_t mask)
Bit n: the HITEC page holds programming port n (hitec_port_quiet_mask()).
Definition kst_port.c:1292
uint8_t kst_port_pin_mask(const kst_port_t *p)
Bit n: programming port n's pin is the wire driver's, not the PWM generator's.
Definition kst_port.c:1299
void kst_port_bench_armed(kst_port_t *p, bool armed)
Whether the bank is armed.
Definition kst_port.c:1285
link_kst_state_t kst_port_state(const kst_port_t *p)
Where the port is.
Definition kst_port.c:1269
bool kst_port_init(kst_port_t *p, const kst_port_hw_t *hw)
Prepare a port in LINK_KST_PWM.
Definition kst_port.c:1249
void kst_port_read(const kst_port_t *p, uint8_t off, uint8_t n, uint16_t *out)
A read of the page, LINK_KS_*.
Definition kst_port.c:878
uint8_t kst_port_write(kst_port_t *p, uint8_t off, uint8_t n, const uint16_t *in, uint32_t now_ms)
A write of the page: 0, or the LINK_NACK_* reason with nothing changed.
Definition kst_port.c:789
KST servo programming protocol: the session with one servo.
The intermediary every output goes through: one set of rules for arming, clamping,...
The driver: the only way to the wire.
Definition kst_session.h:106
The 32 registers, by address.
Definition kst_reg.h:47
What the port needs from the hardware.
Definition kst_port.h:216
void * ctx
The caller's context, passed as the first argument of each hook.
Definition kst_port.h:219
void(*) give(void *ctx)
Close the wire driver and give the pin back to the generator.
Definition kst_port.h:233
kst_driver_t driver
The wire driver.
Definition kst_port.h:246
bool(*) take(void *ctx, uint8_t port, uint8_t pin)
Definition kst_port.h:228
uint8_t ports
Programming ports the build has, 1 to LINK_PG_PORTS_MAX.
Definition kst_port.h:221
bool(*) supply_set(void *ctx, bool on, uint16_t mv, uint16_t ma)
Definition kst_port.h:241
void(*) supply(void *ctx, supply_port_view_t *out)
What the supply says now (supply_page_port_view()).
Definition kst_port.h:238
uint8_t(*) pin(void *ctx, uint8_t port)
Definition kst_port.h:224
The state of one KST port: the hardware, the session, the staged registers and the running or last op...
Definition kst_port.h:253
uint32_t t1_ms
Definition kst_port.h:261
uint8_t on_here
Definition kst_port.h:293
uint16_t seq
Definition kst_port.h:262
uint8_t again
Definition kst_port.h:296
uint8_t sup
Definition kst_port.h:292
uint8_t watch
Definition kst_port.h:294
uint8_t other
Definition kst_port.h:290
uint16_t frames
Definition kst_port.h:263
uint8_t running
Definition kst_port.h:283
uint16_t supply_ma
Definition kst_port.h:265
uint16_t want_ma
Definition kst_port.h:267
uint8_t result
Definition kst_port.h:276
uint8_t view
Definition kst_port.h:287
uint16_t wait_ms
Definition kst_port.h:271
uint8_t from_pwm
Definition kst_port.h:297
uint8_t armed
Definition kst_port.h:289
uint8_t port
Definition kst_port.h:273
uint8_t safe
Definition kst_port.h:288
kst_image_t work
Definition kst_port.h:256
uint8_t op
Definition kst_port.h:275
uint8_t leaving
Definition kst_port.h:284
uint32_t t0_ms
Definition kst_port.h:260
uint8_t framed
Definition kst_port.h:285
uint8_t seen_step
Definition kst_port.h:281
uint16_t back_mv
Definition kst_port.h:268
uint8_t state
Definition kst_port.h:272
uint16_t staged[LINK_KS_W_STAGED]
Definition kst_port.h:258
uint8_t steps_done
Definition kst_port.h:280
uint16_t last_cmd[LINK_KS_W_CMD_FRAME]
Definition kst_port.h:259
uint8_t fail_reg
Definition kst_port.h:279
uint16_t supply_mv
Definition kst_port.h:264
uint16_t want_mv
Definition kst_port.h:266
uint8_t has_pin
Definition kst_port.h:291
uint8_t busy
Definition kst_port.h:282
uint8_t refusal
Definition kst_port.h:278
uint16_t back_ma
Definition kst_port.h:269
uint16_t leave_ms
Definition kst_port.h:270
uint8_t pin
Definition kst_port.h:274
uint8_t must_read
Definition kst_port.h:286
The session with one servo: results and state of its operation.
Definition kst_session.h:175
The supply as a programming port sees it (kst_port.h).
Definition supply_page.h:85
The SUPPLY link page at the IOmcu: a PD mini on a PIO UART, its wiring, what it is to do and what it ...