Files

36 lines
848 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file sbus.h
* @brief SBUS decoder for receiver telemetry input
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* SBUS frame structure (25 bytes) */
typedef struct __attribute__((packed)) {
uint8_t start_byte; /* 0x0F */
uint8_t channel_data[22]; /* 16 channels × 11 bit = 176 bit */
uint8_t flags; /* CH17, CH18, failsafe, lost frame */
uint8_t end_byte; /* 0x00 */
} sbus_frame_t;
/* SBUS flags */
#define SBUS_FLAG_CH17 (1 << 0)
#define SBUS_FLAG_CH18 (1 << 1)
#define SBUS_FLAG_LOST_FRAME (1 << 2)
#define SBUS_FLAG_FAILSAFE (1 << 3)
/* Initialize SBUS decoder */
void sbus_init(void);
/* Decode SBUS frame into channel values */
void sbus_decode(const sbus_frame_t *frame, uint16_t *channels, uint8_t *flags);
#ifdef __cplusplus
}
#endif