Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
autopilot_generated.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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 
27 #define AUTOPILOT_CORE_AP_C
28 
30 #include "autopilot.h"
31 
33 #include "subsystems/commands.h"
34 #include "subsystems/actuators.h"
35 #include "subsystems/settings.h"
37 
38 #include "generated/settings.h"
39 
40 
42 {
43  // call generated init
44  autopilot_core_ap_init();
45  // copy generated mode to public mode (set at startup)
46  autopilot.mode = autopilot_mode_ap;
47 }
48 
49 
51 {
52 
53  autopilot_core_ap_periodic_task();
54 
55  // copy generated mode to public mode (may be changed on internal exceptions)
56  autopilot.mode = autopilot_mode_ap;
57 
58 #if defined MCU_SPI_LINK || defined MCU_UART_LINK || defined MCU_CAN_LINK
59  link_mcu_send();
60 #elif defined INTER_MCU && defined SINGLE_MCU
61 
62  inter_mcu_received_ap = true;
63 #endif
64 
65 }
66 
72 {
74 }
75 
76 
77 void autopilot_generated_set_mode(uint8_t new_autopilot_mode)
78 {
79  autopilot_core_ap_set_mode(new_autopilot_mode);
80  // copy generated mode to public mode
81  autopilot.mode = autopilot_mode_ap;
82 }
83 
84 
86 {
87  // only needed for consistency with other firmwares
88  autopilot.motors_on = motors_on;
89 }
90 
91 static inline void copy_from_to_fbw(void)
92 {
93  PPRZ_MUTEX_LOCK(fbw_state_mtx);
94  PPRZ_MUTEX_LOCK(ap_state_mtx);
95 #ifdef SetAutoCommandsFromRC
96  SetAutoCommandsFromRC(ap_state->commands, fbw_state->channels);
97 #elif defined RADIO_YAW && defined COMMAND_YAW
98  ap_state->commands[COMMAND_YAW] = fbw_state->channels[RADIO_YAW];
99 #endif
100  PPRZ_MUTEX_UNLOCK(ap_state_mtx);
101  PPRZ_MUTEX_UNLOCK(fbw_state_mtx);
102 }
103 
105 {
106 
107  // update electrical from FBW
108  imcu_get_electrical(&ap_electrical);
109 
110  // FIXME what to do here ?
112 
113 }
114 
radio_control.h
autopilot_generated_periodic
void autopilot_generated_periodic(void)
Definition: autopilot_generated.c:50
autopilot_generated_init
void autopilot_generated_init(void)
Definition: autopilot_generated.c:41
settings.h
autopilot_generated_on_rc_frame
void autopilot_generated_on_rc_frame(void)
Definition: autopilot_generated.c:104
pprz_autopilot::mode
uint8_t mode
current autopilot mode
Definition: autopilot.h:63
inter_mcu_received_ap
volatile bool inter_mcu_received_ap
Definition: inter_mcu.c:41
autopilot_generated_SetModeHandler
void autopilot_generated_SetModeHandler(float mode)
AP mode setting handler.
Definition: autopilot_generated.c:71
fbw_state
struct fbw_state * fbw_state
Definition: inter_mcu.c:36
autopilot_generated.h
PPRZ_MUTEX_UNLOCK
#define PPRZ_MUTEX_UNLOCK(_mtx)
Definition: pprz_mutex.h:47
telemetry.h
ap_electrical
struct Electrical ap_electrical
Definition: autopilot_firmware.c:36
pprz_autopilot::motors_on
bool motors_on
motor status
Definition: autopilot.h:68
autopilot
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
uint8_t
unsigned char uint8_t
Definition: types.h:14
autopilot_generated_set_mode
void autopilot_generated_set_mode(uint8_t new_autopilot_mode)
Definition: autopilot_generated.c:77
autopilot.h
PPRZ_MUTEX_LOCK
#define PPRZ_MUTEX_LOCK(_mtx)
Definition: pprz_mutex.h:46
copy_from_to_fbw
static void copy_from_to_fbw(void)
Definition: autopilot_generated.c:91
autopilot_generated_set_motors_on
void autopilot_generated_set_motors_on(bool motors_on)
Definition: autopilot_generated.c:85
RADIO_YAW
#define RADIO_YAW
Definition: intermcu_ap.h:43
ap_state
struct ap_state * ap_state
Definition: inter_mcu.c:37
mode
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
Definition: sonar_bebop.c:69
commands.h
Hardware independent code for commands handling.
actuators.h