33#if RADIO_CONTROL_NB_CHANNEL < SBUS_NB_CHANNEL
34#error "RADIO_CONTROL_NB_CHANNEL mustn't be lower than 16."
40#define SBUS_START_BYTE 0x0f
41#define SBUS_END_BYTE_0 0x00
42#define SBUS_END_BYTE_1 0x04
43#define SBUS_END_BYTE_2 0x14
44#define SBUS_END_BYTE_3 0x24
45#define SBUS_END_BYTE_4 0x34
46#define SBUS_END_BYTE_5 0x08
47#define SBUS_BIT_PER_CHANNEL 11
48#define SBUS_BIT_PER_BYTE 8
49#define SBUS_FLAGS_BYTE 22
50#define SBUS_FRAME_LOST_BIT 2
51#define SBUS_RC_FAILSAFE_BIT 3
52#define SBUS_RC_LOST_BIT 5
54#define SBUS_STATUS_UNINIT 0
55#define SBUS_STATUS_GOT_START 1
61#define SBUS_TIMEOUT_MS 4
70#ifndef RC_SET_POLARITY
71#define RC_SET_POLARITY gpio_set
78 sbus_p->frame_available =
false;
79 sbus_p->rc_failsafe =
true;
104 dst[0] = ((
src[0]) | (
src[1] << 8)) & 0x07FF;
105 dst[1] = ((
src[1] >> 3) | (
src[2] << 5)) & 0x07FF;
106 dst[2] = ((
src[2] >> 6) | (
src[3] << 2) | (
src[4] << 10)) & 0x07FF;
107 dst[3] = ((
src[4] >> 1) | (
src[5] << 7)) & 0x07FF;
108 dst[4] = ((
src[5] >> 4) | (
src[6] << 4)) & 0x07FF;
109 dst[5] = ((
src[6] >> 7) | (
src[7] << 1) | (
src[8] << 9)) & 0x07FF;
110 dst[6] = ((
src[8] >> 2) | (
src[9] << 6)) & 0x07FF;
111 dst[7] = ((
src[9] >> 5) | (
src[10] << 3)) & 0x07FF;
112 dst[8] = ((
src[11]) | (
src[12] << 8)) & 0x07FF;
113 dst[9] = ((
src[12] >> 3) | (
src[13] << 5)) & 0x07FF;
114 dst[10] = ((
src[13] >> 6) | (
src[14] << 2) | (
src[15] << 10)) & 0x07FF;
115 dst[11] = ((
src[15] >> 1) | (
src[16] << 7)) & 0x07FF;
116 dst[12] = ((
src[16] >> 4) | (
src[17] << 4)) & 0x07FF;
117 dst[13] = ((
src[17] >> 7) | (
src[18] << 1) | (
src[19] << 9)) & 0x07FF;
118 dst[14] = ((
src[19] >> 2) | (
src[20] << 6)) & 0x07FF;
119 dst[15] = ((
src[20] >> 5) | (
src[21] << 3)) & 0x07FF;
122#if PERIODIC_TELEMETRY
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
ioportid_t gpio_port_t
Abstract gpio port type for hardware independent part.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
#define USEC_OF_RC_PPM_TICKS(_v)
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
void uart_periph_set_bits_stop_parity(struct uart_periph *periph, uint8_t bits, uint8_t stop, uint8_t parity)
uint8_t uart_getch(struct uart_periph *p)
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
Generic interface for radio control modules.
void sbus_common_init(struct Sbus *sbus_p, struct uart_periph *dev, gpio_port_t gpio_polarity_port, uint16_t gpio_polarity_pin)
Init function.
void sbus_common_decode_event(struct Sbus *sbus_p, struct uart_periph *dev)
Decoding event function.
#define SBUS_RC_FAILSAFE_BIT
#define RC_SET_POLARITY
Set polarity using RC_POLARITY_GPIO.
#define SBUS_STATUS_UNINIT
#define SBUS_STATUS_GOT_START
static void decode_sbus_buffer(const uint8_t *src, uint16_t *dst, bool *is_frame_available, bool *is_rc_failsafe, bool *is_rc_lost, uint16_t *dstppm)
Decode the raw buffer.
#define SBUS_TIMEOUT_MS
Time before timeout when receiving a full SBUS frame.
#define SBUS_FRAME_LOST_BIT
Common sbus structs and defines.
#define SBUS_BUF_LENGTH
Generated code holding the description of a given transmitter.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
void WEAK uart_periph_invert_data_logic(struct uart_periph *p, bool invert_rx, bool invert_tx)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.