Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Futaba SBUS decoder. More...
#include "modules/radio_control/radio_control.h"
#include "modules/radio_control/sbus_common.h"
#include "mcu_periph/sys_time.h"
#include <BOARD_CONFIG>
#include <string.h>
#include <stdbool.h>
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 3 |
#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... | |
Futaba SBUS decoder.
Definition in file sbus_common.c.
#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 71 of file sbus_common.c.
#define SBUS_BIT_PER_BYTE 8 |
Definition at line 48 of file sbus_common.c.
#define SBUS_BIT_PER_CHANNEL 11 |
Definition at line 47 of file sbus_common.c.
#define SBUS_END_BYTE_0 0x00 |
Definition at line 41 of file sbus_common.c.
#define SBUS_END_BYTE_1 0x04 |
Definition at line 42 of file sbus_common.c.
#define SBUS_END_BYTE_2 0x14 |
Definition at line 43 of file sbus_common.c.
#define SBUS_END_BYTE_3 0x24 |
Definition at line 44 of file sbus_common.c.
#define SBUS_END_BYTE_4 0x34 |
Definition at line 45 of file sbus_common.c.
#define SBUS_END_BYTE_5 0x08 |
Definition at line 46 of file sbus_common.c.
#define SBUS_FLAGS_BYTE 22 |
Definition at line 49 of file sbus_common.c.
#define SBUS_FRAME_LOST_BIT 2 |
Definition at line 50 of file sbus_common.c.
#define SBUS_RC_FAILSAFE_BIT 3 |
Definition at line 51 of file sbus_common.c.
#define SBUS_RC_LOST_BIT 5 |
Definition at line 52 of file sbus_common.c.
#define SBUS_START_BYTE 0x0f |
Definition at line 40 of file sbus_common.c.
#define SBUS_STATUS_GOT_START 1 |
Definition at line 55 of file sbus_common.c.
#define SBUS_STATUS_UNINIT 0 |
Definition at line 54 of file sbus_common.c.
#define SBUS_TIMEOUT_MS 4 |
Time before timeout when receiving a full SBUS frame.
Definition at line 61 of file sbus_common.c.
|
static |
Decode the raw buffer.
Definition at line 99 of file sbus_common.c.
References 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().
void sbus_common_decode_event | ( | struct Sbus * | sbus_p, |
struct uart_periph * | dev | ||
) |
Decoding event function.
Definition at line 139 of file sbus_common.c.
References Sbus::buffer, decode_sbus_buffer(), dev, Sbus::frame_available, get_sys_time_msec(), Sbus::idx, Sbus::ppm, Sbus::pulses, Sbus::rc_failsafe, Sbus::rc_lost, SBUS_BUF_LENGTH, SBUS_END_BYTE_0, SBUS_END_BYTE_1, SBUS_END_BYTE_2, SBUS_END_BYTE_3, SBUS_END_BYTE_4, SBUS_END_BYTE_5, SBUS_START_BYTE, SBUS_STATUS_GOT_START, SBUS_STATUS_UNINIT, SBUS_TIMEOUT_MS, Sbus::start_time, Sbus::status, uart_char_available(), and uart_getch().
Referenced by sbus_decode_event(), and sbus_dual_decode_event().
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 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().