Paparazzi UAS  v5.12_stable-4-g9b43e9b
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 <BOARD_CONFIG>
#include <string.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_STATUS_UNINIT   0
 
#define SBUS_STATUS_GOT_START   1
 
#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 *available, 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 57 of file sbus_common.c.

Referenced by sbus_common_init().

#define SBUS_BIT_PER_BYTE   8

Definition at line 42 of file sbus_common.c.

#define SBUS_BIT_PER_CHANNEL   11

Definition at line 41 of file sbus_common.c.

#define SBUS_END_BYTE_0   0x00

Definition at line 35 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_1   0x04

Definition at line 36 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_2   0x14

Definition at line 37 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_3   0x24

Definition at line 38 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_4   0x34

Definition at line 39 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_END_BYTE_5   0x08

Definition at line 40 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_FLAGS_BYTE   22

Definition at line 43 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_FRAME_LOST_BIT   2

Definition at line 44 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_START_BYTE   0x0f

Definition at line 34 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_GOT_START   1

Definition at line 47 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_UNINIT   0

Definition at line 46 of file sbus_common.c.

Referenced by sbus_common_decode_event(), and sbus_common_init().

Function Documentation

static void decode_sbus_buffer ( const uint8_t src,
uint16_t dst,
bool *  available,
uint16_t dstppm 
)
static

Decode the raw buffer.

Definition at line 83 of file sbus_common.c.

References channel, SBUS_FLAGS_BYTE, SBUS_FRAME_LOST_BIT, SBUS_NB_CHANNEL, 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 
)

Init function.

Definition at line 61 of file sbus_common.c.

References B100000, Sbus::frame_available, gpio_setup_output(), RC_SET_POLARITY, SBUS_STATUS_UNINIT, Sbus::status, uart_periph_invert_data_logic(), uart_periph_set_baudrate(), uart_periph_set_bits_stop_parity(), UBITS_8, UPARITY_EVEN, and USTOP_2.

Referenced by radio_control_impl_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: