Skip to content

Commit

Permalink
[stm32][adc] automatically use TIM1 for ADC if TIM2 is already used b…
Browse files Browse the repository at this point in the history
…y RC ppm input on SERVO6

fixes #339
  • Loading branch information
flixr committed Jan 8, 2013
1 parent 159ef4e commit ad81033
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions conf/firmwares/subsystems/shared/radio_control_ppm.makefile
Expand Up @@ -28,8 +28,8 @@ ifeq ($(NORADIO), False)
ap.CFLAGS += -DUSE_PPM_TIM1
fbw.CFLAGS += -DUSE_PPM_TIM1
else ifeq ($(RADIO_CONTROL_PPM_PIN),$(filter $(RADIO_CONTROL_PPM_PIN),PA_01 SERVO6))
ap.CFLAGS += -DUSE_PPM_TIM2
fbw.CFLAGS += -DUSE_PPM_TIM2
ap.CFLAGS += -DUSE_PPM_TIM2 -DUSE_AD_TIM1
fbw.CFLAGS += -DUSE_PPM_TIM2 -DUSE_AD_TIM1
else
$(error unknown configuration for RADIO_CONTROL_PPM_PIN)
endif
Expand Down
7 changes: 5 additions & 2 deletions sw/airborne/arch/stm32/mcu_periph/adc_arch.c
Expand Up @@ -373,11 +373,14 @@ static inline void adc_init_single(uint32_t adc,

adc_set_injected_sequence(adc, num_channels, channels);

#if defined(USE_AD_TIM4)
#if USE_AD_TIM4
#pragma message "Info: Using TIM4 for ADC"
adc_enable_external_trigger_injected(adc, ADC_CR2_JEXTSEL_TIM4_TRGO);
#elif defined(USE_AD_TIM1)
#elif USE_AD_TIM1
#pragma message "Info: Using TIM1 for ADC"
adc_enable_external_trigger_injected(adc, ADC_CR2_JEXTSEL_TIM1_TRGO);
#else
#pragma message "Info: Using default TIM2 for ADC"
adc_enable_external_trigger_injected(adc, ADC_CR2_JEXTSEL_TIM2_TRGO);
#endif

Expand Down

0 comments on commit ad81033

Please sign in to comment.