libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
timer_common_f24.c
Go to the documentation of this file.
1 /** @addtogroup timer_file
2 
3 */
4 
5 /*
6  * This file is part of the libopencm3 project.
7  *
8  * Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
9  * Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
10  *
11  * This library is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 /**@{*/
26 
27 #include <libopencm3/stm32/timer.h>
28 
29 /*---------------------------------------------------------------------------*/
30 /** @brief Set Timer Option
31 
32 Set timer options register on TIM2 or TIM5, used for trigger remapping on TIM2,
33 and similarly for TIM5 for oscillator calibration purposes.
34 
35 @param[in] timer_peripheral Unsigned int32. Timer register address base
36 @param option flags TIM2 @ref tim2_opt_trigger_remap or TIM5 @ref tim5_opt_trigger_remap
37 */
38 
39 void timer_set_option(uint32_t timer_peripheral, uint32_t option)
40 {
41  if (timer_peripheral == TIM2) {
42  TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK;
43  TIM_OR(timer_peripheral) |= option;
44  } else if (timer_peripheral == TIM5) {
45  TIM_OR(timer_peripheral) &= ~TIM5_OR_TI4_RMP_MASK;
46  TIM_OR(timer_peripheral) |= option;
47  }
48 }
49 
50 /**@}*/
51 
52 
#define TIM2
#define TIM5
void timer_set_option(uint32_t timer_peripheral, uint32_t option)
Set Timer Option.
#define TIM5_OR_TI4_RMP_MASK
#define TIM_OR(tim_base)
#define TIM2_OR_ITR1_RMP_MASK