Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fbw_downlink.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006- Pascal Brisset, Antoine Drouin
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
34 #ifndef FBW_DOWNLINK_H
35 #define FBW_DOWNLINK_H
36 
37 #include <inttypes.h>
38 #include "messages.h"
39 #include "generated/periodic_telemetry.h"
40 #include "generated/airframe.h"
41 #include "subsystems/commands.h"
42 #include "subsystems/actuators.h"
43 
44 #include "mcu_periph/uart.h"
47 #include "subsystems/electrical.h"
48 #include "inter_mcu.h"
49 
50 #ifndef DOWNLINK_DEVICE
51 #define DOWNLINK_DEVICE DOWNLINK_FBW_DEVICE
52 #endif
54 
55 #define PERIODIC_SEND_COMMANDS(_trans, _dev) DOWNLINK_SEND_COMMANDS(_trans, _dev, COMMANDS_NB, commands)
56 
57 #ifdef RADIO_CONTROL
58 #define PERIODIC_SEND_FBW_STATUS(_trans, _dev) DOWNLINK_SEND_FBW_STATUS(_trans, _dev, &(radio_control.status), &(radio_control.frame_rate), &fbw_mode, &electrical.vsupply, &electrical.current)
59 #ifdef RADIO_CONTROL_TYPE_PPM
60 #define PERIODIC_SEND_PPM(_trans, _dev) { \
61  uint16_t ppm_pulses_usec[RADIO_CONTROL_NB_CHANNEL]; \
62  for (int i=0;i<RADIO_CONTROL_NB_CHANNEL;i++) \
63  ppm_pulses_usec[i] = USEC_OF_RC_PPM_TICKS(ppm_pulses[i]); \
64  DOWNLINK_SEND_PPM(_trans, _dev, \
65  &radio_control.frame_rate, \
66  PPM_NB_CHANNEL, \
67  ppm_pulses_usec); \
68 }
69 #else
70 #define PERIODIC_SEND_PPM(_trans, _dev) {}
71 #endif
72 #define PERIODIC_SEND_RC(_trans, _dev) DOWNLINK_SEND_RC(_trans, _dev, RADIO_CONTROL_NB_CHANNEL, radio_control.values)
73 #else // RADIO_CONTROL
74 #define PERIODIC_SEND_FBW_STATUS(_trans, _dev) { uint8_t dummy = 0; DOWNLINK_SEND_FBW_STATUS(_trans, _dev, &dummy, &dummy, &fbw_mode, &electrical.vsupply, &electrical.current); }
75 #define PERIODIC_SEND_PPM(_trans, _dev) {}
76 #define PERIODIC_SEND_RC(_trans, _dev) {}
77 #endif // RADIO_CONTROL
78 
79 #ifdef ACTUATORS
80 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
81 #else
82 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
83 #endif
84 
85 #ifdef BRICOLAGE_ADC
86 extern uint16_t adc0_val[];
87 
88 #define PERIODIC_SEND_ADC(_trans, _dev) { \
89  static const uint8_t mcu = 0; \
90  DOWNLINK_SEND_ADC(_trans, _dev, &mcu, 8, adc0_val); \
91  }
92 #else
93 #define PERIODIC_SEND_ADC(_trans, _dev) {}
94 #endif
95 
96 static inline void fbw_downlink_periodic_task(void) {
97  PeriodicSendFbw(DefaultChannel,DefaultDevice)
98 }
99 
100 
101 #endif /* FBW_DOWNLINK_H */
FBW ( FlyByWire ) process API.
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
volatile uint16_t adc0_val[NB_ADC]
Definition: adc_arch.c:53
Hardware independent code for commands handling.
Hardware independent API for actuators (servos, motor controllers).