rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
kst_line.h
Go to the documentation of this file.
1
45#ifndef KST_LINE_H
46#define KST_LINE_H
47
48#include <stdbool.h>
49#include <stdint.h>
50
51#include "kst_pio.h"
52#include "kst_session.h"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
62#define KST_LINE_GRACE_US 1000u
63
72
78typedef struct {
79 kst_pio_clock_t clock;
80 kst_pio_run_t run;
81 void *pio;
82 uint32_t sm;
83 uint32_t offset;
84 uint32_t t_start_us;
85 int8_t dma_tx;
86 int8_t dma_rx;
87 uint8_t pin;
88 uint8_t open;
89 uint8_t busy;
90 uint32_t tx[KST_PIO_TX_WORDS];
91 uint32_t rx[KST_PIO_RX_WORDS];
93
101void kst_line_init(kst_line_t *line);
102
114kst_line_err_t kst_line_open(kst_line_t *line, unsigned pin);
115
124void kst_line_close(kst_line_t *line);
125
132bool kst_line_is_open(const kst_line_t *line);
133
142bool kst_line_busy(const kst_line_t *line);
143
151uint32_t kst_line_half_cell_ns(const kst_line_t *line);
152
161bool kst_line_start(void *ctx, const kst_frame_t *frame, uint32_t window_ns);
169bool kst_line_poll(void *ctx, kst_capture_t *out);
176uint32_t kst_line_now_us(void *ctx);
177
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif /* KST_LINE_H */
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.
Definition kst_line.c:85
uint32_t kst_line_now_us(void *ctx)
Read the microsecond clock; the third of the three driver functions.
Definition kst_line.c:269
bool kst_line_busy(const kst_line_t *line)
A transaction runs: between a start() that returned true and the poll() that returns true.
Definition kst_line.c:182
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.
Definition kst_line.c:187
kst_driver_t kst_line_driver(kst_line_t *line)
The driver for a session on line.
Definition kst_line.c:275
void kst_line_init(kst_line_t *line)
Mark line closed.
Definition kst_line.c:75
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...
Definition kst_line.c:149
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.
Definition kst_line.c:192
bool kst_line_is_open(const kst_line_t *line)
Check whether a line is open.
Definition kst_line.c:177
bool kst_line_poll(void *ctx, kst_capture_t *out)
Poll a transaction; the second of the three driver functions.
Definition kst_line.c:228
kst_line_err_t
Error codes of the KST line driver.
Definition kst_line.h:65
@ KST_LINE_ERR_CLOCK
Definition kst_line.h:68
@ KST_LINE_ERR_PIO
Definition kst_line.h:69
@ KST_LINE_OK
Definition kst_line.h:66
@ KST_LINE_ERR_ARG
Definition kst_line.h:67
@ KST_LINE_ERR_DMA
Definition kst_line.h:70
The numbers and words a PIO pin driver for the KST wire works with.
#define KST_PIO_RX_WORDS
Stamps a transaction keeps: one for a line that is high at the start, KST_CAP_MAX_EDGES edges and one...
Definition kst_pio.h:96
#define KST_PIO_TX_WORDS
Words of the longest stream: 3 counts in front of 4 level words, 3 behind.
Definition kst_pio.h:91
KST servo programming protocol: the session with one servo.
The reply window as the driver saw it.
Definition kst_wire.h:230
The driver: the only way to the wire.
Definition kst_session.h:106
A master frame as line levels, one per half-cell.
Definition kst_wire.h:166
One line.
Definition kst_line.h:78
The counts a system clock gives.
Definition kst_pio.h:99
One transaction, as kst_pio_tx() laid it out.
Definition kst_pio.h:107