Skip to content

File syn_sbus.h

FileList > proto > syn_sbus.h

Go to the source code of this file

Zero-Heap SBUS (Futaba/FrSky) 16-Channel Receiver Decoder. More...

  • #include "syntropic/common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_SBUS_Frame
struct SYN_SBUS_Parser

Public Functions

Type Name
SYN_Status syn_sbus_decode_buffer (const uint8_t buf, SYN_SBUS_Frame * frame)
Decode raw 25-byte SBUS frame buffer directly.
SYN_Status syn_sbus_init (SYN_SBUS_Parser * parser)
Initialize SBUS parser state machine.
SYN_Status syn_sbus_parse_byte (SYN_SBUS_Parser * parser, uint8_t byte, SYN_SBUS_Frame * frame)
Process single incoming byte from UART.
uint16_t syn_sbus_raw_to_us (uint16_t raw_val)
Convert raw 11-bit SBUS channel value to pulse width in microseconds (us).

Macros

Type Name
define SYN_SBUS_FRAME_SIZE 25
define SYN_SBUS_HEADER 0x0FU
define SYN_SBUS_NUM_CHANNELS 16

Detailed Description

SBUS Protocol Specifications: * Baud rate: 100,000 bps, 8 data bits, Even parity, 2 stop bits (8E2), Inverted logic. * Frame length: 25 bytes. * Header byte: 0x0F * Channels: 16 11-bit channels (packed bitstream across bytes 1..22, raw range 172..1811, 1000..2000 us). * Flags (byte 23): Channel 17 (bit 0), Channel 18 (bit 1), Frame Loss (bit 2), Failsafe (bit 3). * Footer byte: 0x00 (or 0x04 for endbyte flags).

Public Functions Documentation

function syn_sbus_decode_buffer

Decode raw 25-byte SBUS frame buffer directly.

SYN_Status syn_sbus_decode_buffer (
    const uint8_t buf,
    SYN_SBUS_Frame * frame
) 

Parameters:

  • buf Pointer to 25-byte buffer.
  • frame Pointer to destination frame struct.

Returns:

SYN_OK on successful decode, SYN_INVALID_PARAM or SYN_ERROR on bad header/footer.

Decode raw 25-byte SBUS frame buffer directly.

Parameters:

  • buf Pointer to 25-byte raw SBUS frame buffer.
  • frame Pointer to output SBUS decoded frame structure.

Returns:

SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on header mismatch.


function syn_sbus_init

Initialize SBUS parser state machine.

SYN_Status syn_sbus_init (
    SYN_SBUS_Parser * parser
) 

Parameters:

  • parser Pointer to parser struct.

Returns:

SYN_OK on success.


function syn_sbus_parse_byte

Process single incoming byte from UART.

SYN_Status syn_sbus_parse_byte (
    SYN_SBUS_Parser * parser,
    uint8_t byte,
    SYN_SBUS_Frame * frame
) 

Parameters:

  • parser Pointer to parser struct.
  • byte Incoming serial byte.
  • frame Pointer to output frame struct (populated when a complete valid 25-byte frame is decoded).

Returns:

SYN_OK if complete frame decoded, SYN_BUSY if byte accepted but frame incomplete, SYN_ERROR on header mismatch.


function syn_sbus_raw_to_us

Convert raw 11-bit SBUS channel value to pulse width in microseconds (us).

uint16_t syn_sbus_raw_to_us (
    uint16_t raw_val
) 

Standard mapping: * 172 raw -> 1000 us * 992 raw -> 1500 us * 1811 raw -> 2000 us

Parameters:

  • raw_val 11-bit raw SBUS channel value (172..1811).

Returns:

Pulse width in microseconds (clamped 1000..2000 us).


Macro Definition Documentation

define SYN_SBUS_FRAME_SIZE

#define SYN_SBUS_FRAME_SIZE `25`

Total byte length of standard SBUS frame (25)


define SYN_SBUS_HEADER

#define SYN_SBUS_HEADER `0x0FU`

SBUS frame header marker byte (0x0F)


define SYN_SBUS_NUM_CHANNELS

#define SYN_SBUS_NUM_CHANNELS `16`

Number of analog channels in SBUS frame (16)



The documentation for this class was generated from the following file src/syntropic/proto/syn_sbus.h