Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
sbus_dual.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Christophe De Wagter
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
29 #include "modules/core/abi.h"
30 #include BOARD_CONFIG
31 #include "mcu_periph/uart.h"
32 #include <string.h>
33 
34 #ifndef RC_POLARITY_GPIO_PORT
35 #define RC_POLARITY_GPIO_PORT 0
36 #endif
37 #ifndef RC_POLARITY_GPIO_PIN
38 #define RC_POLARITY_GPIO_PIN 0
39 #endif
40 
41 #ifndef RC2_POLARITY_GPIO_PORT
42 #define RC2_POLARITY_GPIO_PORT RC_POLARITY_GPIO_PORT
43 #endif
44 #ifndef RC2_POLARITY_GPIO_PIN
45 #define RC2_POLARITY_GPIO_PIN RC_POLARITY_GPIO_PIN
46 #endif
47 
49 struct Sbus sbus1, sbus2;
50 
51 // Telemetry function
52 #if PERIODIC_TELEMETRY
54 
55 static void send_sbus(struct transport_tx *trans, struct link_device *dev)
56 {
57  // Using PPM message
58  pprz_msg_send_PPM(trans, dev, AC_ID,
60 }
61 #endif
62 
63 // Init function
64 void sbus_dual_init(void)
65 {
69 
70  // Register telemetry message
71 #if PERIODIC_TELEMETRY
73 #endif
74 }
75 
76 static inline void sbus_dual_decode_event(void)
77 {
78  sbus_common_decode_event(&sbus1, &SBUS1_UART_DEV);
79  sbus_common_decode_event(&sbus2, &SBUS2_UART_DEV);
80 }
81 
82 void sbus_dual_event(void)
83 {
85  if (sbus2.frame_available) {
88  if (radio_control.radio_ok_cpt > 0) {
90  } else {
92  NormalizePpmIIR(sbus2.pulses, radio_control);
93  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_SBUS_DUAL_ID, &radio_control);
94  }
95  sbus2.frame_available = false;
96  }
97  if (sbus1.frame_available) {
100  if (radio_control.radio_ok_cpt > 0) {
102  } else {
104  NormalizePpmIIR(sbus1.pulses, radio_control);
105  AbiSendMsgRADIO_CONTROL(RADIO_CONTROL_SBUS_DUAL_ID, &radio_control);
106  }
107  sbus1.frame_available = false;
108  }
109 }
Main include for ABI (AirBorneInterface).
#define RADIO_CONTROL_SBUS_DUAL_ID
struct RadioControl radio_control
Definition: radio_control.c:33
Generic interface for radio control modules.
uint8_t time_since_last_frame
Definition: radio_control.h:62
uint8_t status
Definition: radio_control.h:61
uint8_t radio_ok_cpt
Definition: radio_control.h:63
uint8_t frame_rate
Definition: radio_control.h:64
uint8_t frame_cpt
Definition: radio_control.h:65
#define RC_OK
Definition: radio_control.h:49
uint8_t nb_channel
Definition: radio_control.h:66
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: sbus_common.c:74
void sbus_common_decode_event(struct Sbus *sbus_p, struct uart_periph *dev)
Decoding event function.
Definition: sbus_common.c:139
uint16_t pulses[SBUS_NB_CHANNEL]
Decoded values.
Definition: sbus_common.h:69
bool frame_available
A data frame is available.
Definition: sbus_common.h:71
#define SBUS_NB_CHANNEL
Definition: sbus_common.h:63
SBUS structure.
Definition: sbus_common.h:68
#define RC_POLARITY_GPIO_PORT
Definition: sbus_dual.c:35
static void send_sbus(struct transport_tx *trans, struct link_device *dev)
Definition: sbus_dual.c:55
struct Sbus sbus1 sbus2
SBUS struct.
Definition: sbus_dual.c:49
void sbus_dual_event(void)
RC event function.
Definition: sbus_dual.c:82
#define RC_POLARITY_GPIO_PIN
Definition: sbus_dual.c:38
#define RC2_POLARITY_GPIO_PIN
Definition: sbus_dual.c:45
static void sbus_dual_decode_event(void)
Definition: sbus_dual.c:76
#define RC2_POLARITY_GPIO_PORT
Definition: sbus_dual.c:42
void sbus_dual_init(void)
RC init function.
Definition: sbus_dual.c:64
Radio control via two SBUS receivers.
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition: telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition: telemetry.h:66
arch independent UART (Universal Asynchronous Receiver/Transmitter) API