APM:Libraries
Classes | Macros | Functions | Variables
sbus.cpp File Reference
#include <stdint.h>
#include "sbus.h"
Include dependency graph for sbus.cpp:

Go to the source code of this file.

Classes

struct  sbus_bit_pick
 

Macros

#define SBUS_FRAME_SIZE   25
 
#define SBUS_INPUT_CHANNELS   16
 
#define SBUS_FLAGS_BYTE   23
 
#define SBUS_FAILSAFE_BIT   3
 
#define SBUS_FRAMELOST_BIT   2
 
#define SBUS_RANGE_MIN   200.0f
 
#define SBUS_RANGE_MAX   1800.0f
 
#define SBUS_TARGET_MIN   1000.0f
 
#define SBUS_TARGET_MAX   2000.0f
 
#define SBUS_SCALE_FACTOR   ((SBUS_TARGET_MAX - SBUS_TARGET_MIN) / (SBUS_RANGE_MAX - SBUS_RANGE_MIN))
 
#define SBUS_SCALE_OFFSET   (int)(SBUS_TARGET_MIN - (SBUS_SCALE_FACTOR * SBUS_RANGE_MIN + 0.5f))
 

Functions

bool sbus_decode (const uint8_t frame[25], uint16_t *values, uint16_t *num_values, bool *sbus_failsafe, bool *sbus_frame_drop, uint16_t max_values)
 

Variables

static const struct sbus_bit_pick sbus_decoder [SBUS_INPUT_CHANNELS][3]
 

Macro Definition Documentation

◆ SBUS_FAILSAFE_BIT

#define SBUS_FAILSAFE_BIT   3

Definition at line 45 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_FLAGS_BYTE

#define SBUS_FLAGS_BYTE   23

Definition at line 44 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_FRAME_SIZE

#define SBUS_FRAME_SIZE   25

Definition at line 42 of file sbus.cpp.

◆ SBUS_FRAMELOST_BIT

#define SBUS_FRAMELOST_BIT   2

Definition at line 46 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_INPUT_CHANNELS

#define SBUS_INPUT_CHANNELS   16

Definition at line 43 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_RANGE_MAX

#define SBUS_RANGE_MAX   1800.0f

Definition at line 50 of file sbus.cpp.

◆ SBUS_RANGE_MIN

#define SBUS_RANGE_MIN   200.0f

Definition at line 49 of file sbus.cpp.

◆ SBUS_SCALE_FACTOR

#define SBUS_SCALE_FACTOR   ((SBUS_TARGET_MAX - SBUS_TARGET_MIN) / (SBUS_RANGE_MAX - SBUS_RANGE_MIN))

Definition at line 56 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_SCALE_OFFSET

#define SBUS_SCALE_OFFSET   (int)(SBUS_TARGET_MIN - (SBUS_SCALE_FACTOR * SBUS_RANGE_MIN + 0.5f))

Definition at line 57 of file sbus.cpp.

Referenced by sbus_decode().

◆ SBUS_TARGET_MAX

#define SBUS_TARGET_MAX   2000.0f

Definition at line 53 of file sbus.cpp.

◆ SBUS_TARGET_MIN

#define SBUS_TARGET_MIN   1000.0f

Definition at line 52 of file sbus.cpp.

Function Documentation

◆ sbus_decode()

bool sbus_decode ( const uint8_t  frame[25],
uint16_t *  values,
uint16_t *  num_values,
bool *  sbus_failsafe,
bool *  sbus_frame_drop,
uint16_t  max_values 
)

Definition at line 97 of file sbus.cpp.

Variable Documentation

◆ sbus_decoder

const struct sbus_bit_pick sbus_decoder[SBUS_INPUT_CHANNELS][3]
static
Initial value:
= {
{ { 0, 0, 0xff, 0}, { 1, 0, 0x07, 8}, { 0, 0, 0x00, 0} },
{ { 1, 3, 0x1f, 0}, { 2, 0, 0x3f, 5}, { 0, 0, 0x00, 0} },
{ { 2, 6, 0x03, 0}, { 3, 0, 0xff, 2}, { 4, 0, 0x01, 10} },
{ { 4, 1, 0x7f, 0}, { 5, 0, 0x0f, 7}, { 0, 0, 0x00, 0} },
{ { 5, 4, 0x0f, 0}, { 6, 0, 0x7f, 4}, { 0, 0, 0x00, 0} },
{ { 6, 7, 0x01, 0}, { 7, 0, 0xff, 1}, { 8, 0, 0x03, 9} },
{ { 8, 2, 0x3f, 0}, { 9, 0, 0x1f, 6}, { 0, 0, 0x00, 0} },
{ { 9, 5, 0x07, 0}, {10, 0, 0xff, 3}, { 0, 0, 0x00, 0} },
{ {11, 0, 0xff, 0}, {12, 0, 0x07, 8}, { 0, 0, 0x00, 0} },
{ {12, 3, 0x1f, 0}, {13, 0, 0x3f, 5}, { 0, 0, 0x00, 0} },
{ {13, 6, 0x03, 0}, {14, 0, 0xff, 2}, {15, 0, 0x01, 10} },
{ {15, 1, 0x7f, 0}, {16, 0, 0x0f, 7}, { 0, 0, 0x00, 0} },
{ {16, 4, 0x0f, 0}, {17, 0, 0x7f, 4}, { 0, 0, 0x00, 0} },
{ {17, 7, 0x01, 0}, {18, 0, 0xff, 1}, {19, 0, 0x03, 9} },
{ {19, 2, 0x3f, 0}, {20, 0, 0x1f, 6}, { 0, 0, 0x00, 0} },
{ {20, 5, 0x07, 0}, {21, 0, 0xff, 3}, { 0, 0, 0x00, 0} }
}

Definition at line 76 of file sbus.cpp.