Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Spektrum sattelite receiver implementation. More...
#include "std.h"
#include "modules/radio_control/spektrum.h"
#include "modules/radio_control/radio_control.h"
#include "modules/core/abi.h"
#include "mcu_periph/uart.h"
#include "mcu_periph/gpio.h"
#include "mcu_periph/sys_time.h"
Go to the source code of this file.
Macros | |
#define | SPEKTRUM_MASTER_RECEIVER_PULSES 5 |
#define | SPEKTRUM_SLAVE_RECEIVER_PULSES 6 |
#define | RC_SET_POLARITY gpio_clear |
#define | SPEKTRUM_BIND_WAIT 60000 |
#define | SPEKTRUM_SYS_TYPE 0 |
#define | SPEKTRUM_SYS_22_1024_2 0x01 |
Allowed system field valaues. More... | |
#define | SPEKTRUM_SYS_11_2048_2 0x12 |
#define | SPEKTRUM_SYS_22_2048_X 0xa2 |
#define | SPEKTRUM_SYS_11_2048_X 0xb2 |
#define | _UART_RX_PORT(i) i ## _PORT_RX |
#define | UART_RX_PORT(i) _UART_RX_PORT(i) |
#define | _UART_RX(i) i ## _RX |
#define | UART_RX(i) _UART_RX(i) |
#define | SPEKTRUM_PRIMARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_PRIMARY_UART_UPPER) |
By default, the same pin is used for pulse train and uart rx, but they can be different if needed. More... | |
#define | SPEKTRUM_PRIMARY_BIND_CONF_PIN UART_RX(SPEKTRUM_PRIMARY_UART_UPPER) |
#define | SPEKTRUM_SECONDARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_SECONDARY_UART_UPPER) |
#define | SPEKTRUM_SECONDARY_BIND_CONF_PIN UART_RX(SPEKTRUM_SECONDARY_UART_UPPER) |
Functions | |
static void | spektrum_bind (void) |
This function puts the satellite in binding mode. More... | |
static void | spektrum_init_sat (struct spektrum_sat_t *sat) |
Initialize a spektrum sattelite. More... | |
void | spektrum_try_bind (void) |
void | spektrum_init (void) |
Main Radio initialization. More... | |
static void | spektrum_parse_channel (struct spektrum_sat_t *sat, uint16_t chan) |
static void | spektrum_parser (struct spektrum_sat_t *sat) |
static void | spektrum_uart_check (struct uart_periph *dev, struct spektrum_sat_t *sat) |
Check bytes on the UART. More... | |
void | spektrum_event (void) |
Checks if there is one valid satellite and sets the radio_control structure. More... | |
Variables | |
const int8_t | spektrum_signs [] = RADIO_CONTROL_SPEKTRUM_SIGNS |
static struct spektrum_t | spektrum |
Spektrum sattelite receiver implementation.
For the protocol specification see: http://www.spektrumrc.com/ProdInfo/Files/Remote%20Receiver%20Interfacing%20Rev%20A.pdf
Definition in file spektrum.c.
#define _UART_RX | ( | i | ) | i ## _RX |
Definition at line 334 of file spektrum.c.
#define _UART_RX_PORT | ( | i | ) | i ## _PORT_RX |
Definition at line 332 of file spektrum.c.
#define RC_SET_POLARITY gpio_clear |
Definition at line 66 of file spektrum.c.
#define SPEKTRUM_BIND_WAIT 60000 |
Definition at line 73 of file spektrum.c.
#define SPEKTRUM_MASTER_RECEIVER_PULSES 5 |
Definition at line 60 of file spektrum.c.
#define SPEKTRUM_PRIMARY_BIND_CONF_PIN UART_RX(SPEKTRUM_PRIMARY_UART_UPPER) |
Definition at line 345 of file spektrum.c.
#define SPEKTRUM_PRIMARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_PRIMARY_UART_UPPER) |
By default, the same pin is used for pulse train and uart rx, but they can be different if needed.
Definition at line 342 of file spektrum.c.
#define SPEKTRUM_SECONDARY_BIND_CONF_PIN UART_RX(SPEKTRUM_SECONDARY_UART_UPPER) |
Definition at line 351 of file spektrum.c.
#define SPEKTRUM_SECONDARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_SECONDARY_UART_UPPER) |
Definition at line 348 of file spektrum.c.
#define SPEKTRUM_SLAVE_RECEIVER_PULSES 6 |
Definition at line 61 of file spektrum.c.
#define SPEKTRUM_SYS_11_2048_2 0x12 |
Definition at line 100 of file spektrum.c.
#define SPEKTRUM_SYS_11_2048_X 0xb2 |
Definition at line 102 of file spektrum.c.
#define SPEKTRUM_SYS_22_1024_2 0x01 |
Allowed system field valaues.
from datasheet, possible values for the frame format encoded in the system field of the internal remote frame (second byte). Only the first one is encoding values on 10bits, other ones on 11bits.
Definition at line 99 of file spektrum.c.
#define SPEKTRUM_SYS_22_2048_X 0xa2 |
Definition at line 101 of file spektrum.c.
#define SPEKTRUM_SYS_TYPE 0 |
Definition at line 80 of file spektrum.c.
#define UART_RX | ( | i | ) | _UART_RX(i) |
Definition at line 335 of file spektrum.c.
#define UART_RX_PORT | ( | i | ) | _UART_RX_PORT(i) |
Definition at line 333 of file spektrum.c.
|
static |
This function puts the satellite in binding mode.
The requirement of this are that this needs to be done while powering up.
Definition at line 357 of file spektrum.c.
References gpio_set(), gpio_setup_input(), gpio_setup_output(), gpio_toggle(), SPEKTRUM_BIND_WAIT, SPEKTRUM_MASTER_RECEIVER_PULSES, SPEKTRUM_PRIMARY_BIND_CONF_PIN, SPEKTRUM_PRIMARY_BIND_CONF_PORT, SPEKTRUM_SECONDARY_BIND_CONF_PIN, SPEKTRUM_SECONDARY_BIND_CONF_PORT, SPEKTRUM_SLAVE_RECEIVER_PULSES, and sys_time_usleep().
Referenced by spektrum_try_bind().
void spektrum_event | ( | void | ) |
Checks if there is one valid satellite and sets the radio_control structure.
Definition at line 287 of file spektrum.c.
References RadioControl::frame_cpt, MAX_PPRZ, RadioControl::nb_channel, radio_control, RADIO_CONTROL_SPEKTRUM_ID, RC_OK, spektrum_t::satellites, spektrum_t::signs, spektrum, SPEKTRUM_SATELLITES_NB, spektrum_uart_check(), RadioControl::status, RadioControl::time_since_last_frame, spektrum_sat_t::valid, spektrum_t::valid, RadioControl::values, and spektrum_sat_t::values.
void spektrum_init | ( | void | ) |
Main Radio initialization.
Definition at line 165 of file spektrum.c.
References gpio_setup_output(), RadioControl::nb_channel, radio_control, RC_POLARITY_GPIO_PIN, RC_POLARITY_GPIO_PORT, RC_SET_POLARITY, spektrum_t::satellites, spektrum_t::signs, spektrum, spektrum_init_sat(), SPEKTRUM_NB_CHANNEL, and spektrum_signs.
|
inlinestatic |
Initialize a spektrum sattelite.
Definition at line 107 of file spektrum.c.
References get_sys_time_msec(), spektrum_sat_t::idx, SPEKTRUM_MAX_CHANNELS, spektrum_sat_t::timer, spektrum_sat_t::valid, and spektrum_sat_t::values.
Referenced by spektrum_init().
|
inlinestatic |
Definition at line 187 of file spektrum.c.
References MAX_PPRZ, RADIO_THROTTLE, spektrum, SPEKTRUM_SYS_22_1024_2, spektrum_t::tx_type, spektrum_sat_t::valid, spektrum_t::valid, and spektrum_sat_t::values.
Referenced by spektrum_parser().
|
inlinestatic |
Definition at line 233 of file spektrum.c.
References spektrum_sat_t::buf, spektrum_sat_t::lost_frame_cnt, spektrum, SPEKTRUM_CHANNELS_PER_FRAME, spektrum_parse_channel(), SPEKTRUM_SYS_11_2048_2, SPEKTRUM_SYS_11_2048_X, SPEKTRUM_SYS_22_1024_2, SPEKTRUM_SYS_22_2048_X, and spektrum_t::tx_type.
Referenced by spektrum_uart_check().
void spektrum_try_bind | ( | void | ) |
Definition at line 127 of file spektrum.c.
References gpio_get(), gpio_setup_input_pulldown(), gpio_setup_input_pullup(), spektrum_bind(), SPEKTRUM_BIND_PIN, SPEKTRUM_BIND_PIN_PORT, and sys_time_usleep().
|
static |
Check bytes on the UART.
Definition at line 259 of file spektrum.c.
References spektrum_sat_t::buf, dev, get_sys_time_msec(), spektrum_sat_t::idx, SPEKTRUM_FRAME_LEN, SPEKTRUM_MIN_FRAME_SPACE, spektrum_parser(), spektrum_sat_t::timer, uart_char_available(), and uart_getch().
Referenced by spektrum_event().
|
static |
Definition at line 84 of file spektrum.c.
Referenced by spektrum_event(), spektrum_init(), spektrum_parse_channel(), and spektrum_parser().
const int8_t spektrum_signs[] = RADIO_CONTROL_SPEKTRUM_SIGNS |
Definition at line 84 of file spektrum.c.
Referenced by spektrum_init().