rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
prog_port.h
Go to the documentation of this file.
1
61#ifndef RCBENCH_PROG_PORT_H
62#define RCBENCH_PROG_PORT_H
63
64#include <stdbool.h>
65#include <stdint.h>
66
67#include "link_pages.h"
68#include "outputs.h"
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
78#define PROG_PORT_CHANNEL0 9u
80#define PROG_PORT_RATE_HZ 50u
86#define PROG_PORT_DEFAULT_PIN 13u
88#define PROG_PORT_NO_PIN 0xFFu
89
92#define PROG_PORT_KEPT 4u
93#define PROG_PORT_KEPT_COUNT (LINK_PG_PORTS_MAX * PROG_PORT_KEPT)
94
99typedef struct {
100 uint16_t regs[LINK_PG_REGS];
101 uint8_t count;
102 uint8_t bound;
103 uint8_t blocked;
105 uint16_t hz;
109
117void prog_port_init(prog_port_t *p, uint8_t count);
118
121#define PROG_PORT_FUNC_UNSTORED 0u
122
130void prog_port_defaults(uint16_t *kept, uint16_t pin0);
131
150void prog_port_restore(prog_port_t *p, const uint16_t *kept, outputs_t *o,
151 uint64_t taken);
152
169void prog_port_restore_fn(prog_port_t *p, const uint16_t *kept,
170 uint16_t func_word, outputs_t *o, uint64_t taken);
171
178uint16_t prog_port_kept_func(const prog_port_t *p);
179
186void prog_port_kept(const prog_port_t *p, uint16_t *kept);
187
235uint8_t prog_port_write(prog_port_t *p, uint8_t off, uint8_t n,
236 const uint16_t *in, outputs_t *o, uint64_t taken,
237 bool locked, uint32_t now_ms);
238
248void prog_port_read(const prog_port_t *p, uint8_t off, uint8_t n,
249 uint16_t *out);
250
261void prog_port_revert(prog_port_t *p, const prog_port_t *was, outputs_t *o);
262
274void prog_port_bound(prog_port_t *p, uint8_t mask);
275
282uint8_t prog_port_count(const prog_port_t *p);
283
292uint8_t prog_port_func(const prog_port_t *p, uint8_t port);
293
301uint8_t prog_port_pwm_ports(const prog_port_t *p);
302
310uint8_t prog_port_parked(const prog_port_t *p);
311
320uint8_t prog_port_dshot(const prog_port_t *p);
321
330uint16_t prog_port_kbit(const prog_port_t *p, uint8_t port);
331
340uint8_t prog_port_pin(const prog_port_t *p, uint8_t port);
341
353uint8_t prog_port_wire_pin(const prog_port_t *p, uint8_t port, uint8_t bound);
354
361uint64_t prog_port_pins(const prog_port_t *p);
362
369uint8_t prog_port_pwm(const prog_port_t *p);
370
378uint16_t prog_port_pwm_channels(const prog_port_t *p);
379
388uint16_t prog_port_sliced_channels(const prog_port_t *p);
389
398void prog_port_rate(prog_port_t *p, uint16_t hz);
399
407uint16_t prog_port_port_hz(const prog_port_t *p, uint8_t port);
408
416uint8_t prog_port_target(const prog_port_t *p);
417
424uint8_t prog_port_channel(uint8_t port);
425
439uint8_t prog_port_slots_check(const prog_port_t *p, const uint16_t *slots);
440
452unsigned prog_port_slots_free(uint16_t *slots);
453
454#ifdef __cplusplus
455}
456#endif
457
458#endif /* RCBENCH_PROG_PORT_H */
The intermediary every output goes through: one set of rules for arming, clamping,...
void prog_port_defaults(uint16_t *kept, uint16_t pin0)
The kept registers of a board that has stored none: port 0 on pin0 (LINK_PG_PIN_NONE for none),...
Definition prog_port.c:210
uint8_t prog_port_write(prog_port_t *p, uint8_t off, uint8_t n, const uint16_t *in, outputs_t *o, uint64_t taken, bool locked, uint32_t now_ms)
A write of the page: 0, or the LINK_NACK_* reason with nothing changed.
Definition prog_port.c:353
uint16_t prog_port_pwm_channels(const prog_port_t *p)
The bank channels of the ports whose pulse is switched on, bit c for channel c: what servo_page_ports...
Definition prog_port.c:703
void prog_port_restore_fn(prog_port_t *p, const uint16_t *kept, uint16_t func_word, outputs_t *o, uint64_t taken)
As prog_port_restore(), with each port's function from the kept word func_word (prog_port_kept_func()...
Definition prog_port.c:245
void prog_port_kept(const prog_port_t *p, uint16_t *kept)
The kept registers as they stand, PROG_PORT_KEPT_COUNT of them.
Definition prog_port.c:299
void prog_port_read(const prog_port_t *p, uint8_t off, uint8_t n, uint16_t *out)
Read a window of the PROG page's registers into out.
Definition prog_port.c:537
void prog_port_rate(prog_port_t *p, uint16_t hz)
The SERVO page's frame rate, 0 while it names none.
Definition prog_port.c:718
uint8_t prog_port_parked(const prog_port_t *p)
The NONE ports that hold a pin, bit n for port n: the pins the caller parks as inputs.
Definition prog_port.c:622
uint16_t prog_port_sliced_channels(const prog_port_t *p)
The bank channels of the ports whose pin shares a PWM slice with another port's pin,...
Definition prog_port.c:733
uint8_t prog_port_wire_pin(const prog_port_t *p, uint8_t port, uint8_t bound)
The pin a wire page (KST, HITEC) may take for a session on port port: the port's pin while the IOmcu ...
Definition prog_port.c:674
uint8_t prog_port_channel(uint8_t port)
The bank channel of port.
Definition prog_port.c:759
uint8_t prog_port_pwm_ports(const prog_port_t *p)
The SERVO PWM ports whose pin the generator has, bit n for port n: the ports a pulse bit and the TARG...
Definition prog_port.c:607
uint8_t prog_port_func(const prog_port_t *p, uint8_t port)
Port port's function, a link_pg_func_t; NONE for a port the model does not hold.
Definition prog_port.c:599
void prog_port_init(prog_port_t *p, uint8_t count)
count ports, 0 to LINK_PG_PORTS_MAX, none with a pin, all at PROG_PORT_RATE_HZ.
Definition prog_port.c:193
uint8_t prog_port_dshot(const prog_port_t *p)
The DShot ports that hold a pin (FUNC DSHOT150 to DSHOT600, 4.28), bit n for port n: the pins the cal...
Definition prog_port.c:638
uint8_t prog_port_target(const prog_port_t *p)
0 for the standard servo ports, 1 + n for port n.
Definition prog_port.c:754
uint8_t prog_port_pin(const prog_port_t *p, uint8_t port)
The pin port port holds, or PROG_PORT_NO_PIN.
Definition prog_port.c:666
uint8_t prog_port_pwm(const prog_port_t *p)
Bit n: port n's pulse is switched on.
Definition prog_port.c:698
uint8_t prog_port_count(const prog_port_t *p)
The number of ports the model holds.
Definition prog_port.c:661
unsigned prog_port_slots_free(uint16_t *slots)
Unbinds every slot of slots whose channel range reaches a port's bank channel, for a stored page read...
Definition prog_port.c:781
uint16_t prog_port_kept_func(const prog_port_t *p)
The functions as they stand, as the kept word: bits 4n to 4n + 3 hold 1 + port n's FUNC,...
Definition prog_port.c:313
void prog_port_revert(prog_port_t *p, const prog_port_t *was, outputs_t *o)
Undo a write the silicon could not follow: the page as was, and each port's channel in o with the sle...
Definition prog_port.c:568
void prog_port_restore(prog_port_t *p, const uint16_t *kept, outputs_t *o, uint64_t taken)
Take the kept registers at start, after the slots and the other pin holders are restored.
Definition prog_port.c:224
uint16_t prog_port_port_hz(const prog_port_t *p, uint8_t port)
The frame rate port port runs at: the SERVO page's rate for the TARGET port while it names one,...
Definition prog_port.c:725
uint64_t prog_port_pins(const prog_port_t *p)
Every pin the ports hold, one bit per pin.
Definition prog_port.c:683
void prog_port_bound(prog_port_t *p, uint8_t mask)
Tell the page which ports' pins are held by their function, bit n for port n: bound to the generator ...
Definition prog_port.c:579
uint16_t prog_port_kbit(const prog_port_t *p, uint8_t port)
Port port's DShot bit rate in kbit/s, 0 for another function.
Definition prog_port.c:653
uint8_t prog_port_slots_check(const prog_port_t *p, const uint16_t *slots)
Whether the OUTPUTS page slots may be taken beside the ports: 0, or LINK_NACK_BAD_VALUE for a slot on...
Definition prog_port.c:799
The state of a bank of channels and slots.
Definition outputs.h:143
The state of the programming ports: the PROG page's registers and which ports hold their pin.
Definition prog_port.h:99
uint8_t blocked
Definition prog_port.h:103
uint8_t count
Definition prog_port.h:101
uint8_t bound
Definition prog_port.h:102
uint16_t hz
Definition prog_port.h:105