diff --git a/conf/airframes/mm/extra/turbine_trigger.xml b/conf/airframes/mm/extra/turbine_trigger.xml index 0d75a5c658..c02889cc5d 100644 --- a/conf/airframes/mm/extra/turbine_trigger.xml +++ b/conf/airframes/mm/extra/turbine_trigger.xml @@ -1,17 +1,34 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -77,18 +94,14 @@ -
- - -
@@ -97,59 +110,41 @@ - - -
- - - - + - - - + - - - + - - - +
- + - - - - -
@@ -158,13 +153,13 @@
- - - - - - - + + + + + + +
@@ -176,82 +171,5 @@ -
- - -
- -
- -
- -
- - - - - - - - - - - - - - - - - -
- - -CONFIG = \"tiny_2_1.h\" - -include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile - -FLASH_MODE=IAP - -ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DLED -DTIME_LED=1 -ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c - -ap.srcs += commands.c - -ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017 -ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c - -ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B57600 -ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c - -ap.CFLAGS += -DINTER_MCU -ap.srcs += inter_mcu.c - -ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_4 -ap.srcs += $(SRC_ARCH)/adc_hw.c - -ap.CFLAGS += -DGPS -DUBX -DUSE_UART0 -DGPS_LINK=Uart0 -DUART0_BAUD=B38400 -DGPS_USE_LATLONG -# -DGPS_LED=2 -ap.srcs += gps_ubx.c gps.c latlong.c - -ap.CFLAGS += -DINFRARED -DALT_KALMAN -DWIND_INFO -DWIND_INFO_RET -ap.srcs += infrared.c estimator.c - -ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM -ap.srcs += nav.c fw_h_ctl.c fw_v_ctl.c - -ap.srcs += nav_line.c -ap.srcs += nav_survey_rectangle.c - -ap.srcs += $(SRC_ARCH)/trig_ext_hw.c -ap.CFLAGS += -DTRIG_EXT_PULSE_TYPE=TRIG_EXT_EDGE_FALLING -DTRIGGER_EXT - -ap.CFLAGS += -DGPS_TIMESTAMP - -# Config for SITL simulation -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile -sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -sim.srcs += nav_line.c nav_survey_rectangle.c - - -
+ diff --git a/conf/modules/trigger_ext.xml b/conf/modules/trigger_ext.xml new file mode 100644 index 0000000000..dbfaec861c --- /dev/null +++ b/conf/modules/trigger_ext.xml @@ -0,0 +1,20 @@ + + + +
+ +
+ + + + + ap.srcs += $(SRC_ARCH)/trig_ext_hw.c + + + + + + + +
+ diff --git a/sw/airborne/arch/lpc21/sys_time_hw.c b/sw/airborne/arch/lpc21/sys_time_hw.c index b27fb2dada..71d83c61f0 100644 --- a/sw/airborne/arch/lpc21/sys_time_hw.c +++ b/sw/airborne/arch/lpc21/sys_time_hw.c @@ -53,7 +53,7 @@ uint32_t sys_time_chrono; /* T0TC ticks */ #endif #ifdef TRIGGER_EXT -#include "trig_ext.h" +#include "trig_ext_hw.h" #endif #define TIMER0_IT_MASK (ACTUATORS_IT |\ diff --git a/sw/airborne/arch/lpc21/trig_ext_hw.c b/sw/airborne/arch/lpc21/trig_ext_hw.c index 7d79ec9d87..891372b810 100644 --- a/sw/airborne/arch/lpc21/trig_ext_hw.c +++ b/sw/airborne/arch/lpc21/trig_ext_hw.c @@ -1,12 +1,33 @@ -//#include "trig_ext.h" + #include "std.h" -#include "sys_time.h" - - - +#include "LPC21xx.h" +#include "trig_ext_hw.h" +#include BOARD_CONFIG uint32_t trigger_t0; uint32_t delta_t0; volatile bool_t trig_ext_valid; +void TRIG_ISR() { + static uint32_t last; + trigger_t0 = PPM_CR; + delta_t0 = trigger_t0 - last; + last = trigger_t0; + trig_ext_valid = TRUE; +} + +void trig_ext_init ( void ) { + /* select pin for capture */ + PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT; + /* enable capture 0.2 on falling or rising edge + trigger interrupt */ +#if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING + T0CCR = PPM_CCR_CRR | PPM_CCR_CRI; +#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING + T0CCR = PPM_CCR_CRF | PPM_CCR_CRI; +#else +#error "trig_ext_hw.h: Unknown PULSE_TYPE" +#endif + trig_ext_valid = FALSE; +} + diff --git a/sw/airborne/arch/lpc21/trig_ext_hw.h b/sw/airborne/arch/lpc21/trig_ext_hw.h index e31e797e5f..d2a4441a51 100644 --- a/sw/airborne/arch/lpc21/trig_ext_hw.h +++ b/sw/airborne/arch/lpc21/trig_ext_hw.h @@ -1,6 +1,7 @@ #ifndef TRIG_EXT_HW_H #define TRIG_EXT_HW_H +#include "std.h" /** * falling/rising edge @@ -8,34 +9,12 @@ #define TRIG_EXT_EDGE_RISING 1 #define TRIG_EXT_EDGE_FALLING 0 +extern uint32_t trigger_t0; +extern uint32_t delta_t0; +extern volatile bool_t trig_ext_valid; - -#include "LPC21xx.h" -#include BOARD_CONFIG - - -static inline void trig_ext_init ( void ) { - /* select pin for capture */ - PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT; - /* enable capture 0.2 on falling or rising edge + trigger interrupt */ -#if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING - T0CCR = PPM_CCR_CRR | PPM_CCR_CRI; -#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING - T0CCR = PPM_CCR_CRF | PPM_CCR_CRI; -#else -#error "trig_ext_hw.h: Unknown PULSE_TYPE" -#endif - trig_ext_valid = FALSE; -} - -#define TRIG_ISR() { \ - static uint32_t last; \ - trigger_t0 = PPM_CR; \ - delta_t0 = trigger_t0 - last; \ - last = trigger_t0; \ - trig_ext_valid = TRUE; \ -} - +void TRIG_ISR(void); +void trig_ext_init( void ); #endif /* TRIG_EXT_HW_H */ diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index 9e08c3abcc..90e227f8c9 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -123,10 +123,6 @@ #include "baro_ets.h" #endif // USE_BARO_ETS -#ifdef TRIGGER_EXT -#include "trig_ext.h" -#endif // TRIGGER_EXT - /*code added by Haiyang Chao for using Xsens IMU for fixed wing UAV 20080804*/ #ifdef UGEAR #include "osam_imu_ugear.h" @@ -773,10 +769,6 @@ void init_ap( void ) { power_switch = FALSE; -#ifdef TRIGGER_EXT - trig_ext_init(); -#endif - /************ Multi-uavs status ***************/ #ifdef TRAFFIC_INFO @@ -932,23 +924,6 @@ void event_task_ap( void ) { } #endif -#ifdef TRIGGER_EXT - if (trig_ext_valid == TRUE) { - uint8_t turb_id = 0; - uint32_t sync_itow, cycle_time; - - sync_itow = itow_from_ticks(trigger_t0); - cycle_time = MSEC_OF_SYS_TICS(delta_t0); - - DOWNLINK_SEND_WINDTURBINE_STATUS_(DefaultChannel, - &turb_id, - &turb_id, - &sync_itow, - &cycle_time ); - trig_ext_valid = FALSE; - } -#endif - if (inter_mcu_received_fbw) { /* receive radio control task from fbw */ inter_mcu_received_fbw = FALSE; diff --git a/sw/airborne/modules/meteo/humid_hih.c b/sw/airborne/modules/meteo/humid_hih.c index 894c58dc3c..430bcc7e9e 100644 --- a/sw/airborne/modules/meteo/humid_hih.c +++ b/sw/airborne/modules/meteo/humid_hih.c @@ -28,7 +28,7 @@ * This reads the values for humidity from the Honeywell HIH-4030 sensor. */ - +#include #include "humid_hih.h" #include "temp_tmp102.h" #include "adc.h" diff --git a/sw/airborne/modules/sensors/trigger_ext.c b/sw/airborne/modules/sensors/trigger_ext.c new file mode 100644 index 0000000000..297d74c147 --- /dev/null +++ b/sw/airborne/modules/sensors/trigger_ext.c @@ -0,0 +1,63 @@ +/* + * $Id$ + * + * Copyright (C) 2010 Martin Mueller + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** \file trigger_ext.c + * \brief Measure external trigger pulse at PPM input + * + * This measures a trigger pulse length (e.g. duration of a wind turbine + * rotation) and sends a message with the info. + */ + + +#include "trigger_ext.h" +#include "trig_ext_hw.h" +#include "gps.h" +#include "sys_time.h" +#include "uart.h" +#include "messages.h" +#include "downlink.h" + + +void trigger_ext_init ( void ) { + trig_ext_init(); +} + +void trigger_ext_periodic( void ) { + if (trig_ext_valid == TRUE) { + uint8_t ac_id = 0; + uint8_t turb_id = TURBINE_ID; + uint32_t sync_itow, cycle_time; + + sync_itow = itow_from_ticks(trigger_t0); + cycle_time = MSEC_OF_SYS_TICS(delta_t0); + + DOWNLINK_SEND_WINDTURBINE_STATUS_(DefaultChannel, + &ac_id, + &turb_id, + &sync_itow, + &cycle_time ); + trig_ext_valid = FALSE; + } +} + diff --git a/sw/airborne/modules/sensors/trigger_ext.h b/sw/airborne/modules/sensors/trigger_ext.h new file mode 100644 index 0000000000..ee509ac426 --- /dev/null +++ b/sw/airborne/modules/sensors/trigger_ext.h @@ -0,0 +1,10 @@ +#ifndef TRIGGER_EXT_H +#define TRIGGER_EXT_H + + +void trigger_ext_init ( void ); +void trigger_ext_periodic( void ); + +#endif + + diff --git a/sw/airborne/trig_ext.h b/sw/airborne/trig_ext.h deleted file mode 100644 index 006c1878ae..0000000000 --- a/sw/airborne/trig_ext.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $Id: ppm.h 4281 2009-10-19 18:32:12Z mmm $ - * - * (c) 2005 Pascal Brisset, Antoine Drouin - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#ifndef TRIG_EXT_H -#define TRIG_EXT_H - -#if defined TRIGGER_EXT - -#include "std.h" -extern uint32_t trigger_t0; -extern uint32_t delta_t0; -extern volatile bool_t trig_ext_valid; - -#include "trig_ext_hw.h" - -#endif /* TRIGGER_EXT */ - -#endif