rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
kst_pio.h
Go to the documentation of this file.
1
52
#ifndef KST_PIO_H
53
#define KST_PIO_H
54
55
#include <stdbool.h>
56
#include <stdint.h>
57
58
#include "
kst_wire.h
"
59
60
#ifdef __cplusplus
61
extern
"C"
{
62
#endif
63
65
#define KST_PIO_TICK_CYCLES 4u
67
#define KST_PIO_BIT_OVERHEAD 4u
72
#define KST_PIO_LOW_OVERHEAD 2u
74
#define KST_PIO_SAMPLE_LEAD 3u
76
#define KST_PIO_SYNC_CYCLES 2u
77
79
#define KST_PIO_QUIET_NS 165000u
80
82
#define KST_PIO_MAX_TICK_NS 500u
83
85
#define KST_PIO_MAX_ERROR_PPM 2000u
86
91
#define KST_PIO_TX_WORDS 9u
96
#define KST_PIO_RX_WORDS (KST_CAP_MAX_EDGES + 2u)
97
99
typedef
struct
{
100
uint32_t sys_hz;
101
uint32_t
half_cycles
;
102
uint32_t
release_cycles
;
103
uint32_t
quiet_ticks
;
104
}
kst_pio_clock_t
;
105
107
typedef
struct
{
108
uint32_t
window_ns
;
109
uint32_t
window_ticks
;
110
uint32_t
lead_ns
;
111
}
kst_pio_run_t
;
112
125
bool
kst_pio_clock
(uint32_t sys_hz,
kst_pio_clock_t
*out);
126
133
uint32_t
kst_pio_half_cell_ns
(
const
kst_pio_clock_t
*clock);
134
141
uint32_t
kst_pio_tick_ns
(
const
kst_pio_clock_t
*clock);
142
158
unsigned
kst_pio_tx
(
const
kst_pio_clock_t
*clock,
const
kst_frame_t
*frame,
159
uint32_t window_ns, uint32_t *words,
kst_pio_run_t
*run);
160
177
void
kst_pio_capture
(
const
kst_pio_clock_t
*clock,
const
kst_pio_run_t
*run,
178
const
uint32_t *stamps,
unsigned
n,
bool
lost,
179
kst_capture_t
*out);
180
181
#ifdef __cplusplus
182
}
183
#endif
184
185
#endif
/* KST_PIO_H */
kst_pio_tx
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.
Definition
kst_pio.c:75
kst_pio_tick_ns
uint32_t kst_pio_tick_ns(const kst_pio_clock_t *clock)
One tick of clock in ns, rounded up.
Definition
kst_pio.c:60
kst_pio_capture
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.
Definition
kst_pio.c:128
kst_pio_half_cell_ns
uint32_t kst_pio_half_cell_ns(const kst_pio_clock_t *clock)
The transmit half-cell of clock in ns, rounded to nearest.
Definition
kst_pio.c:55
kst_pio_clock
bool kst_pio_clock(uint32_t sys_hz, kst_pio_clock_t *out)
The counts for a system clock of sys_hz.
Definition
kst_pio.c:25
kst_wire.h
KST servo programming protocol: frames and the reply decoder.
kst_capture_t
The reply window as the driver saw it.
Definition
kst_wire.h:230
kst_frame_t
A master frame as line levels, one per half-cell.
Definition
kst_wire.h:166
kst_pio_clock_t
The counts a system clock gives.
Definition
kst_pio.h:99
kst_pio_clock_t::half_cycles
uint32_t half_cycles
Definition
kst_pio.h:101
kst_pio_clock_t::release_cycles
uint32_t release_cycles
Definition
kst_pio.h:102
kst_pio_clock_t::quiet_ticks
uint32_t quiet_ticks
Definition
kst_pio.h:103
kst_pio_run_t
One transaction, as kst_pio_tx() laid it out.
Definition
kst_pio.h:107
kst_pio_run_t::window_ticks
uint32_t window_ticks
Definition
kst_pio.h:109
kst_pio_run_t::window_ns
uint32_t window_ns
Definition
kst_pio.h:108
kst_pio_run_t::lead_ns
uint32_t lead_ns
Definition
kst_pio.h:110
protocols
kst
include
kst_pio.h
Generated by
1.18.0