|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The Hitec servo wire on a programming port: the OPEN, transaction, POWER and CLOSE states. More...
Macros | |
| #define | COUNT_MAX 0x0FFFu |
| The transaction count stops at this value (12 bits). | |
| #define | ST(p, reg) |
Functions | |
| static uint32_t | st32 (const hitec_port_t *p, unsigned lo) |
Read the 32-bit staged value at write offset lo, low word first. | |
| static bool | supply_view (const hitec_port_t *p, supply_port_view_t *v) |
Read the supply's view of the port into v. | |
| static void | supply_off (hitec_port_t *p) |
| Ask the supply off, when the build has a supply to switch. | |
| static void | op_begin (hitec_port_t *p, link_hitec_op_t op) |
| Start an operation: record its code and set the result to RUNNING. | |
| static void | go_free (hitec_port_t *p) |
| Back to free: the line closed, the pin the generator's. | |
| static void | finish (hitec_port_t *p) |
| The capture is in: decode it as the transaction asked. | |
| static void | cut (hitec_port_t *p) |
| Cut the running transaction; its capture comes at the next poll. | |
| static void | start (hitec_port_t *p, const hitec_xfer_t *x, uint8_t keyed) |
Start x on the line: BUSY, or OPEN with LINK_HITEC_RESULT_START. | |
| static void | on_stop (hitec_port_t *p) |
| Apply a stop to the port, by its state. | |
| static bool | decoder_ok (const hitec_port_t *p, link_hitec_op_t op) |
| The decoder the staged registers ask for, checked against the family. | |
| static bool | staged_xfer (const hitec_port_t *p, link_hitec_op_t op, hitec_xfer_t *x) |
The transaction the staged registers say for op; false when it is not one the line runs. | |
| static bool | power_range_ok (const supply_port_view_t *v, uint16_t mv, uint16_t ma, uint16_t off_ms) |
Whether the PD mini gives the servo mv and ma: inside the POWER bounds, and under the input with the module's cap. | |
| static link_hitec_refusal_t | open_port (hitec_port_t *p, uint8_t port, const uint16_t *in, uint32_t now_ms) |
Start OPEN on port: take the staged line and the port's pin, and enter STOPPING. | |
| static link_hitec_refusal_t | close_port (hitec_port_t *p, uint8_t port) |
Start CLOSE on port: cut what runs, close the line and free the port. | |
| static void | abort_op (hitec_port_t *p) |
| Cut what runs: a STOPPING port is freed, a BUSY port is cut, and a POWER in its off time ends. | |
| static link_hitec_refusal_t | power (hitec_port_t *p, const hitec_xfer_t *x, uint32_t now_ms) |
| Start POWER: check the supply and the set points, then ask the supply off. | |
| static bool | puts_byte_out (link_hitec_op_t op, const hitec_xfer_t *x) |
| Whether a transaction puts a byte on the wire. | |
| static link_hitec_refusal_t | transaction (hitec_port_t *p, link_hitec_op_t op, uint8_t port, const uint16_t *in, uint32_t now_ms) |
| SEND, LISTEN, LEVEL and POWER. | |
| static link_hitec_refusal_t | dispatch (hitec_port_t *p, link_hitec_op_t op, uint8_t port, const uint16_t *in, uint32_t now_ms) |
| Route one command to its operation. | |
| static uint8_t | command (hitec_port_t *p, const uint16_t *in, uint32_t now_ms) |
| Handle the command frame, registers 0 to 3. | |
| uint8_t | hitec_port_write (hitec_port_t *p, uint8_t off, uint8_t n, const uint16_t *in, uint32_t now_ms) |
| A write of the page: 0, or the LINK_NACK_* reason with nothing changed. | |
| static void | put32 (uint16_t *at, uint32_t v) |
| Store a 32-bit value in two registers, low word first. | |
| static uint16_t | state_reg (const hitec_port_t *p) |
| The STATE register: the state, the port and the flags. | |
| static void | data_regs (const hitec_port_t *p, uint16_t *all) |
Registers 16 to 31 of all, as VIEW selects. | |
| void | hitec_port_read (const hitec_port_t *p, uint8_t off, uint8_t n, uint16_t *out) |
| A read of the page, LINK_HT_*. | |
| static void | step_busy (hitec_port_t *p, uint32_t now_ms) |
| The pass of a BUSY port: take the capture, or cut a precharge line or a run past its time. | |
| static void | step_power (hitec_port_t *p, uint32_t now_ms) |
| The pass of a POWER port: wait for the supply to read off, its off time, then the ON and the listen. | |
| void | hitec_port_step (hitec_port_t *p, bool safe, bool stop, uint32_t now_ms) |
| One pass. | |
| bool | hitec_port_init (hitec_port_t *p, const hitec_port_hw_t *hw) |
| Prepare a free port. | |
| link_hitec_state_t | hitec_port_state (const hitec_port_t *p) |
| Where the port is. | |
| uint8_t | hitec_port_quiet_mask (const hitec_port_t *p) |
| Bit n: programming port n renders no PWM pulse. | |
| uint8_t | hitec_port_pin_mask (const hitec_port_t *p) |
| Bit n: programming port n's pin is the wire driver's. | |
| void | hitec_port_bench_armed (hitec_port_t *p, bool armed) |
| Whether the bank is armed: OPEN is refused while it is. | |
| void | hitec_port_other_mask (hitec_port_t *p, uint8_t mask) |
| Bit n: the KST page holds programming port n (kst_port_quiet_mask()). OPEN on it is refused with LINK_HITEC_REF_HELD. | |
| bool | hitec_port_supply_hold (const hitec_port_t *p) |
| The port holds the SUPPLY page (supply_page_hold()): every state but LINK_HITEC_FREE, from OPEN to CLOSE. | |
| bool | hitec_port_frame_out (const hitec_port_t *p, uint32_t now_ms) |
| A byte may be on the wire: a SEND from its start until the lead and the bytes have had their time, counted in whole ms; a LISTEN or a POWER that answers, while it runs. | |
The Hitec servo wire on a programming port: the OPEN, transaction, POWER and CLOSE states.
SPDX-License-Identifier: MIT
| #define ST | ( | p, | |
| reg ) |
|
static |
Cut what runs: a STOPPING port is freed, a BUSY port is cut, and a POWER in its off time ends.
| p | The port. |
|
static |
Start CLOSE on port: cut what runs, close the line and free the port.
| p | The port. |
| port | Programming port index. |
|
static |
Handle the command frame, registers 0 to 3.
| p | The port. |
| in | The command frame's four registers. |
| now_ms | Current time in milliseconds. |
|
static |
Cut the running transaction; its capture comes at the next poll.
| p | The port. |
|
static |
Registers 16 to 31 of all, as VIEW selects.
| p | The port. |
| all | The register image, LINK_HT_COUNT entries, filled in place. |
|
static |
The decoder the staged registers ask for, checked against the family.
| p | The port. |
| op | The operation the registers were staged for. |
|
static |
Route one command to its operation.
| p | The port. |
| op | The operation. |
| port | Programming port index. |
| in | The command frame's registers. |
| now_ms | Current time in milliseconds. |
|
static |
The capture is in: decode it as the transaction asked.
| p | The port. |
|
static |
Back to free: the line closed, the pin the generator's.
| p | The port. |
| void hitec_port_bench_armed | ( | hitec_port_t * | p, |
| bool | armed ) |
Whether the bank is armed: OPEN is refused while it is.
| p | The port, or NULL; a NULL p is ignored. |
| armed | true when the bank is armed. |
| bool hitec_port_frame_out | ( | const hitec_port_t * | p, |
| uint32_t | now_ms ) |
A byte may be on the wire: a SEND from its start until the lead and the bytes have had their time, counted in whole ms; a LISTEN or a POWER that answers, while it runs.
| p | The port, or NULL. |
| now_ms | Current time in milliseconds. |
| bool hitec_port_init | ( | hitec_port_t * | p, |
| const hitec_port_hw_t * | hw ) |
Prepare a free port.
False when hw names no port or lacks a function other than run and the supply's two, or has one of those two.
| p | The port to prepare; zeroed first. |
| hw | The hardware hooks, copied into the port. |
| void hitec_port_other_mask | ( | hitec_port_t * | p, |
| uint8_t | mask ) |
Bit n: the KST page holds programming port n (kst_port_quiet_mask()). OPEN on it is refused with LINK_HITEC_REF_HELD.
| p | The port, or NULL; a NULL p is ignored. |
| mask | Bit n: the KST page holds programming port n. |
| uint8_t hitec_port_pin_mask | ( | const hitec_port_t * | p | ) |
Bit n: programming port n's pin is the wire driver's.
From the take until CLOSE.
| p | The port, or NULL. |
| uint8_t hitec_port_quiet_mask | ( | const hitec_port_t * | p | ) |
Bit n: programming port n renders no PWM pulse.
The held port in every state but LINK_HITEC_FREE.
| p | The port, or NULL. |
| void hitec_port_read | ( | const hitec_port_t * | p, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| uint16_t * | out ) |
A read of the page, LINK_HT_*.
| p | The port. |
| off | First register of the window. |
| n | Number of registers to read. |
| out | Receives n register values; left unchanged for a NULL p or out, or a window past LINK_HT_COUNT. |
| link_hitec_state_t hitec_port_state | ( | const hitec_port_t * | p | ) |
Where the port is.
| p | The port, or NULL. |
| void hitec_port_step | ( | hitec_port_t * | p, |
| bool | safe, | ||
| bool | stop, | ||
| uint32_t | now_ms ) |
One pass.
safe: the heartbeat is trusted and the link is not silent. stop: the bank was switched off or disarmed since the last pass.
| p | The port. |
| safe | true when the heartbeat is trusted and the link is not silent. |
| stop | true when the bank was switched off or disarmed since the last pass. |
| now_ms | Current time in milliseconds. |
| bool hitec_port_supply_hold | ( | const hitec_port_t * | p | ) |
The port holds the SUPPLY page (supply_page_hold()): every state but LINK_HITEC_FREE, from OPEN to CLOSE.
| p | The port, or NULL. |
| uint8_t hitec_port_write | ( | hitec_port_t * | p, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| const uint16_t * | in, | ||
| uint32_t | now_ms ) |
A write of the page: 0, or the LINK_NACK_* reason with nothing changed.
A window that starts in registers 0 to 3 is a command and has to be exactly those 4. Registers 4 to 23 are taken in any windows; 24 and up are LINK_NACK_READ_ONLY. A VIEW or an RX_MODE above the last is LINK_NACK_BAD_VALUE.
| p | The port. |
| off | First register of the window. |
| n | Number of registers in the window; 0 is refused. |
| in | The n register values to write. |
| now_ms | Current time in milliseconds. |
|
static |
Apply a stop to the port, by its state.
| p | The port. |
|
static |
Start an operation: record its code and set the result to RUNNING.
| p | The port. |
| op | The operation to record. |
|
static |
Start OPEN on port: take the staged line and the port's pin, and enter STOPPING.
| p | The port. |
| port | Programming port index. |
| in | The command frame's registers. |
| now_ms | Current time in milliseconds. |
|
static |
Start POWER: check the supply and the set points, then ask the supply off.
| p | The port. |
| x | The listen the POWER runs after the ON. |
| now_ms | Current time in milliseconds. |
|
static |
Whether the PD mini gives the servo mv and ma: inside the POWER bounds, and under the input with the module's cap.
| v | The supply's view. |
| mv | The supply set point in mV. |
| ma | The supply current limit in mA. |
| off_ms | The off time in milliseconds. |
|
static |
Store a 32-bit value in two registers, low word first.
| at | The first of two registers. |
| v | The value. |
|
static |
Whether a transaction puts a byte on the wire.
| op | The operation. |
| x | The transaction. |
|
static |
Read the 32-bit staged value at write offset lo, low word first.
| p | The port. |
| lo | Write offset of the low 16-bit register. |
|
static |
The transaction the staged registers say for op; false when it is not one the line runs.
| p | The port. |
| op | The operation the registers were staged for. |
| x | Receives the transaction the staged registers describe. |
|
static |
Start x on the line: BUSY, or OPEN with LINK_HITEC_RESULT_START.
| p | The port. |
| x | The transaction to start. |
| keyed | 1 when the transaction puts a byte out, else 0. |
|
static |
The STATE register: the state, the port and the flags.
| p | The port. |
|
static |
The pass of a BUSY port: take the capture, or cut a precharge line or a run past its time.
| p | The port. |
| now_ms | Current time in milliseconds. |
|
static |
The pass of a POWER port: wait for the supply to read off, its off time, then the ON and the listen.
| p | The port. |
| now_ms | Current time in milliseconds. |
|
static |
Ask the supply off, when the build has a supply to switch.
| p | The port. |
|
static |
Read the supply's view of the port into v.
| p | The port. |
| v | Receives the view; zeroed first. |
|
static |
SEND, LISTEN, LEVEL and POWER.
| p | The port. |
| op | The operation. |
| port | Programming port index. |
| in | The command frame's registers. |
| now_ms | Current time in milliseconds. |