|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Cycle counts and divider of the PIO pin driver for the KST wire. More...
Functions | |
| static uint32_t | cycles_of (uint32_t hz, uint32_t ns) |
ns as cycles of hz, rounded to nearest. | |
| static uint32_t | ns_of (uint32_t hz, uint64_t cycles) |
cycles of hz as ns, rounded to nearest. | |
| bool | kst_pio_clock (uint32_t sys_hz, kst_pio_clock_t *out) |
The counts for a system clock of sys_hz. | |
| uint32_t | kst_pio_half_cell_ns (const kst_pio_clock_t *clock) |
The transmit half-cell of clock in ns, rounded to nearest. | |
| uint32_t | kst_pio_tick_ns (const kst_pio_clock_t *clock) |
One tick of clock in ns, rounded up. | |
| static uint32_t | first_sample_cycles (const kst_pio_clock_t *clock) |
| Cycles from the last edge to the first sample of the pin, as the pin was when the sample was taken. | |
| unsigned | kst_pio_tx (const kst_pio_clock_t *clock, const kst_frame_t *frame, uint32_t window_ns, uint32_t *words, kst_pio_run_t *run) |
The word stream for frame and a capture until window_ns after its last edge. | |
| void | kst_pio_capture (const kst_pio_clock_t *clock, const kst_pio_run_t *run, const uint32_t *stamps, unsigned n, bool lost, kst_capture_t *out) |
The capture from the n stamps of a transaction, in the order the program gave them. | |
Cycle counts and divider of the PIO pin driver for the KST wire.
SPDX-License-Identifier: MIT
| void kst_pio_capture | ( | const kst_pio_clock_t * | clock, |
| const kst_pio_run_t * | run, | ||
| const uint32_t * | stamps, | ||
| unsigned | n, | ||
| bool | lost, | ||
| kst_capture_t * | out ) |
The capture from the n stamps of a transaction, in the order the program gave them.
lost says the program gave more stamps than were kept. A first stamp equal to the window count is a line that was high at the first sample: it sets level0 and is no edge. More than KST_CAP_MAX_EDGES edges, lost, and a stamp no count of the stream can give set overflow.
| clock | Counts of the clock. |
| run | Layout of the transaction. |
| stamps | Stamps the program gave, in order. |
| n | Number of stamps. |
| lost | true when the program gave more stamps than were kept. |
| out | Receives the capture. |
| bool kst_pio_clock | ( | uint32_t | sys_hz, |
| kst_pio_clock_t * | out ) |
The counts for a system clock of sys_hz.
False when a tick is longer than KST_PIO_MAX_TICK_NS, which it is below 8 MHz, and when the half-cell the clock gives is more than 0.2% from KST_HALF_CELL_NS. Every clock from 9.9MHz up gives one within 0.2%, and a multiple of 5MHz gives it exactly.
| sys_hz | System clock, in Hz. |
| out | Receives the counts; left unchanged when false is returned. |
| uint32_t kst_pio_half_cell_ns | ( | const kst_pio_clock_t * | clock | ) |
The transmit half-cell of clock in ns, rounded to nearest.
| clock | Counts of the clock. |
| uint32_t kst_pio_tick_ns | ( | const kst_pio_clock_t * | clock | ) |
One tick of clock in ns, rounded up.
| clock | Counts of the clock. |
| unsigned kst_pio_tx | ( | const kst_pio_clock_t * | clock, |
| const kst_frame_t * | frame, | ||
| uint32_t | window_ns, | ||
| uint32_t * | words, | ||
| kst_pio_run_t * | run ) |
The word stream for frame and a capture until window_ns after its last edge.
Returns the number of words written to words, at most KST_PIO_TX_WORDS, or 0 for a frame without half-cells, one longer than KST_FRAME_MAX_HALF_CELLS, or a window that ends before the release.
| clock | Counts of the clock. |
| frame | Frame to send. |
| window_ns | Capture end, in ns after the last edge. |
| words | Receives the word stream. |
| run | Receives the layout of the transaction. |