diff --git a/conf/airframes/Poine/booz2_a1.xml b/conf/airframes/Poine/booz2_a1.xml index ee2cd5d4db..d2ce549035 100644 --- a/conf/airframes/Poine/booz2_a1.xml +++ b/conf/airframes/Poine/booz2_a1.xml @@ -196,13 +196,10 @@ - - - - + - + @@ -213,9 +210,10 @@ - - - + + + + diff --git a/conf/airframes/Poine/booz2_a7.xml b/conf/airframes/Poine/booz2_a7.xml index ce2895d005..d3b42fb2f7 100644 --- a/conf/airframes/Poine/booz2_a7.xml +++ b/conf/airframes/Poine/booz2_a7.xml @@ -175,11 +175,11 @@ - + +--> @@ -191,7 +191,7 @@ - + @@ -202,9 +202,10 @@ - - - + + + + diff --git a/conf/autopilot/booz_test_progs.makefile b/conf/autopilot/booz_test_progs.makefile index 17f2dd07df..d5147cb3c0 100644 --- a/conf/autopilot/booz_test_progs.makefile +++ b/conf/autopilot/booz_test_progs.makefile @@ -121,7 +121,7 @@ test_baro.srcs += $(SRC_BOOZ)/booz2_battery.c # -# test_spektrum : +# test_rc_spektrum : # # TODO # @@ -131,3 +131,36 @@ test_baro.srcs += $(SRC_BOOZ)/booz2_battery.c +# +# test rc ppm +# +# configuration +# SYS_TIME_LED +# MODEM_PORT +# MODEM_BAUD +# RADIO_CONTROL_LED +# +test_rc_ppm.ARCHDIR = $(ARCHI) +test_rc_ppm.ARCH = arm7tdmi +test_rc_ppm.TARGET = test_rc_ppm +test_rc_ppm.TARGETDIR = test_rc_ppm + +test_rc_ppm.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) +test_rc_ppm.CFLAGS += -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -I$(SRC_BOARD) +test_rc_ppm.CFLAGS += -DPERIPHERALS_AUTO_INIT +test_rc_ppm.srcs += $(SRC_BOOZ)/test/booz2_test_radio_control.c +test_rc_ppm.CFLAGS += -DUSE_LED +test_rc_ppm.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))' +test_rc_ppm.CFLAGS += -DTIME_LED=$(SYS_TIME_LED) +test_rc_ppm.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c + +test_rc_ppm.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) +test_rc_ppm.srcs += $(SRC_ARCH)/uart_hw.c +test_rc_ppm.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT) +test_rc_ppm.srcs += downlink.c pprz_transport.c +test_rc_ppm.CFLAGS += -DUSE_RADIO_CONTROL -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/booz_radio_control_ppm.h\" +test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_PPM +test_rc_ppm.srcs += $(SRC_BOOZ)/booz_radio_control.c \ + $(SRC_BOOZ)/radio_control/booz_radio_control_ppm.c \ + $(SRC_BOOZ_ARCH)/radio_control/booz_radio_control_ppm_arch.c \ No newline at end of file diff --git a/conf/autopilot/fixedwing.xml b/conf/autopilot/fixedwing.xml index 95f0142ee9..86cf30d497 100644 --- a/conf/autopilot/fixedwing.xml +++ b/conf/autopilot/fixedwing.xml @@ -3,7 +3,7 @@ - + diff --git a/conf/autopilot/lisa_l_test_progs.makefile b/conf/autopilot/lisa_l_test_progs.makefile index d172f52971..27366fed21 100644 --- a/conf/autopilot/lisa_l_test_progs.makefile +++ b/conf/autopilot/lisa_l_test_progs.makefile @@ -117,40 +117,81 @@ test_baro.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c # -# test_spektrum : sends RADIO_CONTROL messages on telemetry +# test_rc_spektrum : sends RADIO_CONTROL messages on telemetry # # configuration -# MODEM_PORT : -# MODEM_BAUD : -# RADIO_CONROL_LINK : +# SYS_TIME_LED +# MODEM_PORT +# MODEM_BAUD +# RADIO_CONTROL_LED +# RADIO_CONROL_LINK # +test_rc_spektrum.ARCHDIR = $(ARCHI) +test_rc_spektrum.TARGET = test_rc_spektrum +test_rc_spektrum.TARGETDIR = test_rc_spektrum + +test_rc_spektrum.CFLAGS += -I$(SRC_ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT +test_rc_spektrum.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) +test_rc_spektrum.srcs += $(SRC_BOOZ_TEST)/booz2_test_radio_control.c \ + $(SRC_ARCH)/stm32_exceptions.c \ + $(SRC_ARCH)/stm32_vector_table.c + +test_rc_spektrum.CFLAGS += -DUSE_LED +test_rc_spektrum.srcs += $(SRC_ARCH)/led_hw.c +test_rc_spektrum.CFLAGS += -DUSE_SYS_TIME +test_rc_spektrum.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))' +test_rc_spektrum.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED) +test_rc_spektrum.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c +test_rc_spektrum.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) +test_rc_spektrum.srcs += $(SRC_ARCH)/uart_hw.c +test_rc_spektrum.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT) +test_rc_spektrum.srcs += downlink.c pprz_transport.c +test_rc_spektrum.CFLAGS += -DUSE_RADIO_CONTROL +test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/booz_radio_control_spektrum.h\" +test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_SPEKTRUM_MODEL_H=\"radio_control/booz_radio_control_spektrum_dx7se.h\" +test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_LINK=$(RADIO_CONTROL_LINK) +test_rc_spektrum.CFLAGS += -DUSE_$(RADIO_CONTROL_LINK) -D$(RADIO_CONTROL_LINK)_BAUD=B115200 +test_rc_spektrum.srcs += $(SRC_BOOZ)/booz_radio_control.c \ + $(SRC_BOOZ)/radio_control/booz_radio_control_spektrum.c \ + $(SRC_BOOZ_ARCH)/radio_control/booz_radio_control_spektrum_arch.c + + # -test_spektrum.ARCHDIR = $(ARCHI) -test_spektrum.TARGET = test_spektrum -test_spektrum.TARGETDIR = test_spektrum -test_spektrum.CFLAGS += -I$(SRC_ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT -test_spektrum.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) -test_spektrum.srcs += $(SRC_BOOZ_TEST)/booz2_test_radio_control.c \ - $(SRC_ARCH)/stm32_exceptions.c \ - $(SRC_ARCH)/stm32_vector_table.c +# test_rc_ppm +# +# configuration +# SYS_TIME_LED +# MODEM_PORT +# MODEM_BAUD +# RADIO_CONTROL_LED +# +test_rc_ppm.ARCHDIR = $(ARCHI) +test_rc_ppm.TARGET = test_rc_ppm +test_rc_ppm.TARGETDIR = test_rc_ppm -test_spektrum.CFLAGS += -DUSE_LED -test_spektrum.srcs += $(SRC_ARCH)/led_hw.c -test_spektrum.CFLAGS += -DUSE_SYS_TIME -test_spektrum.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))' -test_spektrum.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED) -test_spektrum.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c -test_spektrum.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) -test_spektrum.srcs += $(SRC_ARCH)/uart_hw.c -test_spektrum.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT) -test_spektrum.srcs += downlink.c pprz_transport.c -test_spektrum.CFLAGS += -DUSE_RADIO_CONTROL -test_spektrum.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) -test_spektrum.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/booz_radio_control_spektrum.h\" -test_spektrum.CFLAGS += -DRADIO_CONTROL_SPEKTRUM_MODEL_H=\"radio_control/booz_radio_control_spektrum_dx7se.h\" -test_spektrum.CFLAGS += -DRADIO_CONTROL_LINK=$(RADIO_CONTROL_LINK) -test_spektrum.CFLAGS += -DUSE_$(RADIO_CONTROL_LINK) -D$(RADIO_CONTROL_LINK)_BAUD=B115200 -test_spektrum.srcs += $(SRC_BOOZ)/booz_radio_control.c \ - $(SRC_BOOZ)/radio_control/booz_radio_control_spektrum.c \ - $(SRC_BOOZ_ARCH)/radio_control/booz_radio_control_spektrum_arch.c +test_rc_ppm.CFLAGS += -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -I$(SRC_BOARD) +test_rc_ppm.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG) +test_rc_ppm.CFLAGS += -DPERIPHERALS_AUTO_INIT +test_rc_ppm.srcs += $(SRC_BOOZ)/test/booz2_test_radio_control.c \ + $(SRC_ARCH)/stm32_exceptions.c \ + $(SRC_ARCH)/stm32_vector_table.c +test_rc_ppm.CFLAGS += -DUSE_LED +test_rc_ppm.srcs += $(SRC_ARCH)/led_hw.c +test_rc_ppm.CFLAGS += -DUSE_SYS_TIME +test_rc_ppm.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))' +test_rc_ppm.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED) +test_rc_ppm.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c +test_rc_ppm.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD) +test_rc_ppm.srcs += $(SRC_ARCH)/uart_hw.c +test_rc_ppm.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT) +test_rc_ppm.srcs += downlink.c pprz_transport.c +test_rc_ppm.CFLAGS += -DUSE_RADIO_CONTROL +test_rc_ppm.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) +test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/booz_radio_control_ppm.h\" +test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_PPM +test_rc_ppm.srcs += $(SRC_BOOZ)/booz_radio_control.c \ + $(SRC_BOOZ)/radio_control/booz_radio_control_ppm.c \ + $(SRC_BOOZ_ARCH)/radio_control/booz_radio_control_ppm_arch.c +test_rc_ppm.CFLAGS += -DUSE_TIM2_IRQ diff --git a/conf/autopilot/subsystems/rotorcraft/radio_control_ppm.makefile b/conf/autopilot/subsystems/rotorcraft/radio_control_ppm.makefile index b72fd4c78f..d9efd595c7 100644 --- a/conf/autopilot/subsystems/rotorcraft/radio_control_ppm.makefile +++ b/conf/autopilot/subsystems/rotorcraft/radio_control_ppm.makefile @@ -1,7 +1,7 @@ # # Autopilot # -ap.CFLAGS += -DUSE_RADIO_CONTROL -DRADIO_CONTROL_LED=1 +ap.CFLAGS += -DUSE_RADIO_CONTROL -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) ap.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"radio_control/booz_radio_control_ppm.h\" ap.CFLAGS += -DRADIO_CONTROL_TYPE_PPM ap.srcs += $(SRC_BOOZ)/booz_radio_control.c \ diff --git a/conf/messages.xml b/conf/messages.xml index 736d510794..9cc40d6749 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -344,7 +344,7 @@ - + diff --git a/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.c b/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.c index 9ea6e335b9..30980fae91 100644 --- a/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.c +++ b/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.c @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2010 Antoine Drouin + * Copyright (C) 2010 The Paparazzi Team * * This file is part of paparazzi. * @@ -23,6 +23,111 @@ #include "booz_radio_control.h" -void booz_radio_control_ppm_hw_init ( void ) { +#include +#include +#include +#include + +#include "sys_time.h" + +#include "my_debug_servo.h" + + +/* + * + * This a radio control ppm driver for stm32 + * signal on PA1 TIM2/CH2 (uart1 trig on lisa/L) + * + */ +uint8_t booz_radio_control_ppm_cur_pulse; +uint32_t booz_radio_control_ppm_last_pulse_time; + +uint32_t debug_len; + +void tim2_irq_handler(void); + +void booz_radio_control_ppm_arch_init ( void ) { + + /* TIM2 channel 2 pin (PA.01) configuration */ + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* TIM2 clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); + + /* GPIOA clock enable */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); + + /* TIM2 configuration: Input Capture mode --------------------- + The external signal is connected to TIM2 CH2 pin (PA.01) + The Rising edge is used as active edge, + ------------------------------------------------------------ */ + TIM_ICInitTypeDef TIM_ICInitStructure; + TIM_ICInitStructure.TIM_Channel = TIM_Channel_2; + TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; + TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; + TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; + TIM_ICInitStructure.TIM_ICFilter = 0x0; + TIM_ICInit(TIM2, &TIM_ICInitStructure); + + + /* Enable the TIM2 global Interrupt */ + NVIC_InitTypeDef NVIC_InitStructure; + NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + /* TIM2 enable counter */ + TIM_Cmd(TIM2, ENABLE); + + /* Enable the CC2 Interrupt Request */ + TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE); + + booz_radio_control_ppm_last_pulse_time = 0; + booz_radio_control_ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL; + + DEBUG_SERVO2_INIT(); + +} + + +void tim2_irq_handler(void) { + + DEBUG_S4_ON(); + + if(TIM_GetITStatus(TIM2, TIM_IT_CC2) == SET) { + TIM_ClearITPendingBit(TIM2, TIM_IT_CC2); + + uint32_t now = TIM_GetCapture2(TIM2); + uint32_t length = now - booz_radio_control_ppm_last_pulse_time; + debug_len = length; + booz_radio_control_ppm_last_pulse_time = now; + + if (booz_radio_control_ppm_cur_pulse == RADIO_CONTROL_NB_CHANNEL) { + if (length > SYS_TICS_OF_USEC(PPM_SYNC_MIN_LEN) && + length < SYS_TICS_OF_USEC(PPM_SYNC_MAX_LEN)) { + booz_radio_control_ppm_cur_pulse = 0; + } + } + else { + if (length > SYS_TICS_OF_USEC(PPM_DATA_MIN_LEN) && + length < SYS_TICS_OF_USEC(PPM_DATA_MAX_LEN)) { + booz_radio_control_ppm_pulses[booz_radio_control_ppm_cur_pulse] = length; + booz_radio_control_ppm_cur_pulse++; + if (booz_radio_control_ppm_cur_pulse == RADIO_CONTROL_NB_CHANNEL) { + booz_radio_control_ppm_frame_available = TRUE; + } + } + else + booz_radio_control_ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL; + } + } + + DEBUG_S4_OFF(); } diff --git a/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.h b/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.h index 0832563097..85457192d1 100644 --- a/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.h +++ b/sw/airborne/booz/arch/stm32/radio_control/booz_radio_control_ppm_arch.h @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2010 Antoine Drouin + * Copyright (C) 2010 The Paparazzi Team * * This file is part of paparazzi. * @@ -26,4 +26,3 @@ * */ -extern void booz_radio_control_ppm_hw_init ( void ); diff --git a/sw/airborne/booz/radio_control/booz_radio_control_ppm.h b/sw/airborne/booz/radio_control/booz_radio_control_ppm.h index 8a366220b4..9dc3bda6ea 100644 --- a/sw/airborne/booz/radio_control/booz_radio_control_ppm.h +++ b/sw/airborne/booz/radio_control/booz_radio_control_ppm.h @@ -56,7 +56,7 @@ extern volatile bool_t booz_radio_control_ppm_frame_available; radio_control.status = RADIO_CONTROL_OK; \ NormalizePpm(); \ _received_frame_handler(); \ - } \ + } \ booz_radio_control_ppm_frame_available = FALSE; \ } \ } diff --git a/sw/airborne/booz/test/booz2_test_radio_control.c b/sw/airborne/booz/test/booz2_test_radio_control.c index f70a561e43..c8f35f1ad6 100644 --- a/sw/airborne/booz/test/booz2_test_radio_control.c +++ b/sw/airborne/booz/test/booz2_test_radio_control.c @@ -54,6 +54,8 @@ static inline void main_init( void ) { int_enable(); } +extern uint32_t debug_len; + static inline void main_periodic_task( void ) { RunOnceEvery(51, {/*LED_TOGGLE(2);*/ DOWNLINK_SEND_TIME(DefaultChannel, &cpu_time_sec);}); @@ -69,6 +71,10 @@ static inline void main_periodic_task( void ) { &radio_control.values[RADIO_CONTROL_MODE], \ &foo, \ &radio_control.status);}); + uint8_t bar; + RunOnceEvery(10, { DOWNLINK_SEND_CHRONO(DefaultChannel, &bar, &debug_len)}); + + LED_PERIODIC(); } diff --git a/sw/airborne/stm32/sys_time_hw.h b/sw/airborne/stm32/sys_time_hw.h index 33b600d45f..ff830509c3 100644 --- a/sw/airborne/stm32/sys_time_hw.h +++ b/sw/airborne/stm32/sys_time_hw.h @@ -1,7 +1,7 @@ /* * Paparazzi $Id$ * - * Copyright (C) 2009 Antoine Drouin + * Copyright (C) 2009-2010 The Paparazzi Team * * This file is part of paparazzi. *