This mainly moves the STM32 timers' code to the common area.
F2 and F4 have a common section to deal with the options register (TIM2 and TIM5 only) L1 has been made common with timer_common_all as its options register has very different settings to F2/F4. Code is in the L1/timer.c L1/timer.h files Note that F3 and F05 timers should fit into this scheme, with F3 having additional features. Bundled with this is L1/pwr.h to change a documentation setting Also all the Doxyfiles have added "ENABLE_PREPROCESSING = NO" to fix a problem introduced by commit 118.
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
/** @defgroup STM32F1xx-timer-file Timers
|
||||
|
||||
@ingroup STM32F1xx
|
||||
|
||||
@brief <b>libopencm3 STM32 Timers</b>
|
||||
|
||||
@version 1.0.0
|
||||
/** @addtogroup timer_file
|
||||
|
||||
@author @htmlonly © @endhtmlonly 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
@author @htmlonly © @endhtmlonly 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
|
||||
@date 18 August 2012
|
||||
@section tim_common Notes for All Timers
|
||||
|
||||
This library supports the General Purpose and Advanced Control Timers for
|
||||
the STM32 series of ARM Cortex Microcontrollers by ST Microelectronics.
|
||||
@@ -66,6 +61,7 @@ push-pull outputs where the PWM output will appear.
|
||||
@todo input capture example
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
@@ -97,23 +93,9 @@ push-pull outputs where the PWM output will appear.
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
|
||||
#if defined(STM32F1)
|
||||
#define ADVANCED_TIMERS (defined (TIM1_BASE) || defined(TIM8_BASE))
|
||||
# include <libopencm3/stm32/f1/rcc.h>
|
||||
#elif defined(STM32F2)
|
||||
#define ADVANCED_TIMERS (defined (TIM1_BASE) || defined(TIM8_BASE))
|
||||
# include <libopencm3/stm32/f2/timer.h>
|
||||
# include <libopencm3/stm32/f2/rcc.h>
|
||||
#elif defined(STM32F4)
|
||||
#define ADVANCED_TIMERS (defined (TIM1_BASE) || defined(TIM8_BASE))
|
||||
# include <libopencm3/stm32/f4/timer.h>
|
||||
# include <libopencm3/stm32/f4/rcc.h>
|
||||
#elif defined(STM32L1)
|
||||
# include <libopencm3/stm32/l1/rcc.h>
|
||||
#else
|
||||
# error "stm32 family not defined."
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Reset a Timer.
|
||||
@@ -1836,29 +1818,6 @@ u32 timer_get_counter(u32 timer_peripheral)
|
||||
return TIM_CNT(timer_peripheral);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Set Timer Option
|
||||
|
||||
Set timer options register on TIM2 or TIM5, used for oscillator calibration
|
||||
on TIM5 and trigger remapping on TIM2. Only available on F4 and F2.
|
||||
|
||||
@param[in] timer_peripheral Unsigned int32. Timer register address base
|
||||
@returns Unsigned int32. Option flags.
|
||||
*/
|
||||
|
||||
#if (defined(STM32F4) || defined(STM32F2))
|
||||
void timer_set_option(u32 timer_peripheral, u32 option)
|
||||
{
|
||||
if (timer_peripheral == TIM2) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
} else if (timer_peripheral == TIM5) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM5_OR_TI4_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Set Counter
|
||||
|
||||
51
lib/stm32/common/timer_common_f24.c
Normal file
51
lib/stm32/common/timer_common_f24.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/** @addtogroup timer_file
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Set Timer Option
|
||||
|
||||
Set timer options register on TIM2 or TIM5, used for trigger remapping on TIM2,
|
||||
and similarly for TIM5 for oscillator calibration purposes.
|
||||
|
||||
@param[in] timer_peripheral Unsigned int32. Timer register address base
|
||||
@returns Unsigned int32. Option flags TIM2: @ref tim2_opt_trigger_remap, TIM5: @ref tim5_opt_trigger_remap.
|
||||
*/
|
||||
|
||||
void timer_set_option(u32 timer_peripheral, u32 option)
|
||||
{
|
||||
if (timer_peripheral == TIM2) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
} else if (timer_peripheral == TIM5) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM5_OR_TI4_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
}
|
||||
}
|
||||
/**@}*/
|
||||
|
||||
|
||||
@@ -32,13 +32,17 @@ CFLAGS = -Os -g \
|
||||
-ffunction-sections -fdata-sections -MD -DSTM32F1
|
||||
# ARFLAGS = rcsv
|
||||
ARFLAGS = rcs
|
||||
OBJS = rcc.o gpio.o adc.o flash.o rtc.o dma.o exti.o ethernet.o \
|
||||
usb_f103.o usb.o usb_control.o usb_standard.o can.o \
|
||||
timer.o usb_f107.o desig.o pwr_common_all.o \
|
||||
usb_fx07_common.o \
|
||||
gpio_common_all.o dma_common_f13.o spi_common_all.o \
|
||||
dac_common_all.o usart_common_all.o iwdg_common_all.o \
|
||||
i2c_common_all.o crc_common_all.o
|
||||
|
||||
OBJS = adc.o can.o desig.o exti.o ethernet.o flash.o gpio.o \
|
||||
rcc.o rtc.o
|
||||
|
||||
OBJS += crc_common_all.o dac_common_all.o dma_common_f13.o \
|
||||
gpio_common_all.o i2c_common_all.o iwdg_common_all.o \
|
||||
pwr_common_all.o spi_common_all.o \
|
||||
timer_common_all.o usart_common_all.o
|
||||
|
||||
OBJS += usb.o usb_control.o usb_standard.o usb_f103.o usb_f107.o \
|
||||
usb_fx07_common.o
|
||||
|
||||
VPATH += ../../usb:../:../../cm3:../common
|
||||
|
||||
|
||||
40
lib/stm32/f1/timer.c
Normal file
40
lib/stm32/f1/timer.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* This file is used for documentation purposes. It does not need
|
||||
to be compiled. All source code is in the common area.
|
||||
If there is any device specific code required it can be included here,
|
||||
in which case this file must be added to the compile list. */
|
||||
|
||||
/** @defgroup timer_file Timers
|
||||
|
||||
@ingroup STM32F1xx
|
||||
|
||||
@brief <b>libopencm3 STM32F1xx Timers</b>
|
||||
|
||||
@version 1.0.0
|
||||
|
||||
@date 18 August 2012
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/common/timer_common_all.h>
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
LIBNAME = libopencm3_stm32f2
|
||||
|
||||
PREFIX ?= arm-none-eabi
|
||||
# PREFIX ?= arm-elf
|
||||
PREFIX ?= arm-none-eabi
|
||||
# PREFIX ?= arm-elf
|
||||
CC = $(PREFIX)-gcc
|
||||
AR = $(PREFIX)-ar
|
||||
CFLAGS = -Os -g \
|
||||
@@ -32,11 +32,13 @@ CFLAGS = -Os -g \
|
||||
-ffunction-sections -fdata-sections -MD -DSTM32F2
|
||||
# ARFLAGS = rcsv
|
||||
ARFLAGS = rcs
|
||||
OBJS = rcc.o gpio.o flash.o exti2.o timer.o \
|
||||
gpio_common_all.o gpio_common_f24.o dma_common_f24.o spi_common_all.o \
|
||||
dac_common_all.o usart_common_all.o iwdg_common_all.o i2c_common_all.o \
|
||||
crc_common_all.o \
|
||||
rtc_common_bcd.o
|
||||
|
||||
OBJS = gpio.o exti2.o flash.o rcc.o
|
||||
|
||||
OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
||||
gpio_common_all.o gpio_common_f24.o i2c_common_all.o \
|
||||
iwdg_common_all.o rtc_common_bcd.o spi_common_all.o \
|
||||
timer_common_all.o timer_common_f24.o usart_common_all.o
|
||||
|
||||
VPATH += ../../usb:../:../../cm3:../common
|
||||
|
||||
|
||||
40
lib/stm32/f2/timer.c
Normal file
40
lib/stm32/f2/timer.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* This file is used for documentation purposes. It does not need
|
||||
to be compiled. All source code is in the common area.
|
||||
If there is any device specific code required it can be included here,
|
||||
in which case this file must be added to the compile list. */
|
||||
|
||||
/** @defgroup timer_file Timers
|
||||
|
||||
@ingroup STM32F2xx
|
||||
|
||||
@brief <b>libopencm3 STM32F2xx Timers</b>
|
||||
|
||||
@version 1.0.0
|
||||
|
||||
@date 18 August 2012
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/common/timer_common_f24.h>
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
LIBNAME = libopencm3_stm32f4
|
||||
|
||||
PREFIX ?= arm-none-eabi
|
||||
# PREFIX ?= arm-elf
|
||||
PREFIX ?= arm-none-eabi
|
||||
# PREFIX ?= arm-elf
|
||||
CC = $(PREFIX)-gcc
|
||||
AR = $(PREFIX)-ar
|
||||
CFLAGS = -Os -g \
|
||||
@@ -33,16 +33,17 @@ CFLAGS = -Os -g \
|
||||
-ffunction-sections -fdata-sections -MD -DSTM32F4
|
||||
# ARFLAGS = rcsv
|
||||
ARFLAGS = rcs
|
||||
OBJS = rcc.o gpio.o flash.o exti2.o pwr.o timer.o \
|
||||
usb.o usb_standard.o usb_control.o usb_fx07_common.o usb_f107.o \
|
||||
usb_f207.o adc.o dma.o \
|
||||
pwr_common_all.o \
|
||||
gpio_common_all.o gpio_common_f24.o dma_common_f24.o spi_common_all.o \
|
||||
dac_common_all.o usart_common_all.o iwdg_common_all.o i2c_common_all.o \
|
||||
crc_common_all.o \
|
||||
rtc_common_bcd.o \
|
||||
rtc.o \
|
||||
can.o
|
||||
|
||||
OBJS = adc.o can.o gpio.o exti2.o flash.o pwr.o rcc.o
|
||||
|
||||
OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
||||
gpio_common_all.o gpio_common_f24.o i2c_common_all.o \
|
||||
iwdg_common_all.o pwr_common_all.o rtc_common_bcd.o \
|
||||
spi_common_all.o timer_common_all.o timer_common_f24.o \
|
||||
usart_common_all.o
|
||||
|
||||
OBJS += usb.o usb_standard.o usb_control.o usb_fx07_common.o \
|
||||
usb_f107.o usb_f207.o
|
||||
|
||||
VPATH += ../../usb:../:../../cm3:../common
|
||||
|
||||
|
||||
40
lib/stm32/f4/timer.c
Normal file
40
lib/stm32/f4/timer.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* This file is used for documentation purposes. It does not need
|
||||
to be compiled. All source code is in the common area.
|
||||
If there is any device specific code required it can be included here,
|
||||
in which case this file must be added to the compile list. */
|
||||
|
||||
/** @defgroup timer_file Timers
|
||||
|
||||
@ingroup STM32F4xx
|
||||
|
||||
@brief <b>libopencm3 STM32F4xx Timers</b>
|
||||
|
||||
@version 1.0.0
|
||||
|
||||
@date 18 August 2012
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/common/timer_common_f24.h>
|
||||
|
||||
@@ -32,11 +32,11 @@ CFLAGS = -Os -g \
|
||||
-ffunction-sections -fdata-sections -MD -DSTM32L1
|
||||
# ARFLAGS = rcsv
|
||||
ARFLAGS = rcs
|
||||
OBJS = rcc.o desig.o crc.o usart.o exti2.o flash.o timer.o
|
||||
OBJS += gpio_common_all.o gpio_common_f24.o spi_common_all.o crc_common_all.o
|
||||
OBJS += dac_common_all.o usart_common_all.o iwdg_common_all.o i2c_common_all.o
|
||||
OBJS += pwr_common_all.o pwr.o
|
||||
OBJS += rtc_common_bcd.o
|
||||
OBJS = crc.o desig.o exti2.o flash.o rcc.o usart.o
|
||||
OBJS += crc_common_all.o dac_common_all.o gpio_common_all.o
|
||||
OBJS += gpio_common_f24.o i2c_common_all.o iwdg_common_all.o
|
||||
OBJS += pwr_common_all.o pwr.o rtc_common_bcd.o
|
||||
OBJS += spi_common_all.o timer_common_all.o usart_common_all.o
|
||||
|
||||
VPATH += ../../usb:../:../../cm3:../common
|
||||
|
||||
|
||||
59
lib/stm32/l1/timer.c
Normal file
59
lib/stm32/l1/timer.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/** @defgroup timer_file Timers
|
||||
|
||||
@ingroup STM32L1xx
|
||||
|
||||
@brief <b>libopencm3 STM32L1xx Timers</b>
|
||||
|
||||
@version 1.0.0
|
||||
|
||||
@date 18 August 2012
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/common/timer_common_all.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Set Timer Option
|
||||
|
||||
Set timer options register on TIM2 or TIM3, used for trigger remapping.
|
||||
|
||||
@param[in] timer_peripheral Unsigned int32. Timer register address base
|
||||
@returns Unsigned int32. Option flags TIM2: @ref tim2_opt_trigger_remap, TIM3: @ref tim3_opt_trigger_remap.
|
||||
*/
|
||||
|
||||
void timer_set_option(u32 timer_peripheral, u32 option)
|
||||
{
|
||||
if (timer_peripheral == TIM2) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
} else if (timer_peripheral == TIM3) {
|
||||
TIM_OR(timer_peripheral) &= ~TIM3_OR_ITR2_RMP_MASK;
|
||||
TIM_OR(timer_peripheral) |= option;
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
Reference in New Issue
Block a user