Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fbw_downlink.h
Go to the documentation of this file.
1 /*
2  * Paparazzi $Id$
3  *
4  * Copyright (C) 2006- Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
35 #ifndef FBW_DOWNLINK_H
36 #define FBW_DOWNLINK_H
37 
38 #include <inttypes.h>
39 #include "messages.h"
40 #include "generated/periodic_telemetry.h"
41 #include "generated/airframe.h"
42 #include "commands.h"
43 #include "actuators.h"
44 
45 #include "mcu_periph/uart.h"
48 #include "subsystems/electrical.h"
49 #include "inter_mcu.h"
50 
51 #ifndef DOWNLINK_DEVICE
52 #define DOWNLINK_DEVICE DOWNLINK_FBW_DEVICE
53 #endif
55 
56 #define PERIODIC_SEND_COMMANDS(_trans, _dev) DOWNLINK_SEND_COMMANDS(_trans, _dev, COMMANDS_NB, commands)
57 
58 #ifdef RADIO_CONTROL
59 #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)
60 #ifdef RADIO_CONTROL_TYPE_PPM
61 #define PERIODIC_SEND_PPM(_trans, _dev) { \
62  uint16_t ppm_pulses_usec[RADIO_CONTROL_NB_CHANNEL]; \
63  for (int i=0;i<RADIO_CONTROL_NB_CHANNEL;i++) \
64  ppm_pulses_usec[i] = USEC_OF_RC_PPM_TICKS(ppm_pulses[i]); \
65  DOWNLINK_SEND_PPM(_trans, _dev, \
66  &radio_control.frame_rate, \
67  PPM_NB_CHANNEL, \
68  ppm_pulses_usec); \
69 }
70 #else
71 #define PERIODIC_SEND_PPM(_trans, _dev) {}
72 #endif
73 #define PERIODIC_SEND_RC(_trans, _dev) DOWNLINK_SEND_RC(_trans, _dev, RADIO_CONTROL_NB_CHANNEL, radio_control.values)
74 #else // RADIO_CONTROL
75 #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); }
76 #define PERIODIC_SEND_PPM(_trans, _dev) {}
77 #define PERIODIC_SEND_RC(_trans, _dev) {}
78 #endif // RADIO_CONTROL
79 
80 #ifdef ACTUATORS
81 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, SERVOS_NB, actuators)
82 #else
83 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
84 #endif
85 
86 #ifdef BRICOLAGE_ADC
87 extern uint16_t adc0_val[];
88 
89 #define PERIODIC_SEND_ADC(_trans, _dev) { \
90  static const uint8_t mcu = 0; \
91  DOWNLINK_SEND_ADC(_trans, _dev, &mcu, 8, adc0_val); \
92  }
93 #else
94 #define PERIODIC_SEND_ADC(_trans, _dev) {}
95 #endif
96 
97 static inline void fbw_downlink_periodic_task(void) {
98  PeriodicSendFbw(DefaultChannel,DefaultDevice)
99 }
100 
101 
102 #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:48