From d8d63b3184f38199f8b58f5a7b8c0959a861a94d Mon Sep 17 00:00:00 2001 From: Themroc Date: Tue, 4 Aug 2020 18:48:50 +0200 Subject: [PATCH] stm32: timer common all: Fix documentation Provide gpio examples for both f1 and "everyone else" gpio blocks Originally filed at: https://github.com/libopencm3/libopencm3/pull/1243 Reviewed-by: Karl Palsson (Merged old and new into two new examples) --- lib/stm32/common/timer_common_all.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/stm32/common/timer_common_all.c b/lib/stm32/common/timer_common_all.c index 64701836..30671ad1 100644 --- a/lib/stm32/common/timer_common_all.c +++ b/lib/stm32/common/timer_common_all.c @@ -44,14 +44,20 @@ Output Compare mode to PWM and enable the output of channel 1. Note that for the advanced timers the break functionality must be enabled before the signal will appear at the output, even though break is not being used. This is in addition to the normal output enable. Enable the alternate function clock (APB2 -only) and port A clock. Set ports A8 and A9 (timer 1 channel 1 compare outputs) -to alternate function push-pull outputs where the PWM output will appear. +only) and port A clock. Set port A8 (timer 1 channel 1 compare output) to +alternate function push-pull output where the PWM output will appear. @code - rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_TIM1); - gpio_set_output_options(GPIOA, GPIO_OTYPE_PP, - GPIO_OSPEED_50MHZ, GPIO8 | GPIO9); + rcc_periph_clock_enable(RCC_GPIOA); + + // for F1.... + gpio_set_output_options(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO8); + // For anyone else + rcc_periph_clock_enable(RCC_AFIO); + gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8); + // End of family specific + rcc_periph_clock_enable(RCC_TIM1); timer_set_mode(TIM1, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_CENTER_1, TIM_CR1_DIR_UP);