|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The SUPPLY link page. More...
Functions | |
| uint32_t | supply_page_baud (uint16_t setting) |
| The baud rate of a UART setting. | |
| void | supply_page_init (supply_page_t *p) |
| Clears the page to its start: BAUD 1 (19200), BAUD_FOUND AUTO, the scan at 1. | |
| bool | supply_page_enabled (const supply_page_t *p) |
| Whether the page drives a supply, and on which pins. | |
| uint8_t | supply_page_tx (const supply_page_t *p) |
| The TX pin register, as a GPIO number. | |
| uint8_t | supply_page_rx (const supply_page_t *p) |
| The RX pin register, as a GPIO number. | |
| uint64_t | supply_page_pins (const supply_page_t *p) |
| The pins it holds, as a reservation mask; 0 while not enabled. | |
| static bool | pin_free (const supply_page_t *p, const outputs_t *o, uint16_t pin) |
Whether pin may carry the supply: in the bank, not reserved unless it is one this page already holds, and no output's. | |
| static uint16_t | wire_flags (const supply_page_t *p) |
| FLAGS bits 8, 9 and 11, kept whether or not a driver runs. | |
| static void | wire_publish (supply_page_t *p) |
| Bits 8, 9 and 11 onto the page as they change, not at the next step: a read between the two must not show a refusal already cleared, or no wait. | |
| static uint8_t | page_write (supply_page_t *p, uint8_t off, uint8_t n, const uint16_t *in, const outputs_t *o, bool beat_alive, bool checked) |
A write, judged whole; checked for the wiring a state read cleared, which does not wait again. | |
| 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. | |
| 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) and whether its module has answered. | |
| 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 is SUPPLY_WIRE_READY. | |
| 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, FLAGS bit 9, as a refused read is. | |
| 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_follow() last took it, without waiting again. 0, or the NACK reason, which refuses it (FLAGS bit 9). | |
| static void | wire_step (supply_page_t *p, pdmini_t *drv) |
The wiring change waiting, followed: its read asked of drv, and its answer taken. | |
| 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. | |
| uint32_t | supply_page_uart_baud (const supply_page_t *p) |
| The baud the UART is to be opened at now. | |
| 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 the supply holds; 0 otherwise. | |
| void | supply_page_read (const supply_page_t *p, uint8_t off, uint8_t n, uint16_t *out) |
| Copies registers of the SUPPLY page. | |
| 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 the read-only registers. | |
| 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. | |
| 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. | |
| 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_step(). | |
| void | supply_page_hold (supply_page_t *p, bool held) |
| Whether a programming port holds the command registers (FLAGS bit 11, LINK_SP_PORT). | |
|
static |
A write, judged whole; checked for the wiring a state read cleared, which does not wait again.
| p | The page state. |
| off | First register, 0 to LINK_SP_COUNT - 1. |
| n | Number of registers to write. |
| in | The n new register values. |
| o | The outputs bank. |
| beat_alive | Whether the panel's heartbeat is live. |
| checked | true when a state read of the driver has just cleared the wiring, so a wiring change does not wait again. |
|
static |
Whether pin may carry the supply: in the bank, not reserved unless it is one this page already holds, and no output's.
| p | The page state, for the pins it already holds. |
| o | The outputs bank. |
| pin | GPIO number to judge. |
| uint32_t supply_page_baud | ( | uint16_t | setting | ) |
The baud rate of a UART setting.
| setting | UART setting, 0 to SUPPLY_BAUD_COUNT - 1. |
| bool supply_page_enabled | ( | const supply_page_t * | p | ) |
Whether the page drives a supply, and on which pins.
| p | The page state. |
| 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) and whether its module has answered.
drv NULL for no driver: nothing answered, nothing on. supply_page_step() does the same every pass.
| p | The page state, updated. |
| drv | The PD mini driver, or NULL. |
| void supply_page_hold | ( | supply_page_t * | p, |
| bool | held ) |
Whether a programming port holds the command registers (FLAGS bit 11, LINK_SP_PORT).
While it does, supply_page_write() takes an OFF, which leaves SET_MV and SET_MA as they are whatever the write names, and refuses every other write of OUTPUT to SET_MA that changes one of the three with LINK_NACK_BAD_VALUE: the panel can switch the supply off, and cannot switch it on or move a set point under the servo.
| p | The page state. Nothing is done when NULL. |
| held | true while the programming port holds the registers. |
| void supply_page_init | ( | supply_page_t * | p | ) |
Clears the page to its start: BAUD 1 (19200), BAUD_FOUND AUTO, the scan at 1.
Nothing is done when p is NULL.
| p | The page state, overwritten. |
| uint64_t supply_page_pins | ( | const supply_page_t * | p | ) |
The pins it holds, as a reservation mask; 0 while not enabled.
| p | The page state. |
| 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_step().
An OFF taken while one is – written by the panel or forced by a lost heartbeat – reaches the driver when the frame has ended, SUPPLY_PAGE_OFF_WAIT_MS after it was asked at the latest. OUTPUT reads 0 from the moment it is asked.
| p | The page state. Nothing is done when NULL. |
| frame_out | true while a frame is on the wire. |
| now_ms | Current time in milliseconds. |
| 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.
Off is always taken and leaves the set points. On is refused (false, nothing changed) without a live heartbeat, while the supply is not wired or a wiring change waits, for set points outside the module's range, and for a voltage above SET_MV while OUTPUT is 1: the voltage of an output that is on is not raised here.
| p | The page state. |
| on | true for ON, false for OFF. |
| mv | Set voltage in millivolts, for ON. |
| ma | Set current in milliamps, for ON. |
| beat_alive | Whether the panel's heartbeat is live. |
| 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.
| p | The page state. |
| out | Receives the view. Zeroed first; nothing else is done when p is NULL. Nothing is done when out is NULL. |
| 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.
The setting itself, or under AUTO the one being tried: the next after every WHO_AM_I drv reports without a valid answer, until a module has answered once, from when the rate holds. Publishes it in BAUD_FOUND – 7 while AUTO has found none. drv NULL leaves the scan where it is.
| p | The page state. BAUD_FOUND is updated. |
| drv | The PD mini driver, or NULL. |
p. | void supply_page_read | ( | const supply_page_t * | p, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| uint16_t * | out ) |
Copies registers of the SUPPLY page.
Nothing is done when p or out is NULL, or when off and n reach past LINK_SP_COUNT.
| p | The page state, not changed. |
| off | First register, 0 to LINK_SP_COUNT - 1. |
| n | Number of registers to copy. |
| out | Receives the n register values. |
| uint8_t supply_page_rx | ( | const supply_page_t * | p | ) |
The RX pin register, as a GPIO number.
| p | The page state. |
| 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 the supply holds; 0 otherwise.
Checked before the page is stored, so no binding is kept that the bank would leave unbound – and that a restart, with the supply not yet wired, would drive on the module's pin.
| p | The page state. |
| slots | The OUTPUTS page, LINK_OS_COUNT registers. |
slots or a slot with a driver on a pin in supply_page_pins(), 0 otherwise. | 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 the read-only registers.
drv may be NULL while no supply is wired. A wiring change waiting asks the driver for its state read and follows the answer: off makes it SUPPLY_WIRE_READY, anything else refuses it (FLAGS bit 9). With no driver it is ready: nothing is attached to the module to switch it off.
| p | The page state. Nothing is done when NULL. |
| beat_alive | Whether the panel's heartbeat is live. |
| drv | The PD mini driver, or NULL. |
| uint8_t supply_page_tx | ( | const supply_page_t * | p | ) |
The TX pin register, as a GPIO number.
| p | The page state. |
| uint32_t supply_page_uart_baud | ( | const supply_page_t * | p | ) |
The baud the UART is to be opened at now.
| p | The page state. |
| 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 is SUPPLY_WIRE_READY.
The caller writes it with supply_page_wire_write() in the same pass.
| p | The page state. |
| regs | Receives the four wiring registers, ENABLE to BAUD. Not written when false is returned. |
regs is filled, false otherwise or for NULL. | 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, FLAGS bit 9, as a refused read is.
| p | The page state. Nothing is done when NULL. |
| 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_follow() last took it, without waiting again. 0, or the NACK reason, which refuses it (FLAGS bit 9).
| p | The page state. |
| o | The outputs bank, for the pins. |
| 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.
Refused: off the page (BAD_RANGE); a read-only register (READ_ONLY); a wiring change while the output is asked on or may be on, a pin past the bank, reserved, bound to an output or the other pin, a baud setting past 7 (AUTO), an ON without the supply enabled or without its set points in the same frame, a set point above the module's range, an ON while a wiring change waits, a wiring change that waits in the same frame as OUTPUT to SET_MA (BAD_VALUE); an ON without a live heartbeat (NOT_ARMED).
A wiring change that passes, while the driver's module has answered (supply_page_follow()), is acknowledged and not yet taken: it waits (SUPPLY_WIRE_WAIT, FLAGS bit 8) for a state read the next supply_page_step() asks of the driver. Another change replaces it and is read for again; a write of the wiring in force drops it.
| p | The page state, changed only when the write is taken. |
| off | First register, 0 to LINK_SP_COUNT - 1. |
| n | Number of registers to write. 0 is taken with no change. |
| in | The n new register values. |
| o | The outputs bank, for the pins a wiring change takes. |
| beat_alive | Whether the panel's heartbeat is live. |
|
static |
FLAGS bits 8, 9 and 11, kept whether or not a driver runs.
| p | The page state. |
|
static |
Bits 8, 9 and 11 onto the page as they change, not at the next step: a read between the two must not show a refusal already cleared, or no wait.
| p | The page state. Only those three FLAGS bits are replaced. |
|
static |
The wiring change waiting, followed: its read asked of drv, and its answer taken.
| p | The page state. |
| drv | The PD mini driver, or NULL. |