|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
40 #ifndef SPEKTRUM_PRIMARY_UART
41 #error "You must at least define the primary Spektrum satellite receiver."
53 #define SPEKTRUM_MASTER_RECEIVER_PULSES 9 // only one receiver should be in master mode
54 #define SPEKTRUM_SLAVE_RECEIVER_PULSES 10
56 #define SPEKTRUM_MASTER_RECEIVER_PULSES 5 // only one receiver should be in master mode
57 #define SPEKTRUM_SLAVE_RECEIVER_PULSES 6
61 #ifndef RC_SET_POLARITY
62 #define RC_SET_POLARITY gpio_clear
68 #ifndef SPEKTRUM_BIND_WAIT
69 #define SPEKTRUM_BIND_WAIT 60000
75 #ifndef SPEKTRUM_SYS_TYPE
76 #define SPEKTRUM_SYS_TYPE 0 // unknown type, determined from incoming frame
95 #define SPEKTRUM_SYS_22_1024_2 0x01 // 22ms 1024 DSM2
96 #define SPEKTRUM_SYS_11_2048_2 0x12 // 11ms 2048 DSM2
97 #define SPEKTRUM_SYS_22_2048_X 0xa2 // 22ms 2048 DSMX
98 #define SPEKTRUM_SYS_11_2048_X 0xb2 // 11ms 2048 DSMX
125 #ifdef SPEKTRUM_BIND_PIN_PORT
126 #ifdef SPEKTRUM_BIND_PIN_HIGH
169 #ifdef RC_POLARITY_GPIO_PORT
176 #ifdef SPEKTRUM_SECONDARY_UART
185 if (chan == 0xFFFF) {
191 uint8_t chan_num = (chan & 0xFC00) >> 10;
192 sat->
values[chan_num] = chan & 0x03FF;
199 sat->
values[chan_num] -= (1 << 9);
207 uint8_t chan_num = (chan & 0x7800) >> 11;
208 sat->
values[chan_num] = chan & 0x07FF;
215 sat->
values[chan_num] -= (1 << 10);
263 for (
uint8_t i = 0; i < bytes_cnt; i++) {
286 #ifdef SPEKTRUM_SECONDARY_UART
327 #define _UART_RX_PORT(i) i ## _PORT_RX
328 #define UART_RX_PORT(i) _UART_RX_PORT(i)
329 #define _UART_RX(i) i ## _RX
330 #define UART_RX(i) _UART_RX(i)
336 #ifndef SPEKTRUM_PRIMARY_BIND_CONF_PORT
337 #define SPEKTRUM_PRIMARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_PRIMARY_UART_UPPER)
339 #ifndef SPEKTRUM_PRIMARY_BIND_CONF_PIN
340 #define SPEKTRUM_PRIMARY_BIND_CONF_PIN UART_RX(SPEKTRUM_PRIMARY_UART_UPPER)
342 #ifndef SPEKTRUM_SECONDARY_BIND_CONF_PORT
343 #define SPEKTRUM_SECONDARY_BIND_CONF_PORT UART_RX_PORT(SPEKTRUM_SECONDARY_UART_UPPER)
345 #ifndef SPEKTRUM_SECONDARY_BIND_CONF_PIN
346 #define SPEKTRUM_SECONDARY_BIND_CONF_PIN UART_RX(SPEKTRUM_SECONDARY_UART_UPPER)
360 #ifdef SPEKTRUM_SECONDARY_UART
370 #if SPEKTRUM_BIND_WAIT
379 #ifdef SPEKTRUM_SECONDARY_UART
388 #ifdef SPEKTRUM_SECONDARY_UART
#define SPEKTRUM_SLAVE_RECEIVER_PULSES
#define RC_POLARITY_GPIO_PIN
#define SPEKTRUM_BIND_WAIT
#define RADIO_CONTROL_SPEKTRUM_SIGNS
static struct spektrum_t spektrum
#define SPEKTRUM_SATELLITES_NB
uint8_t uart_getch(struct uart_periph *p)
bool valid
True when we received a packet else false.
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
uint8_t tx_type
Transmitter type encoded (see wiki)
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
int8_t signs[RADIO_CONTROL_NB_CHANNEL]
Signs for the RC channels.
#define SPEKTRUM_SYS_22_2048_X
uint8_t time_since_last_frame
static void spektrum_parse_channel(struct spektrum_sat_t *sat, uint16_t chan)
uint8_t buf[SPEKTRUM_FRAME_LEN]
input buffer
#define SPEKTRUM_FRAME_LEN
16 bytes in a standard frame
static void spektrum_parser(struct spektrum_sat_t *sat)
void spektrum_try_bind(void)
#define SPEKTRUM_MAX_CHANNELS
struct spektrum_sat_t satellites[SPEKTRUM_SATELLITES_NB]
All the satellites connected.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void gpio_setup_input_pulldown(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull down resistors enabled.
uint8_t idx
input buffer index
#define SPEKTRUM_SYS_TYPE
void gpio_setup_input(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
#define SPEKTRUM_MIN_FRAME_SPACE
Minum amount of time between frames (7ms), in fact either 11 or 22 ms.
#define SPEKTRUM_MASTER_RECEIVER_PULSES
#define SPEKTRUM_BIND_PIN
static const struct usb_device_descriptor dev
#define SPEKTRUM_PRIMARY_BIND_CONF_PIN
bool valid
True when we received a packet else false.
Architecture independent timing functions.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
#define RADIO_CONTROL_NB_CHANNEL
void radio_control_impl_init(void)
Main Radio initialization.
static void spektrum_uart_check(struct uart_periph *dev, struct spektrum_sat_t *sat)
Check bytes on the UART.
#define SPEKTRUM_SECONDARY_BIND_CONF_PIN
uint32_t timer
Timer to keep track of the UART synchronisation.
static void gpio_toggle(ioportid_t port, uint16_t pin)
Toggle a gpio output to low level.
#define SPEKTRUM_CHANNELS_PER_FRAME
Maximum amount of RC channels per frame.
#define SPEKTRUM_SYS_11_2048_2
const int8_t spektrum_signs[]
#define SPEKTRUM_BIND_PIN_PORT
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
#define SPEKTRUM_SYS_22_1024_2
Allowed system field valaues.
#define SPEKTRUM_SECONDARY_BIND_CONF_PORT
#define RC_POLARITY_GPIO_PORT
static void spektrum_bind(void)
This function puts the satellite in binding mode.
timer subsystem type(config options) --------------------------------------------(advanced timers using RCC_APB1) TIM1 adc(if USE_AD_TIM1) radio_control/ppm(if USE_PPM_TIM1
uint8_t lost_frame_cnt
Amount of RC frames lost.
static void spektrum_init_sat(struct spektrum_sat_t *sat)
Initialize a spektrum sattelite.
#define SPEKTRUM_PRIMARY_BIND_CONF_PORT
By default, the same pin is used for pulse train and uart rx, but they can be different if needed.
void gpio_setup_input_pullup(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull up resistor enabled.
int16_t values[SPEKTRUM_MAX_CHANNELS]
RC channel values.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
#define SPEKTRUM_SYS_11_2048_X
struct RadioControl radio_control
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
void spektrum_event(void(*frame_handler)(void))
Checks if there is one valid satellite and sets the radio_control structure.