Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
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 "mcu_periph/gpio.h"
#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   0x00
 
#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)
 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 53 of file sbus_common.c.

Referenced by sbus_common_init().

#define SBUS_BIT_PER_BYTE   8

Definition at line 38 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_BIT_PER_CHANNEL   11

Definition at line 37 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_END_BYTE   0x00

Definition at line 36 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_FLAGS_BYTE   22

Definition at line 39 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_FRAME_LOST_BIT   2

Definition at line 40 of file sbus_common.c.

Referenced by decode_sbus_buffer().

#define SBUS_START_BYTE   0x0f

Definition at line 35 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_GOT_START   1

Definition at line 43 of file sbus_common.c.

Referenced by sbus_common_decode_event().

#define SBUS_STATUS_UNINIT   0

Definition at line 42 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 76 of file sbus_common.c.

References channel, SBUS_BIT_PER_BYTE, SBUS_BIT_PER_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 
)

Decoding event function.

Definition at line 115 of file sbus_common.c.

References Sbus::buffer, decode_sbus_buffer(), Sbus::frame_available, Sbus::idx, Sbus::ppm, Sbus::pulses, SBUS_BUF_LENGTH, SBUS_END_BYTE, SBUS_START_BYTE, SBUS_STATUS_GOT_START, SBUS_STATUS_UNINIT, Sbus::status, uart_char_available(), and uart_getch().

Referenced by sbus_decode_event(), and sbus_dual_decode_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void sbus_common_init ( struct Sbus sbus_p,
struct uart_periph dev 
)

Init function.

Definition at line 57 of file sbus_common.c.

References B100000, Sbus::frame_available, gpio_setup_output(), RC_POLARITY_GPIO_PIN, RC_POLARITY_GPIO_PORT, RC_SET_POLARITY, SBUS_STATUS_UNINIT, Sbus::status, 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: