aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/stm32/common/timer_common_all.c (renamed from lib/stm32/timer.c)51
-rw-r--r--lib/stm32/common/timer_common_f24.c51
-rw-r--r--lib/stm32/f1/Makefile18
-rw-r--r--lib/stm32/f1/timer.c40
-rw-r--r--lib/stm32/f2/Makefile16
-rw-r--r--lib/stm32/f2/timer.c40
-rw-r--r--lib/stm32/f4/Makefile25
-rw-r--r--lib/stm32/f4/timer.c40
-rw-r--r--lib/stm32/l1/Makefile10
-rw-r--r--lib/stm32/l1/timer.c59
10 files changed, 273 insertions, 77 deletions
diff --git a/lib/stm32/timer.c b/lib/stm32/common/timer_common_all.c
index bd73978..ff84fff 100644
--- a/lib/stm32/timer.c
+++ b/lib/stm32/common/timer_common_all.c
@@ -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 &copy; @endhtmlonly 2010 Edward Cheeseman <evbuilder@users.sourceforge.org>
+@author @htmlonly &copy; @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.
@@ -1837,29 +1819,6 @@ u32 timer_get_counter(u32 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
Set the value of a timer's counter register contents.
diff --git a/lib/stm32/common/timer_common_f24.c b/lib/stm32/common/timer_common_f24.c
new file mode 100644
index 0000000..4dd7c08
--- /dev/null
+++ b/lib/stm32/common/timer_common_f24.c
@@ -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;
+ }
+}
+/**@}*/
+
+
diff --git a/lib/stm32/f1/Makefile b/lib/stm32/f1/Makefile
index bd63755..f1048da 100644
--- a/lib/stm32/f1/Makefile
+++ b/lib/stm32/f1/Makefile
@@ -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
diff --git a/lib/stm32/f1/timer.c b/lib/stm32/f1/timer.c
new file mode 100644
index 0000000..c469d55
--- /dev/null
+++ b/lib/stm32/f1/timer.c
@@ -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>
+
diff --git a/lib/stm32/f2/Makefile b/lib/stm32/f2/Makefile
index 8d1c623..c9fa059 100644
--- a/lib/stm32/f2/Makefile
+++ b/lib/stm32/f2/Makefile
@@ -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
diff --git a/lib/stm32/f2/timer.c b/lib/stm32/f2/timer.c
new file mode 100644
index 0000000..1495708
--- /dev/null
+++ b/lib/stm32/f2/timer.c
@@ -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>
+
diff --git a/lib/stm32/f4/Makefile b/lib/stm32/f4/Makefile
index a6a87d6..b1cd38f 100644
--- a/lib/stm32/f4/Makefile
+++ b/lib/stm32/f4/Makefile
@@ -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
diff --git a/lib/stm32/f4/timer.c b/lib/stm32/f4/timer.c
new file mode 100644
index 0000000..7c2e4ba
--- /dev/null
+++ b/lib/stm32/f4/timer.c
@@ -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>
+
diff --git a/lib/stm32/l1/Makefile b/lib/stm32/l1/Makefile
index e081daf..8633016 100644
--- a/lib/stm32/l1/Makefile
+++ b/lib/stm32/l1/Makefile
@@ -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
diff --git a/lib/stm32/l1/timer.c b/lib/stm32/l1/timer.c
new file mode 100644
index 0000000..053c501
--- /dev/null
+++ b/lib/stm32/l1/timer.c
@@ -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;
+ }
+}
+
+/**@}*/
+