|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A write of any width, one frame in flight at a time. More...
Go to the source code of this file.
Data Structures | |
| struct | link_port_t |
| How a request reaches the far end and its answer comes back. More... | |
Functions | |
| bool | link_write_acked (link_host_t *h, const link_port_t *port, uint8_t page, uint8_t offset, uint8_t count, const uint16_t *regs, link_msg_t *reply) |
Write count registers of page from offset, one frame of up to LINK_CAN_REGS_PER_FRAME registers per exchange, each acknowledged before the next is sent. | |
| bool | link_read_window (link_host_t *h, const link_port_t *port, uint8_t page, uint8_t offset, uint8_t count, link_msg_t *reply) |
Read count registers of page from offset in one exchange. | |
A write of any width, one frame in flight at a time.
link_host_write() builds one request, and the CAN (Controller Area Network) mapping renders a request wider than LINK_CAN_REGS_PER_FRAME (4) registers as several frames sent back to back. The IOmcu's controller buffers 2 received frames and is read from a polled loop, so the 8 frames of a 32-register page arrive faster than a loop that is busy for one pass can take them, and the frame that finds both buffers full is gone.
link_write_acked() sends the same registers as one request per frame and waits for each acknowledgement before it builds the next. At most one request frame is on its way at any time, so a slow pass at the far end delays a frame and cannot lose one to a full buffer.
The transport and the clock are the caller's, handed in as a link_port_t, so the sequence runs on the host against a modelled bus.
SPDX-License-Identifier: MIT
| bool link_read_window | ( | link_host_t * | h, |
| const link_port_t * | port, | ||
| uint8_t | page, | ||
| uint8_t | offset, | ||
| uint8_t | count, | ||
| link_msg_t * | reply ) |
Read count registers of page from offset in one exchange.
True when it was answered; reply is the data or the refusal.
| h | The host state. |
| port | The transport and clock. |
| page | Page number to read. |
| offset | First register within the page. |
| count | Number of registers to read. |
| reply | Receives the data or the refusal. |
| bool link_write_acked | ( | link_host_t * | h, |
| const link_port_t * | port, | ||
| uint8_t | page, | ||
| uint8_t | offset, | ||
| uint8_t | count, | ||
| const uint16_t * | regs, | ||
| link_msg_t * | reply ) |
Write count registers of page from offset, one frame of up to LINK_CAN_REGS_PER_FRAME registers per exchange, each acknowledged before the next is sent.
True when the far end answered every frame sent. reply is then one of two things: an ACK (acknowledge) for the whole window, carrying what the far end stored for each register, or the NACK (negative acknowledge) of the first frame it refused, with that frame's offset. Nothing is sent after a refusal.
False when a frame ended unanswered, when a request is already outstanding on h, or when the window does not fit a page; reply is then not meaningful.
The frames before a refused or unanswered one stay applied at the far end: the transport has no rollback. A page that must change whole is written through pages that prepare it; see LINK_PAGE_BIND.
| h | The host state. |
| port | The transport and clock. |
| page | Page number to write. |
| offset | First register within the page. |
| count | Number of registers, 1 to LINK_MAX_REGS. |
| regs | The count values to write. |
| reply | Receives the ACK or the NACK. |