|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The panel's half of the SUPPLY link page. More...
Macros | |
| #define | PAGE_MIN_MV 1000u |
| #define | PAGE_MAX_MV 20000u |
| #define | PAGE_MIN_MA 50u |
| #define | PAGE_MAX_MA 3000u |
Functions | |
| void | supply_link_init (supply_link_t *s) |
| Sets up the supply link state. | |
| void | supply_link_lost (supply_link_t *s) |
| The link went or came back: nothing on the page is known, and the panel's ON, if it had one, is over. | |
| static supply_wiring_t | as_written (const supply_wiring_t *w) |
| The wiring as the page is to hold it: disabled unless both pins are set and differ, with unset pins written as 0. | |
| static bool | same_wiring (const supply_wiring_t *a, const supply_wiring_t *b) |
| Whether two wirings are the same, field by field. | |
| void | supply_link_wire (supply_link_t *s, const supply_wiring_t *w) |
| The wiring the settings name now. | |
| void | supply_link_command (supply_link_t *s, bool on, uint16_t mv, uint16_t ma) |
| What the output is to be; set points clamped to the page's 1000 to 20000mV and 50 to 3000mA. | |
| void | supply_link_reset (supply_link_t *s) |
| Restart the PD mini (protocol 4.4): written once the page's output is off and its wiring written, after any OFF owed. | |
| supply_link_write_t | supply_link_next (supply_link_t *s, uint8_t *off, uint8_t *n, uint16_t *regs) |
| The next write owed, or SUPPLY_LINK_W_NONE. | |
| void | supply_link_written (supply_link_t *s, int result) |
| How the write supply_link_next() gave went: SUPPLY_LINK_ACK, a NACK reason, or SUPPLY_LINK_NO_ANSWER. | |
| bool | supply_link_settled (const supply_link_t *s) |
| Whether nothing is owed: the page holds the command asked and the wiring, or the wiring was refused. | |
| bool | supply_link_event_stands (const supply_link_t *s, uint16_t ev) |
Whether what ev, one SUPPLY_LINK_EV_* bit, says still holds now. | |
| bool | supply_link_read_due (const supply_link_t *s, uint32_t now_ms) |
Whether a read of the page is due at now_ms. | |
| void | supply_link_read (supply_link_t *s, const uint16_t *regs, uint32_t now_ms) |
The whole page as read at now_ms, or regs NULL for a read that was not answered. | |
| void | supply_link_state (const supply_link_t *s, uint32_t now_ms, supply_state_t *st) |
The supply as the page last said, into st: readings, set points read back from the module, the mode – OFF while the module reads its output off – the module's reading count (SAMPLES, the IOmcu's count of output readings the module answered) and the time of the page read that first showed that count, and online only for a page read younger than SUPPLY_LINK_STALE_MS from a module the page drives. | |
| bool | supply_link_blind (const supply_link_t *s, uint32_t now_ms) |
Whether the module's readings have stopped at now_ms: a page has been read and its reading count (SAMPLES) has not moved for SUPPLY_LINK_BLIND_MS or more, counted on the 32-bit millisecond clock across its wrap. | |
| bool | supply_link_adopted (supply_link_t *s, bool *on, uint16_t *mv, uint16_t *ma) |
The command a programming port left on the page, once: true with on, mv and ma filled when the page's command was taken as the one asked since the last call. | |
| uint16_t | supply_link_events (supply_link_t *s) |
| The events since the last call, SUPPLY_LINK_EV_*, and cleared. | |
| void | supply_link_sag (const supply_link_t *s, uint16_t *vin_mv, uint16_t *set_mv) |
| The input and the set point in mV that SUPPLY_LINK_EV_SAGGED was read with: the page's VIN_MV and SET_MV_RB on the read that first showed FLAGS bit 10. | |
| bool | supply_link_wiring_moved (supply_link_follow_t *f, unsigned edits, unsigned word) |
| Whether the PD mini's wiring has moved since it was last followed. | |
| bool | supply_link_held_pins (const supply_link_t *s, int *tx, int *rx) |
| The PD mini's pins the page holds by its last read, as the IOmcu reserves them (supply_page_pins()): TX and RX while ENABLE is on, -1 and -1 while it is off. | |
| bool | supply_link_port_held (const supply_link_t *s) |
| Whether the last read of the page had LINK_SP_PORT set: a programming port holds the supply, and the page takes an OFF of the panel's and no other change of OUTPUT, SET_MV or SET_MA. | |
|
static |
The wiring as the page is to hold it: disabled unless both pins are set and differ, with unset pins written as 0.
| w | The wiring the settings name. |
|
static |
Whether two wirings are the same, field by field.
| a | The first wiring. |
| b | The second wiring. |
| bool supply_link_adopted | ( | supply_link_t * | s, |
| bool * | on, | ||
| uint16_t * | mv, | ||
| uint16_t * | ma ) |
The command a programming port left on the page, once: true with on, mv and ma filled when the page's command was taken as the one asked since the last call.
The caller's own copy of the command follows it; a copy left as it was is written again at the caller's next supply_link_command().
| s | The link state. |
| on | Receives the output state the page holds. |
| mv | Receives the set point voltage, in mV. |
| ma | Receives the set point current, in mA. |
| bool supply_link_blind | ( | const supply_link_t * | s, |
| uint32_t | now_ms ) |
Whether the module's readings have stopped at now_ms: a page has been read and its reading count (SAMPLES) has not moved for SUPPLY_LINK_BLIND_MS or more, counted on the 32-bit millisecond clock across its wrap.
The page may still answer and the module read ONLINE: a display read that fails while the other reads answer. No operator trip acts on such readings, so the caller switches an output that is on off and says why. False before the first page read.
| s | The link state. |
| now_ms | The time, in ms. |
| void supply_link_command | ( | supply_link_t * | s, |
| bool | on, | ||
| uint16_t | mv, | ||
| uint16_t | ma ) |
What the output is to be; set points clamped to the page's 1000 to 20000mV and 50 to 3000mA.
| s | The link state. |
| on | true to switch the output on. |
| mv | The set point voltage, in mV. |
| ma | The set point current, in mA. |
| bool supply_link_event_stands | ( | const supply_link_t * | s, |
| uint16_t | ev ) |
Whether what ev, one SUPPLY_LINK_EV_* bit, says still holds now.
A refused wiring – SUPPLY_LINK_EV_WIRING_REFUSED or _WIRING_LIVE – until a read shows the page holding the wiring the settings ask: pins stepped back to ones the page takes end it with the first read that shows them held. With no IOmcu answering it stands. True for every other event. The caller takes back an alert it showed for a refused wiring once this is false.
| s | The link state. |
| ev | One SUPPLY_LINK_EV_* bit. |
| uint16_t supply_link_events | ( | supply_link_t * | s | ) |
The events since the last call, SUPPLY_LINK_EV_*, and cleared.
| s | The link state. |
| bool supply_link_held_pins | ( | const supply_link_t * | s, |
| int * | tx, | ||
| int * | rx ) |
The PD mini's pins the page holds by its last read, as the IOmcu reserves them (supply_page_pins()): TX and RX while ENABLE is on, -1 and -1 while it is off.
False, both -1, before the first read since the link came up; a refused wiring leaves the page's old one, and that is what is read. tx and rx may be NULL.
| s | The link state. |
| tx | Receives the TX pin, or -1; may be NULL. |
| rx | Receives the RX pin, or -1; may be NULL. |
| void supply_link_init | ( | supply_link_t * | s | ) |
Sets up the supply link state.
| s | The link state to set up. |
| void supply_link_lost | ( | supply_link_t * | s | ) |
The link went or came back: nothing on the page is known, and the panel's ON, if it had one, is over.
| s | The link state. |
| supply_link_write_t supply_link_next | ( | supply_link_t * | s, |
| uint8_t * | off, | ||
| uint8_t * | n, | ||
| uint16_t * | regs ) |
The next write owed, or SUPPLY_LINK_W_NONE.
off and n say where on the page and how many registers, regs what; the caller writes them and reports with supply_link_written().
| s | The link state. |
| off | Receives the page offset of the write. |
| n | Receives the number of registers. |
| regs | Receives the register values. |
| bool supply_link_port_held | ( | const supply_link_t * | s | ) |
Whether the last read of the page had LINK_SP_PORT set: a programming port holds the supply, and the page takes an OFF of the panel's and no other change of OUTPUT, SET_MV or SET_MA.
The KST page holds it for its whole session; from protocol 4.29 the HITEC page holds it from its OPEN to its CLOSE. False before the first read since the link came up.
| s | The link state. |
| void supply_link_read | ( | supply_link_t * | s, |
| const uint16_t * | regs, | ||
| uint32_t | now_ms ) |
The whole page as read at now_ms, or regs NULL for a read that was not answered.
| s | The link state. |
| regs | The page as read, or NULL for a read not answered. |
| now_ms | The time, in ms. |
| bool supply_link_read_due | ( | const supply_link_t * | s, |
| uint32_t | now_ms ) |
Whether a read of the page is due at now_ms.
| s | The link state. |
| now_ms | The time, in ms. |
| void supply_link_reset | ( | supply_link_t * | s | ) |
Restart the PD mini (protocol 4.4): written once the page's output is off and its wiring written, after any OFF owed.
| s | The link state. |
| void supply_link_sag | ( | const supply_link_t * | s, |
| uint16_t * | vin_mv, | ||
| uint16_t * | set_mv ) |
The input and the set point in mV that SUPPLY_LINK_EV_SAGGED was read with: the page's VIN_MV and SET_MV_RB on the read that first showed FLAGS bit 10.
An input reading taken between the IOmcu's cut and that read replaces the one that cut.
| s | The link state. |
| vin_mv | Receives the input voltage, in mV. |
| set_mv | Receives the set point, in mV. |
| bool supply_link_settled | ( | const supply_link_t * | s | ) |
Whether nothing is owed: the page holds the command asked and the wiring, or the wiring was refused.
| s | The link state. |
| void supply_link_state | ( | const supply_link_t * | s, |
| uint32_t | now_ms, | ||
| supply_state_t * | st ) |
The supply as the page last said, into st: readings, set points read back from the module, the mode – OFF while the module reads its output off – the module's reading count (SAMPLES, the IOmcu's count of output readings the module answered) and the time of the page read that first showed that count, and online only for a page read younger than SUPPLY_LINK_STALE_MS from a module the page drives.
The readings are marked valid (ok) only while the count moved within the last SUPPLY_LINK_STALE_MS; behind a count that stands still they stay as the last ones with ok 0. Left as they are: output, which is what the panel asked, and the run's extremes, totals and trip.
| s | The link state. |
| now_ms | The time, in ms. |
| st | Receives the supply state. |
| void supply_link_wire | ( | supply_link_t * | s, |
| const supply_wiring_t * | w ) |
The wiring the settings name now.
| s | The link state. |
| w | The wiring the settings name. |
| bool supply_link_wiring_moved | ( | supply_link_follow_t * | f, |
| unsigned | edits, | ||
| unsigned | word ) |
Whether the PD mini's wiring has moved since it was last followed.
| f | The followed wiring state, updated. |
| edits | The edit count now. |
| word | The wiring word now. |
| void supply_link_written | ( | supply_link_t * | s, |
| int | result ) |
How the write supply_link_next() gave went: SUPPLY_LINK_ACK, a NACK reason, or SUPPLY_LINK_NO_ANSWER.
| s | The link state. |
| result | The result: an acknowledgement, a NACK's reason or SUPPLY_LINK_NO_ANSWER. |