aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/include/libmaple/stm32.h43
-rw-r--r--libmaple/stm32f1/include/series/stm32.h8
-rw-r--r--libmaple/stm32f2/include/series/stm32.h1
3 files changed, 48 insertions, 4 deletions
diff --git a/libmaple/include/libmaple/stm32.h b/libmaple/include/libmaple/stm32.h
index 097a016..94fb689 100644
--- a/libmaple/include/libmaple/stm32.h
+++ b/libmaple/include/libmaple/stm32.h
@@ -70,14 +70,36 @@ extern "C" {
#include <series/stm32.h>
/* Ensure the series header isn't broken. */
-#if (!defined(STM32_PCLK1) || !defined(STM32_PCLK2) || \
- !defined(STM32_MCU_SERIES) || !defined(STM32_NR_INTERRUPTS) || \
- !defined(STM32_NR_GPIO_PORTS) || !defined(STM32_DELAY_US_MULT) || \
- !defined(STM32_SRAM_END) || !defined(STM32_HAVE_FSMC) || \
+#if (!defined(STM32_PCLK1) || \
+ !defined(STM32_PCLK2) || \
+ !defined(STM32_MCU_SERIES) || \
+ !defined(STM32_NR_INTERRUPTS) || \
+ !defined(STM32_NR_GPIO_PORTS) || \
+ !defined(STM32_TIMER_MASK) || \
+ !defined(STM32_DELAY_US_MULT) || \
+ !defined(STM32_SRAM_END) || \
+ !defined(STM32_HAVE_FSMC) || \
!defined(STM32_HAVE_USB))
#error "Bad STM32F1 configuration. Check <series/stm32.h> header for your MCU."
#endif
+/*
+ * Derived macros
+ */
+
+/* FIXME [0.0.13] add this to ReST API page */
+/**
+ * @brief Statically determine whether a timer is present.
+ *
+ * Given a constant timer number n (starting from 1), this macro has a
+ * nonzero value exactly when TIMERn is available.
+ */
+#define STM32_HAVE_TIMER(n) (STM32_TIMER_MASK & (1 << (n)))
+
+/*
+ * Doxygen for functionality provided by series header.
+ */
+
#ifdef __DOXYGEN__
/*
@@ -128,6 +150,19 @@ extern "C" {
*/
#define STM32_NR_GPIO_PORTS
+/* FIXME [0.0.13] add this to ReST API page */
+/**
+ * @brief Bitmask of timers available on the MCU.
+ *
+ * That is, if TIMERn is available, then STM32_TIMER_MASK & (1 << n)
+ * will be nonzero. For example, a nonzero value of "STM32_TIMER_MASK
+ * & 0x2" means TIMER1 is available.
+ *
+ * A bitmask is necessary as some STM32 MCUs have "holes" in the range
+ * of available timers.
+ */
+#define STM32_TIMER_MASK
+
/**
* @brief Multiplier to convert microseconds into loop iterations
* in delay_us().
diff --git a/libmaple/stm32f1/include/series/stm32.h b/libmaple/stm32f1/include/series/stm32.h
index e01c494..59205c3 100644
--- a/libmaple/stm32f1/include/series/stm32.h
+++ b/libmaple/stm32f1/include/series/stm32.h
@@ -94,6 +94,7 @@ extern "C" {
#elif defined(MCU_STM32F100RB)
# define STM32_F1_LINE STM32_F1_LINE_VALUE
# define STM32_NR_GPIO_PORTS 4
+# define STM32_TIMER_MASK 0x380DE /* Timers: 1-4, 6, 7, 15-17. */
# define STM32_SRAM_END ((void*)0x20002000)
# define STM32_MEDIUM_DENSITY
@@ -112,9 +113,16 @@ extern "C" {
# ifdef STM32_MEDIUM_DENSITY
# define STM32_NR_INTERRUPTS 43
+# define STM32_TIMER_MASK 0x1E /* TIMER1--TIMER4 */
# define STM32_HAVE_FSMC 0
# elif defined(STM32_HIGH_DENSITY)
# define STM32_NR_INTERRUPTS 60
+# define STM32_TIMER_MASK 0x1FE /* TIMER1--TIMER8 */
+# define STM32_HAVE_FSMC 1
+# endif
+# elif defined(STM32_XL_DENSITY)
+# define STM32_NR_INTERRUPTS 60
+# define STM32_TIMER_MASK 0x7FFE /* TIMER1--TIMER14 */
# define STM32_HAVE_FSMC 1
# endif
diff --git a/libmaple/stm32f2/include/series/stm32.h b/libmaple/stm32f2/include/series/stm32.h
index 9e88a70..b53b7b6 100644
--- a/libmaple/stm32f2/include/series/stm32.h
+++ b/libmaple/stm32f2/include/series/stm32.h
@@ -63,6 +63,7 @@ extern "C" {
#if defined(MCU_STM32F207IC) || defined(MCU_STM32F207IG)
# define STM32_NR_GPIO_PORTS 9
+# define STM32_TIMER_MASK 0x7FFE /* TIMER1-TIMER14. */
# define STM32_SRAM_END ((void*)0x20020000)
#else
#error "Unrecognized STM32F2 MCU, or no MCU specified."