rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
sbus.h
Go to the documentation of this file.
1
31
32
#ifndef RCBENCH_SBUS_H
33
#define RCBENCH_SBUS_H
34
35
#include <stdbool.h>
36
#include <stdint.h>
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
43
#define SBUS_FRAME_BYTES 25u
44
#define SBUS_HEADER 0x0Fu
45
#define SBUS_CHANNELS 16u
46
48
#define SBUS_RAW_MIN 0u
49
#define SBUS_RAW_MAX 2047u
50
58
#define SBUS_RAW_1000US 172u
59
#define SBUS_RAW_2000US 1811u
60
68
#define SBUS_GAP_US 2000u
69
71
#define SBUS_FLAG_CH17 0x01u
72
#define SBUS_FLAG_CH18 0x02u
73
#define SBUS_FLAG_FRAME_LOST 0x04u
74
#define SBUS_FLAG_FAILSAFE 0x08u
75
77
typedef
struct
{
78
uint16_t
channel
[
SBUS_CHANNELS
];
79
bool
ch17
;
80
bool
ch18
;
82
bool
frame_lost
;
87
bool
failsafe
;
88
}
sbus_frame_t
;
89
91
typedef
struct
{
92
uint8_t
buf
[
SBUS_FRAME_BYTES
];
93
uint8_t
len
;
94
uint32_t
last_byte_us
;
95
bool
have_time
;
96
97
/* Diagnostics, for the analyser view. */
98
uint32_t frames;
99
uint32_t
resyncs
;
100
uint32_t
bad_footer
;
101
}
sbus_decoder_t
;
102
108
void
sbus_decoder_reset
(
sbus_decoder_t
*d);
109
124
bool
sbus_decode_byte
(
sbus_decoder_t
*d, uint8_t
byte
, uint32_t now_us,
125
sbus_frame_t
*out);
126
133
uint16_t
sbus_to_us
(uint16_t raw);
134
135
#ifdef __cplusplus
136
}
137
#endif
138
139
#endif
/* RCBENCH_SBUS_H */
SBUS_FRAME_BYTES
#define SBUS_FRAME_BYTES
Frame layout: byte count, header byte and channel count.
Definition
sbus.h:43
sbus_to_us
uint16_t sbus_to_us(uint16_t raw)
Microseconds for a raw channel value, clamped to a sane pulse.
Definition
sbus.c:113
SBUS_CHANNELS
#define SBUS_CHANNELS
Definition
sbus.h:45
sbus_decode_byte
bool sbus_decode_byte(sbus_decoder_t *d, uint8_t byte, uint32_t now_us, sbus_frame_t *out)
Feed one byte with the time it arrived; true when out holds a frame.
Definition
sbus.c:57
sbus_decoder_reset
void sbus_decoder_reset(sbus_decoder_t *d)
Clear a decoder, including its diagnostic counters.
Definition
sbus.c:26
sbus_decoder_t
Decoder state for one S.BUS byte stream.
Definition
sbus.h:91
sbus_decoder_t::resyncs
uint32_t resyncs
Definition
sbus.h:99
sbus_decoder_t::last_byte_us
uint32_t last_byte_us
Definition
sbus.h:94
sbus_decoder_t::have_time
bool have_time
Definition
sbus.h:95
sbus_decoder_t::buf
uint8_t buf[SBUS_FRAME_BYTES]
Definition
sbus.h:92
sbus_decoder_t::bad_footer
uint32_t bad_footer
Definition
sbus.h:100
sbus_decoder_t::len
uint8_t len
Definition
sbus.h:93
sbus_frame_t
One decoded S.BUS frame.
Definition
sbus.h:77
sbus_frame_t::ch17
bool ch17
Definition
sbus.h:79
sbus_frame_t::channel
uint16_t channel[SBUS_CHANNELS]
Definition
sbus.h:78
sbus_frame_t::ch18
bool ch18
Definition
sbus.h:80
sbus_frame_t::failsafe
bool failsafe
The receiver has lost the transmitter and is generating these values.
Definition
sbus.h:87
sbus_frame_t::frame_lost
bool frame_lost
This frame did not arrive intact at the receiver.
Definition
sbus.h:82
protocols
sbus
include
sbus.h
Generated by
1.18.0