|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The KST wire on one RP2350 pin. More...
#include "kst_line.h"#include <string.h>#include "hardware/clocks.h"#include "hardware/dma.h"#include "hardware/gpio.h"#include "hardware/pio.h"#include "hardware/timer.h"#include "pico.h"#include "kst_line.pio.h"Macros | |
| #define | IDLE_PC 1u |
| The instruction the state machine stalls on between transactions. | |
| #define | DMA_COUNT_MASK 0x0FFFFFFFu |
| A transfer count's low 28 bits are the count; the rest is the mode. | |
Functions | |
| static PIO | line_pio (const kst_line_t *l) |
| Get the PIO block of a line. | |
| static bool | line_idle (const kst_line_t *l) |
| The state machine waits for a stream: it stalls on the first out, the FIFO is empty and the channel has handed over every word. | |
| static void | line_restart (kst_line_t *l) |
| Put the state machine at the start of the program with the pad driven low, whatever it was doing. | |
| void | kst_line_init (kst_line_t *line) |
Mark line closed. | |
| kst_line_err_t | kst_line_open (kst_line_t *line, unsigned pin) |
Claim the resources and take pin: from the return on the pad drives low. | |
| void | kst_line_close (kst_line_t *line) |
| Stop the state machine, give back what the open claimed and leave the pad an input with its pull-down on. | |
| bool | kst_line_is_open (const kst_line_t *line) |
| Check whether a line is open. | |
| bool | kst_line_busy (const kst_line_t *line) |
| A transaction runs: between a start() that returned true and the poll() that returns true. | |
| uint32_t | kst_line_half_cell_ns (const kst_line_t *line) |
| The transmit half-cell the system clock gives, in ns; 0 on a closed line. | |
| bool | kst_line_start (void *ctx, const kst_frame_t *frame, uint32_t window_ns) |
The three functions of kst_driver_t; ctx is the kst_line_t. | |
| bool | kst_line_poll (void *ctx, kst_capture_t *out) |
| Poll a transaction; the second of the three driver functions. | |
| uint32_t | kst_line_now_us (void *ctx) |
| Read the microsecond clock; the third of the three driver functions. | |
| kst_driver_t | kst_line_driver (kst_line_t *line) |
The driver for a session on line. | |
| bool kst_line_busy | ( | const kst_line_t * | line | ) |
A transaction runs: between a start() that returned true and the poll() that returns true.
| line | Line object. |
| void kst_line_close | ( | kst_line_t * | line | ) |
Stop the state machine, give back what the open claimed and leave the pad an input with its pull-down on.
A transaction on the wire is cut. Safe on a closed line.
| line | Line object. |
| kst_driver_t kst_line_driver | ( | kst_line_t * | line | ) |
The driver for a session on line.
| line | Line object. |
| uint32_t kst_line_half_cell_ns | ( | const kst_line_t * | line | ) |
The transmit half-cell the system clock gives, in ns; 0 on a closed line.
| line | Line object. |
| void kst_line_init | ( | kst_line_t * | line | ) |
Mark line closed.
Call once, before the first open.
| line | Line object to mark closed. |
| bool kst_line_is_open | ( | const kst_line_t * | line | ) |
Check whether a line is open.
| line | Line object. |
| uint32_t kst_line_now_us | ( | void * | ctx | ) |
Read the microsecond clock; the third of the three driver functions.
| ctx | The kst_line_t. |
| kst_line_err_t kst_line_open | ( | kst_line_t * | line, |
| unsigned | pin ) |
Claim the resources and take pin: from the return on the pad drives low.
The caller has stopped every other use of the pin. On an error nothing stays claimed and the pin is not touched. An open line is closed first.
| line | Line object. |
| pin | GPIO number. |
| bool kst_line_poll | ( | void * | ctx, |
| kst_capture_t * | out ) |
Poll a transaction; the second of the three driver functions.
| ctx | The kst_line_t. |
| out | Receives the capture when the transaction has ended. |
| bool kst_line_start | ( | void * | ctx, |
| const kst_frame_t * | frame, | ||
| uint32_t | window_ns ) |
The three functions of kst_driver_t; ctx is the kst_line_t.
| ctx | The kst_line_t. |
| frame | Frame to send. |
| window_ns | Capture end, in ns after the last edge. |
|
static |
The state machine waits for a stream: it stalls on the first out, the FIFO is empty and the channel has handed over every word.
A stream is 6 words or more and the FIFO and the shift register hold 5, so this is false from the start of a transfer to the end of the capture.