Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
opa_controller_fbw.c
Go to the documentation of this file.
1/*
2 * Copyright (C) Freek van Tienen <freek.v.tienen@gmail.com>
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 */
28#include "generated/airframe.h"
29#include "mcu_periph/gpio.h"
30#include "led.h"
31
32#define OFF_TIMER 5*1 // FIXME: make nicer
33#define MIN_ARMING_TRIG 1*1 //FIXME: make nicer
34
35/* Whether the autopilot arming LED is on */
36static bool arming_led = false;
37extern bool autopilot_motors_on;
39
40
42 /* Setup E-Stop, Arming and On/Off button as input */
46
47 /* Enable Autopilot power */
50
51 /* Enable Main power (25V) */
54
55 /* Enable Balancer power */
58
59#if defined ARMING_LED
60 /* Disable the arming LED */
62#endif
63}
64
66 static uint16_t off_cnt = 0;
67 static uint16_t arming_cnt = 0;
68
69 /* Check E-Stop and power off Main power if pressed */
76 arming_led = false;
77 return;
78 }
79
80 /* AP soft disarm */
84 arming_led = false;
86 }
87
88 /* Check On/Off button and disable if pressed for 3 seconds */
90 if(off_cnt >= OFF_TIMER) {
93 arming_led = false;
94 } else {
95 off_cnt++;
96 }
97 }
98 else {
99 off_cnt = 0;
100 }
101
102 /* Check Arming button and set LED */
105 arming_led = true;
108 //AP_PWR_ON(AP_PWR, AP_PWR_PIN);
109 //RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER_PORT,RADIO_CONTROL_POWER_PIN);
110 } else {
111 arming_cnt++;
112 }
113 }
114 else {
115 arming_cnt = 0;
116 }
117
118#if defined ARMING_LED
119 /* Update Arming LED */
120 if (arming_led) {
122 } else {
124 }
125 // autopilot_motors_on;
126#endif
127}
#define LED_ON(i)
Definition led_hw.h:51
#define LED_OFF(i)
Definition led_hw.h:52
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition gpio_arch.c:33
void gpio_setup_input(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
Definition gpio_arch.c:40
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
Definition gpio_arch.h:94
Some architecture independent helper functions for GPIOs.
Inter-MCU interface.
@ INTERMCU_CMD_DISARM
Whether or not to dis-arm the FBW.
Definition intermcu.h:58
#define INTERMCU_CLR_CMD_STATUS(_bit)
Definition intermcu.h:65
#define INTERMCU_GET_CMD_STATUS(_bit)
Definition intermcu.h:66
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
bool autopilot_motors_on
void opa_controller_periodic(void)
#define MIN_ARMING_TRIG
static bool arming_led
#define OFF_TIMER
void opa_controller_init(void)
bool opa_controller_disarm
#define AP_PWR_ON
Definition opa_ftd_1.0.h:45
#define MAIN_PWR_ON
Definition opa_ftd_1.0.h:51
#define MCU_PWR
Definition opa_ftd_1.0.h:37
#define BTN_ESTOP_PIN
Definition opa_ftd_1.0.h:66
#define MCU_PWR_OFF
Definition opa_ftd_1.0.h:40
#define BTN_ON_PIN
Definition opa_ftd_1.0.h:74
#define BTN_ARMING_PIN
Definition opa_ftd_1.0.h:70
#define RADIO_CONTROL_POWER_PIN
#define AP_PWR_PIN
Definition opa_ftd_1.0.h:44
#define BAL_PWR_ON
Definition opa_ftd_1.0.h:57
#define MAIN_PWR
Definition opa_ftd_1.0.h:49
#define MAIN_PWR_PIN
Definition opa_ftd_1.0.h:50
#define RADIO_CONTROL_POWER_PORT
#define MAIN_PWR_OFF
Definition opa_ftd_1.0.h:52
#define BAL_PWR
Definition opa_ftd_1.0.h:55
#define MCU_PWR_PIN
Definition opa_ftd_1.0.h:38
#define BTN_ARMING
Definition opa_ftd_1.0.h:69
#define RADIO_CONTROL_POWER_OFF
#define AP_PWR_OFF
Definition opa_ftd_1.0.h:46
#define AP_PWR
Definition opa_ftd_1.0.h:43
#define BTN_ON
Definition opa_ftd_1.0.h:73
#define BAL_PWR_OFF
Definition opa_ftd_1.0.h:58
#define BTN_ESTOP
Definition opa_ftd_1.0.h:65
#define BAL_PWR_PIN
Definition opa_ftd_1.0.h:56
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.