diff --git a/conf/airframes/mm/extra/press_t.xml b/conf/airframes/mm/extra/press_t.xml new file mode 100755 index 0000000000..ddfbf40840 --- /dev/null +++ b/conf/airframes/mm/extra/press_t.xml @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + +
+ + +
+ +
+ + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + + +
+ +
+ + + + + +
+ +
+ + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ + +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 += -DRADIO_CONTROL +ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.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 + +#TRANSPARENT +#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -DDATALINK=PPRZ -DUART1_BAUD=B9600 +#ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.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 += humid_sht.c +ap.CFLAGS += -DUSE_HUMID_SHT -DDAT_PIN=3 -DSCK_PIN=2 + +ap.srcs += baro_scp.c +ap.CFLAGS += -DUSE_BARO_SCP + +#ap.CFLAGS += -DMICROMAG_DRDY_VIC_SLOT=9 -DSSP_VIC_SLOT=11 -DUSE_MICROMAG_FW +#ap.srcs += micromag_fw.c $(SRC_ARCH)/micromag_fw_hw.c + +#ap.CFLAGS += -DMAX11040_DRDY_VIC_SLOT=12 -DSSP_VIC_SLOT=11 -DUSE_MAX11040 +#ap.srcs += max11040.c $(SRC_ARCH)/max11040_hw.c + +ap.srcs += joystick.c +ap.CFLAGS += -DUSE_JOYSTICK + +ap.srcs += bomb.c + +ap.srcs += snav.c + +# distance sensor +ap.CFLAGS += -DUSE_ADC_3 -DUSE_ADC_GENERIC -DADC_CHANNEL_GENERIC1=ADC_3 -DADC_CHANNEL_GENERIC_NB_SAMPLES=16 +ap.srcs += adc_generic.c + +# 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 + +sim.srcs += joystick.c +sim.CFLAGS += -DUSE_JOYSTICK + + + +
diff --git a/conf/airframes/mm/extra/probe_t.xml b/conf/airframes/mm/extra/probe_t.xml new file mode 100755 index 0000000000..0b57114834 --- /dev/null +++ b/conf/airframes/mm/extra/probe_t.xml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + +
+ + +
+ +
+ + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + + +
+ +
+ + + + + +
+ +
+ + +
+ +
+ + + + + + + + + + + + +
+ + +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 += -DRADIO_CONTROL +ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.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 + +#TRANSPARENT +#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -DDATALINK=PPRZ -DUART1_BAUD=B9600 +#ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.c + + +ap.CFLAGS += -DINTER_MCU +ap.srcs += inter_mcu.c + +ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 +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 + +# MAX11040 adc +ap.CFLAGS += -DMAX11040_DRDY_VIC_SLOT=12 -DSSP_VIC_SLOT=11 -DUSE_MAX11040 +ap.srcs += max11040.c $(SRC_ARCH)/max11040_hw.c + +ap.srcs += snav.c + +# 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 + +sim.srcs += joystick.c +sim.CFLAGS += -DUSE_JOYSTICK + + + +
diff --git a/conf/airframes/mm/extra/turbine_trigger.xml b/conf/airframes/mm/extra/turbine_trigger.xml new file mode 100644 index 0000000000..dac950f0de --- /dev/null +++ b/conf/airframes/mm/extra/turbine_trigger.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + +
+ + +
+ +
+ + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + + +
+ +
+ + + + + +
+ +
+ + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + +
+ + +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/sw/airborne/arm7/sys_time_hw.c b/sw/airborne/arm7/sys_time_hw.c index c83d2eeaa8..fbf978c8c3 100644 --- a/sw/airborne/arm7/sys_time_hw.c +++ b/sw/airborne/arm7/sys_time_hw.c @@ -50,6 +50,9 @@ uint32_t sys_time_chrono; /* T0TC ticks */ #define AMI601_IT 0x00 #endif +#ifdef TRIGGER_EXT +#include "trig_ext.h" +#endif #define TIMER0_IT_MASK (ACTUATORS_IT |\ PPM_IT |\ @@ -85,6 +88,14 @@ void TIMER0_ISR ( void ) { T0IR = PPM_IT; } #endif +#ifdef TRIGGER_EXT +#define TRIGGER_IT PPM_CRI + if (T0IR&TRIGGER_IT) { + TRIG_ISR(); + T0IR = TRIGGER_IT; +LED_TOGGLE(3); + } +#endif #if defined USE_RADIO_CONTROL && defined RADIO_CONTROL_TYPE_PPM if (T0IR&RADIO_CONTROL_PPM_IT) { RADIO_CONTROL_PPM_ISR(); diff --git a/sw/airborne/arm7/sys_time_hw.h b/sw/airborne/arm7/sys_time_hw.h index c448485815..14853079e7 100644 --- a/sw/airborne/arm7/sys_time_hw.h +++ b/sw/airborne/arm7/sys_time_hw.h @@ -125,6 +125,7 @@ static inline void sys_time_init( void ) { #define SIGNED_SYS_TICS_OF_USEC(us) SIGNED_SYS_TICS_OF_SEC((us) * 1e-6) #define SEC_OF_SYS_TICS(st) (st / PCLK * T0_PCLK_DIV) +#define MSEC_OF_SYS_TICS(st) (st / (PCLK/1000) * T0_PCLK_DIV) #define GET_CUR_TIME_FLOAT() ((float)cpu_time_sec + SEC_OF_SYS_TICS((float)cpu_time_ticks)) diff --git a/sw/airborne/arm7/trig_ext_hw.c b/sw/airborne/arm7/trig_ext_hw.c new file mode 100644 index 0000000000..7d79ec9d87 --- /dev/null +++ b/sw/airborne/arm7/trig_ext_hw.c @@ -0,0 +1,12 @@ +//#include "trig_ext.h" +#include "std.h" +#include "sys_time.h" + + + + +uint32_t trigger_t0; +uint32_t delta_t0; +volatile bool_t trig_ext_valid; + + diff --git a/sw/airborne/arm7/trig_ext_hw.h b/sw/airborne/arm7/trig_ext_hw.h new file mode 100644 index 0000000000..3f2b428a33 --- /dev/null +++ b/sw/airborne/arm7/trig_ext_hw.h @@ -0,0 +1,41 @@ +#ifndef TRIG_EXT_HW_H +#define TRIG_EXT_HW_H + + +/** + * falling/rising edge + */ +#define TRIG_EXT_EDGE_RISING 1 +#define TRIG_EXT_EDGE_FALLING 0 + + + +#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_CRF | PPM_CCR_CRI; +#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING + T0CCR = PPM_CCR_CRR | 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; \ +} + + +#endif /* TRIG_EXT_HW_H */ + diff --git a/sw/airborne/gps_ubx.c b/sw/airborne/gps_ubx.c index b724c2e38f..5343f4492a 100644 --- a/sw/airborne/gps_ubx.c +++ b/sw/airborne/gps_ubx.c @@ -38,6 +38,11 @@ #include "nav.h" #include "latlong.h" +#ifdef GPS_TIMESTAMP +#include "sys_time.h" +#define MSEC_PER_WEEK (1000*60*60*24*7) +#endif + #define UbxInitCheksum() { send_ck_a = send_ck_b = 0; } #define UpdateChecksum(c) { send_ck_a += c; send_ck_b += send_ck_a; } #define UbxTrailer() { GpsUartSend1(send_ck_a); GpsUartSend1(send_ck_b); GpsUartSendMessage(); } @@ -64,6 +69,11 @@ uint16_t gps_week; uint32_t gps_itow; +#ifdef GPS_TIMESTAMP +uint32_t gps_t0; +uint32_t gps_t0_itow; +uint32_t gps_t0_frac; +#endif int32_t gps_alt; uint16_t gps_gspeed; int16_t gps_climb; @@ -248,6 +258,13 @@ void parse_gps_msg( void ) { gps_pos_available = TRUE; /* The 3 UBX messages are sent in one rafale */ } else if (ubx_id == UBX_NAV_SOL_ID) { +#ifdef GPS_TIMESTAMP + /* get hardware clock ticks */ + gps_t0 = T0TC; + /* set receive time */ + gps_t0_itow = UBX_NAV_SOL_ITOW(ubx_msg_buf); + gps_t0_frac = UBX_NAV_SOL_Frac(ubx_msg_buf); +#endif gps_mode = UBX_NAV_SOL_GPSfix(ubx_msg_buf); gps_PDOP = UBX_NAV_SOL_PDOP(ubx_msg_buf); gps_Pacc = UBX_NAV_SOL_Pacc(ubx_msg_buf); @@ -339,3 +356,31 @@ void parse_ubx( uint8_t c ) { ubx_status = UNINIT; return; } + +#ifdef GPS_TIMESTAMP + +#ifndef PCLK +#error unknown PCLK frequency +#endif + +uint32_t itow_from_ticks(uint32_t clock_ticks) +{ + uint32_t clock_delta; + uint32_t time_delta; + uint32_t itow_now; + + if (clock_ticks < gps_t0) { + clock_delta = (0xFFFFFFFF - clock_ticks) + gps_t0 + 1; + } else { + clock_delta = clock_ticks - gps_t0; + } + + time_delta = MSEC_OF_SYS_TICS(clock_delta); + + itow_now = gps_t0_itow + time_delta; + if (itow_now > MSEC_PER_WEEK) itow_now %= MSEC_PER_WEEK; + + return itow_now; +} +#endif + diff --git a/sw/airborne/gps_ubx.h b/sw/airborne/gps_ubx.h index a388831ab2..15b17004e8 100644 --- a/sw/airborne/gps_ubx.h +++ b/sw/airborne/gps_ubx.h @@ -93,4 +93,8 @@ extern void ubxsend_cfg_rst(uint16_t, uint8_t); ubxsend_cfg_rst(gps_reset, CFG_RST_Reset_Controlled); \ } +#ifdef GPS_TIMESTAMP +uint32_t itow_from_ticks(uint32_t clock_ticks); +#endif + #endif /* UBX_H */ diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index d5c2f4714b..1188f9025f 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -138,6 +138,10 @@ #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" @@ -842,6 +846,10 @@ void init_ap( void ) { LightInit(); #endif +#ifdef TRIGGER_EXT + trig_ext_init(); +#endif + /************ Multi-uavs status ***************/ #ifdef TRAFFIC_INFO @@ -991,6 +999,23 @@ 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/trig_ext.h b/sw/airborne/trig_ext.h new file mode 100644 index 0000000000..006c1878ae --- /dev/null +++ b/sw/airborne/trig_ext.h @@ -0,0 +1,38 @@ +/* $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