rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
supply_page.h
Go to the documentation of this file.
1
23
24#pragma once
25
26#include <stdbool.h>
27#include <stdint.h>
28
29#include "link_pages.h"
30#include "outputs.h"
31#include "pdmini.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
38#define SUPPLY_BAUD_COUNT 7u
39#define SUPPLY_BAUD_AUTO 7u
40
48uint32_t supply_page_baud(uint16_t setting);
49
55#define SUPPLY_PAGE_OFF_WAIT_MS 12u
56
63
65typedef struct {
66 uint16_t regs[LINK_SP_COUNT];
67 bool commanded;
68 bool answered;
69 uint8_t wire;
70 bool wire_ask;
72 uint16_t wire_next[4];
74 uint8_t scan;
75 uint16_t scan_seen;
76 bool held;
77 bool frame_out;
78 bool was_on;
79 bool off_wait;
80 uint32_t now_ms;
81 uint32_t off_t0;
83
85typedef struct {
86 bool online;
88 bool asked_on;
89 bool on;
91 bool off;
92 uint16_t set_mv;
93 uint16_t set_ma;
94 uint16_t vin_mv;
96
106
120uint8_t supply_page_rate(supply_page_t *p, const pdmini_t *drv);
121
129uint32_t supply_page_uart_baud(const supply_page_t *p);
130
158uint8_t supply_page_write(supply_page_t *p, uint8_t off, uint8_t n,
159 const uint16_t *in, const outputs_t *o,
160 bool beat_alive);
161
172void supply_page_follow(supply_page_t *p, const pdmini_t *drv);
173
186bool supply_page_wire_ready(const supply_page_t *p, uint16_t *regs);
187
199
207
221uint8_t supply_page_slots_check(const supply_page_t *p, const uint16_t *slots);
222
234void supply_page_read(const supply_page_t *p, uint8_t off, uint8_t n,
235 uint16_t *out);
236
244
251uint8_t supply_page_tx(const supply_page_t *p);
252
259uint8_t supply_page_rx(const supply_page_t *p);
260
267uint64_t supply_page_pins(const supply_page_t *p);
268
282void supply_page_step(supply_page_t *p, bool beat_alive, pdmini_t *drv);
283
292
311bool supply_page_port_set(supply_page_t *p, bool on, uint16_t mv,
312 uint16_t ma, bool beat_alive);
313
327void supply_page_hold(supply_page_t *p, bool held);
328
342void supply_page_port_frame(supply_page_t *p, bool frame_out,
343 uint32_t now_ms);
344
345#ifdef __cplusplus
346}
347#endif
The intermediary every output goes through: one set of rules for arming, clamping,...
The WeAct PD Power Mini V1 Buck on its UART: the codec and a driver that talks to it one transaction ...
The state of a bank of channels and slots.
Definition outputs.h:143
Driver state: what is asked, what is known, and the transaction under way.
Definition pdmini.h:290
The SUPPLY page state: registers, and the wiring change in hand.
Definition supply_page.h:65
uint8_t scan
Definition supply_page.h:74
uint8_t wire
Definition supply_page.h:69
bool off_wait
Definition supply_page.h:79
uint32_t now_ms
Definition supply_page.h:80
uint16_t regs[LINK_SP_COUNT]
Definition supply_page.h:66
uint16_t scan_seen
Definition supply_page.h:75
uint32_t off_t0
Definition supply_page.h:81
uint16_t wire_next[4]
Definition supply_page.h:72
bool commanded
Definition supply_page.h:67
bool frame_out
Definition supply_page.h:77
bool answered
Definition supply_page.h:68
bool was_on
Definition supply_page.h:78
bool held
Definition supply_page.h:76
bool reset_owed
Definition supply_page.h:73
bool wire_ask
Definition supply_page.h:70
bool wire_refused
Definition supply_page.h:71
The supply as a programming port sees it (kst_port.h).
Definition supply_page.h:85
uint16_t set_mv
Definition supply_page.h:92
uint16_t set_ma
Definition supply_page.h:93
uint16_t vin_mv
Definition supply_page.h:94
bool asked_on
Definition supply_page.h:88
bool off
Definition supply_page.h:91
bool online
Definition supply_page.h:86
bool on
Definition supply_page.h:89
uint8_t supply_page_write(supply_page_t *p, uint8_t off, uint8_t n, const uint16_t *in, const outputs_t *o, bool beat_alive)
A write, validated whole before any of it is stored.
Definition supply_page.c:287
uint64_t supply_page_pins(const supply_page_t *p)
The pins it holds, as a reservation mask; 0 while not enabled.
Definition supply_page.c:50
uint32_t supply_page_uart_baud(const supply_page_t *p)
The baud the UART is to be opened at now.
Definition supply_page.c:401
bool supply_page_port_set(supply_page_t *p, bool on, uint16_t mv, uint16_t ma, bool beat_alive)
A programming port's request, in place of a link write of OUTPUT to SET_MA.
Definition supply_page.c:530
void supply_page_wire_refuse(supply_page_t *p)
The ready wiring could not be put in force after it was written (no UART for its pins): refused,...
Definition supply_page.c:316
uint8_t supply_page_slots_check(const supply_page_t *p, const uint16_t *slots)
LINK_NACK_BAD_VALUE for an OUTPUTS page (slots, LINK_OS_COUNT registers) that binds a slot to a pin t...
Definition supply_page.c:410
void supply_page_init(supply_page_t *p)
Clears the page to its start: BAUD 1 (19200), BAUD_FOUND AUTO, the scan at 1.
Definition supply_page.c:25
bool supply_page_enabled(const supply_page_t *p)
Whether the page drives a supply, and on which pins.
Definition supply_page.c:35
uint8_t supply_page_wire_write(supply_page_t *p, const outputs_t *o)
The ready wiring written: judged whole as a link write is, against the driver's state as supply_page_...
Definition supply_page.c:326
void supply_page_step(supply_page_t *p, bool beat_alive, pdmini_t *drv)
One pass: the output off without a heartbeat, what the driver is to do, and what it last said into th...
Definition supply_page.c:438
void supply_page_follow(supply_page_t *p, const pdmini_t *drv)
What the driver says now, straight before a write is judged: FLAGS bit 6 (the output on or maybe on) ...
Definition supply_page.c:294
uint32_t supply_page_baud(uint16_t setting)
The baud rate of a UART setting.
Definition supply_page.c:17
void supply_page_read(const supply_page_t *p, uint8_t off, uint8_t n, uint16_t *out)
Copies registers of the SUPPLY page.
Definition supply_page.c:426
uint8_t supply_page_rx(const supply_page_t *p)
The RX pin register, as a GPIO number.
Definition supply_page.c:45
supply_wire_t
Where a wiring change that waits for a state read is.
Definition supply_page.h:58
@ SUPPLY_WIRE_IDLE
Definition supply_page.h:59
@ SUPPLY_WIRE_READY
Definition supply_page.h:61
@ SUPPLY_WIRE_WAIT
Definition supply_page.h:60
bool supply_page_wire_ready(const supply_page_t *p, uint16_t *regs)
The wiring change whose state read showed the output off, into regs (ENABLE to BAUD): true while one ...
Definition supply_page.c:307
void supply_page_port_frame(supply_page_t *p, bool frame_out, uint32_t now_ms)
Whether a programming port has a frame on the wire, and the clock, once a pass before supply_page_ste...
Definition supply_page.c:556
uint8_t supply_page_rate(supply_page_t *p, const pdmini_t *drv)
The rate the UART is to run at now, 0 to 6.
Definition supply_page.c:378
uint8_t supply_page_tx(const supply_page_t *p)
The TX pin register, as a GPIO number.
Definition supply_page.c:40
void supply_page_hold(supply_page_t *p, bool held)
Whether a programming port holds the command registers (FLAGS bit 11, LINK_SP_PORT).
Definition supply_page.c:565
void supply_page_port_view(const supply_page_t *p, supply_port_view_t *out)
The page as of the last supply_page_step(), for a programming port.
Definition supply_page.c:505