rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
outputs_pages.h
Go to the documentation of this file.
1
22
23#pragma once
24
25#include <stdint.h>
26
27#include "outputs.h"
28
41
50uint8_t outputs_arm_roles_of(uint16_t arm);
51
62uint16_t outputs_arm_value_of(uint8_t roles);
63
76uint16_t outputs_arm_value_for(uint16_t far_minor, uint8_t roles);
77
78/* --- SERVO: with the standard target, the frame rate of every PWM output
79 * rendering a surface; the page itself is servo_page.h */
80
93uint8_t outputs_servo_rate_check(const outputs_t *o, uint16_t hz);
94
108void outputs_slot_rates(const outputs_t *o, uint16_t servo_hz,
109 uint16_t *rate);
110
130 const uint16_t *chan_cfg,
131 uint16_t servo_hz);
132
144uint8_t outputs_slots_rate_check(const outputs_t *o, const uint16_t *slots,
145 uint16_t servo_hz);
146
168uint8_t outputs_pulse_check(const outputs_t *o, uint16_t servo_hz,
169 uint16_t channels, uint16_t channels_hz);
170
189 const uint16_t *chan_cfg,
190 const uint16_t *slots,
191 uint16_t servo_hz);
192
205uint8_t outputs_slots_pulse_check(const outputs_t *o, const uint16_t *slots,
206 uint16_t servo_hz);
207
223unsigned outputs_slots_free_long(const outputs_t *o, uint16_t *slots);
224
234uint8_t outputs_slots_changed(const uint16_t *prev, const uint16_t *next);
235
251uint8_t outputs_bind_check(const outputs_t *o, uint8_t watch,
252 uint8_t bound_after);
253
279uint8_t outputs_chan_cfg_armed_check(const uint16_t *regs,
280 const uint16_t *next, bool armed);
281
291uint8_t outputs_slots_armed_check(const uint16_t *regs, const uint16_t *next,
292 bool armed);
293
294/* --- CHAN_CFG: what each channel is -- role, slew, and its pulse endpoints */
295
305void outputs_chan_cfg_defaults(uint16_t *regs);
306
321uint8_t outputs_chan_cfg_write(uint16_t *regs, uint8_t off, uint8_t n,
322 const uint16_t *in);
323
334void outputs_chan_cfg_apply(outputs_t *o, const uint16_t *regs);
335
346void outputs_chan_cfg_restore(uint16_t *regs, const uint16_t *saved);
347
369bool outputs_chan_cfg_set_throttle_range(uint16_t *regs, uint16_t min_us,
370 uint16_t max_us);
371
372/* --- OUTPUTS: which driver renders which channels, on which pin, how often */
373
382void outputs_slots_defaults(uint16_t *regs);
383
400uint8_t outputs_slots_write(uint16_t *regs, uint8_t off, uint8_t n,
401 const uint16_t *in);
402
410void outputs_slots_apply(outputs_t *o, const uint16_t *regs);
411
435uint8_t outputs_role_channels(const uint16_t *slots, const uint16_t *chan_cfg,
436 out_role_t role);
437
452uint64_t outputs_role_pins(const uint16_t *slots, const uint16_t *chan_cfg,
453 out_role_t role);
454
455/* --- CHANNELS: what each output is asked for.
456 *
457 * Clamped, not refused, because a command arrives many times a second from a
458 * host that may be mid-drag. */
459
467void outputs_channels_defaults(uint16_t *regs);
468
481void outputs_channels_from_bank(const outputs_t *o, uint16_t *regs);
482
494uint8_t outputs_channels_write(uint16_t *regs, uint8_t off, uint8_t n,
495 const uint16_t *in);
496
504void outputs_channels_apply(outputs_t *o, const uint16_t *regs,
505 uint32_t now_ms);
The intermediary every output goes through: one set of rules for arming, clamping,...
out_driver_t
The drivers a slot can be configured as.
Definition outputs.h:83
out_role_t
What rest means for a channel, which is the one thing a command cannot say.
Definition outputs.h:70
uint8_t outputs_chan_cfg_armed_check(const uint16_t *regs, const uint16_t *next, bool armed)
Whether a CHAN_CFG or OUTPUTS write is refused because the bench is armed: 0, or LINK_NACK_BAD_VALUE,...
Definition outputs_pages.c:123
uint8_t outputs_slots_armed_check(const uint16_t *regs, const uint16_t *next, bool armed)
The OUTPUTS write counterpart of outputs_chan_cfg_armed_check().
Definition outputs_pages.c:147
uint8_t outputs_chan_cfg_rate_check(const outputs_t *o, const uint16_t *chan_cfg, uint16_t servo_hz)
Whether the bank o, given the CHAN_CFG page chan_cfg or the OUTPUTS page slots, would leave the SERVO...
Definition outputs_pages.c:268
uint8_t outputs_arm_roles_of(uint16_t arm)
The roles a CONTROL ARM value arms, as OUT_ROLE_BIT()s: OUT_ROLES_ALL for LINK_ARM_ALL,...
Definition outputs_pages.c:615
uint16_t outputs_arm_value_for(uint16_t far_minor, uint8_t roles)
The ARM value the panel writes to arm roles, OUT_ROLE_BIT()s, at an IOmcu of protocol minor far_minor...
Definition outputs_pages.c:640
unsigned outputs_slots_free_long(const outputs_t *o, uint16_t *slots)
A stored OUTPUTS page made safe to restore under the channels of o: every PWM slot whose channel's lo...
Definition outputs_pages.c:365
uint8_t outputs_bind_check(const outputs_t *o, uint8_t watch, uint8_t bound_after)
Whether an OUTPUTS write the bank has taken must be refused because the silicon did not bind it: LINK...
Definition outputs_pages.c:398
void outputs_channels_defaults(uint16_t *regs)
Sets the CHANNELS page to zero: every output asked for 0.
Definition outputs_pages.c:495
void outputs_chan_cfg_defaults(uint16_t *regs)
Sets the CHAN_CFG page to its defaults: every channel a surface, slew 0, and the default endpoints.
Definition outputs_pages.c:65
uint16_t outputs_arm_value_of(uint8_t roles)
The CONTROL ARM value that arms roles, OUT_ROLE_BIT()s: a set of LINK_ARM_ROLES, or 0 for no role.
Definition outputs_pages.c:628
void outputs_chan_cfg_restore(uint16_t *regs, const uint16_t *saved)
The CHAN_CFG page saved, kept in flash, into regs at start.
Definition outputs_pages.c:111
uint8_t outputs_pulse_check(const outputs_t *o, uint16_t servo_hz, uint16_t channels, uint16_t channels_hz)
Whether every pulse the bank o can render fits the frame that carries it: 0, or LINK_NACK_BAD_VALUE (...
Definition outputs_pages.c:314
uint8_t outputs_slots_write(uint16_t *regs, uint8_t off, uint8_t n, const uint16_t *in)
Stores a window of the OUTPUTS page, refusing the whole window on an unknown driver or pin.
Definition outputs_pages.c:426
void outputs_channels_apply(outputs_t *o, const uint16_t *regs, uint32_t now_ms)
Commands every channel of the CHANNELS page into the bank.
Definition outputs_pages.c:549
uint8_t outputs_slots_pulse_check(const outputs_t *o, const uint16_t *slots, uint16_t servo_hz)
outputs_pulse_check() of the bank an OUTPUTS write would leave, judged on a copy.
Definition outputs_pages.c:354
void outputs_chan_cfg_apply(outputs_t *o, const uint16_t *regs)
Puts a CHAN_CFG page into the bank: role, slew and endpoints of each channel.
Definition outputs_pages.c:174
uint8_t outputs_channels_write(uint16_t *regs, uint8_t off, uint8_t n, const uint16_t *in)
Stores a window of the CHANNELS page, clamping each command to LINK_CH_SPAN.
Definition outputs_pages.c:515
void outputs_slots_apply(outputs_t *o, const uint16_t *regs)
Puts an OUTPUTS page into the bank: each configured slot is configured in turn, and a refused slot is...
Definition outputs_pages.c:457
uint8_t outputs_servo_rate_check(const outputs_t *o, uint16_t hz)
Whether the SERVO page may take the frame rate hz against the bank o as it is: 0, or LINK_NACK_BAD_VA...
Definition outputs_pages.c:224
uint8_t outputs_role_channels(const uint16_t *slots, const uint16_t *chan_cfg, out_role_t role)
The channels these two pages render and mark with role, as a mask.
Definition outputs_pages.c:578
uint8_t outputs_chan_cfg_write(uint16_t *regs, uint8_t off, uint8_t n, const uint16_t *in)
Stores a window of the CHAN_CFG page, refusing the whole window on a bad value.
Definition outputs_pages.c:79
uint64_t outputs_role_pins(const uint16_t *slots, const uint16_t *chan_cfg, out_role_t role)
The GPIOs of the slots that render a channel marked with role, as a mask: bit n is GPIO n.
Definition outputs_pages.c:555
uint8_t outputs_slots_rate_check(const outputs_t *o, const uint16_t *slots, uint16_t servo_hz)
The same as outputs_chan_cfg_rate_check(), for an OUTPUTS page.
Definition outputs_pages.c:283
void outputs_slots_defaults(uint16_t *regs)
Sets the OUTPUTS page to its defaults: every field zero, so no slot is configured.
Definition outputs_pages.c:416
uint16_t link_driver_of(out_driver_t d)
A bank driver as the wire numbers it.
Definition outputs_pages.c:39
void outputs_channels_from_bank(const outputs_t *o, uint16_t *regs)
The page as a mirror of the bank, for the two moments the bank is the authority and the page is not: ...
Definition outputs_pages.c:505
uint8_t outputs_slots_changed(const uint16_t *prev, const uint16_t *next)
The slots, one bit each, whose four OUTPUTS registers differ between prev and next.
Definition outputs_pages.c:384
uint8_t outputs_chan_cfg_pulse_check(const outputs_t *o, const uint16_t *chan_cfg, const uint16_t *slots, uint16_t servo_hz)
outputs_pulse_check() of the bank a write would leave, judged on a copy: chan_cfg applied,...
Definition outputs_pages.c:338
void outputs_slot_rates(const outputs_t *o, uint16_t servo_hz, uint16_t *rate)
The frame rate each slot of o is bound at, into rate (OUT_MAX_SLOTS entries): the slot's own,...
Definition outputs_pages.c:212
bool outputs_chan_cfg_set_throttle_range(uint16_t *regs, uint16_t min_us, uint16_t max_us)
Give every channel regs marks as a throttle the endpoints min_us and max_us, and leave every other ch...
Definition outputs_pages.c:156
The state of a bank of channels and slots.
Definition outputs.h:143