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.h File Reference

Common sbus structs and defines. More...

#include "std.h"
#include "mcu_periph/uart.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
 
#define RADIO_CONTROL_NB_CHANNEL   SBUS_NB_CHANNEL
 Default number of channels to actually use. More...
 
#define RadioControlEvent(_received_frame_handler)   radio_control_impl_event(_received_frame_handler)
 Event macro with handler callback. More...
 

Functions

void sbus_common_init (struct Sbus *sbus, struct uart_periph *dev)
 Init function. More...
 
void sbus_common_decode_event (struct Sbus *sbus, struct uart_periph *dev)
 Decoding event function. More...
 
void radio_control_impl_event (void(*_received_frame_handler)(void))
 RC event function with handler callback. More...
 

Detailed Description

Common sbus structs and defines.

Definition in file sbus_common.h.


Data Structure Documentation

struct Sbus

SBUS structure.

Definition at line 78 of file sbus_common.h.

Data Fields
uint8_t buffer[SBUS_BUF_LENGTH] input buffer
bool frame_available new frame available
uint8_t idx input index
uint16_t ppm[SBUS_NB_CHANNEL] decoded and converted values
uint16_t pulses[SBUS_NB_CHANNEL] decoded values
uint8_t status decoder state machine status

Macro Definition Documentation

#define RADIO_CONTROL_NB_CHANNEL   SBUS_NB_CHANNEL

Default number of channels to actually use.

Definition at line 68 of file sbus_common.h.

#define RadioControlEvent (   _received_frame_handler)    radio_control_impl_event(_received_frame_handler)

Event macro with handler callback.

Definition at line 106 of file sbus_common.h.

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

Definition at line 43 of file sbus_common.h.

#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 42 of file sbus_common.h.

#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 61 of file sbus_common.h.

Referenced by sbus_common_decode_event().

#define SBUS_NB_CHANNEL   16

Definition at line 62 of file sbus_common.h.

Referenced by decode_sbus_buffer(), and send_sbus().

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

Definition at line 44 of file sbus_common.h.

Function Documentation

void radio_control_impl_event ( void(*)(void)  _received_frame_handler)

RC event function with handler callback.

PPM frames are normalized using the IIR filter.

Definition at line 80 of file ppm.c.

void sbus_common_decode_event ( struct Sbus sbus,
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,
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: