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
autopilot_arming_switch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 The Paparazzi Team
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 
22 #ifndef AUTOPILOT_ARMING_SWITCH_H
23 #define AUTOPILOT_ARMING_SWITCH_H
24 
25 #include "autopilot_rc_helpers.h"
26 
27 #ifndef RADIO_KILL_SWITCH
28 #error "You need to have a RADIO_KILL_SWITCH configured to arm the motors with the switch!"
29 #endif
30 
36 };
37 
40 
41 static inline void autopilot_arming_init(void) {
44 }
45 
46 static inline void autopilot_arming_set(bool_t motors_on) {
47  if (motors_on) {
49  }
50  else {
53  /* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
54  if (autopilot_mode != MODE_MANUAL) {
56  }
57  else {
59  }
60  }
61  }
62 }
63 
71 static inline void autopilot_arming_check_motors_on( void ) {
72  switch(autopilot_arming_state) {
73  case STATE_UNINIT:
75  if (kill_switch_is_on()) {
77  }
78  else {
80  }
81  break;
82  case STATE_WAITING:
84  if (kill_switch_is_on()) {
86  }
87  break;
88  case STATE_STARTABLE:
90  if (!kill_switch_is_on() &&
95  }
96  break;
97  case STATE_MOTORS_ON:
99  if (kill_switch_is_on()) {
100  /* if killed, go to STATE_STARTABLE where motors will be turned off */
102  /* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
103  if (autopilot_mode != MODE_MANUAL) {
105  }
106  else {
108  }
109  }
110  break;
111  default:
112  break;
113  }
114 
115 }
116 
117 #endif /* AUTOPILOT_ARMING_SWITCH_H */
uint8_t autopilot_mode
Definition: autopilot.c:31
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF using the kill switch.
bool_t autopilot_unarmed_in_auto
static bool_t kill_switch_is_on(void)
static void autopilot_arming_set(bool_t motors_on)
static bool_t rc_attitude_sticks_centered(void)
enum arming_state autopilot_arming_state
#define THROTTLE_STICK_DOWN()
#define FALSE
Definition: imu_chimu.h:141
bool_t autopilot_motors_on
Definition: autopilot.c:38
static void autopilot_arming_init(void)
#define TRUE
Definition: imu_chimu.h:144
#define MODE_MANUAL
Definition: autopilot.h:71