Paparazzi UAS  v5.15_devel-111-g8fb4629
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sbus_common.c File Reference

Futaba SBUS decoder. More...

#include "subsystems/radio_control.h"
#include "subsystems/radio_control/sbus_common.h"
#include "mcu_periph/sys_time.h"
#include <BOARD_CONFIG>
#include <string.h>
#include <stdbool.h>
+ Include dependency graph for sbus_common.c:

Go to the source code of this file.

Macros

#define SBUS_START_BYTE   0x0f
 
#define SBUS_END_BYTE_0   0x00
 
#define SBUS_END_BYTE_1   0x04
 
#define SBUS_END_BYTE_2   0x14
 
#define SBUS_END_BYTE_3   0x24
 
#define SBUS_END_BYTE_4   0x34
 
#define SBUS_END_BYTE_5   0x08
 
#define SBUS_BIT_PER_CHANNEL   11
 
#define SBUS_BIT_PER_BYTE   8
 
#define SBUS_FLAGS_BYTE   22
 
#define SBUS_FRAME_LOST_BIT   2
 
#define SBUS_RC_FAILSAFE_BIT   4
 
#define SBUS_RC_LOST_BIT   5
 
#define SBUS_STATUS_UNINIT   0
 
#define SBUS_STATUS_GOT_START   1
 
#define SBUS_TIMEOUT_MS   4
 Time before timeout when receiving a full SBUS frame. More...
 
#define RC_SET_POLARITY   gpio_set
 Set polarity using RC_POLARITY_GPIO. More...
 

Functions

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. More...
 
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. More...
 
void sbus_common_decode_event (struct Sbus *sbus_p, struct uart_periph *dev)
 Decoding event function. More...
 

Detailed Description

Futaba SBUS decoder.

Definition in file sbus_common.c.

Macro Definition Documentation

#define RC_SET_POLARITY   gpio_set

Set polarity using RC_POLARITY_GPIO.

SBUS signal has a reversed polarity compared to normal UART this allows to using hardware UART peripheral by changing the input signal polarity. Setting this gpio ouput high inverts the signal, output low sets it to normal polarity.

Definition at line 67 of file sbus_common.c.

Referenced by sbus_common_init().

#define SBUS_BIT_PER_BYTE   8

Definition at line 44 of file sbus_common.c.

#define SBUS_BIT_PER_CHANNEL   11

Definition at line 43 of file sbus_common.c.

#define SBUS_END_BYTE_0   0x00

Definition at line 37 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_1   0x04

Definition at line 38 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_2   0x14

Definition at line 39 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_3   0x24

Definition at line 40 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_4   0x34

Definition at line 41 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_5   0x08

Definition at line 42 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_FLAGS_BYTE   22

Definition at line 45 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_FRAME_LOST_BIT   2

Definition at line 46 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_RC_FAILSAFE_BIT   4

Definition at line 47 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_RC_LOST_BIT   5

Definition at line 48 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_START_BYTE   0x0f

Definition at line 36 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_GOT_START   1

Definition at line 51 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_UNINIT   0

Definition at line 50 of file sbus_common.c.

Referenced by sbus_common_decode_event(), and sbus_common_init().

#define SBUS_TIMEOUT_MS   4

Time before timeout when receiving a full SBUS frame.

Definition at line 57 of file sbus_common.c.

Referenced by sbus_common_decode_event().

Function Documentation

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 
)
static

Decode the raw buffer.

Definition at line 95 of file sbus_common.c.

References channel, SBUS_FLAGS_BYTE, SBUS_FRAME_LOST_BIT, SBUS_NB_CHANNEL, SBUS_RC_FAILSAFE_BIT, SBUS_RC_LOST_BIT, and USEC_OF_RC_PPM_TICKS.

Referenced by sbus_common_decode_event().

+ Here is the caller graph for this function:

void sbus_common_decode_event ( struct Sbus sbus_p,
struct uart_periph dev 
)
void sbus_common_init ( struct Sbus sbus_p,
struct uart_periph dev,
gpio_port_t  gpio_polarity_port,
uint16_t  gpio_polarity_pin 
)