Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
sbus_common.h File Reference

Common sbus structs and defines. More...

#include "std.h"
#include "mcu_periph/uart.h"
#include "mcu_periph/gpio.h"
#include "generated/airframe.h"
#include "generated/radio.h"
+ Include dependency graph for sbus_common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Sbus
 SBUS structure. More...
 

Macros

#define RC_PPM_TICKS_OF_USEC(_v)   ((((_v) - 880) * 8) / 5)
 Macro to use radio.h file. More...
 
#define RC_PPM_SIGNED_TICKS_OF_USEC(_v)   (((_v) * 8) / 5)
 
#define USEC_OF_RC_PPM_TICKS(_v)   ((((_v) * 5) / 8) + 880)
 
#define SBUS_BUF_LENGTH   24
 Generated code holding the description of a given transmitter. More...
 
#define SBUS_NB_CHANNEL   16
 

Functions

void sbus_common_init (struct Sbus *sbus, struct uart_periph *dev, gpio_port_t gpio_polarity_port, uint16_t gpio_polarity_pin)
 Init function. More...
 
void sbus_common_decode_event (struct Sbus *sbus, struct uart_periph *dev)
 Decoding event function. More...
 

Detailed Description

Common sbus structs and defines.

Definition in file sbus_common.h.


Data Structure Documentation

◆ Sbus

struct Sbus

SBUS structure.

Definition at line 68 of file sbus_common.h.

Data Fields
uint8_t buffer[SBUS_BUF_LENGTH] Input buffer.
bool frame_available A data frame is available.
uint8_t idx Input index.
uint16_t ppm[SBUS_NB_CHANNEL] Decoded and converted to ppm values.
uint16_t pulses[SBUS_NB_CHANNEL] Decoded values.
bool rc_failsafe Receiver set to in failsafe mode.
bool rc_lost RC reception is lost.
uint32_t start_time Decoder start time.
uint8_t status Decoder state-machine status.

Macro Definition Documentation

◆ RC_PPM_SIGNED_TICKS_OF_USEC

#define RC_PPM_SIGNED_TICKS_OF_USEC (   _v)    (((_v) * 8) / 5)

Definition at line 44 of file sbus_common.h.

◆ RC_PPM_TICKS_OF_USEC

#define RC_PPM_TICKS_OF_USEC (   _v)    ((((_v) - 880) * 8) / 5)

Macro to use radio.h file.

SBUS: 0..1024..2047 (sweep 2048) PPM: 880..1520..2160 (sweep 1280)

Definition at line 43 of file sbus_common.h.

◆ SBUS_BUF_LENGTH

#define SBUS_BUF_LENGTH   24

Generated code holding the description of a given transmitter.

Define number of channels.

SBUS frame always have 16 channels but only the X first one will be available depending of the RC transmitter. The radio XML file is used to assign the input values to RC channels.

Definition at line 62 of file sbus_common.h.

◆ SBUS_NB_CHANNEL

#define SBUS_NB_CHANNEL   16

Definition at line 63 of file sbus_common.h.

◆ USEC_OF_RC_PPM_TICKS

#define USEC_OF_RC_PPM_TICKS (   _v)    ((((_v) * 5) / 8) + 880)

Definition at line 45 of file sbus_common.h.

Function Documentation

◆ sbus_common_decode_event()

void sbus_common_decode_event ( struct Sbus sbus,
struct uart_periph dev 
)

◆ sbus_common_init()

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

Init function.

Definition at line 74 of file sbus_common.c.

References B100000, dev, Sbus::frame_available, gpio_setup_output(), Sbus::rc_failsafe, Sbus::rc_lost, RC_SET_POLARITY, SBUS_STATUS_UNINIT, Sbus::start_time, 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 sbus_dual_init(), and sbus_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: